diff --git a/scripts/node_area/node_area.gml b/scripts/node_area/node_area.gml index 864fdf0ab..d022738fe 100644 --- a/scripts/node_area/node_area.gml +++ b/scripts/node_area/node_area.gml @@ -5,8 +5,7 @@ function Node_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons w = 96; - - inputs[| 0] = nodeValue("Postion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) + inputs[| 0] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) .setDisplay(VALUE_DISPLAY.vector) .setVisible(true, true); inputs[| 1] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16 ] ) diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index a23d460eb..4a458c8bb 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -94,7 +94,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x outputs = ds_list_create(); inputMap = ds_map_create(); outputMap = ds_map_create(); - + input_value_map = {}; + use_display_list = true; input_display_list = -1; output_display_list = -1; @@ -439,11 +440,18 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x return array_safe_get(inputs_data, index, def); } #endregion + static setInputData = function(index, value) { #region + gml_pragma("forceinline"); + + inputs_data[index] = value; + input_value_map[$ inputs[| index].internalName] = value; + } #endregion + static getInputs = function(frame = CURRENT_FRAME) { #region inputs_data = array_create(ds_list_size(inputs), undefined); for(var i = 0; i < ds_list_size(inputs); i++) - inputs_data[i] = inputs[| i].getValue(frame,,, false); + setInputData(i, inputs[| i].getValue(frame,,, false)); } #endregion static forceUpdate = function() { #region diff --git a/scripts/node_number/node_number.gml b/scripts/node_number/node_number.gml index 2e1a90a56..8b2aa2b9c 100644 --- a/scripts/node_number/node_number.gml +++ b/scripts/node_number/node_number.gml @@ -43,7 +43,7 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co w = 96; min_h = 56; - + switch(disp) { case 0 : inputs[| 3].setVisible(false); diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index a378c2cb3..07b4ca678 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -261,7 +261,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct if(amo == 1) val = val[0]; //spread single array amo = max(1, amo); - inputs_data[i] = val; + setInputData(i, val); inputs_is_array[i] = inputs[| i].isArray(val); switch(attributes.array_process) { diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 24b3b56e7..c5dafe896 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -465,7 +465,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru static updateName = function(_name) { name = _name; - internalName = string_lower(string_replace_all(name, " ", "_")); + internalName = string_to_var(name); name_custom = true; } updateName(_name); @@ -541,6 +541,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru attributes = {}; node.inputs_data[index] = _value; + node.input_value_map[$ internalName] = _value; #endregion #region ---- draw ---- @@ -592,12 +593,19 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru expUse = false; expression = ""; expTree = noone; - + expContext = { + name: name, + node_name: node.display_name, + value: 0, + node_values: node.input_value_map, + }; + express_edit = new textArea(TEXTBOX_INPUT.text, function(str) { expression = str; expressionUpdate(); }); express_edit.autocomplete_server = pxl_autocomplete_server; + express_edit.autocomplete_context = expContext; express_edit.function_guide_server = pxl_function_guide_server; express_edit.parser_server = pxl_document_parser; express_edit.format = TEXT_AREA_FORMAT.codeLUA; @@ -1456,14 +1464,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru //printCallStack(); global.EVALUATE_HEAD = self; - var params = { + expContext = { name: name, node_name: node.display_name, - node: self, - value: val[0] + value: val[0], + node_values: node.input_value_map, }; - var _exp_res = expTree.eval(variable_clone(params)); + var _exp_res = expTree.eval(variable_clone(expContext)); //print(json_stringify(expTree, true)); //print($"======= {_exp_res}"); @@ -1639,7 +1647,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(connect_type == JUNCTION_CONNECT.output) return; - node.inputs_data[self.index] = animator.getValue(time); + node.setInputData(self.index, animator.getValue(time)); if(tags != VALUE_TAG.none) return true; @@ -2356,7 +2364,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(APPENDING) def_val = getValue(0); if(connect_type == JUNCTION_CONNECT.input && index >= 0) { - node.inputs_data[index] = animator.getValue(0); + setInputData(index, animator.getValue(0)); //print($"Set input {node.name} - {index} = {node.inputs_data[index]} | {node.inputs_data}"); } diff --git a/scripts/pcx_ast/pcx_ast.gml b/scripts/pcx_ast/pcx_ast.gml index 971a50bf6..0cd56db34 100644 --- a/scripts/pcx_ast/pcx_ast.gml +++ b/scripts/pcx_ast/pcx_ast.gml @@ -275,9 +275,11 @@ return struct_try_get(params, val); val = string_trim(val); + if(_string(val)) return _string_trim(val); - if(_string(val)) - return _string_trim(val); + var _str = string_splice(val, "."); + if(array_length(_str) > 1 && _str[0] == "self" && struct_has(params, "node_values")) + return struct_try_get(params.node_values, _str[1]); return nodeGetData(val); } #endregion diff --git a/scripts/pcx_server/pcx_server.gml b/scripts/pcx_server/pcx_server.gml index f6f3def51..20bffeabe 100644 --- a/scripts/pcx_server/pcx_server.gml +++ b/scripts/pcx_server/pcx_server.gml @@ -1,4 +1,5 @@ global.NODE_SUB_CATAG = [ "input", "output" ]; +global.PCX_CONSTANT = [ "value", "self" ]; function pxl_document_parser(prompt) { var params = []; @@ -20,13 +21,28 @@ function pxl_document_parser(prompt) { return params; } -function pxl_autocomplete_server(prompt, params = []) { +function pxl_autocomplete_server(prompt, params = [], context = {}) { var res = []; var pr_list = ds_priority_create(); ////////////////////////////////// ds_priority_clear(pr_list); + for( var i = 0, n = array_length(global.PCX_CONSTANT); i < n; i++ ) { + var gl = global.PCX_CONSTANT[i]; + + var match = string_partial_match(string_lower(gl), string_lower(prompt)); + if(match == -9999) continue; + + ds_priority_add(pr_list, [[THEME.ac_constant, 2], gl, "local", gl], match); + } + + repeat(ds_priority_size(pr_list)) + array_push(res, ds_priority_delete_max(pr_list)); + + ////////////////////////////////// + ds_priority_clear(pr_list); + for( var i = 0, n = array_length(params); i < n; i++ ) { var gl = params[i]; @@ -36,10 +52,6 @@ function pxl_autocomplete_server(prompt, params = []) { ds_priority_add(pr_list, [[THEME.ac_constant, 2], gl, "local", gl], match); } - gl = "value"; - var match = string_partial_match(string_lower(gl), string_lower(prompt)); - if(match != -9999) ds_priority_add(pr_list, [[THEME.ac_constant, 2], gl, "local", gl], match); - repeat(ds_priority_size(pr_list)) array_push(res, ds_priority_delete_max(pr_list)); @@ -98,6 +110,18 @@ function pxl_autocomplete_server(prompt, params = []) { ds_priority_add(pr_list, [[THEME.ac_constant, 0], _key, sp[0], $"{sp[0]}.{_key}"], match); } + } else if(sp[0] == "self" && array_length(sp) == 2) { + var _val = context[$ "node_values"]; + var _arr = variable_struct_get_names(_val); + + for( var i = 0, n = array_length(_arr); i < n; i++ ) { + var _key = _arr[i]; + var match = string_partial_match(string_lower(_key), string_lower(sp[1])); + if(match == -9999 && sp[1] != "") + continue; + + ds_priority_add(pr_list, [[THEME.ac_constant, 2], _key, "self", $"{sp[0]}.{_key}"], match); + } } else if(ds_map_exists(PROJECT.nodeNameMap, sp[0])) { if(array_length(sp) == 2) { for( var i = 0, n = array_length(global.NODE_SUB_CATAG); i < n; i++ ) { diff --git a/scripts/string_functions/string_functions.gml b/scripts/string_functions/string_functions.gml index afff0757c..189dd3e6e 100644 --- a/scripts/string_functions/string_functions.gml +++ b/scripts/string_functions/string_functions.gml @@ -58,9 +58,14 @@ function string_real(val, digMax = 999) { #region function string_char_last(str, shift = 0) { #region gml_pragma("forceinline"); return string_char_at(str, string_length(str) - shift); -} #region +} #endregion function filename_name_only(name) { #region name = filename_name(name); return string_replace(name, filename_ext(name), "") +} #endregion + +function string_to_var(str) { #region + gml_pragma("forceinline"); + return string_replace_all(string_lower(str), " ", "_"); } #endregion \ No newline at end of file diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index eca87d32f..cbaff5b83 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -51,6 +51,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor autocomplete_box.textbox = self; autocomplete_server = noone; autocomplete_object = noone; + autocomplete_context = {}; function_guide_box = instance_create(0, 0, o_dialog_textbox_function_guide); function_guide_box.textbox = self; @@ -103,11 +104,11 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor var slp = string_splice(crop, [" ", "(", "[", "{", ",", "\n"]); var pmt = array_safe_get(slp, -1,, ARRAY_OVERFLOW.loop); - var params = []; + var localParams = []; if(parser_server != noone) - params = parser_server(crop, autocomplete_object); + localParams = parser_server(crop, autocomplete_object); - var data = autocomplete_server(pmt, params); + var data = autocomplete_server(pmt, localParams, autocomplete_context); if(array_length(data)) { autocomplete_box.data = data;