project close bug

This commit is contained in:
Tanasart 2023-07-23 21:15:45 +02:00
parent 89694e99e8
commit a0843b6aa7
8 changed files with 76 additions and 59 deletions

View file

@ -2,36 +2,37 @@
if(OS == os_windows && gameframe_is_minimized()) exit; if(OS == os_windows && gameframe_is_minimized()) exit;
//print("===== Step start ====="); //print("===== Step start =====");
#region animation if(PROJECT.active) {
if(PROJECT.animator.is_playing && PROJECT.animator.play_freeze == 0) { #region animation
PROJECT.animator.time_since_last_frame += PROJECT.animator.framerate * (delta_time / 1000000); if(PROJECT.animator.is_playing && PROJECT.animator.play_freeze == 0) {
PROJECT.animator.time_since_last_frame += PROJECT.animator.framerate * (delta_time / 1000000);
if(PROJECT.animator.time_since_last_frame >= 1) if(PROJECT.animator.time_since_last_frame >= 1)
PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1);
} else { } else {
PROJECT.animator.frame_progress = false; PROJECT.animator.frame_progress = false;
PROJECT.animator.setFrame(PROJECT.animator.real_frame); PROJECT.animator.setFrame(PROJECT.animator.real_frame);
PROJECT.animator.time_since_last_frame = 0; PROJECT.animator.time_since_last_frame = 0;
}
PROJECT.animator.play_freeze = max(0, PROJECT.animator.play_freeze - 1);
#endregion
#region step
PROJECT.globalNode.step();
try {
if(PANEL_MAIN != 0)
PANEL_MAIN.step();
for(var i = 0; i < ds_list_size(PROJECT.nodes); i++) {
PROJECT.nodes[| i].triggerCheck();
PROJECT.nodes[| i].step();
} }
} catch(e) {
noti_warning("Step error: " + exception_print(e)); PROJECT.animator.play_freeze = max(0, PROJECT.animator.play_freeze - 1);
} #endregion
#endregion
#region step
PROJECT.globalNode.step();
try {
if(PANEL_MAIN != 0)
PANEL_MAIN.step();
for(var i = 0; i < ds_list_size(PROJECT.nodes); i++) {
PROJECT.nodes[| i].triggerCheck();
PROJECT.nodes[| i].step();
}
} catch(e)
noti_warning("Step error: " + exception_print(e));
#endregion
}
#region hotkey #region hotkey
HOTKEY_MOD = 0; HOTKEY_MOD = 0;

View file

@ -1,4 +1,5 @@
/// @description init /// @description init
//print(PROJECT.path);
global.cache_call = 0; global.cache_call = 0;
global.cache_hit = 0; global.cache_hit = 0;
@ -77,26 +78,29 @@ _HOVERING_ELEMENT = noone;
//physics_pause_enable(true); //physics_pause_enable(true);
DEF_SURFACE_RESET(); DEF_SURFACE_RESET();
var _k = ds_map_find_first(PROJECT.nodeMap); if(PROJECT.active) {
var _a = ds_map_size(PROJECT.nodeMap); var _k = ds_map_find_first(PROJECT.nodeMap);
repeat(_a) { var _a = ds_map_size(PROJECT.nodeMap);
PROJECT.nodeMap[? _k].stepBegin(); repeat(_a) {
_k = ds_map_find_next(PROJECT.nodeMap, _k); PROJECT.nodeMap[? _k].stepBegin();
_k = ds_map_find_next(PROJECT.nodeMap, _k);
}
if(PROJECT.animator.is_playing || PROJECT.animator.rendering) {
if(PROJECT.animator.frame_progress) {
__addon_preAnim();
Render();
__addon_postAnim();
}
PROJECT.animator.frame_progress = false;
} else {
if(UPDATE & RENDER_TYPE.full)
Render();
else if(UPDATE & RENDER_TYPE.partial)
Render(true);
}
} }
if(PROJECT.animator.is_playing || PROJECT.animator.rendering) {
if(PROJECT.animator.frame_progress) {
__addon_preAnim();
Render();
__addon_postAnim();
}
PROJECT.animator.frame_progress = false;
} else {
if(UPDATE & RENDER_TYPE.full)
Render();
else if(UPDATE & RENDER_TYPE.partial)
Render(true);
}
UPDATE = RENDER_TYPE.none; UPDATE = RENDER_TYPE.none;
#endregion #endregion

