From 3556d96f6ba393bef3b3a264812bca578a8026ce Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:34:05 -0700 Subject: [PATCH] Warning shit added --- assets/images/editors/ui/grayscale-popup.png | Bin 0 -> 1585 bytes assets/images/editors/ui/grayscale-popup.xml | 13 ++++++ assets/images/editors/warning.aseprite | Bin 1970 -> 0 bytes assets/images/editors/warning.png | Bin 1929 -> 0 bytes assets/images/editors/warnings/warning.png | Bin 0 -> 1921 bytes source/funkin/backend/system/Main.hx | 4 +- .../utils/{WindowTitle.hx => WindowUtils.hx} | 20 ++++++++- source/funkin/editors/SaveWarning.hx | 39 ++++++++++++++++++ .../editors/character/CharacterEditor.hx | 11 ++++- source/funkin/editors/charter/Charter.hx | 23 ++++------- source/funkin/editors/ui/UIState.hx | 5 ++- source/funkin/editors/ui/UIWarningSubstate.hx | 6 +-- source/funkin/menus/PauseSubState.hx | 9 +++- 13 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 assets/images/editors/ui/grayscale-popup.png create mode 100644 assets/images/editors/ui/grayscale-popup.xml delete mode 100644 assets/images/editors/warning.aseprite delete mode 100644 assets/images/editors/warning.png create mode 100644 assets/images/editors/warnings/warning.png rename source/funkin/backend/utils/{WindowTitle.hx => WindowUtils.hx} (63%) create mode 100644 source/funkin/editors/SaveWarning.hx diff --git a/assets/images/editors/ui/grayscale-popup.png b/assets/images/editors/ui/grayscale-popup.png new file mode 100644 index 0000000000000000000000000000000000000000..b01136031a3d21d074066ab513a4ff6a82cf6fad GIT binary patch literal 1585 zcmV-12G043P)Px)>q$gGRCr$Pol8h7R~X07gc|i?uHv&@)JqjXL>Foa6}qyzZx_;qm4dkQd3}S= z#K#yl7~d|ei>gpiSFUyALMsGZsI+7y;=NabFO;j%nki@II=yYvP7=pC8S_8jM!q@U zoZt83`!r4rM|`Z};^Hrplas$qOicVLK0f}7q@<*1Uvc;z2>c%bx7&T-a=C^V78X`~ z#c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R za`pAn`5>QiEp->6H~ECx+FIQ~#trM6!070xICga*A4abKvgx7wjgF2=&-2yP)cAig zM1p_{1jfe3AfE~xu|*IBbR!=|ZeZ2b!`PMOtFEpN>~x3*fkzS;A0L;-ZYax#t`~fj zL%9RW@>Nw;1%EJ=J0`A1-Ka#HGi zgpjxYyo8h1C-jRDLchrU{rw912LIQBI}1vczk@Ucs;F!*XtENtb3{fA><|^BI2d5j%qL%?l_M7gAj5j j2*Rx(2=wAleI@!6i(Siuud1b#00000NkvXXu0mjfFH!NW literal 0 HcmV?d00001 diff --git a/assets/images/editors/ui/grayscale-popup.xml b/assets/images/editors/ui/grayscale-popup.xml new file mode 100644 index 00000000..021dd81a --- /dev/null +++ b/assets/images/editors/ui/grayscale-popup.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/images/editors/warning.aseprite b/assets/images/editors/warning.aseprite deleted file mode 100644 index 74aa0e65202489ef627499bd184f1c3f983a75e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1970 zcmcJN`#)RvAIIa?)H;o{E-jI!l4WX!#3n`R(yk3^ZCz@N?}8M?cOj{iR#nGJu_O&z z)TLFd7q^-!UnW+UN?dA6r!!%R&}zOd(W%msz0>Z8{sa4*$9aA}kMlX_@p`__IX@v0 zh(9Ye5J%v^Av6#OnBN}+gogSeLLZKQV~`<#MXB>PRR;o$;6&oyM!pxf0PC$d!arB= z@9n%@st^cs+-JbO7F1w_0}06YcLGkbh``^kL;#<6UIM;eum=`S9|A@TZGn_LCUAe0 z4bW#l0Z67g09{<-fwm#3z#yg+$S6_)=>u|L-yd&)Di{bvQB4!@`_mb~sOV^5puZ3B z`0gxVHJJ?j{VN7=G^qv1&-Vmo#j4Zg<95J?8ntsw1fmRqFflPv9fxAt>hGa04dtL2 z)Phb>2--ju=m9050qBD}h=VmKgD=Q}DQK!4RVuIpHShu{FajNL0THkO1;~eRNQT&L z>QtQ8+n4$dAca68yh2ZevvH)e@P%}6|7>W!o7F$e5kz9~vyz|~1CqfRt-T)@b z(;qP6P4-4VU_49?Gi}*~sODQCa`&7#PMQGk(UGBpryc4Xg$J&rbGz@=*r%+7a4{YR zhneH;l9?hKC%OC8I2I$Rp>ru=RE(C#aTs%qeAP0m1mm`G8%3LMNj$;3x>c%3-+&6! zM4dC0uRq`_!O`N(yY$!u=Jzdbye{q*=6O8J{GzGcz4+YhI)_b0^>9arW~Uxo+b96` zZk=f%xlky1a`!}6iN#h?T_cIqc#!uYvI|Q5Hl-1svnEm)>r=d}3bZy4Cy4~+!IHS} zyPAa+yH-x>jOYz39ujD8I!3txRFPn4eW7pRL^*Mwaa>Eb&kHLT;esW)psdK4s|Xs0Wg{6$8}=BiCR}jD)`Hr@^z^^{>Wg@pdWw<7OYKGeof|a$&-5X6& zbGMg&tJ*lZ`s;LiJ0HnsMT9X}vE>7oUC_+M(z7827&yR1$jB&v@%mS*59UvSCI>NPRyF zWqoYzm~e>KB}5sgWz1ha5-J1MC+>Jqu+4w9VP=y)&FK`_QXKKCwfCvG z)qD4}(lYBz)21wXDu!0QEl?7wXMP-Zjp6S}!!h%O`HzE}jFD3G)SOtpr6G*0sUS>ihzefCn%1ja1JJLqC#-QZyPH$2xmN<7u?VAfnv8>@P{t0RGH zyin|R0bl$1;63eL&690q+v>g^WA)`NN{52>D1&`(DbLvI23<25@1tXBfrE_s`NFvw z8G2YS&#_z%%s&z@rP-g9@j{-(c7<)Xs}Db~<#Um9a4FEYIwtgatn1*e<1PJz1E>9(P#nV21YP*q zYf?_zigeg{M9}hVwbFxSbv30%$u=7+{q~!YqD0l^b+UcpJ+G8et@~#Sg}g@rhh#tY zmiOv;p2CthhY4KvV>t?$-6ekm Da2QNX diff --git a/assets/images/editors/warning.png b/assets/images/editors/warning.png deleted file mode 100644 index 71c841547a2569029f922d172e5ffe4d2e711974..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1929 zcmV;42X^?0P)Px+LrFwIRCt{2oX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XxTFm++x=9Pwrb!mJ`=WOvrhu3wYZe3EEPKP?7FId zi+T}(?x0;;vb%BH@63`{71)tMw%W4Q;*v5%hmLzX!H6tz51{@Nh9wQym@%}w_GC80 z{ParGlufn8{!!Buy}k3Yu|&GcQlVpaHQ**d+K|jvXOr#Fz;3lAnkV715laRQF@5U- zLHD0&PoMJN^6a`k!phz}371SPks`!wUwO&e^k@h3<{xIJg*Txowb?{2Q%Zz}*w|N2 zs<_b=J2vzzdlx;2m48YG39^;>r5OL{woX7e3Y$Etp0DcpzA zR#*JsVi|macjsbL)Xd;RJ6#QrRikxuULM@EVo*lDu_- z)7ijS3}}mGa#5A|p_928!$!!cP03DBe^@I?WJCevpmdD;`@`XbPOBekArP>#^y7HRrEfAxnpH P00000NkvXXu0mjf7>|`# diff --git a/assets/images/editors/warnings/warning.png b/assets/images/editors/warnings/warning.png new file mode 100644 index 0000000000000000000000000000000000000000..6c864eafa5ff855137d735914990cdba2afcee10 GIT binary patch literal 1921 zcmV-{2Y&d8P)Px+J4r-ARCt{2ox5%vHyDKvhpW}j%CZH-fQ?mv2yUX*0pe#d{3xze`B98CsoVwW z(&Y(K87V9ksUpXQjCDp#L2{Qn%bDT*qUZnv*q$4ghaZ35h6e6{PFE{-x>~W^>9`lT z82}i7J7G$bI{`k@8Bn_^RT}~TmseNXKi8^i4H+Y$W=g6x1ke*vJ0(>bVnRTzlvHU5 zFit|vlvHPkP06p3lIjcr%m}EJlBx`GDe<*YQk5ZqUCFPJl4=a`Dd{y)QjHkn4QLrKxB`LegRS%-ky45WtQOshTM%){q!AP~MI75IibV$`kNl}KRq{H-`sa2FAKv+7Y zYNDhVLvqkz`tFpPb5GT{_}LEluk)jLu}|!6?36nZc4HfVnatLl}t%CLtN=dp`4UtB_szOQl(Oo#Sl|E z&c36mlC-B>lw>1hijMQ|_swu=%8uPrA|=TU@m+cYzM66qF<(WQ>l--w+%fO`Gxdr}xh9x4AbrB~cBTDpAWNaC}Vg;0QQ8jG2;f zicLv$L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`=D8$gv{FHRP_q`ky7ik|LcU^e;gy89u#(K`9-_J0~{1lSSZWD@S1BGp> zbF7KYjje{d{sC(96<);h?cx0Px_%00000NkvXX Hu0mjfybh3V literal 0 HcmV?d00001 diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index fbe59ac1..088c8619 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -1,5 +1,6 @@ package funkin.backend.system; +import funkin.editors.SaveWarning; import funkin.backend.assets.AssetsLibraryList; import funkin.backend.system.framerate.SystemInfo; import openfl.utils.AssetLibrary; @@ -107,7 +108,8 @@ class Main extends Sprite } public static function loadGameSettings() { - WindowTitle.init(); + WindowUtils.init(); + SaveWarning.init(); MemoryUtil.init(); @:privateAccess FlxG.game.getTimer = getTimer; diff --git a/source/funkin/backend/utils/WindowTitle.hx b/source/funkin/backend/utils/WindowUtils.hx similarity index 63% rename from source/funkin/backend/utils/WindowTitle.hx rename to source/funkin/backend/utils/WindowUtils.hx index 239efa4f..d1ddec7c 100644 --- a/source/funkin/backend/utils/WindowTitle.hx +++ b/source/funkin/backend/utils/WindowUtils.hx @@ -2,7 +2,7 @@ package funkin.backend.utils; import openfl.Lib; -class WindowTitle { +class WindowUtils { public static var winTitle(default, set):String; public static function set_winTitle(newWinTitle:String):String { winTitle = newWinTitle; @@ -22,9 +22,25 @@ class WindowTitle { return endPrefix; } - public static inline function init() + public static var preventClosing:Bool = true; + public static var onClosing:Void->Void; + + static var __triedClosing:Bool = false; + public static inline function resetClosing() __triedClosing = false; + + public static inline function init() { reset(); + Lib.application.window.onClose.add(function () { + if (preventClosing && !__triedClosing) { + Lib.application.window.onClose.cancel(); + __triedClosing = true; + } + if (onClosing != null) onClosing(); + }); + } + + public static inline function reset() { winTitle = Lib.application.meta["name"]; prefix = endfix = ""; diff --git a/source/funkin/editors/SaveWarning.hx b/source/funkin/editors/SaveWarning.hx new file mode 100644 index 00000000..fc30ea32 --- /dev/null +++ b/source/funkin/editors/SaveWarning.hx @@ -0,0 +1,39 @@ +package funkin.editors; + +class SaveWarning { + public static var showWarning(default, set):Bool; + public static function set_showWarning(warning:Bool):Bool + return WindowUtils.preventClosing = showWarning = warning; + + public static var selectionClass:Class = null; + + public static function init() { + showWarning = false; + + WindowUtils.onClosing = function () { + if (SaveWarning.showWarning) triggerWarning(true); + } + } + + public static function triggerWarning(?resetClosing: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", + onClick: function(_) { + if (selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, [])); + if (resetClosing) WindowUtils.resetClosing(); + } + }, + { + label: "Cancel", + onClick: function (_) {if (resetClosing) WindowUtils.resetClosing();} + }], false)); + } + } + + public static inline function reset() { + SaveWarning.showWarning = false; + SaveWarning.selectionClass = null; + } +} \ No newline at end of file diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index b41a89cc..cf0434d4 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -51,7 +51,8 @@ class CharacterEditor extends UIState { public override function create() { super.create(); - WindowTitle.endfix = " (Character Editor)"; + WindowUtils.endfix = " (Character Editor)"; + SaveWarning.selectionClass = CharacterSelection; topMenu = [ { label: "File", @@ -310,12 +311,16 @@ class CharacterEditor extends UIState { characterBG.scale.set(FlxG.width/characterBG.width, FlxG.height/characterBG.height); characterBG.scale.set(characterBG.scale.x / charCamera.zoom, characterBG.scale.y / charCamera.zoom); + + WindowUtils.prefix = undos.unsaved ? "* " : ""; + SaveWarning.showWarning = undos.unsaved; } // TOP MENU OPTIONS #if REGION function _file_exit(_) { - FlxG.switchState(new CharacterSelection()); + if (undos.unsaved) SaveWarning.triggerWarning(); + else FlxG.switchState(new CharacterSelection()); } function _file_new(_) { @@ -327,6 +332,7 @@ class CharacterEditor extends UIState { '${Paths.getAssetsRoot()}/data/characters/${character.curCharacter}.xml', buildCharacter() ); + undos.save(); return; #end _file_saveas(_); @@ -336,6 +342,7 @@ class CharacterEditor extends UIState { openSubState(new SaveSubstate(buildCharacter(), { defaultSaveFile: '${character.curCharacter}.xml' })); + undos.save(); } function buildCharacter():String { diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 4e4d9d98..a5207063 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -93,7 +93,8 @@ class Charter extends UIState { public override function create() { super.create(); - WindowTitle.endfix = " (Chart Editor)"; + WindowUtils.endfix = " (Chart Editor)"; + SaveWarning.selectionClass = CharterSelection; topMenu = [ { label: "File", @@ -591,7 +592,7 @@ class Charter extends UIState { // Some maths, so cool bro -lunar (i dont know why i quopte my self here) if (s.step + changePoint.x < 0) boundedChange.x += Math.abs(s.step + changePoint.x); - if (s.step + changePoint.x > Charter.instance.__endStep-1) boundedChange.x -= (s.step + changePoint.x) - (Charter.instance.__endStep-1); + if (s.step + changePoint.x > __endStep-1) boundedChange.x -= (s.step + changePoint.x) - (__endStep-1); if (s is CharterNote) { var note:CharterNote = cast (s, CharterNote); @@ -896,7 +897,8 @@ class Charter extends UIState { if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, 0.125))) updateDisplaySprites(); - WindowTitle.prefix = undos.unsaved ? "* " : ""; + WindowUtils.prefix = undos.unsaved ? "* " : ""; + SaveWarning.showWarning = undos.unsaved; } public static var startTime:Float = 0; @@ -931,19 +933,8 @@ class Charter extends UIState { // TOP MENU OPTIONS #if REGION function _file_exit(_) { - if (undos.unsaved) { - 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", - onClick: function(_) FlxG.switchState(new CharterSelection()) - }, - { - label: "Cancel", - onClick: function (_) {} - } - ], false)); - } else - FlxG.switchState(new CharterSelection()); + if (undos.unsaved) SaveWarning.triggerWarning(); + else FlxG.switchState(new CharterSelection()); } function _file_save(_) { diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index 4987d8fb..1120c614 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -127,8 +127,11 @@ class UIState extends MusicBeatState { public override function destroy() { super.destroy(); - WindowTitle.reset(); __mousePos.put(); + + WindowUtils.reset(); + SaveWarning.reset(); + FlxG.stage.window.onKeyDown.remove(onKeyDown); FlxG.stage.window.onKeyUp.remove(onKeyUp); FlxG.stage.window.onTextInput.remove(onTextInput); diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 9fee13e2..43633410 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -56,16 +56,16 @@ class UIWarningSubstate extends MusicBeatSubstate { warnCam.zoom = 0.1; FlxG.cameras.add(warnCam, false); - var spr = new UISliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), 232, "editors/ui/normal-popup"); + var spr = new UISliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), 232, 'editors/ui/${isError ? "normal" : "grayscale"}-popup'); spr.x = (FlxG.width - spr.bWidth) / 2; spr.y = (FlxG.height - spr.bHeight) / 2; - spr.color = 0xFFFF0000; + spr.color = isError ? 0xFFFF0000 : 0xFFFFFF00; add(spr); add(titleSpr = new UIText(spr.x + 25, spr.y, spr.bWidth - 50, title, 15, -1)); titleSpr.y = spr.y + ((30 - titleSpr.height) / 2); - var sprIcon:FlxSprite = new FlxSprite(spr.x + 26, spr.y + 28 + 26).makeSolid(100, 100, -1); + var sprIcon:FlxSprite = new FlxSprite(spr.x + 26, spr.y + 28 + 26).loadGraphic(Paths.image('editors/warnings/${isError ? "error" : "warning"}')); add(sprIcon); add(messageSpr = new UIText(sprIcon.x + 100 + 16, sprIcon.y + 12, spr.bWidth - 100 - (26 * 2), message)); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index 7568c27a..3464f3ce 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -22,7 +22,7 @@ class PauseSubState extends MusicBeatSubstate var grpMenuShit:FlxTypedGroup; - var menuItems:Array = ['Resume', 'Restart Song', 'Change Controls', 'Options','Exit to menu']; + var menuItems:Array = ['Resume', 'Restart Song', 'Change Controls', 'Change Options', 'Exit to menu', "Exit to charter"]; var curSelected:Int = 0; var pauseMusic:FlxSound; @@ -42,6 +42,9 @@ class PauseSubState extends MusicBeatSubstate { super.create(); + if (menuItems.contains("Exit to charter") && !PlayState.chartingMode) + menuItems.remove("Exit to charter"); + add(parentDisabler = new FunkinParentDisabler()); pauseScript = Script.create(Paths.script(script)); @@ -147,8 +150,10 @@ class PauseSubState extends MusicBeatSubstate case "Change Controls": persistentDraw = false; openSubState(new KeybindsOptions()); - case "Options": + case "Change Options": FlxG.switchState(new OptionsMenu()); + case "Exit to charter": + FlxG.switchState(new funkin.editors.charter.Charter(PlayState.SONG.meta.name, PlayState.difficulty, false)); case "Exit to menu": CoolUtil.playMenuSong(); FlxG.switchState(PlayState.isStoryMode ? new StoryMenuState() : new FreeplayState());