Prevent overlapping transitions and checks for both backbutton and optionsbutton
Co-authored-by: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com>
This commit is contained in:
co-authored by
Mihai Alexandru
parent
9e3efc0de7
commit
4772dfdc13
@@ -36,7 +36,7 @@ class MenuTypedList<T:MenuListItem> extends FlxTypedGroup<T>
|
||||
var byName = new Map<String, T>();
|
||||
|
||||
/** Set to true, internally to disable controls, without affecting vars like `enabled` */
|
||||
public var busy(default, null):Bool = false;
|
||||
public var busy:Bool = false;
|
||||
|
||||
// bit awkward because BACK is also a menu control and this doesn't affect that
|
||||
// #if mobile
|
||||
|
||||
@@ -52,6 +52,8 @@ class MainMenuState extends MusicBeatState
|
||||
#end
|
||||
|
||||
var overrideMusic:Bool = false;
|
||||
var goingToOptions:Bool = false;
|
||||
var goingBack:Bool = false;
|
||||
|
||||
static var rememberedSelectedIndex:Int = 0;
|
||||
|
||||
@@ -257,9 +259,20 @@ class MainMenuState extends MusicBeatState
|
||||
camFollow.y = bg.getGraphicMidpoint().y;
|
||||
|
||||
addBackButton(FlxG.width - 230, FlxG.height - 200, FlxColor.WHITE, goBack, 1.0);
|
||||
|
||||
addOptionsButton(35, FlxG.height - 210, function() {
|
||||
startExitState(() -> new funkin.ui.options.OptionsState());
|
||||
});
|
||||
|
||||
backButton.onConfirmStart.add(function():Void {
|
||||
backButton.active = true;
|
||||
goingBack = true;
|
||||
});
|
||||
optionsButton.onConfirmStart.add(function():Void {
|
||||
optionsButton.active = true;
|
||||
goingToOptions = true;
|
||||
menuItems.busy = true;
|
||||
});
|
||||
#end
|
||||
|
||||
super.create();
|
||||
@@ -325,6 +338,7 @@ class MainMenuState extends MusicBeatState
|
||||
backButton.animation.play('idle');
|
||||
optionsButton.animation.play('idle');
|
||||
backButton.resetCallbacks();
|
||||
optionsButton.resetCallbacks();
|
||||
#end
|
||||
super.closeSubState();
|
||||
}
|
||||
@@ -528,10 +542,9 @@ class MainMenuState extends MusicBeatState
|
||||
|
||||
if (_exiting) menuItems.enabled = false;
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
backButton.active = menuItems.enabled && !menuItems.busy;
|
||||
optionsButton.active = menuItems.enabled && !menuItems.busy;
|
||||
backButton.active = (goingBack || (menuItems.enabled && !menuItems.busy && !goingToOptions));
|
||||
optionsButton.active = (goingToOptions || (menuItems.enabled && !menuItems.busy && !goingBack));
|
||||
#end
|
||||
|
||||
if (controls.BACK)
|
||||
{
|
||||
goBack();
|
||||
@@ -542,6 +555,7 @@ class MainMenuState extends MusicBeatState
|
||||
{
|
||||
if (menuItems.enabled && !menuItems.busy)
|
||||
{
|
||||
menuItems.busy = true;
|
||||
rememberedSelectedIndex = menuItems.selectedIndex;
|
||||
FlxG.switchState(() -> new TitleState());
|
||||
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
||||
|
||||
Reference in New Issue
Block a user