From 554dfbf60b539eff893780cdf4f11d3d8fdd45ff Mon Sep 17 00:00:00 2001 From: MtH Date: Tue, 30 Mar 2021 20:52:24 +0200 Subject: [PATCH] tighten main menu security to prevent weird crashes during transitions --- source/MainMenuState.hx | 6 +++++- source/ui/MenuList.hx | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index bdcbd277c..abfc753aa 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -218,6 +218,7 @@ class MainMenuState extends MusicBeatState function startExitState(state:FlxState) { + menuItems.enabled = false; // disable for exit var duration = 0.4; menuItems.forEach(function(item) { @@ -241,7 +242,10 @@ class MainMenuState extends MusicBeatState FlxG.sound.music.volume += 0.5 * FlxG.elapsed; } - if (menuItems.enabled && controls.BACK) + if (_exiting) + menuItems.enabled = false; + + if (controls.BACK && menuItems.enabled && !menuItems.busy) FlxG.switchState(new TitleState()); super.update(elapsed); diff --git a/source/ui/MenuList.hx b/source/ui/MenuList.hx index 6d20d7d82..cee2f78b4 100644 --- a/source/ui/MenuList.hx +++ b/source/ui/MenuList.hx @@ -24,7 +24,8 @@ class MenuTypedList extends FlxTypedGroup var byName = new Map(); /** Set to true, internally to disable controls, without affecting vars like `enabled` */ - var busy:Bool = false; + public var busy(default, null):Bool = false; + // bit awkward because BACK is also a menu control and this doesn't affect that public function new (navControls:NavControls = Vertical, ?wrapMode:WrapMode) {