mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
cmd
This commit is contained in:
parent
acdbee9a30
commit
fa630da244
10 changed files with 87 additions and 76 deletions
|
@ -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
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#region global
|
||||
globalvar PROJECTS, PROJECT;
|
||||
PROJECT = noone;
|
||||
#endregion
|
||||
|
||||
#region project
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue