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