@@ -100,30 +100,8 @@ class GameOverSubstate extends MusicBeatSubstate
100100 if (__cancelDefault )
101101 return ;
102102
103- if (controls. ACCEPT )
104- {
105- endBullshit ();
106- }
107-
108- if (controls. BACK )
109- {
110- if (PlayState .chartingMode && Charter .undos .unsaved )
111- game .saveWarn (false );
112- else {
113- PlayState .resetSongInfos ();
114- if (Charter .instance != null ) Charter .instance .__clearStatics ();
115-
116- if (FlxG .sound .music != null )
117- FlxG .sound .music .stop ();
118- FlxG .sound .music = null ;
119-
120- if (PlayState .isStoryMode )
121- FlxG .switchState (new StoryMenuState ());
122- else
123- FlxG .switchState (new FreeplayState ());
124- }
125-
126- }
103+ if (controls. ACCEPT ) endBullshit ();
104+ if (controls. BACK ) exit ();
127105
128106 if (! isEnding && ((! lossSFX .playing ) || (character .getAnimName () == " firstDeath" && character .isAnimFinished ())) && (FlxG .sound .music == null || ! FlxG .sound .music .playing ))
129107 {
@@ -192,6 +170,26 @@ class GameOverSubstate extends MusicBeatSubstate
192170 });
193171 }
194172
173+ function exit ()
174+ {
175+ var event = new CancellableEvent ();
176+ gameoverScript .call (' onReturnToMenu' , [event ]);
177+
178+ if (event .cancelled )
179+ return ;
180+
181+ if (PlayState .chartingMode && Charter .undos .unsaved ) game .saveWarn (false );
182+ else {
183+ PlayState .resetSongInfos ();
184+ if (Charter .instance != null ) Charter .instance .__clearStatics ();
185+
186+ if (FlxG .sound .music != null ) FlxG .sound .music .stop ();
187+ FlxG .sound .music = null ;
188+
189+ FlxG .switchState (PlayState .isStoryMode ? new StoryMenuState () : new FreeplayState ());
190+ }
191+ }
192+
195193 override function destroy ()
196194 {
197195 gameoverScript .call (" destroy" );
0 commit comments