From fa630da244e3a085c27ef71434a9c184b7ff0b9e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 11 Feb 2024 20:53:33 +0700 Subject: [PATCH] cmd --- objects/o_main/Create_0.gml | 24 +++++-- objects/o_main/Step_1.gml | 16 +++-- .../animation_controller.gml | 2 + scripts/load_function/load_function.gml | 2 +- scripts/node_data/node_data.gml | 23 +++--- scripts/node_export/node_export.gml | 7 +- scripts/node_image/node_image.gml | 5 +- .../node_terminal_trigger.gml | 11 --- scripts/project_data/project_data.gml | 1 + scripts/render_data/render_data.gml | 72 +++++++++---------- 10 files changed, 87 insertions(+), 76 deletions(-) diff --git a/objects/o_main/Create_0.gml b/objects/o_main/Create_0.gml index 8fc822f1a..e6163f95e 100644 --- a/objects/o_main/Create_0.gml +++ b/objects/o_main/Create_0.gml @@ -316,7 +316,16 @@ alarm[1] = 2; globalvar PROGRAM_ARGUMENTS; - PROGRAM_ARGUMENTS = {}; + PROGRAM_ARGUMENTS = { + run : false, + }; + + //PROGRAM_ARGUMENTS = { + // path: "D:/Project/MakhamDev/LTS-PixelComposer/TEST/terminal/outline.pxc", + // image: "D:/Project/MakhamDev/LTS-PixelComposer/TEST/terminal/05.png", + // run : true, + // persist : false, + //}; var paramCount = parameter_count(); var paramType = "path"; @@ -332,10 +341,8 @@ run_in(1, function() { dialogCall(o_dialog_crashed); }); break; - case "--h" : - draw_enable_drawevent(false); - run_in(3, Terminal_Trigger); - break; + case "--h" : PROGRAM_ARGUMENTS.run = true; break; + case "--p" : PROGRAM_ARGUMENTS.persist = true; break; } } else if(string_starts_with(param, "-")) { @@ -347,7 +354,7 @@ path = string_replace_all(path, "\"", ""); if(file_exists_empty(path) && filename_ext(path) == ".pxc") - PROGRAM_ARGUMENTS[$ string_trim(paramType, ["-"])] = path; + PROGRAM_ARGUMENTS.path = path; } else { PROGRAM_ARGUMENTS[$ paramType] = param; @@ -357,9 +364,12 @@ if(struct_exists(PROGRAM_ARGUMENTS, "path")) { var path = PROGRAM_ARGUMENTS.path; - if(PROJECT.path != path) { + if(PROJECT == noone || PROJECT.path != path) { file_open_parameter = path; run_in(1, function() { load_file_path(file_open_parameter); }); } } + + if(PROGRAM_ARGUMENTS.run) + draw_enable_drawevent(false); #endregion \ No newline at end of file diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index b309acb44..6826b8da2 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -74,7 +74,7 @@ _HOVERING_ELEMENT = noone; #region animation & render DEF_SURFACE_RESET(); - if(!PROJECT.safeMode&& UPDATE_RENDER_ORDER) { + if(!PROJECT.safeMode && UPDATE_RENDER_ORDER) { ResetAllNodesRender(); NodeTopoSort(); } @@ -100,10 +100,18 @@ _HOVERING_ELEMENT = noone; } PROJECT.animator.frame_progress = false; } else { - if(UPDATE & RENDER_TYPE.full) - Render(); - else if(UPDATE & RENDER_TYPE.partial) + if(UPDATE & RENDER_TYPE.full) { + if(PROGRAM_ARGUMENTS.run) { + exportAll(); + PROGRAM_ARGUMENTS.run = false; + + if(!IS_RENDERING && !struct_try_get(PROGRAM_ARGUMENTS, "persist", true)) game_end(); + } else + Render(); + + } else if(UPDATE & RENDER_TYPE.partial) Render(true); + } } } diff --git a/scripts/animation_controller/animation_controller.gml b/scripts/animation_controller/animation_controller.gml index 333e607d4..b4a81bfeb 100644 --- a/scripts/animation_controller/animation_controller.gml +++ b/scripts/animation_controller/animation_controller.gml @@ -166,6 +166,8 @@ is_playing = false; is_rendering = false; time_since_last_frame = 0; + + if(struct_try_get(PROGRAM_ARGUMENTS, "persist", true)) game_end(); } } diff --git a/scripts/load_function/load_function.gml b/scripts/load_function/load_function.gml index 4255d1645..618b90df8 100644 --- a/scripts/load_function/load_function.gml +++ b/scripts/load_function/load_function.gml @@ -57,7 +57,7 @@ function LOAD_AT(path, readonly = false, override = false) { #region if(DEMO) return false; if(!file_exists_empty(path)) { - log_warning("LOAD", "File not found"); + log_warning("LOAD", $"File not found: {path}"); return false; } diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 418bf13b2..111d1f0ee 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -476,19 +476,19 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } #endregion #region ++++ inspector update ++++ - static inspector1Update = function() { - if(error_update_enabled && error_noti_update != noone) - noti_remove(error_noti_update); - error_noti_update = noone; + static inspector1Update = function() { + if(error_update_enabled && error_noti_update != noone) + noti_remove(error_noti_update); + error_noti_update = noone; - onInspector1Update(); - } - static onInspector1Update = noone; - static hasInspector1Update = function() { return onInspector1Update != noone; } + onInspector1Update(); + } + static onInspector1Update = noone; + static hasInspector1Update = function() { return onInspector1Update != noone; } - static inspector2Update = function() { onInspector2Update(); } - static onInspector2Update = noone; - static hasInspector2Update = function() { return onInspector2Update != noone; } + static inspector2Update = function() { onInspector2Update(); } + static onInspector2Update = noone; + static hasInspector2Update = function() { return onInspector2Update != noone; } #endregion static stepBegin = function() { #region @@ -708,6 +708,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var _to = _outp.value_to[j]; if(!_to.node.active || _to.value_from != _outp) continue; + //LOG_IF(global.FLAG.render == 1, $"|| Forwarding dynamic to {_to.node.name} ||"); _to.node.passiveDynamic = true; _to.node.rendered = false; } diff --git a/scripts/node_export/node_export.gml b/scripts/node_export/node_export.gml index 3ee87950e..29e37e133 100644 --- a/scripts/node_export/node_export.gml +++ b/scripts/node_export/node_export.gml @@ -22,15 +22,13 @@ MPEG-4 (.mp4)|*.mp4", function exportAll() { if(IS_RENDERING) return; - Render(); - var key = ds_map_find_first(PROJECT.nodeMap); repeat(ds_map_size(PROJECT.nodeMap)) { var node = PROJECT.nodeMap[? key]; key = ds_map_find_next(PROJECT.nodeMap, key); if(!node.active) continue; - if(instanceof(node) != "Node_Export") continue; + if(!is_instanceof(node, Node_Export)) continue; node.doInspectorAction(); } @@ -493,6 +491,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor static save_surface = function(_surf, _path) { #region var form = getInputData(3); + //print($">>>>>>>>>>>>>>>>>>>> save surface {_surf} - {_path} <<<<<<<<<<<<<<<<<<<<"); if(form == NODE_EXPORT_FORMAT.animation) { surface_save_safe(_surf, _path); @@ -694,7 +693,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } #endregion static doInspectorAction = function() { #region - if(LOADING || APPENDING) return; + if(!PROGRAM_ARGUMENTS.run && (LOADING || APPENDING)) return; var path = getInputData(1); if(path == "") return; diff --git a/scripts/node_image/node_image.gml b/scripts/node_image/node_image.gml index 679b689b7..bff5402c4 100644 --- a/scripts/node_image/node_image.gml +++ b/scripts/node_image/node_image.gml @@ -99,6 +99,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { static update = function(frame = CURRENT_FRAME) { #region var path = getInputData(0); var pad = getInputData(1); + if(path == "") return; if(path_current != path) updatePaths(path); @@ -107,7 +108,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { var ww = sprite_get_width(spr) + pad[0] + pad[2]; var hh = sprite_get_height(spr) + pad[1] + pad[3]; - var _outsurf = outputs[| 0].getValue(); + var _outsurf = outputs[| 0].getValue(); _outsurf = surface_verify(_outsurf, ww, hh, attrDepth()); outputs[| 0].setValue(_outsurf); @@ -115,6 +116,8 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { draw_sprite(spr, 0, pad[2], pad[1]); surface_reset_shader(); + //print($"Image: {spr} | {_outsurf} | {surface_exists(_outsurf)}"); + if(!first_update) return; first_update = false; diff --git a/scripts/node_terminal_trigger/node_terminal_trigger.gml b/scripts/node_terminal_trigger/node_terminal_trigger.gml index 99f05afdf..59f9df2ec 100644 --- a/scripts/node_terminal_trigger/node_terminal_trigger.gml +++ b/scripts/node_terminal_trigger/node_terminal_trigger.gml @@ -12,15 +12,4 @@ function Node_Terminal_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) co draw_sprite_bbox(s_node_terminal_trigger, 0, bbox); } -} - -function Terminal_Trigger() { - var keys = ds_map_keys_to_array(PROJECT.nodeMap); - - for( var i = 0, n = array_length(keys); i < n; i++ ) { - var node = PROJECT.nodeMap[? keys[i]]; - if(!is_instanceof(node, Node_Terminal_Trigger)) continue; - - node.outputs[| 0].setValue(true); - } } \ No newline at end of file diff --git a/scripts/project_data/project_data.gml b/scripts/project_data/project_data.gml index 442a3804c..f3550fe4c 100644 --- a/scripts/project_data/project_data.gml +++ b/scripts/project_data/project_data.gml @@ -1,5 +1,6 @@ #region global globalvar PROJECTS, PROJECT; + PROJECT = noone; #endregion #region project diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index 252aa5d61..8824800b0 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -64,12 +64,44 @@ function NodeTopoSort() { #region } ds_list_clear(PROJECT.nodeTopo); - __sortGraph(PROJECT.nodeTopo, PROJECT.nodes); + topoSort(PROJECT.nodeTopo, PROJECT.nodes); LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++"); } #endregion -function __sortGraph(_list, _nodeList) { #region +function __sortNode(_list, _node) { #region + if(_node.topoSorted) return; + + var _childs = []; + var _prev = _node.getPreviousNodes(); + + for( var i = 0, n = array_length(_prev); i < n; i++ ) { + var _in = _prev[i]; + if(_in.topoSorted) continue; + + array_push(_childs, _in); + } + + //print($" > Checking {_node.name}: {array_length(_childs)}"); + + if(array_empty(_childs)) { + if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder) + topoSort(_list, _node.nodes); + + } else { + for( var i = 0, n = array_length(_childs); i < n; i++ ) + __sortNode(_list, _childs[i]); + } + + if(!_node.topoSorted) { + ds_list_add(_list, _node); + _node.topoSorted = true; + + //print($" > Adding > {_node.name}"); + } +} #endregion + +function topoSort(_list, _nodeList) { #region var _root = []; var _leftOver = []; @@ -102,42 +134,8 @@ function __sortGraph(_list, _nodeList) { #region //print($" > Roots: {_root}"); - var _sortQueue = ds_queue_create(); - for( var i = 0, n = array_length(_root); i < n; i++ ) - ds_queue_enqueue(_sortQueue, _root[i]); - - while(!ds_queue_empty(_sortQueue)) { - var _node = ds_queue_dequeue(_sortQueue); - if(_node.topoSorted) continue; - - var _childs = []; - var _prev = _node.getPreviousNodes(); - - for( var i = 0, n = array_length(_prev); i < n; i++ ) { - var _in = _prev[i]; - - if(!ds_list_exist(_nodeList, _in)) continue; - if(_in.topoSorted) continue; - - array_push(_childs, _in); - } - - //print($" > Checking {_node.name}: {array_length(_childs)}"); - - if(array_empty(_childs)) { - if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder) - __sortGraph(_list, _node.nodes); - } else { - for( var i = 0, n = array_length(_childs); i < n; i++ ) - ds_queue_enqueue(_sortQueue, _childs[i]); - } - - if(!_node.topoSorted) { - ds_list_add(_list, _node); - _node.topoSorted = true; - } - } + __sortNode(_list, _root[i]); for( var i = 0, n = array_length(_leftOver); i < n; i++ ) { if(!_leftOver[i].topoSorted)