2023-03-11 01:40:17 +01:00
|
|
|
function NodeTool(name, spr) constructor {
|
2023-10-04 05:52:20 +02:00
|
|
|
node = other;
|
|
|
|
self.name = name;
|
|
|
|
self.spr = spr;
|
2023-03-11 01:40:17 +01:00
|
|
|
|
|
|
|
subtools = is_array(spr)? array_length(spr) : 0;
|
|
|
|
selecting = 0;
|
|
|
|
settings = [];
|
|
|
|
attribute = {};
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
static checkHotkey = function() {
|
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
|
|
|
return getHotkey(instanceof(node), name);
|
|
|
|
}
|
|
|
|
|
2023-07-15 20:01:29 +02:00
|
|
|
static getName = function(index = 0) {
|
2023-10-04 05:52:20 +02:00
|
|
|
var _key = checkHotkey();
|
|
|
|
|
|
|
|
var _nme = is_array(name)? array_safe_get(name, index, "") : name;
|
|
|
|
if(_key != "") _nme += $" ({_key})";
|
|
|
|
|
|
|
|
return _nme;
|
2023-07-15 20:01:29 +02:00
|
|
|
}
|
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
static addSetting = function(name, type, onEdit, keyAttr, val) {
|
|
|
|
var w;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case VALUE_TYPE.float :
|
|
|
|
w = new textBox(TEXTBOX_INPUT.number, onEdit);
|
|
|
|
w.font = f_p2;
|
|
|
|
break;
|
|
|
|
case VALUE_TYPE.boolean :
|
|
|
|
w = new checkBox(onEdit);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
array_push(settings, [ name, w, keyAttr, attribute ]);
|
|
|
|
attribute[$ keyAttr] = val;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
static toggle = function(index = 0) {
|
2023-03-11 01:40:17 +01:00
|
|
|
if(subtools == 0) {
|
|
|
|
PANEL_PREVIEW.tool_current = PANEL_PREVIEW.tool_current == self? noone : self;
|
|
|
|
} else {
|
2023-07-14 20:34:35 +02:00
|
|
|
if(PANEL_PREVIEW.tool_current == self && index == selecting) {
|
2023-03-11 01:40:17 +01:00
|
|
|
PANEL_PREVIEW.tool_current = noone;
|
2023-07-14 20:34:35 +02:00
|
|
|
selecting = 0;
|
|
|
|
} else {
|
2023-03-11 01:40:17 +01:00
|
|
|
PANEL_PREVIEW.tool_current = self;
|
2023-07-14 20:34:35 +02:00
|
|
|
selecting = index;
|
|
|
|
}
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
if(PANEL_PREVIEW.tool_current == self)
|
|
|
|
onToggle();
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
static toggleKeyboard = function() {
|
|
|
|
if(subtools == 0) {
|
|
|
|
PANEL_PREVIEW.tool_current = PANEL_PREVIEW.tool_current == self? noone : self;
|
|
|
|
} else if(PANEL_PREVIEW.tool_current != self) {
|
|
|
|
PANEL_PREVIEW.tool_current = self;
|
|
|
|
selecting = 0;
|
|
|
|
} else if(selecting == subtools - 1) {
|
|
|
|
PANEL_PREVIEW.tool_current = noone;
|
|
|
|
selecting = 0;
|
|
|
|
} else
|
|
|
|
selecting++;
|
|
|
|
|
|
|
|
if(PANEL_PREVIEW.tool_current == self)
|
|
|
|
onToggle();
|
|
|
|
}
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
static onToggle = function() {}
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|