View file

@ -15,6 +15,8 @@
#region project #region project
function Project() constructor { function Project() constructor {
active = true;
path = ""; path = "";
version = 0; version = 0;
seed = irandom_range(100000, 999999); seed = irandom_range(100000, 999999);

View file

@ -1826,6 +1826,7 @@ function Panel_Animation() : PanelContent() constructor {
function drawContent(panel) { function drawContent(panel) {
draw_clear_alpha(COLORS.panel_bg_clear, 0); draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(!PROJECT.active) return;
if(tool_width_drag) { if(tool_width_drag) {
CURSOR = cr_size_we; CURSOR = cr_size_we;

View file

@ -910,9 +910,7 @@ function PanelContent() constructor {
function drawGUI() {} function drawGUI() {}
function close() { function close() { panel.remove(self); }
panel.remove(self);
}
function onClose() {} function onClose() {}
} }

View file

@ -175,17 +175,16 @@
} }
function _findPanels(_type, _pane, _arr = []) { function _findPanels(_type, _pane, _arr = []) {
if(instanceof(_pane) != "Panel") if(!is_instanceof(_pane, Panel))
return _res; return _arr;
if(!ds_exists(_pane.childs, ds_type_list)) if(!ds_exists(_pane.childs, ds_type_list))
return _res; return _arr;
if(ds_list_size(_pane.childs) == 0) { for( var i = 0; i < array_length(_pane.content); i++ ) {
for( var i = 0; i < array_length(_pane.content); i++ ) var _cnt = instanceof(_pane.content[i]);
if(instanceof(_pane.content[i]) == _type) { //print($" - content {_cnt} \ {_cnt == _type}");
array_append(_arr, _pane.content[i]); if(_cnt == _type)
return _arr; array_push(_arr, _pane.content[i]);
}
} }
for(var i = 0; i < ds_list_size(_pane.childs); i++) for(var i = 0; i < ds_list_size(_pane.childs); i++)

View file

@ -256,6 +256,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
PANEL_GRAPH = self; PANEL_GRAPH = self;
PROJECT = project; PROJECT = project;
PANEL_ANIMATION.updatePropertyList(); PANEL_ANIMATION.updatePropertyList();
//print($"Focus {PROJECT.path}");
} }
function stepBegin() { function stepBegin() {
@ -1755,6 +1757,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
function drawContent(panel) { function drawContent(panel) {
if(!project.active) return;
dragGraph(); dragGraph();
if(project.path == "") title = "New project"; if(project.path == "") title = "New project";
@ -1907,7 +1911,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
function close() { function close() {
if(nodes_list != project.nodes) return; if(nodes_list != project.nodes) {
panel.remove(self);
return;
}
if(!project.modified || project.readonly) { if(!project.modified || project.readonly) {
closeProject(project); closeProject(project);
return; return;

View file

@ -1,6 +1,9 @@
/// @desc Function Description /// @desc Function Description
/// @param {Struct.Project} project Description /// @param {Struct.Project} project Description
function closeProject(project) { function closeProject(project) {
//print($"Close {PROJECT.path}");
PROJECT.active = false;
array_remove(PROJECTS, project); array_remove(PROJECTS, project);
if(array_length(PROJECTS) == 0) if(array_length(PROJECTS) == 0)
PROJECT = new Project(); PROJECT = new Project();
@ -9,6 +12,7 @@ function closeProject(project) {
for( var i = array_length(panels) - 1; i >= 0; i-- ) { for( var i = array_length(panels) - 1; i >= 0; i-- ) {
var panel = panels[i]; var panel = panels[i];
//print($" Check {panel.project.path}");
if(panel.project == project) { if(panel.project == project) {
panel.panel.remove(panel); panel.panel.remove(panel);
array_remove(panels, panel) array_remove(panels, panel)