From f5dbe5e7c3dba38b997e06d0f65c1504589c801a Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Mon, 18 Sep 2023 15:15:11 -0700 Subject: [PATCH] warning changes --- assets/images/editors/ui/grayscale-button.png | Bin 0 -> 867 bytes assets/images/editors/ui/grayscale-button.xml | 33 ++++++++++++++++++ source/funkin/backend/utils/WindowUtils.hx | 6 ++-- source/funkin/editors/SaveWarning.hx | 17 ++++++--- .../editors/character/CharacterAnimButtons.hx | 1 + source/funkin/editors/ui/UIState.hx | 2 +- source/funkin/editors/ui/UIWarningSubstate.hx | 7 +++- 7 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 assets/images/editors/ui/grayscale-button.png create mode 100644 assets/images/editors/ui/grayscale-button.xml diff --git a/assets/images/editors/ui/grayscale-button.png b/assets/images/editors/ui/grayscale-button.png new file mode 100644 index 0000000000000000000000000000000000000000..1467fece5a4b6fbc0cf733a2d019a250413afdcd GIT binary patch literal 867 zcmV-p1DyPcP)Px&9Z5t%R9HvtnOjRLQ546Q8j_Vsgd%i-P|ky9Wsz?Zy`K+YWzT*AFVF`NynF$l z)#?MBZ_t~9mWdCN1YID6pt}}c4*z}53~DdUo)H>s!=Mba{_ORewP&rpwub(XR4UaK z{`33>0s&30U8PcyrRQ)shN`EOzig5a%VaWtc)$rZe!u^>01@yak%$~Qip63iK!jek zTBT;Q$u245{r#OZ;N{H*K9Vk`|WmHiX3%19qM+w^!oZr@K>V*yk3Z2ub1S) z6Z8NP1MuqgI@M}5YBU;>9DaCsAg9ww)6>(mwY5bjCnp4WcoEP75Ge!CkB^U&PN!oK zRRQqq?2JmK65ZU~kVezDvcKdz9NyU2AiP`voSB)S=jUg7dV2bj{oq5Blaqw&<>h5K z0K?%h*Te>m;_*1UmCxs?SS-^0{XLiN?CdPL-EP|4+++YvCKGcW5P62tXr!sBDSCW- z91g%xD8w_bPd14}g5AsIa&&rnDhuG++8TL0p3wyO6M>xZC`91M0SpF%oXGmklF6j_ z4J;H2vX=1r`nr0)fx`fZOpH>7XILy2T3uZoZGb-!$PqfdOZZzyU^E)7a`^Yjv7xGT8MD8?uL!_&I?Z%0E-vWq?v5@mFX`jsLz1>$ucxJ@C9+zrWVhSJb{4wP zZ*OmsJJJ9+F)={~gW+F45VKLD7DN% literal 0 HcmV?d00001 diff --git a/assets/images/editors/ui/grayscale-button.xml b/assets/images/editors/ui/grayscale-button.xml new file mode 100644 index 00000000..0c0811f4 --- /dev/null +++ b/assets/images/editors/ui/grayscale-button.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/funkin/backend/utils/WindowUtils.hx b/source/funkin/backend/utils/WindowUtils.hx index d1ddec7c..609e3977 100644 --- a/source/funkin/backend/utils/WindowUtils.hx +++ b/source/funkin/backend/utils/WindowUtils.hx @@ -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(); diff --git a/source/funkin/editors/SaveWarning.hx b/source/funkin/editors/SaveWarning.hx index fc30ea32..73b465ac 100644 --- a/source/funkin/editors/SaveWarning.hx +++ b/source/funkin/editors/SaveWarning.hx @@ -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)); } } diff --git a/source/funkin/editors/character/CharacterAnimButtons.hx b/source/funkin/editors/character/CharacterAnimButtons.hx index e0ebd3b9..bccc51a4 100644 --- a/source/funkin/editors/character/CharacterAnimButtons.hx +++ b/source/funkin/editors/character/CharacterAnimButtons.hx @@ -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); diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index 1120c614..ba7a3943 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -129,7 +129,7 @@ class UIState extends MusicBeatState { super.destroy(); __mousePos.put(); - WindowUtils.reset(); + WindowUtils.resetTitle(); SaveWarning.reset(); FlxG.stage.window.onKeyDown.remove(onKeyDown); diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 43633410..a67db6f9 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -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; } \ No newline at end of file