Add Remember Selection to MainMenuState

This commit is contained in:
gamerbross 2024-05-19 00:29:46 +02:00
parent 28bee8397e
commit bc1c15e91c

View file

@ -42,6 +42,8 @@ class MainMenuState extends MusicBeatState
var magenta:FlxSprite; var magenta:FlxSprite;
var camFollow:FlxObject; var camFollow:FlxObject;
static var rememberedSelectedIndex:Int = 0;
override function create():Void override function create():Void
{ {
#if discord_rpc #if discord_rpc
@ -137,6 +139,8 @@ class MainMenuState extends MusicBeatState
menuItem.scrollFactor.y = 0.4; menuItem.scrollFactor.y = 0.4;
} }
menuItems.selectItem(rememberedSelectedIndex);
resetCamStuff(); resetCamStuff();
subStateOpened.add(sub -> { subStateOpened.add(sub -> {
@ -285,6 +289,8 @@ class MainMenuState extends MusicBeatState
function startExitState(state:NextState):Void function startExitState(state:NextState):Void
{ {
menuItems.enabled = false; // disable for exit menuItems.enabled = false; // disable for exit
rememberedSelectedIndex = menuItems.selectedIndex;
var duration = 0.4; var duration = 0.4;
menuItems.forEach(function(item) { menuItems.forEach(function(item) {
if (menuItems.selectedIndex != item.ID) if (menuItems.selectedIndex != item.ID)