From f9e5e3ea9c8ffce543e62d05d2d1a47b3381f4ea Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 23 Nov 2023 08:32:26 +0700 Subject: [PATCH] Lua update, array processor --- scripts/append_function/append_function.gml | 12 +-- scripts/load_function/load_function.gml | 36 ++++++-- scripts/node_3d_depth/node_3d_depth.gml | 8 +- scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml | 14 ++-- scripts/node_collection/node_collection.gml | 1 + .../node_group_thumbnail.gml | 3 + scripts/node_lua_compute/node_lua_compute.gml | 83 +++++++++---------- scripts/node_lua_global/node_lua_global.gml | 34 ++++---- scripts/node_lua_surface/node_lua_surface.gml | 76 ++++++++--------- scripts/node_processor/node_processor.gml | 2 + scripts/panel_menu/panel_menu.gml | 7 ++ scripts/save_function/save_function.gml | 40 ++++----- 12 files changed, 172 insertions(+), 144 deletions(-) diff --git a/scripts/append_function/append_function.gml b/scripts/append_function/append_function.gml index e85d62db6..356efc35c 100644 --- a/scripts/append_function/append_function.gml +++ b/scripts/append_function/append_function.gml @@ -1,4 +1,4 @@ -function APPEND(_path, context = PANEL_GRAPH.getCurrentContext()) { +function APPEND(_path, context = PANEL_GRAPH.getCurrentContext()) { #region if(_path == "") return noone; var _map = json_load_struct(_path); @@ -12,9 +12,9 @@ function APPEND(_path, context = PANEL_GRAPH.getCurrentContext()) { log_message("FILE", "append file " + _path, THEME.noti_icon_file_load); return node_create; -} +} #endregion -function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { +function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { #region static log = false; UNDO_HOLDING = true; @@ -149,13 +149,13 @@ function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { } return node_create; -} +} #endregion -function GetAppendID(old_id) { +function GetAppendID(old_id) { #region if(old_id == noone) return noone; if(ds_map_exists(APPEND_MAP, old_id)) return APPEND_MAP[? old_id]; print("Get append ID error: " + string(old_id)); return noone; -} \ No newline at end of file +} #endregion \ No newline at end of file diff --git a/scripts/load_function/load_function.gml b/scripts/load_function/load_function.gml index d0fb3d4ce..0d640b3d8 100644 --- a/scripts/load_function/load_function.gml +++ b/scripts/load_function/load_function.gml @@ -1,4 +1,4 @@ -function LOAD(safe = false) { +function LOAD(safe = false) { #region if(DEMO) return false; var path = get_open_filename("Pixel Composer PROJECT (.pxc)|*.pxc", ""); @@ -8,9 +8,9 @@ function LOAD(safe = false) { gc_collect(); var proj = LOAD_PATH(path, false, safe); -} +} #endregion -function TEST_PATH(path) { +function TEST_PATH(path) { #region TESTING = true; TEST_ERROR = true; @@ -19,9 +19,9 @@ function TEST_PATH(path) { PANEL_GRAPH.setProject(PROJECT); __LOAD_PATH(path); -} +} #endregion -function LOAD_PATH(path, readonly = false, safe_mode = false) { +function LOAD_PATH(path, readonly = false, safe_mode = false) { #region for( var i = 0, n = array_length(PROJECTS); i < n; i++ ) if(PROJECTS[i].path == path) return; @@ -47,9 +47,9 @@ function LOAD_PATH(path, readonly = false, safe_mode = false) { setFocus(PANEL_GRAPH.panel); return PROJECT; -} +} #endregion -function __LOAD_PATH(path, readonly = false, override = false) { +function __LOAD_PATH(path, readonly = false, override = false) { #region if(DEMO) return false; if(!file_exists(path)) { @@ -250,4 +250,24 @@ function __LOAD_PATH(path, readonly = false, override = false) { PANEL_GRAPH.toCenterNode(); return true; -} \ No newline at end of file +} #endregion + +function __IMPORT_ZIP() { #region + var path = get_open_filename("Pixel Composer portable project (.zip)|*.zip", ""); + + var _fname = filename_name_only(path); + var _fext = filename_ext(path); + if(_fext != ".zip") return false; + + directory_verify(TEMPDIR + "proj/"); + var _dir = TEMPDIR + "proj/" + _fname; + directory_create(_dir); + zip_unzip(path, _dir); + + var _f = file_find_first(_dir + "/*.pxc", fa_none); + var _proj = $"{_dir}/{_f}"; + print(_proj); + if(!file_exists(_proj)) return false; + + LOAD_PATH(_proj, true); +} #endregion \ No newline at end of file diff --git a/scripts/node_3d_depth/node_3d_depth.gml b/scripts/node_3d_depth/node_3d_depth.gml index e7db11e52..7acb2308c 100644 --- a/scripts/node_3d_depth/node_3d_depth.gml +++ b/scripts/node_3d_depth/node_3d_depth.gml @@ -42,10 +42,10 @@ function Node_3D_Depth(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var right_y = sin(x_rad) * sin(y_rad) * cos(z_rad) - cos(x_rad) * sin(z_rad); var right_z = cos(x_rad) * sin(y_rad) * cos(z_rad) + sin(x_rad) * sin(z_rad); - print($"POS: {_cx}, {_cy}, {_cz}"); - print($"UP: {up_x}, {up_y}, {up_z}"); - print($"RIGHT: {right_x}, {right_y}, {right_z}"); - print(""); + //print($"POS: {_cx}, {_cy}, {_cz}"); + //print($"UP: {up_x}, {up_y}, {up_z}"); + //print($"RIGHT: {right_x}, {right_y}, {right_z}"); + //print(""); surface_set_shader(_outSurf, sh_3d_depth); DRAW_CLEAR diff --git a/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml b/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml index c51a1bccf..0d8d23746 100644 --- a/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml +++ b/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml @@ -119,13 +119,13 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) use_display_list = true; if(obj_raw == noone) return; - var txt = $"========== OBJ import ==========\n"; - txt += $"Vertex counts: {obj_raw.vertex_count}\n"; - txt += $"Object counts: {obj_raw.object_counts}\n"; - txt += $"Material counts: {array_length(obj_raw.materials)}\n"; - txt += $"Model BBOX: {obj_raw.model_size}\n"; - txt += $"Load completed in {(get_timer() - obj_read_time) / 1000} ms\n"; - print(txt); + //var txt = $"========== OBJ import ==========\n"; + //txt += $"Vertex counts: {obj_raw.vertex_count}\n"; + //txt += $"Object counts: {obj_raw.object_counts}\n"; + //txt += $"Material counts: {array_length(obj_raw.materials)}\n"; + //txt += $"Model BBOX: {obj_raw.model_size}\n"; + //txt += $"Load completed in {(get_timer() - obj_read_time) / 1000} ms\n"; + //print(txt); var span = max(abs(obj_raw.model_size.x), abs(obj_raw.model_size.y), abs(obj_raw.model_size.z)); if(span > 10) noti_warning($"The model is tool large to display properly ({span}u). Scale the model down to preview."); diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index ef030940c..73bbe16d1 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -551,6 +551,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static getGraphPreviewSurface = function() { #region var _output_junc = outputs[| preview_channel]; + for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) { if(!nodes[| i].active) continue; if(is_instanceof(nodes[| i], Node_Group_Thumbnail)) diff --git a/scripts/node_group_thumbnail/node_group_thumbnail.gml b/scripts/node_group_thumbnail/node_group_thumbnail.gml index dfcffcedf..4ffc1b9f5 100644 --- a/scripts/node_group_thumbnail/node_group_thumbnail.gml +++ b/scripts/node_group_thumbnail/node_group_thumbnail.gml @@ -5,6 +5,9 @@ function Node_Group_Thumbnail(_x, _y, _group = noone) : Node(_x, _y, _group) con inputs[| 0] = nodeValue("Input", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) .setVisible(true, true); + + outputs[| 0] = nodeValue("Output", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); static getGraphPreviewSurface = function() { #region return getInputData(0); diff --git a/scripts/node_lua_compute/node_lua_compute.gml b/scripts/node_lua_compute/node_lua_compute.gml index 238c9fa50..7f72aafc7 100644 --- a/scripts/node_lua_compute/node_lua_compute.gml +++ b/scripts/node_lua_compute/node_lua_compute.gml @@ -15,19 +15,6 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs[| 4] = nodeValue("Execute on frame", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true) - static createNewInput = function() { - var index = ds_list_size(inputs); - inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ); - - inputs[| index + 1] = nodeValue("Argument type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) - .setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "String", "Surface", "Struct" ], update_hover: false }); - inputs[| index + 1].editWidget.interactable = false; - - inputs[| index + 2] = nodeValue("Argument value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) - .setVisible(true, true); - inputs[| index + 2].editWidget.interactable = false; - } - outputs[| 0] = nodeValue("Execution thread", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, noone ); outputs[| 1] = nodeValue("Return value", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, 0); @@ -51,9 +38,20 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru error_notification = noone; compiled = false; - if(!LOADING && !APPENDING) createNewInput(); + static createNewInput = function() { #region + var index = ds_list_size(inputs); + inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ); + + inputs[| index + 1] = nodeValue("Argument type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) + .setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "String", "Surface", "Struct" ], update_hover: false }); + inputs[| index + 1].editWidget.interactable = false; + + inputs[| index + 2] = nodeValue("Argument value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) + .setVisible(true, true); + inputs[| index + 2].editWidget.interactable = false; + } if(!LOADING && !APPENDING) createNewInput(); #endregion - static stepBegin = function() { + static stepBegin = function() { #region if(PROJECT.animator.frame_progress) setRenderStatus(false); @@ -77,15 +75,15 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru case 1 : outputs[| 1].setType(VALUE_TYPE.text); break; case 2 : outputs[| 1].setType(VALUE_TYPE.struct); break; } - } + } #endregion - static getState = function() { + static getState = function() { #region if(inputs[| 3].isLeaf()) return lua_state; return inputs[| 3].value_from.node.getState(); - } + } #endregion - static refreshDynamicInput = function() { + static refreshDynamicInput = function() { #region var _in = ds_list_create(); for( var i = 0; i < input_fix_len; i++ ) @@ -127,13 +125,13 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs = _in; createNewInput(); - } + } #endregion - static onValueFromUpdate = function(index) { + static onValueFromUpdate = function(index) { #region if(index == 0 || index == 2) compiled = false; - } + } #endregion - static onValueUpdate = function(index = 0) { + static onValueUpdate = function(index = 0) { #region if(index == 0 || index == 2) compiled = false; if(index == 3) { @@ -149,16 +147,16 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru compiled = false; refreshDynamicInput(); - } + } #endregion - static step = function() { + static step = function() { #region for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) { var name = getInputData(i + 0); inputs[| i + 2].name = name; } - } + } #endregion - static update = function(frame = CURRENT_FRAME) { + static update = function(frame = CURRENT_FRAME) { #region if(!compiled) return; //if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return; @@ -172,12 +170,6 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) array_push(argument_val, getInputData(i + 2)); - //if(CURRENT_FRAME == 0) { //refresh state on the first frame - // lua_state_destroy(lua_state); - // lua_state = lua_create(); - // addCode(); - //} - lua_projectData(getState()); var res = 0; @@ -188,9 +180,9 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru } outputs[| 1].setValue(res); - } + } #endregion - static addCode = function() { + static addCode = function() { #region var _func = getInputData(0); var _code = getInputData(2); argument_name = []; @@ -207,15 +199,14 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru lua_code += ")\n"; lua_code += _code; lua_code += "\nend"; - //print(lua_code); lua_add_code(getState(), lua_code); - } + } #endregion insp1UpdateTooltip = __txt("Compile"); insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ]; - static onInspector1Update = function() { //compile + static onInspector1Update = function() { #region var thrd = inputs[| 3].value_from; if(thrd == noone) { doCompile(); @@ -223,9 +214,9 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru } thrd.node.onInspector1Update(); - } + } #endregion - static doCompile = function() { + static doCompile = function() { #region compiled = true; addCode(); @@ -236,9 +227,9 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru } doUpdate(); - } + } #endregion - static doApplyDeserialize = function() { + static doApplyDeserialize = function() { #region refreshDynamicInput(); for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) { @@ -256,11 +247,13 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs[| i + 2].setDisplay(VALUE_DISPLAY._default); } - } + + doCompile(); + } #endregion - static onDestroy = function() { + static onDestroy = function() { #region lua_state_destroy(lua_state); if(error_notification != noone) noti_remove(error_notification); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_lua_global/node_lua_global.gml b/scripts/node_lua_global/node_lua_global.gml index cd3b3ec98..88ae824d3 100644 --- a/scripts/node_lua_global/node_lua_global.gml +++ b/scripts/node_lua_global/node_lua_global.gml @@ -24,7 +24,7 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc error_notification = noone; compiled = false; - static stepBegin = function() { + static stepBegin = function() { #region var _type = getInputData(1); if(PROJECT.animator.is_playing && PROJECT.animator.frame_progress && (CURRENT_FRAME == 0 || _type == 1)) @@ -43,22 +43,22 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc noti_remove(error_notification); error_notification = noone; } - } + } #endregion - static getState = function() { + static getState = function() { #region if(inputs[| 2].isLeaf()) return lua_state; return inputs[| 2].value_from.node.getState(); - } + } #endregion - static onValueFromUpdate = function(index) { + static onValueFromUpdate = function(index) { #region if(index == 0 || index == 2) compiled = false; - } + } #endregion - static onValueUpdate = function(index = 0) { + static onValueUpdate = function(index = 0) { #region if(index == 0 || index == 2) compiled = false; - } + } #endregion - static update = function(frame = CURRENT_FRAME) { + static update = function(frame = CURRENT_FRAME) { #region if(!compiled) return; //if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return; @@ -77,9 +77,9 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc try { lua_add_code(getState(), _code); } catch(e) { noti_warning(exception_print(e),, self); } } - } + } #endregion - static onInspector1Update = function() { //compile + static onInspector1Update = function() { #region var thrd = inputs[| 2].value_from; if(thrd == noone) { doCompile(); @@ -87,9 +87,9 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc } thrd.node.onInspector1Update(); - } + } #endregion - static doCompile = function() { + static doCompile = function() { #region compiled = true; for( var i = 0; i < ds_list_size(outputs[| 0].value_to); i++ ) { @@ -99,11 +99,13 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc } doUpdate(); - } + } #endregion - static onDestroy = function() { + static doApplyDeserialize = function() { doCompile(); } + + static onDestroy = function() { #region lua_state_destroy(lua_state); if(error_notification != noone) noti_remove(error_notification); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_lua_surface/node_lua_surface.gml b/scripts/node_lua_surface/node_lua_surface.gml index 1af18e01d..26cf6d15d 100644 --- a/scripts/node_lua_surface/node_lua_surface.gml +++ b/scripts/node_lua_surface/node_lua_surface.gml @@ -15,19 +15,6 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs[| 4] = nodeValue("Execute on frame", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true) - static createNewInput = function() { - var index = ds_list_size(inputs); - inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ); - - inputs[| index + 1] = nodeValue("Argument type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) - .setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "String", "Surface", "Struct" ], update_hover: false }); - inputs[| index + 1].editWidget.interactable = false; - - inputs[| index + 2] = nodeValue("Argument value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) - .setVisible(true, true); - inputs[| index + 2].editWidget.interactable = false; - } - outputs[| 0] = nodeValue("Execution thread", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, noone ); outputs[| 1] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -52,9 +39,20 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru error_notification = noone; compiled = false; - if(!LOADING && !APPENDING) createNewInput(); + static createNewInput = function() { #region + var index = ds_list_size(inputs); + inputs[| index + 0] = nodeValue("Argument name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ); + + inputs[| index + 1] = nodeValue("Argument type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) + .setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "String", "Surface", "Struct" ], update_hover: false }); + inputs[| index + 1].editWidget.interactable = false; + + inputs[| index + 2] = nodeValue("Argument value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) + .setVisible(true, true); + inputs[| index + 2].editWidget.interactable = false; + } if(!LOADING && !APPENDING) createNewInput(); #endregion - static stepBegin = function() { + static stepBegin = function() { #region if(PROJECT.animator.frame_progress) setRenderStatus(false); @@ -71,15 +69,15 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru noti_remove(error_notification); error_notification = noone; } - } + } #endregion - static getState = function() { + static getState = function() { #region if(inputs[| 3].isLeaf()) return lua_state; return inputs[| 3].value_from.node.getState(); - } + } #endregion - static refreshDynamicInput = function() { + static refreshDynamicInput = function() { #region var _in = ds_list_create(); for( var i = 0; i < input_fix_len; i++ ) @@ -121,13 +119,13 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs = _in; createNewInput(); - } + } #endregion - static onValueFromUpdate = function(index) { + static onValueFromUpdate = function(index) { #region if(index == 0 || index == 2) compiled = false; - } + } #endregion - static onValueUpdate = function(index = 0) { + static onValueUpdate = function(index = 0) { #region if(index == 0 || index == 2) compiled = false; if(index == 3) { @@ -143,16 +141,16 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru compiled = false; refreshDynamicInput(); - } + } #endregion - static step = function() { + static step = function() { #region for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) { var name = getInputData(i + 0); inputs[| i + 2].name = name; } - } + } #endregion - static update = function(frame = CURRENT_FRAME) { + static update = function(frame = CURRENT_FRAME) { #region if(!compiled) return; //if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return; @@ -184,9 +182,9 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru surface_reset_target(); outputs[| 1].setValue(_outSurf); - } + } #endregion - static addCode = function() { + static addCode = function() { #region var _func = getInputData(0); var _code = getInputData(2); argument_name = []; @@ -205,12 +203,12 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru lua_code += "\nend"; lua_add_code(getState(), lua_code); - } + } #endregion insp1UpdateTooltip = __txt("Compile"); insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ]; - static onInspector1Update = function() { //compile + static onInspector1Update = function() { #region var thrd = inputs[| 3].value_from; if(thrd == noone) { doCompile(); @@ -218,9 +216,9 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru } thrd.node.onInspector1Update(); - } + } #endregion - static doCompile = function() { + static doCompile = function() { #region addCode(); compiled = true; @@ -231,9 +229,9 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru } doUpdate(); - } + } #endregion - static doApplyDeserialize = function() { + static doApplyDeserialize = function() { #region refreshDynamicInput(); for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) { @@ -251,11 +249,13 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs[| i + 2].setDisplay(VALUE_DISPLAY._default); } - } + + doCompile(); + } #endregion - static onDestroy = function() { + static onDestroy = function() { #region lua_state_destroy(lua_state); if(error_notification != noone) noti_remove(error_notification); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index 66ce5d91d..bcb063f53 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -49,6 +49,8 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct if(!_n.isArray()) return _in; var _aIndex = _arr; + if(!is_array(_arr)) return 0; + switch(attributes.array_process) { case ARRAY_PROCESS.loop : _aIndex = safe_mod(_arr, array_length(_in)); break; case ARRAY_PROCESS.hold : _aIndex = min(_arr, array_length(_in) - 1); break; diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index 5234c7751..ae965c628 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -32,6 +32,13 @@ function Panel_Menu() : PanelContent() constructor { return submenuCall(_dat, arr); }).setIsShelf(), menuItem(__txtx("panel_menu_auto_save_folder", "Open autosave folder"), function() { shellOpenExplorer(DIRECTORY + "autosave"); }, THEME.save_auto), + menuItem(__txt("Import"), function(_dat) { + var arr = [ + menuItem(__txt("Portable project (.zip)") + "...", function() { __IMPORT_ZIP(); }), + ]; + + return submenuCall(_dat, arr); + }).setIsShelf(), menuItem(__txt("Export"), function(_dat) { var arr = [ menuItem(__txt("Portable project (.zip)") + "...", function() { exportPortable(PROJECT); }), diff --git a/scripts/save_function/save_function.gml b/scripts/save_function/save_function.gml index 6bf7a9175..5513ad9b7 100644 --- a/scripts/save_function/save_function.gml +++ b/scripts/save_function/save_function.gml @@ -1,16 +1,16 @@ globalvar SAVING; SAVING = false; -function NEW() { +function NEW() { #region PROJECT = new Project(); array_push(PROJECTS, PROJECT); var graph = new Panel_Graph(PROJECT); PANEL_GRAPH.panel.setContent(graph, true); PANEL_GRAPH = graph; -} +} #endregion -function save_serialize(project = PROJECT, _outMap = false) { +function save_serialize(project = PROJECT, _outMap = false) { #region var _map = {}; _map.version = SAVE_VERSION; @@ -57,9 +57,9 @@ function save_serialize(project = PROJECT, _outMap = false) { if(_outMap) return _map; return PREFERENCES.save_file_minify? json_stringify_minify(_map) : json_stringify(_map, true); -} +} #endregion -function SET_PATH(project, path) { +function SET_PATH(project, path) { #region if(path == "") { project.readonly = false; } else if(!project.readonly) { @@ -73,22 +73,22 @@ function SET_PATH(project, path) { } project.path = path; -} +} #endregion -function SAVE_ALL() { +function SAVE_ALL() { #region for( var i = 0, n = array_length(PROJECTS); i < n; i++ ) SAVE(PROJECTS[i]); -} +} #endregion -function SAVE(project = PROJECT) { +function SAVE(project = PROJECT) { #region if(DEMO) return false; if(project.path == "" || project.readonly) return SAVE_AS(project); return SAVE_AT(project, project.path); -} +} #endregion -function SAVE_AS(project = PROJECT) { +function SAVE_AS(project = PROJECT) { #region if(DEMO) return false; var path = get_save_filename("Pixel Composer project (.pxc)|*.pxc", ""); @@ -104,9 +104,9 @@ function SAVE_AS(project = PROJECT) { SET_PATH(project, path); return true; -} +} #endregion -function SAVE_AT(project = PROJECT, path = "", log = "save at ") { +function SAVE_AT(project = PROJECT, path = "", log = "save at ") { #region if(DEMO) return false; SAVING = true; @@ -125,11 +125,11 @@ function SAVE_AT(project = PROJECT, path = "", log = "save at ") { PANEL_MENU.setNotiIcon(THEME.noti_icon_file_save); return true; -} +} #endregion /////////////////////////////////////////////////////// COLLECTION /////////////////////////////////////////////////////// -function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { +function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { #region var _content = {}; _content.version = SAVE_VERSION; @@ -171,9 +171,9 @@ function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone, c log_message("COLLECTION", "save collection at " + _path, THEME.noti_icon_file_save); PANEL_MENU.setNotiIcon(THEME.noti_icon_file_save); -} +} #endregion -function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { +function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { #region if(save_surface) { var preview_surface = PANEL_PREVIEW.getNodePreviewSurface(); if(is_surface(preview_surface)) { @@ -206,9 +206,9 @@ function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone, co log_message("COLLECTION", "save collection at " + _path, THEME.noti_icon_file_save); PANEL_MENU.setNotiIcon(THEME.noti_icon_file_save); -} +} #endregion -function SAVE_NODE(_arr, _node, dx = 0, dy = 0, scale = false, context = PANEL_GRAPH.getCurrentContext()) { +function SAVE_NODE(_arr, _node, dx = 0, dy = 0, scale = false, context = PANEL_GRAPH.getCurrentContext()) { #region if(struct_has(_node, "nodes")) { for(var i = 0; i < ds_list_size(_node.nodes); i++) SAVE_NODE(_arr, _node.nodes[| i], dx, dy, scale, context); @@ -222,4 +222,4 @@ function SAVE_NODE(_arr, _node, dx = 0, dy = 0, scale = false, context = PANEL_G if(m.group == c) m.group = noone; array_push(_arr, m); -} \ No newline at end of file +} #endregion \ No newline at end of file