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;
//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;

View file

@ -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

View file

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

View file

@ -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;

View file

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

View file

@ -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++)

View file

@ -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;

View file

@ -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)