clear temp on close

This commit is contained in:
Tanasart 2023-09-26 19:45:15 +07:00
parent e750f30168
commit 5b80234f0b
5 changed files with 21 additions and 12 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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();
}