From a0843b6aa7b6b339b3a5a8ffc03a40bff012bbac Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Sun, 23 Jul 2023 21:15:45 +0200 Subject: [PATCH] project close bug --- objects/o_main/Step_0.gml | 57 ++++++++++--------- objects/o_main/Step_1.gml | 40 +++++++------ scripts/globals/globals.gml | 2 + scripts/panel_animation/panel_animation.gml | 1 + scripts/panel_data/panel_data.gml | 4 +- scripts/panel_function/panel_function.gml | 17 +++--- scripts/panel_graph/panel_graph.gml | 10 +++- scripts/project_function/project_function.gml | 4 ++ 8 files changed, 76 insertions(+), 59 deletions(-) diff --git a/objects/o_main/Step_0.gml b/objects/o_main/Step_0.gml index 3d86a3c66..a2e20aef7 100644 --- a/objects/o_main/Step_0.gml +++ b/objects/o_main/Step_0.gml @@ -2,36 +2,37 @@ if(OS == os_windows && gameframe_is_minimized()) exit; //print("===== Step start ====="); -#region animation - if(PROJECT.animator.is_playing && PROJECT.animator.play_freeze == 0) { - PROJECT.animator.time_since_last_frame += PROJECT.animator.framerate * (delta_time / 1000000); +if(PROJECT.active) { + #region animation + 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) - PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); - } else { - PROJECT.animator.frame_progress = false; - PROJECT.animator.setFrame(PROJECT.animator.real_frame); - 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(); + if(PROJECT.animator.time_since_last_frame >= 1) + PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); + } else { + PROJECT.animator.frame_progress = false; + PROJECT.animator.setFrame(PROJECT.animator.real_frame); + PROJECT.animator.time_since_last_frame = 0; } - } catch(e) { - noti_warning("Step error: " + exception_print(e)); - } -#endregion + + 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)); + #endregion +} #region hotkey HOTKEY_MOD = 0; diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index abf88e77c..c964bd827 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -1,4 +1,5 @@ /// @description init +//print(PROJECT.path); global.cache_call = 0; global.cache_hit = 0; @@ -77,26 +78,29 @@ _HOVERING_ELEMENT = noone; //physics_pause_enable(true); DEF_SURFACE_RESET(); - var _k = ds_map_find_first(PROJECT.nodeMap); - var _a = ds_map_size(PROJECT.nodeMap); - repeat(_a) { - PROJECT.nodeMap[? _k].stepBegin(); - _k = ds_map_find_next(PROJECT.nodeMap, _k); + if(PROJECT.active) { + var _k = ds_map_find_first(PROJECT.nodeMap); + var _a = ds_map_size(PROJECT.nodeMap); + repeat(_a) { + 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; #endregion diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index d745a9799..e376443b0 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -15,6 +15,8 @@ #region project function Project() constructor { + active = true; + path = ""; version = 0; seed = irandom_range(100000, 999999); diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index 16f9d32b7..298bece0b 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -1826,6 +1826,7 @@ function Panel_Animation() : PanelContent() constructor { function drawContent(panel) { draw_clear_alpha(COLORS.panel_bg_clear, 0); + if(!PROJECT.active) return; if(tool_width_drag) { CURSOR = cr_size_we; diff --git a/scripts/panel_data/panel_data.gml b/scripts/panel_data/panel_data.gml index 25c1616cf..0a03738b8 100644 --- a/scripts/panel_data/panel_data.gml +++ b/scripts/panel_data/panel_data.gml @@ -910,9 +910,7 @@ function PanelContent() constructor { function drawGUI() {} - function close() { - panel.remove(self); - } + function close() { panel.remove(self); } function onClose() {} } diff --git a/scripts/panel_function/panel_function.gml b/scripts/panel_function/panel_function.gml index 44bb06224..5832f75f4 100644 --- a/scripts/panel_function/panel_function.gml +++ b/scripts/panel_function/panel_function.gml @@ -175,17 +175,16 @@ } function _findPanels(_type, _pane, _arr = []) { - if(instanceof(_pane) != "Panel") - return _res; + if(!is_instanceof(_pane, Panel)) + return _arr; 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++ ) - if(instanceof(_pane.content[i]) == _type) { - array_append(_arr, _pane.content[i]); - return _arr; - } + for( var i = 0; i < array_length(_pane.content); i++ ) { + var _cnt = instanceof(_pane.content[i]); + //print($" - content {_cnt} \ {_cnt == _type}"); + if(_cnt == _type) + array_push(_arr, _pane.content[i]); } for(var i = 0; i < ds_list_size(_pane.childs); i++) diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 82995a0e9..724503b27 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -256,6 +256,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { PANEL_GRAPH = self; PROJECT = project; PANEL_ANIMATION.updatePropertyList(); + + //print($"Focus {PROJECT.path}"); } function stepBegin() { @@ -1755,6 +1757,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } function drawContent(panel) { + if(!project.active) return; + dragGraph(); if(project.path == "") title = "New project"; @@ -1907,7 +1911,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } function close() { - if(nodes_list != project.nodes) return; + if(nodes_list != project.nodes) { + panel.remove(self); + return; + } + if(!project.modified || project.readonly) { closeProject(project); return; diff --git a/scripts/project_function/project_function.gml b/scripts/project_function/project_function.gml index 32389a175..50fb6e5fb 100644 --- a/scripts/project_function/project_function.gml +++ b/scripts/project_function/project_function.gml @@ -1,6 +1,9 @@ /// @desc Function Description /// @param {Struct.Project} project Description function closeProject(project) { + //print($"Close {PROJECT.path}"); + + PROJECT.active = false; array_remove(PROJECTS, project); if(array_length(PROJECTS) == 0) PROJECT = new Project(); @@ -9,6 +12,7 @@ function closeProject(project) { for( var i = array_length(panels) - 1; i >= 0; i-- ) { var panel = panels[i]; + //print($" Check {panel.project.path}"); if(panel.project == project) { panel.panel.remove(panel); array_remove(panels, panel)