This commit is contained in:
Tanasart 2024-02-11 20:53:33 +07:00
parent acdbee9a30
commit fa630da244
10 changed files with 87 additions and 76 deletions

View file

@ -316,7 +316,16 @@
alarm[1] = 2; alarm[1] = 2;
globalvar PROGRAM_ARGUMENTS; 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 paramCount = parameter_count();
var paramType = "path"; var paramType = "path";
@ -332,10 +341,8 @@
run_in(1, function() { dialogCall(o_dialog_crashed); }); run_in(1, function() { dialogCall(o_dialog_crashed); });
break; break;
case "--h" : case "--h" : PROGRAM_ARGUMENTS.run = true; break;
draw_enable_drawevent(false); case "--p" : PROGRAM_ARGUMENTS.persist = true; break;
run_in(3, Terminal_Trigger);
break;
} }
} else if(string_starts_with(param, "-")) { } else if(string_starts_with(param, "-")) {
@ -347,7 +354,7 @@
path = string_replace_all(path, "\"", ""); path = string_replace_all(path, "\"", "");
if(file_exists_empty(path) && filename_ext(path) == ".pxc") if(file_exists_empty(path) && filename_ext(path) == ".pxc")
PROGRAM_ARGUMENTS[$ string_trim(paramType, ["-"])] = path; PROGRAM_ARGUMENTS.path = path;
} else { } else {
PROGRAM_ARGUMENTS[$ paramType] = param; PROGRAM_ARGUMENTS[$ paramType] = param;
@ -357,9 +364,12 @@
if(struct_exists(PROGRAM_ARGUMENTS, "path")) { if(struct_exists(PROGRAM_ARGUMENTS, "path")) {
var path = PROGRAM_ARGUMENTS.path; var path = PROGRAM_ARGUMENTS.path;
if(PROJECT.path != path) { if(PROJECT == noone || PROJECT.path != path) {
file_open_parameter = path; file_open_parameter = path;
run_in(1, function() { load_file_path(file_open_parameter); }); run_in(1, function() { load_file_path(file_open_parameter); });
} }
} }
if(PROGRAM_ARGUMENTS.run)
draw_enable_drawevent(false);
#endregion #endregion

View file

@ -74,7 +74,7 @@ _HOVERING_ELEMENT = noone;
#region animation & render #region animation & render
DEF_SURFACE_RESET(); DEF_SURFACE_RESET();
if(!PROJECT.safeMode&& UPDATE_RENDER_ORDER) { if(!PROJECT.safeMode && UPDATE_RENDER_ORDER) {
ResetAllNodesRender(); ResetAllNodesRender();
NodeTopoSort(); NodeTopoSort();
} }
@ -100,10 +100,18 @@ _HOVERING_ELEMENT = noone;
} }
PROJECT.animator.frame_progress = false; PROJECT.animator.frame_progress = false;
} else { } else {
if(UPDATE & RENDER_TYPE.full) 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(); Render();
else if(UPDATE & RENDER_TYPE.partial)
} else if(UPDATE & RENDER_TYPE.partial)
Render(true); Render(true);
} }
} }
} }

View file

@ -166,6 +166,8 @@
is_playing = false; is_playing = false;
is_rendering = false; is_rendering = false;
time_since_last_frame = 0; time_since_last_frame = 0;
if(struct_try_get(PROGRAM_ARGUMENTS, "persist", true)) game_end();
} }
} }

View file

@ -57,7 +57,7 @@ function LOAD_AT(path, readonly = false, override = false) { #region
if(DEMO) return false; if(DEMO) return false;
if(!file_exists_empty(path)) { if(!file_exists_empty(path)) {
log_warning("LOAD", "File not found"); log_warning("LOAD", $"File not found: {path}");
return false; return false;
} }

View file

@ -708,6 +708,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
var _to = _outp.value_to[j]; var _to = _outp.value_to[j];
if(!_to.node.active || _to.value_from != _outp) continue; 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.passiveDynamic = true;
_to.node.rendered = false; _to.node.rendered = false;
} }

View file

@ -22,15 +22,13 @@ MPEG-4 (.mp4)|*.mp4",
function exportAll() { function exportAll() {
if(IS_RENDERING) return; if(IS_RENDERING) return;
Render();
var key = ds_map_find_first(PROJECT.nodeMap); var key = ds_map_find_first(PROJECT.nodeMap);
repeat(ds_map_size(PROJECT.nodeMap)) { repeat(ds_map_size(PROJECT.nodeMap)) {
var node = PROJECT.nodeMap[? key]; var node = PROJECT.nodeMap[? key];
key = ds_map_find_next(PROJECT.nodeMap, key); key = ds_map_find_next(PROJECT.nodeMap, key);
if(!node.active) continue; if(!node.active) continue;
if(instanceof(node) != "Node_Export") continue; if(!is_instanceof(node, Node_Export)) continue;
node.doInspectorAction(); 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 static save_surface = function(_surf, _path) { #region
var form = getInputData(3); var form = getInputData(3);
//print($">>>>>>>>>>>>>>>>>>>> save surface {_surf} - {_path} <<<<<<<<<<<<<<<<<<<<");
if(form == NODE_EXPORT_FORMAT.animation) { if(form == NODE_EXPORT_FORMAT.animation) {
surface_save_safe(_surf, _path); surface_save_safe(_surf, _path);
@ -694,7 +693,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} #endregion } #endregion
static doInspectorAction = function() { #region static doInspectorAction = function() { #region
if(LOADING || APPENDING) return; if(!PROGRAM_ARGUMENTS.run && (LOADING || APPENDING)) return;
var path = getInputData(1); var path = getInputData(1);
if(path == "") return; if(path == "") return;

View file

@ -99,6 +99,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) { #region
var path = getInputData(0); var path = getInputData(0);
var pad = getInputData(1); var pad = getInputData(1);
if(path == "") return; if(path == "") return;
if(path_current != path) updatePaths(path); if(path_current != path) updatePaths(path);
@ -115,6 +116,8 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
draw_sprite(spr, 0, pad[2], pad[1]); draw_sprite(spr, 0, pad[2], pad[1]);
surface_reset_shader(); surface_reset_shader();
//print($"Image: {spr} | {_outsurf} | {surface_exists(_outsurf)}");
if(!first_update) return; if(!first_update) return;
first_update = false; first_update = false;

View file

@ -13,14 +13,3 @@ function Node_Terminal_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) co
draw_sprite_bbox(s_node_terminal_trigger, 0, bbox); 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);
}
}

View file

@ -1,5 +1,6 @@
#region global #region global
globalvar PROJECTS, PROJECT; globalvar PROJECTS, PROJECT;
PROJECT = noone;
#endregion #endregion
#region project #region project

View file

@ -64,12 +64,44 @@ function NodeTopoSort() { #region
} }
ds_list_clear(PROJECT.nodeTopo); 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 +++++++"); LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++");
} #endregion } #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 _root = [];
var _leftOver = []; var _leftOver = [];
@ -102,42 +134,8 @@ function __sortGraph(_list, _nodeList) { #region
//print($" > Roots: {_root}"); //print($" > Roots: {_root}");
var _sortQueue = ds_queue_create();
for( var i = 0, n = array_length(_root); i < n; i++ ) for( var i = 0, n = array_length(_root); i < n; i++ )
ds_queue_enqueue(_sortQueue, _root[i]); __sortNode(_list, _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;
}
}
for( var i = 0, n = array_length(_leftOver); i < n; i++ ) { for( var i = 0, n = array_length(_leftOver); i < n; i++ ) {
if(!_leftOver[i].topoSorted) if(!_leftOver[i].topoSorted)