warning changes
This commit is contained in:
@@ -29,7 +29,8 @@ class WindowUtils {
|
||||
public static inline function resetClosing() __triedClosing = false;
|
||||
|
||||
public static inline function init() {
|
||||
reset();
|
||||
resetTitle();
|
||||
resetClosing();
|
||||
|
||||
Lib.application.window.onClose.add(function () {
|
||||
if (preventClosing && !__triedClosing) {
|
||||
@@ -39,9 +40,8 @@ class WindowUtils {
|
||||
if (onClosing != null) onClosing();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static inline function reset() {
|
||||
public static inline function resetTitle() {
|
||||
winTitle = Lib.application.meta["name"];
|
||||
prefix = endfix = "";
|
||||
updateTitle();
|
||||
|
||||
@@ -15,19 +15,26 @@ class SaveWarning {
|
||||
}
|
||||
}
|
||||
|
||||
public static function triggerWarning(?resetClosing:Bool = false) {
|
||||
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: "Exit To Menu",
|
||||
label: closingWindow ? "Exit Window" : "Exit To Menu",
|
||||
color: 0x74732D,
|
||||
onClick: function(_) {
|
||||
if (selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, []));
|
||||
if (resetClosing) WindowUtils.resetClosing();
|
||||
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",
|
||||
onClick: function (_) {if (resetClosing) WindowUtils.resetClosing();}
|
||||
color: 0x969533,
|
||||
onClick: function (_) {if (closingWindow) WindowUtils.resetClosing();}
|
||||
}], false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class CharacterAnimButtons extends UIButton {
|
||||
editButton = new UIButton(ghostButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.editAnimWithUI(this.anim);
|
||||
}, 32);
|
||||
editButton.frames = Paths.getFrames("editors/ui/grayscale-button");
|
||||
editButton.color = FlxColor.YELLOW;
|
||||
editButton.autoAlpha = false;
|
||||
members.push(editButton);
|
||||
|
||||
@@ -129,7 +129,7 @@ class UIState extends MusicBeatState {
|
||||
super.destroy();
|
||||
__mousePos.put();
|
||||
|
||||
WindowUtils.reset();
|
||||
WindowUtils.resetTitle();
|
||||
SaveWarning.reset();
|
||||
|
||||
FlxG.stage.window.onKeyDown.remove(onKeyDown);
|
||||
|
||||
@@ -72,10 +72,14 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
|
||||
var xPos = (FlxG.width - (30 + (170 * buttons.length))) / 2;
|
||||
for(k=>b in buttons) {
|
||||
var button = new UIButton(xPos + 20 + (170 * k), spr.y + spr.bHeight - (32 + 16), b.label, function() {
|
||||
var button = new UIButton(xPos + 20 + (170 * k), spr.y + spr.bHeight - (42 + 16), b.label, function() {
|
||||
b.onClick(this);
|
||||
close();
|
||||
}, 160, 30);
|
||||
if (b.color != null) {
|
||||
button.frames = Paths.getFrames("editors/ui/grayscale-button");
|
||||
button.color = b.color;
|
||||
}
|
||||
add(button);
|
||||
}
|
||||
|
||||
@@ -105,5 +109,6 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
|
||||
typedef WarningButton = {
|
||||
var label:String;
|
||||
var ?color:Int;
|
||||
var onClick:UIWarningSubstate->Void;
|
||||
}
|
||||
Reference in New Issue
Block a user