mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-25 14:46:43 +00:00
Remember character ID between visits to Freeplay, plus some fixes to prevent spamming keys
This commit is contained in:
parent
570e672296
commit
2e7eabc494
|
@ -177,9 +177,22 @@ class FreeplayState extends MusicBeatSubState
|
||||||
|
|
||||||
var stickerSubState:Null<StickerSubState> = null;
|
var stickerSubState:Null<StickerSubState> = null;
|
||||||
|
|
||||||
public static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
|
/**
|
||||||
|
* The difficulty we were on when this menu was last accessed.
|
||||||
|
*/
|
||||||
|
public static var rememberedDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The song we were on when this menu was last accessed.
|
||||||
|
* NOTE: `null` if the last song was `Random`.
|
||||||
|
*/
|
||||||
public static var rememberedSongId:Null<String> = 'tutorial';
|
public static var rememberedSongId:Null<String> = 'tutorial';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character we were on when this menu was last accessed.
|
||||||
|
*/
|
||||||
|
public static var rememberedCharacterId:String = Constants.DEFAULT_CHARACTER;
|
||||||
|
|
||||||
var funnyCam:FunkinCamera;
|
var funnyCam:FunkinCamera;
|
||||||
var rankCamera:FunkinCamera;
|
var rankCamera:FunkinCamera;
|
||||||
var rankBg:FunkinSprite;
|
var rankBg:FunkinSprite;
|
||||||
|
@ -209,14 +222,16 @@ class FreeplayState extends MusicBeatSubState
|
||||||
|
|
||||||
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
|
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
|
||||||
{
|
{
|
||||||
currentCharacterId = params?.character ?? Constants.DEFAULT_CHARACTER;
|
currentCharacterId = params?.character ?? rememberedCharacterId;
|
||||||
var fetchPlayableCharacter = function():PlayableCharacter {
|
var fetchPlayableCharacter = function():PlayableCharacter {
|
||||||
var result = PlayerRegistry.instance.fetchEntry(params?.character ?? Constants.DEFAULT_CHARACTER);
|
var result = PlayerRegistry.instance.fetchEntry(params?.character ?? rememberedCharacterId);
|
||||||
if (result == null) throw 'No valid playable character with id ${params?.character}';
|
if (result == null) throw 'No valid playable character with id ${params?.character}';
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
currentCharacter = fetchPlayableCharacter();
|
currentCharacter = fetchPlayableCharacter();
|
||||||
|
|
||||||
|
rememberedCharacterId = currentCharacter?.id ?? Constants.DEFAULT_CHARACTER;
|
||||||
|
|
||||||
fromResultsParams = params?.fromResults;
|
fromResultsParams = params?.fromResults;
|
||||||
|
|
||||||
if (fromResultsParams?.playRankAnim == true)
|
if (fromResultsParams?.playRankAnim == true)
|
||||||
|
@ -743,10 +758,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
var tempSongs:Array<Null<FreeplaySongData>> = songs;
|
var tempSongs:Array<Null<FreeplaySongData>> = songs;
|
||||||
|
|
||||||
// Remember just the difficulty because it's important for song sorting.
|
// Remember just the difficulty because it's important for song sorting.
|
||||||
if (rememberedDifficulty != null)
|
|
||||||
{
|
|
||||||
currentDifficulty = rememberedDifficulty;
|
currentDifficulty = rememberedDifficulty;
|
||||||
}
|
|
||||||
|
|
||||||
if (filterStuff != null) tempSongs = sortSongs(tempSongs, filterStuff);
|
if (filterStuff != null) tempSongs = sortSongs(tempSongs, filterStuff);
|
||||||
|
|
||||||
|
@ -1190,7 +1202,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
/**
|
/**
|
||||||
* If true, disable interaction with the interface.
|
* If true, disable interaction with the interface.
|
||||||
*/
|
*/
|
||||||
var busy:Bool = false;
|
public var busy:Bool = false;
|
||||||
|
|
||||||
var originalPos:FlxPoint = new FlxPoint();
|
var originalPos:FlxPoint = new FlxPoint();
|
||||||
|
|
||||||
|
@ -1326,6 +1338,8 @@ class FreeplayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputs(elapsed);
|
handleInputs(elapsed);
|
||||||
|
|
||||||
|
if (dj != null) FlxG.watch.addQuick('dj-anim', dj.getCurrentAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInputs(elapsed:Float):Void
|
function handleInputs(elapsed:Float):Void
|
||||||
|
@ -1483,7 +1497,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
generateSongList(currentFilter, true);
|
generateSongList(currentFilter, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controls.BACK)
|
if (controls.BACK && !busy)
|
||||||
{
|
{
|
||||||
busy = true;
|
busy = true;
|
||||||
FlxTween.globalManager.clear();
|
FlxTween.globalManager.clear();
|
||||||
|
@ -1891,7 +1905,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
intendedCompletion = 0.0;
|
intendedCompletion = 0.0;
|
||||||
diffIdsCurrent = diffIdsTotal;
|
diffIdsCurrent = diffIdsTotal;
|
||||||
rememberedSongId = null;
|
rememberedSongId = null;
|
||||||
rememberedDifficulty = null;
|
rememberedDifficulty = Constants.DEFAULT_DIFFICULTY;
|
||||||
albumRoll.albumId = null;
|
albumRoll.albumId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2000,10 +2014,13 @@ class DifficultySelector extends FlxSprite
|
||||||
var controls:Controls;
|
var controls:Controls;
|
||||||
var whiteShader:PureColor;
|
var whiteShader:PureColor;
|
||||||
|
|
||||||
public function new(x:Float, y:Float, flipped:Bool, controls:Controls)
|
var parent:FreeplayState;
|
||||||
|
|
||||||
|
public function new(parent:FreeplayState, x:Float, y:Float, flipped:Bool, controls:Controls)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
|
||||||
|
this.parent = parent;
|
||||||
this.controls = controls;
|
this.controls = controls;
|
||||||
|
|
||||||
frames = Paths.getSparrowAtlas('freeplay/freeplaySelector');
|
frames = Paths.getSparrowAtlas('freeplay/freeplaySelector');
|
||||||
|
@ -2019,8 +2036,8 @@ class DifficultySelector extends FlxSprite
|
||||||
|
|
||||||
override function update(elapsed:Float):Void
|
override function update(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
if (flipX && controls.UI_RIGHT_P) moveShitDown();
|
if (flipX && controls.UI_RIGHT_P && !parent.busy) moveShitDown();
|
||||||
if (!flipX && controls.UI_LEFT_P) moveShitDown();
|
if (!flipX && controls.UI_LEFT_P && !parent.busy) moveShitDown();
|
||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue