mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
Merge pull request #210 from FunkinCrew/bugfix/freeplay-random-fix
Fix bug where Freeplay random would crash the game
This commit is contained in:
commit
d9a31d8ab8
2 changed files with 20 additions and 3 deletions
|
@ -84,6 +84,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
|
||||
var dj:DJBoyfriend;
|
||||
|
||||
var letterSort:LetterSort;
|
||||
var typing:FlxInputText;
|
||||
var exitMovers:Map<Array<FlxSprite>, MoveData> = new Map();
|
||||
|
||||
|
@ -413,7 +414,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
txtCompletion.visible = false;
|
||||
add(txtCompletion);
|
||||
|
||||
var letterSort:LetterSort = new LetterSort(400, 75);
|
||||
letterSort = new LetterSort(400, 75);
|
||||
add(letterSort);
|
||||
letterSort.visible = false;
|
||||
|
||||
|
@ -953,6 +954,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
trace("RANDOM SELECTED");
|
||||
|
||||
busy = true;
|
||||
letterSort.inputEnabled = false;
|
||||
|
||||
var availableSongCapsules:Array<SongMenuItem> = grpCapsules.members.filter(function(cap:SongMenuItem) {
|
||||
// Dead capsules are ones which were removed from the list when changing filters.
|
||||
|
@ -963,6 +965,15 @@ class FreeplayState extends MusicBeatSubState
|
|||
return cap.songData.songName;
|
||||
})}');
|
||||
|
||||
if (availableSongCapsules.length == 0)
|
||||
{
|
||||
trace("No songs available!");
|
||||
busy = false;
|
||||
letterSort.inputEnabled = true;
|
||||
FlxG.sound.play(Paths.sound('cancelMenu'));
|
||||
return;
|
||||
}
|
||||
|
||||
var targetSong:SongMenuItem = FlxG.random.getObject(availableSongCapsules);
|
||||
|
||||
// Seeing if I can do an animation...
|
||||
|
@ -976,6 +987,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
function capsuleOnConfirmDefault(cap:SongMenuItem):Void
|
||||
{
|
||||
busy = true;
|
||||
letterSort.inputEnabled = false;
|
||||
|
||||
PlayStatePlaylist.isStoryMode = false;
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ class LetterSort extends FlxTypedSpriteGroup<FlxSprite>
|
|||
var rightArrow:FlxSprite;
|
||||
var grpSeperators:Array<FlxSprite> = [];
|
||||
|
||||
public var inputEnabled:Bool = true;
|
||||
|
||||
public function new(x, y)
|
||||
{
|
||||
super(x, y);
|
||||
|
@ -72,9 +74,12 @@ class LetterSort extends FlxTypedSpriteGroup<FlxSprite>
|
|||
{
|
||||
super.update(elapsed);
|
||||
|
||||
if (inputEnabled)
|
||||
{
|
||||
if (FlxG.keys.justPressed.E) changeSelection(1);
|
||||
if (FlxG.keys.justPressed.Q) changeSelection(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeSelection(diff:Int = 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue