1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-24 22:26:50 +00:00

Merge branch 'mainmenu-remember-selection' into rewrite/master

This commit is contained in:
Cameron Taylor 2024-06-06 20:15:11 -04:00
commit e45e359de7

View file

@ -44,11 +44,12 @@ class MainMenuState extends MusicBeatState
var overrideMusic:Bool = false; var overrideMusic:Bool = false;
static var rememberedSelectedIndex:Int = 0;
public function new(?_overrideMusic:Bool = false) public function new(?_overrideMusic:Bool = false)
{ {
super(); super();
overrideMusic = _overrideMusic; overrideMusic = _overrideMusic;
} }
override function create():Void override function create():Void
@ -63,7 +64,7 @@ class MainMenuState extends MusicBeatState
transIn = FlxTransitionableState.defaultTransIn; transIn = FlxTransitionableState.defaultTransIn;
transOut = FlxTransitionableState.defaultTransOut; transOut = FlxTransitionableState.defaultTransOut;
if(overrideMusic == false) playMenuMusic(); if (overrideMusic == false) playMenuMusic();
// We want the state to always be able to begin with being able to accept inputs and show the anims of the menu items. // We want the state to always be able to begin with being able to accept inputs and show the anims of the menu items.
persistentUpdate = true; persistentUpdate = true;
@ -148,6 +149,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 -> {
@ -172,7 +175,7 @@ class MainMenuState extends MusicBeatState
function playMenuMusic():Void function playMenuMusic():Void
{ {
FunkinSound.playMusic('freakyMenu', FunkinSound.playMusic('freakyMenu',
{ {
overrideExisting: true, overrideExisting: true,
restartTrack: false restartTrack: false
@ -295,6 +298,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)