From cda9311a905a8b9d226f14b8f1e3430f54e70ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:16:34 +0100 Subject: [PATCH] new gamover event for scripts --- source/funkin/game/GameOverSubstate.hx | 46 ++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/source/funkin/game/GameOverSubstate.hx b/source/funkin/game/GameOverSubstate.hx index 66b37968..70f0a799 100644 --- a/source/funkin/game/GameOverSubstate.hx +++ b/source/funkin/game/GameOverSubstate.hx @@ -100,30 +100,8 @@ class GameOverSubstate extends MusicBeatSubstate if (__cancelDefault) return; - if (controls.ACCEPT) - { - endBullshit(); - } - - if (controls.BACK) - { - if (PlayState.chartingMode && Charter.undos.unsaved) - game.saveWarn(false); - else { - PlayState.resetSongInfos(); - if (Charter.instance != null) Charter.instance.__clearStatics(); - - if (FlxG.sound.music != null) - FlxG.sound.music.stop(); - FlxG.sound.music = null; - - if (PlayState.isStoryMode) - FlxG.switchState(new StoryMenuState()); - else - FlxG.switchState(new FreeplayState()); - } - - } + if (controls.ACCEPT) endBullshit(); + if (controls.BACK) exit(); if (!isEnding && ((!lossSFX.playing) || (character.getAnimName() == "firstDeath" && character.isAnimFinished())) && (FlxG.sound.music == null || !FlxG.sound.music.playing)) { @@ -192,6 +170,26 @@ class GameOverSubstate extends MusicBeatSubstate }); } + function exit() + { + var event = new CancellableEvent(); + gameoverScript.call('onReturnToMenu', [event]); + + if (event.cancelled) + return; + + if (PlayState.chartingMode && Charter.undos.unsaved) game.saveWarn(false); + else { + PlayState.resetSongInfos(); + if (Charter.instance != null) Charter.instance.__clearStatics(); + + if (FlxG.sound.music != null) FlxG.sound.music.stop(); + FlxG.sound.music = null; + + FlxG.switchState(PlayState.isStoryMode ? new StoryMenuState() : new FreeplayState()); + } + } + override function destroy() { gameoverScript.call("destroy");