From 5b80234f0b029a9b2993b60a12bdd823b961a66b Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:45:15 +0700 Subject: [PATCH] clear temp on close --- objects/o_dialog_exit/Draw_64.gml | 11 ++++------- objects/o_dialog_preference/Create_0.gml | 8 ++++++++ scripts/panel_menu/panel_menu.gml | 2 +- scripts/preferences/preferences.gml | 1 + scripts/window_functions/window_functions.gml | 11 +++++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/objects/o_dialog_exit/Draw_64.gml b/objects/o_dialog_exit/Draw_64.gml index 48de005b6..72f8138f0 100644 --- a/objects/o_dialog_exit/Draw_64.gml +++ b/objects/o_dialog_exit/Draw_64.gml @@ -49,10 +49,8 @@ if !ready exit; var b = buttonInstant(THEME.button, bx0, by0, bw, bh, mouse_ui, sFOCUS, sHOVER); draw_text(bx0 + bw / 2, by0 + bh / 2, __txtx("dont_save", "Don't save")); if(b == 2) { - PREF_SAVE(); - - if(instance_number(o_dialog_exit) == 1) - game_end(); + if(instance_number(o_dialog_exit) == 1) + close_program(); instance_destroy(); } @@ -60,9 +58,8 @@ if !ready exit; var b = buttonInstant(THEME.button, bx0, by0, bw, bh, mouse_ui, sFOCUS, sHOVER); draw_text(bx0 + bw / 2, by0 + bh / 2, __txt("Save")); if(b == 2 && SAVE(project)) { - PREF_SAVE(); - if(instance_number(o_dialog_exit) == 1) - game_end(); + if(instance_number(o_dialog_exit) == 1) + close_program(); instance_destroy(); } #endregion \ No newline at end of file diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index 58dc761ed..1ebefd417 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -223,6 +223,14 @@ event_inherited(); }) ]); + ds_list_add(pref_global, [ + __txtx("pref_clear_temp", "Clear temp file on close."), + "clear_temp_on_close", + new checkBox(function() { + PREF_MAP[? "clear_temp_on_close"] = !PREF_MAP[? "clear_temp_on_close"]; + PREF_SAVE(); + }) + ]); #endregion #region appearance diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index f282cd3f0..efb252a6b 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -33,7 +33,7 @@ function Panel_Menu() : PanelContent() constructor { menuItem(__txtx("panel_menu_auto_save_folder", "Open autosave folder"), function() { shellOpenExplorer(DIRECTORY + "autosave"); }, THEME.save_auto), menuItem(__txt("Export"), function(_dat) { var arr = [ - menuItem(__txt("Portable project (.zip)") + "...", function() { exportPortable(); }), + menuItem(__txt("Portable project (.zip)") + "...", function() { exportPortable(PROJECT); }), ]; return submenuCall(_dat, arr); diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index b9664983f..ce65bdd09 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -74,6 +74,7 @@ PREF_MAP[? "render_all_export"] = true; PREF_MAP[? "alt_picker"] = true; + PREF_MAP[? "clear_temp_on_close"] = true; #endregion #region hotkeys diff --git a/scripts/window_functions/window_functions.gml b/scripts/window_functions/window_functions.gml index b59ef5797..642959906 100644 --- a/scripts/window_functions/window_functions.gml +++ b/scripts/window_functions/window_functions.gml @@ -1,3 +1,9 @@ +function close_program() { + PREF_SAVE(); + if(PREF_MAP[? "clear_temp_on_close"]) directory_destroy(DIRECTORY + "temp"); + game_end(); +} + function window_close() { var noSave = true; @@ -13,8 +19,5 @@ function window_close() { } } - if(noSave) { - PREF_SAVE(); - game_end(); - } + if(noSave) close_program(); } \ No newline at end of file