here mar mar

This commit is contained in:
lunarcleint
2024-02-04 15:22:58 -07:00
parent 9d2bf7a0c6
commit 6b56d46f1e
3 changed files with 38 additions and 16 deletions
+34 -16
View File
@@ -6,6 +6,7 @@ class SaveWarning {
return WindowUtils.preventClosing = showWarning = warning;
public static var selectionClass:Class<EditorTreeMenu> = null;
public static var saveFunc:Void->Void = null;
public static function init() {
showWarning = false;
@@ -18,29 +19,46 @@ class SaveWarning {
public static function triggerWarning(?closingWindow:Bool = false) {
if (FlxG.state != null && FlxG.state is UIState) {
FlxG.state.openSubState(new UIWarningSubstate("Unsaved Changes!", "Your changes will be lost if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?",
[{
label: closingWindow ? "Exit Game" : "Exit To Menu",
color: 0x969533,
onClick: function(_) {
if (!closingWindow) {
if (selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, []));
if (closingWindow) WindowUtils.resetClosing();
} else {
WindowUtils.preventClosing = false; WindowUtils.resetClosing();
Sys.exit(0);
[
{
label: "Cancel",
color: 0x969533,
onClick: function (_) {if (closingWindow) WindowUtils.resetClosing();}
},
{
label: closingWindow ? "Exit Game" : "Exit To Menu",
color: 0x969533,
onClick: function(_) {
if (!closingWindow) {
if (selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, []));
if (closingWindow) WindowUtils.resetClosing();
} else {
WindowUtils.preventClosing = false; WindowUtils.resetClosing();
Sys.exit(0);
}
}
},
{
label: closingWindow ? "Save & Exit Game" : "Save&Exit To Menu",
color: 0x969533,
onClick: function(_) {
if (saveFunc != null) saveFunc();
if (!closingWindow) {
if (selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, []));
if (closingWindow) WindowUtils.resetClosing();
} else {
WindowUtils.preventClosing = false; WindowUtils.resetClosing();
Sys.exit(0);
}
}
}
},
{
label: "Cancel",
color: 0x969533,
onClick: function (_) {if (closingWindow) WindowUtils.resetClosing();}
}], false));
], false));
}
}
public static inline function reset() {
SaveWarning.showWarning = false;
SaveWarning.selectionClass = null;
SaveWarning.saveFunc = null;
}
}
@@ -53,6 +53,8 @@ class CharacterEditor extends UIState {
WindowUtils.endfix = " (Character Editor)";
SaveWarning.selectionClass = CharacterSelection;
SaveWarning.saveFunc = () -> {_file_save(null);};
topMenu = [
{
label: "File",
+2
View File
@@ -101,6 +101,8 @@ class Charter extends UIState {
WindowUtils.endfix = " (Chart Editor)";
SaveWarning.selectionClass = CharterSelection;
SaveWarning.saveFunc = () -> {_file_save(null);};
topMenu = [
{
label: "File",