mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
str[Struct] Fix crash when creating new key.
This commit is contained in:
parent
af65d007b3
commit
27034ad8a1
4 changed files with 18 additions and 19 deletions
|
@ -25,20 +25,19 @@ function Node_Struct(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
#region //////////////////////////////// Dynamic IO ////////////////////////////////
|
||||
|
||||
static createNewInput = function(list = inputs) {
|
||||
var index = ds_list_size(list);
|
||||
|
||||
var bDel = button(function() { node.deleteInput(index); })
|
||||
var index = array_length(list);
|
||||
var bDel = button(function() { node.deleteInput(index); })
|
||||
.setIcon(THEME.minus_16, 0, COLORS._main_icon);
|
||||
|
||||
list[| index + 0] = nodeValue_Text("Key", self, "" )
|
||||
list[index + 0] = nodeValue_Text("Key", self, "" )
|
||||
.setDisplay(VALUE_DISPLAY.text_box, { side_button : bDel })
|
||||
.setAnimable(false);
|
||||
bDel.setContext(list[| index + 0]);
|
||||
bDel.setContext(list[index + 0]);
|
||||
|
||||
list[| index + 1] = nodeValue("value", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0 )
|
||||
list[index + 1] = nodeValue("value", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0 )
|
||||
.setVisible(false, false);
|
||||
|
||||
return list[| index + 0];
|
||||
return list[index + 0];
|
||||
}
|
||||
|
||||
setDynamicInput(2, false);
|
||||
|
|
|
@ -8,9 +8,9 @@ function Node_Struct_Get(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
|||
|
||||
newInput(1, nodeValue_Text("Key", self, ""));
|
||||
|
||||
outputs[0] = nodeValue_Output("Struct", self, VALUE_TYPE.struct, {});
|
||||
outputs[0] = nodeValue_Output("Value", self, VALUE_TYPE.struct, {});
|
||||
|
||||
static getStructValue = function(str, keys) { #region
|
||||
static getStructValue = function(str, keys) {
|
||||
var _pnt = str, val = 0;
|
||||
if(!is_struct(_pnt)) return [ VALUE_TYPE.any, val ];
|
||||
|
||||
|
@ -40,9 +40,9 @@ function Node_Struct_Get(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
|||
}
|
||||
|
||||
return [ VALUE_TYPE.any, val ];
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static update = function() { #region
|
||||
static update = function() {
|
||||
var str = getInputData(0);
|
||||
var key = getInputData(1);
|
||||
|
||||
|
@ -68,14 +68,13 @@ function Node_Struct_Get(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
|||
outputs[0].setType(val[0]);
|
||||
outputs[0].setValue(val[1]);
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
var str = getInputData(1);
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||||
var ss = string_scale(str, bbox.w, bbox.h);
|
||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
||||
} #endregion
|
||||
draw_text_bbox(bbox, str);
|
||||
}
|
||||
}
|
|
@ -2,14 +2,14 @@ function Node_Struct_JSON_Parse(_x, _y, _group = noone) : Node(_x, _y, _group) c
|
|||
name = "JSON Parse";
|
||||
setDimension(96, 32 + 24);
|
||||
|
||||
newInput(0, nodeValue_Text("JSON string", self, 0))
|
||||
newInput(0, nodeValue_Text("JSON string", self, ""))
|
||||
.setVisible(true, true);
|
||||
|
||||
outputs[0] = nodeValue_Output("Struct", self, VALUE_TYPE.struct, {} );
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
var _str = getInputData(0);
|
||||
var str = json_parse(_str);
|
||||
var str = json_try_parse(_str);
|
||||
outputs[0].setValue(str);
|
||||
}
|
||||
|
||||
|
|
|
@ -986,7 +986,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
extract_node = "Node_Path";
|
||||
break;
|
||||
|
||||
case VALUE_TYPE.any :
|
||||
// case VALUE_TYPE.any :
|
||||
default :
|
||||
editWidget = new outputBox();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue