use UIStateMachine in FreeplayState instead of checking/modifying controls.active everywhere
thus making it easier to fix the "unlocked inputs" issue (fix FUNK-2021)
This commit is contained in:
@@ -8,7 +8,8 @@ enum UIState
|
||||
{
|
||||
Idle;
|
||||
Interacting;
|
||||
Entering;
|
||||
EnteringMainMenu;
|
||||
EnteringFreeplay;
|
||||
Exiting;
|
||||
Disabled;
|
||||
}
|
||||
@@ -17,6 +18,8 @@ enum UIState
|
||||
* Note: Not to be confust with FlxState or FlxSubState!
|
||||
* State as in the design pattern!
|
||||
* https://refactoring.guru/design-patterns/state
|
||||
*
|
||||
* TODO: Generalize this a bit more to allow the UIState enum be defined with any enum
|
||||
*/
|
||||
@:nullSafety
|
||||
class UIStateMachine
|
||||
@@ -31,11 +34,12 @@ class UIStateMachine
|
||||
{
|
||||
// Default valid transitions if none provided
|
||||
validTransitions = transitions != null ? transitions : [
|
||||
Idle => [Interacting, Entering, Exiting, Disabled],
|
||||
Entering => [Idle, Exiting, Disabled, Interacting],
|
||||
Interacting => [Idle, Entering, Exiting, Disabled],
|
||||
Idle => [Interacting, EnteringMainMenu, EnteringFreeplay, Exiting, Disabled],
|
||||
EnteringMainMenu => [Idle, Exiting, Disabled, Interacting],
|
||||
Interacting => [Idle, EnteringMainMenu, EnteringFreeplay, Exiting, Disabled],
|
||||
Exiting => [Idle],
|
||||
Disabled => [Idle]
|
||||
Disabled => [Idle],
|
||||
EnteringFreeplay => [Idle]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -95,6 +99,6 @@ class UIStateMachine
|
||||
public function canInteract():Bool
|
||||
{
|
||||
// Entering is an enabled state since we want to be able to interact even during the screen fade wipe thing
|
||||
return currentState == Idle || currentState == Entering;
|
||||
return currentState == Idle || currentState == EnteringMainMenu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
*/
|
||||
public static final FADE_IN_DELAY:Float = 0.25;
|
||||
|
||||
var uiStateMachine:UIStateMachine = new UIStateMachine();
|
||||
|
||||
var songs:Array<Null<FreeplaySongData>> = [];
|
||||
|
||||
var curSelected:Int = 0;
|
||||
@@ -350,8 +352,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
backingImage = FunkinSprite.create(backingCard.pinkBack.width * 0.74, 0, styleData == null ? 'freeplay/freeplayBGweek1-bf' : styleData.getBgAssetKey());
|
||||
|
||||
// TODO: refactor DifficultySelector to *not* use `this` as input? Handle it's animations and style data in different manner
|
||||
diffSelLeft = new DifficultySelector((CUTOUT_WIDTH * DJ_POS_MULTI) + 20, grpDifficulties.y - 10, false, controls, styleData);
|
||||
diffSelRight = new DifficultySelector((CUTOUT_WIDTH * DJ_POS_MULTI) + 325, grpDifficulties.y - 10, true, controls, styleData);
|
||||
diffSelLeft = new DifficultySelector((CUTOUT_WIDTH * DJ_POS_MULTI) + 20, grpDifficulties.y - 10, false, controls, styleData, uiStateMachine);
|
||||
diffSelRight = new DifficultySelector((CUTOUT_WIDTH * DJ_POS_MULTI) + 325, grpDifficulties.y - 10, true, controls, styleData, uiStateMachine);
|
||||
}
|
||||
|
||||
override function create():Void
|
||||
@@ -388,7 +390,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
#end
|
||||
|
||||
// Block input until the intro finishes.
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(EnteringFreeplay);
|
||||
|
||||
// Add a null entry that represents the RANDOM option
|
||||
songs.push(null);
|
||||
@@ -721,7 +723,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
// be careful not to "add()" things in here unless it's to a group that's already added to the state
|
||||
// otherwise it won't be properly attatched to funnyCamera (relavent code should be at the bottom of create())
|
||||
var onDJIntroDone:Void->Void = () -> {
|
||||
controls.active = true;
|
||||
if (!uiStateMachine.is(Interacting)) uiStateMachine.transition(Idle);
|
||||
|
||||
dispatchEvent(new FreeplayScriptEvent(FREEPLAY_INTRO));
|
||||
|
||||
@@ -975,15 +977,11 @@ class FreeplayState extends MusicBeatSubState
|
||||
// Initialize the random capsule, with empty/blank info (which we display once bf/pico does his hand)
|
||||
var randomCapsule:SongMenuItem = grpCapsules.recycle(SongMenuItem);
|
||||
randomCapsule.initRandom(styleData);
|
||||
randomCapsule.onConfirm = function() {
|
||||
capsuleOnOpenRandom(randomCapsule);
|
||||
};
|
||||
randomCapsule.onConfirm = () -> capsuleOnOpenRandom(randomCapsule);
|
||||
|
||||
if (fromCharSelect || forceSkipIntro || noJumpIn) randomCapsule.forcePosition();
|
||||
else
|
||||
{
|
||||
randomCapsule.initJumpIn(0, force);
|
||||
}
|
||||
|
||||
var hsvShader:HSVShader = new HSVShader();
|
||||
randomCapsule.hsvShader = hsvShader;
|
||||
@@ -997,9 +995,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
var funnyMenu:SongMenuItem = grpCapsules.recycle(SongMenuItem);
|
||||
funnyMenu.initPosition(FlxG.width, 0);
|
||||
funnyMenu.initData(tempSong, styleData, i + 1);
|
||||
funnyMenu.onConfirm = function() {
|
||||
capsuleOnOpenDefault(funnyMenu);
|
||||
};
|
||||
funnyMenu.onConfirm = () -> capsuleOnOpenDefault(funnyMenu);
|
||||
funnyMenu.y = funnyMenu.intendedY(i + 1) + 10;
|
||||
funnyMenu.targetPos.x = funnyMenu.x;
|
||||
funnyMenu.ID = i;
|
||||
@@ -1013,7 +1009,6 @@ class FreeplayState extends MusicBeatSubState
|
||||
funnyMenu.initJumpIn(0, force);
|
||||
|
||||
grpCapsules.add(funnyMenu);
|
||||
// add(funnyMenu.theActualHitbox);
|
||||
}
|
||||
|
||||
FlxG.console.registerFunction('changeSelection', changeSelection);
|
||||
@@ -1081,7 +1076,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function rankAnimStart(fromResults:FromResultsParams, capsuleToRank:SongMenuItem):Void
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Interacting);
|
||||
// We get the current selected capsule, in-case someone changes the song selection during a timer
|
||||
capsuleToRank.sparkle.alpha = 0;
|
||||
// capsuleToRank.forcePosition();
|
||||
@@ -1130,9 +1125,6 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
capsuleToRank.doLerp = false;
|
||||
|
||||
// originalPos.x = capsuleToRank.x;
|
||||
// originalPos.y = capsuleToRank.y;
|
||||
|
||||
originalPos.x = (CUTOUT_WIDTH * SONGS_POS_MULTI) + 320.488;
|
||||
originalPos.y = 235.6;
|
||||
trace(originalPos);
|
||||
@@ -1296,7 +1288,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
capsule.cameras = [funnyCam];
|
||||
|
||||
// NOW we can interact with the menu
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
capsule.sparkle.alpha = 0.7;
|
||||
playCurSongPreview(capsule);
|
||||
}, null);
|
||||
@@ -1476,7 +1468,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
return;
|
||||
}
|
||||
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
|
||||
FunkinSound.playOnce(Paths.sound('confirmMenu'));
|
||||
|
||||
@@ -1492,7 +1484,6 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function transitionToCharSelect():Void
|
||||
{
|
||||
controls.active = false;
|
||||
var transitionGradient:FlxSprite = new FlxSprite(0, 720).loadGraphic(Paths.image('freeplay/transitionGradient'));
|
||||
transitionGradient.scale.set(1280, 1);
|
||||
transitionGradient.updateHitbox();
|
||||
@@ -1504,6 +1495,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
wait: 0.1
|
||||
});
|
||||
add(transitionGradient);
|
||||
|
||||
for (index => capsule in grpCapsules.members)
|
||||
{
|
||||
var distFromSelected:Float = Math.abs(index - curSelected) - 1;
|
||||
@@ -1554,7 +1546,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function enterFromCharSel():Void
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(EnteringFreeplay);
|
||||
if (_parentState != null) _parentState.persistentDraw = false;
|
||||
|
||||
var transitionGradient = new FlxSprite(0, 720).loadGraphic(Paths.image('freeplay/transitionGradient'));
|
||||
@@ -1588,13 +1580,11 @@ class FreeplayState extends MusicBeatSubState
|
||||
FlxTween.tween(spr, {y: spr.y - moveDataY}, moveDataSpeed * 1.2,
|
||||
{
|
||||
ease: FlxEase.expoOut,
|
||||
onComplete: function(_) {
|
||||
for (index => capsule in grpCapsules.members)
|
||||
{
|
||||
onComplete: (_) -> {
|
||||
fromCharSelect = false;
|
||||
|
||||
for (capsule in grpCapsules.members)
|
||||
capsule.doLerp = true;
|
||||
fromCharSelect = false;
|
||||
controls.active = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1625,12 +1615,12 @@ class FreeplayState extends MusicBeatSubState
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
if (backButton != null && !backTransitioning)
|
||||
{
|
||||
if (!controls.active)
|
||||
if (!uiStateMachine.canInteract())
|
||||
{
|
||||
backButton.animation.play("idle");
|
||||
backButton.alpha = backButton.restingOpacity;
|
||||
}
|
||||
backButton.enabled = controls.active;
|
||||
backButton.enabled = uiStateMachine.canInteract();
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -1664,17 +1654,19 @@ class FreeplayState extends MusicBeatSubState
|
||||
}
|
||||
#end // ^<-- FEATURE_DEBUG_FUNCTIONS
|
||||
|
||||
if ((controls.FREEPLAY_CHAR_SELECT && !fromCharSelect #if FEATURE_TOUCH_CONTROLS
|
||||
|| (TouchUtil.pressAction(djHitbox, funnyCam, false) && !SwipeUtil.swipeAny) #end)
|
||||
&& controls.active
|
||||
&& !FlxG.debugger.visible)
|
||||
if (uiStateMachine.canInteract())
|
||||
{
|
||||
tryOpenCharSelect();
|
||||
}
|
||||
if ((controls.FREEPLAY_CHAR_SELECT && !fromCharSelect #if FEATURE_TOUCH_CONTROLS
|
||||
|| (TouchUtil.pressAction(djHitbox, funnyCam, false) && !SwipeUtil.swipeAny) #end)
|
||||
&& !FlxG.debugger.visible)
|
||||
{
|
||||
tryOpenCharSelect();
|
||||
}
|
||||
|
||||
if (controls.FREEPLAY_FAVORITE && controls.active) favoriteSong();
|
||||
if (controls.FREEPLAY_JUMP_TO_TOP && controls.active) changeSelection(-curSelected);
|
||||
if (controls.FREEPLAY_JUMP_TO_BOTTOM && controls.active) changeSelection(grpCapsules.countLiving() - curSelected - 1);
|
||||
if (controls.FREEPLAY_FAVORITE) favoriteSong();
|
||||
if (controls.FREEPLAY_JUMP_TO_TOP) changeSelection(-curSelected);
|
||||
if (controls.FREEPLAY_JUMP_TO_BOTTOM) changeSelection(grpCapsules.countLiving() - curSelected - 1);
|
||||
}
|
||||
|
||||
lerpScoreDisplays();
|
||||
|
||||
@@ -1733,7 +1725,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
function handleInputs(elapsed:Float):Void
|
||||
{
|
||||
@:privateAccess
|
||||
if (!controls.active || (stickerSubState?.switchingState ?? false)) return;
|
||||
if (!uiStateMachine.canInteract() || (stickerSubState?.switchingState ?? false)) return;
|
||||
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
handleTouchCapsuleClick();
|
||||
@@ -1773,7 +1765,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
goBack();
|
||||
}
|
||||
|
||||
if (controls.ACCEPT_P && controls.active)
|
||||
if (controls.ACCEPT_P && uiStateMachine.canInteract())
|
||||
{
|
||||
currentCapsule.onConfirm();
|
||||
}
|
||||
@@ -1815,6 +1807,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function handleDifficultySwitch():Void
|
||||
{
|
||||
if (!uiStateMachine.canInteract()) return;
|
||||
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
final leftPressed:Bool = controls.UI_LEFT_P || TouchUtil.pressAction(diffSelLeft, funnyCam, false);
|
||||
final rightPressed:Bool = controls.UI_RIGHT_P || TouchUtil.pressAction(diffSelRight, funnyCam, false);
|
||||
@@ -1840,10 +1834,10 @@ class FreeplayState extends MusicBeatSubState
|
||||
function handleDebugKeys():Void
|
||||
{
|
||||
#if FEATURE_CHART_EDITOR
|
||||
if (!controls.active) return;
|
||||
if (!uiStateMachine.canInteract()) return;
|
||||
if (controls.DEBUG_CHART)
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
|
||||
var targetSongID = currentCapsule?.freeplayData?.data.id ?? 'unknown';
|
||||
if (targetSongID == 'unknown')
|
||||
@@ -1862,7 +1856,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (availableSongCapsules.length == 0)
|
||||
{
|
||||
trace('No songs available!');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
||||
return;
|
||||
@@ -1890,10 +1884,11 @@ class FreeplayState extends MusicBeatSubState
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
#if FEATURE_STAGE_EDITOR
|
||||
if (controls.DEBUG_STAGE)
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
|
||||
var targetSongID = grpCapsules.members[curSelected]?.freeplayData?.data.id ?? 'unknown';
|
||||
if (targetSongID == 'unknown')
|
||||
@@ -1913,7 +1908,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (availableSongCapsules.length == 0)
|
||||
{
|
||||
trace('No songs available!');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
||||
return;
|
||||
@@ -1931,7 +1926,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetSongNullable == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find song with id (${targetSongID})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -1942,7 +1937,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetDifficulty == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find difficulty with id (${currentDifficulty})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -2140,7 +2135,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
currentCapsule.doLerp = true;
|
||||
}
|
||||
|
||||
if (!controls.active) return;
|
||||
if (!uiStateMachine.canInteract()) return;
|
||||
if (currentDifficultySprite == null) return;
|
||||
|
||||
// If we press onto our difficulty, we want to "grab" it rather than simply check if we are overlapping
|
||||
@@ -2206,7 +2201,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
function goBack():Void
|
||||
{
|
||||
@:privateAccess
|
||||
if (!controls.active || (stickerSubState?.switchingState ?? false)) return;
|
||||
if (!uiStateMachine.canInteract() || (stickerSubState?.switchingState ?? false)) return;
|
||||
backTransitioning = true;
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
if (backButton != null)
|
||||
@@ -2215,7 +2210,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
backButton.animation.play("confirm");
|
||||
}
|
||||
#end
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
FlxTween.globalManager.clear();
|
||||
FlxTimer.globalManager.clear();
|
||||
dj?.onIntroDone.removeAll();
|
||||
@@ -2337,7 +2332,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
{
|
||||
if (currentCapsule != null)
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Interacting);
|
||||
currentCapsule.doLerp = false;
|
||||
|
||||
var movement:Float = (change > 0) ? 15 : -15;
|
||||
@@ -2354,12 +2349,13 @@ class FreeplayState extends MusicBeatSubState
|
||||
diff.visible = true;
|
||||
final newX:Int = (change > 0) ? -320 : 500;
|
||||
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Interacting);
|
||||
|
||||
FlxTween.tween(diff, {x: newX + (CUTOUT_WIDTH * DJ_POS_MULTI)}, 0.2,
|
||||
{
|
||||
ease: FlxEase.circInOut,
|
||||
onComplete: function(_) {
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
diff.x = 90 + (CUTOUT_WIDTH * DJ_POS_MULTI);
|
||||
diff.visible = false;
|
||||
}
|
||||
@@ -2502,7 +2498,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
// Set the album graphic and play the animation if relevant.
|
||||
var newAlbumId:Null<String> = daSong?.data.getAlbumId(currentDifficulty, currentVariation);
|
||||
if (albumRoll.albumId != newAlbumId && (currentVariation != previousVariation || controls.active) && !fromCharSelect)
|
||||
if (albumRoll.albumId != newAlbumId && (currentVariation != previousVariation || uiStateMachine.canInteract()) && !fromCharSelect)
|
||||
{
|
||||
albumRoll.albumId = newAlbumId;
|
||||
albumRoll.skipIntro();
|
||||
@@ -2526,7 +2522,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function handleDiffBoundaryChange(change:Int):Void
|
||||
{
|
||||
if (!controls.active) return;
|
||||
if (!uiStateMachine.canInteract()) return;
|
||||
dj?.onPlayerAction(); // dj?.resetAFKTimer();
|
||||
changeDiff(change);
|
||||
generateSongList(currentFilter, true, false);
|
||||
@@ -2556,7 +2552,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (availableSongCapsules.length == 0)
|
||||
{
|
||||
trace('No songs available!');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = true;
|
||||
#end
|
||||
@@ -2564,7 +2561,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
return;
|
||||
}
|
||||
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = false;
|
||||
#end
|
||||
@@ -2590,7 +2588,6 @@ class FreeplayState extends MusicBeatSubState
|
||||
function capsuleOnConfirmRandom(availableSongCapsules:Array<SongMenuItem>, instChoice:String):Void
|
||||
{
|
||||
cleanupCapsuleOptionsMenu();
|
||||
controls.active = false;
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = false;
|
||||
#end
|
||||
@@ -2605,7 +2602,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetSongNullable == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find song with id (${targetSongId})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = true;
|
||||
#end
|
||||
@@ -2619,7 +2616,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetDifficulty == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find difficulty with id (${targetDifficultyId})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = true;
|
||||
#end
|
||||
@@ -2650,7 +2647,6 @@ class FreeplayState extends MusicBeatSubState
|
||||
*/
|
||||
function capsuleOnOpenDefault(cap:SongMenuItem):Void
|
||||
{
|
||||
controls.active = false;
|
||||
letterSort.inputEnabled = false;
|
||||
var targetDifficultyId:String = currentDifficulty;
|
||||
var targetVariation:Null<String> = currentVariation;
|
||||
@@ -2659,7 +2655,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetSongNullable == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find song with id (${targetSongId})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -2672,7 +2668,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetDifficulty == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find difficulty with id (${targetDifficultyId})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -2699,6 +2695,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
#else
|
||||
trace('NO ALTS');
|
||||
#end
|
||||
|
||||
capsuleOnConfirmDefault(cap);
|
||||
}
|
||||
|
||||
@@ -2709,6 +2706,8 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
function openInstrumentalList(cap:SongMenuItem, instrumentalIds:Array<String>):Void
|
||||
{
|
||||
uiStateMachine.transition(Interacting);
|
||||
|
||||
capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.targetPos.x + 175, cap.targetPos.y + 115, instrumentalIds);
|
||||
capsuleOptionsMenu.cameras = [funnyCam];
|
||||
capsuleOptionsMenu.zIndex = 10000;
|
||||
@@ -2723,7 +2722,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
|
||||
public function cleanupCapsuleOptionsMenu():Void
|
||||
{
|
||||
this.controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
|
||||
if (capsuleOptionsMenu != null)
|
||||
@@ -2738,7 +2737,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
*/
|
||||
function capsuleOnConfirmDefault(cap:SongMenuItem, ?targetInstId:String):Void
|
||||
{
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Exiting);
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
letterSort.inputEnabled = false;
|
||||
#end
|
||||
@@ -2753,7 +2752,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetSongNullable == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find song with id (${targetSongId})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -2769,7 +2768,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (targetDifficulty == null)
|
||||
{
|
||||
FlxG.log.warn('WARN: could not find difficulty with id (${currentDifficulty})');
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
letterSort.inputEnabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -2961,7 +2960,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
if (index < curSelected) capsule.targetPos.y -= 100; // another 100 for good measure
|
||||
}
|
||||
|
||||
if (grpCapsules.countLiving() > 0 && !prepForNewRank && controls.active)
|
||||
if (grpCapsules.countLiving() > 0 && !prepForNewRank && uiStateMachine.canInteract())
|
||||
{
|
||||
FlxG.sound.music?.pause();
|
||||
FlxTimer.wait(FADE_IN_DELAY, playCurSongPreview.bind(currentCapsule));
|
||||
@@ -3104,7 +3103,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
FunkinSound.playOnce(Paths.sound('fav'), 1);
|
||||
selectedCapsule.checkClip();
|
||||
selectedCapsule.selected = true; // set selected again, so it can run its getter function to initialize movement
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Interacting);
|
||||
|
||||
selectedCapsule.doLerp = false;
|
||||
FlxTween.tween(selectedCapsule, {y: selectedCapsule.y - 5}, 0.1, {ease: FlxEase.expoOut});
|
||||
@@ -3115,7 +3114,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
startDelay: 0.1,
|
||||
onComplete: function(_) {
|
||||
selectedCapsule.doLerp = true;
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3131,7 +3130,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
selectedCapsule.selected = true; // set selected again, so it can run its getter function to initialize movement
|
||||
});
|
||||
|
||||
controls.active = false;
|
||||
uiStateMachine.transition(Interacting);
|
||||
selectedCapsule.doLerp = false;
|
||||
FlxTween.tween(selectedCapsule, {y: selectedCapsule.y + 5}, 0.1, {ease: FlxEase.expoOut});
|
||||
FlxTween.tween(selectedCapsule, {y: selectedCapsule.y - 5}, 0.1,
|
||||
@@ -3140,7 +3139,7 @@ class FreeplayState extends MusicBeatSubState
|
||||
startDelay: 0.1,
|
||||
onComplete: function(_) {
|
||||
selectedCapsule.doLerp = true;
|
||||
controls.active = true;
|
||||
uiStateMachine.transition(Idle);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3155,16 +3154,18 @@ class FreeplayState extends MusicBeatSubState
|
||||
class DifficultySelector extends FlxSprite
|
||||
{
|
||||
var controls:Controls;
|
||||
var uiStateMachine:UIStateMachine;
|
||||
var whiteShader:PureColor;
|
||||
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
var pressed:Bool = false;
|
||||
#end
|
||||
|
||||
public function new(x:Float, y:Float, flipped:Bool, controls:Controls, ?styleData:FreeplayStyle)
|
||||
public function new(x:Float, y:Float, flipped:Bool, controls:Controls, ?styleData:FreeplayStyle, uiStateMachine:UIStateMachine)
|
||||
{
|
||||
super(x, y);
|
||||
this.controls = controls;
|
||||
this.uiStateMachine = uiStateMachine;
|
||||
this.whiteShader = new PureColor(FlxColor.WHITE);
|
||||
this.whiteShader.colorSet = true;
|
||||
|
||||
@@ -3178,7 +3179,7 @@ class DifficultySelector extends FlxSprite
|
||||
|
||||
override function update(elapsed:Float):Void
|
||||
{
|
||||
if (!controls.active) return;
|
||||
if (!uiStateMachine.canInteract()) return;
|
||||
|
||||
if (flipX && controls.UI_RIGHT_P) moveShitDown();
|
||||
if (!flipX && controls.UI_LEFT_P) moveShitDown();
|
||||
@@ -3436,7 +3437,7 @@ class FreeplaySongData
|
||||
return Save.instance.getSongRank(data.id, FreeplayState.rememberedDifficulty, curVariation);
|
||||
}
|
||||
|
||||
function get_curVariation()
|
||||
function get_curVariation():String
|
||||
{
|
||||
// Temporarily fetch the song to check for the first valid variation of it.
|
||||
// For example if the current character is bf, for songs such as darnell we want to use the 'bf' variation instead of 'normal'.
|
||||
@@ -3445,7 +3446,7 @@ class FreeplaySongData
|
||||
|
||||
var variations:Array<String> = song.getVariationsByCharacterId(FreeplayState.rememberedCharacterId);
|
||||
var variation:Null<String> = song.getFirstValidVariation(FreeplayState.rememberedDifficulty, null, variations);
|
||||
if (variation == null) variation = Constants.DEFAULT_VARIATION;
|
||||
variation ??= Constants.DEFAULT_VARIATION;
|
||||
|
||||
return variation;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class MainMenuState extends MusicBeatState
|
||||
overrideMusic = _overrideMusic;
|
||||
|
||||
// Start in Entering state during screen fade in
|
||||
uiStateMachine.transition(Entering);
|
||||
uiStateMachine.transition(EnteringMainMenu);
|
||||
|
||||
upgradeSparkles = new FlxTypedSpriteGroup<UpgradeSparkle>();
|
||||
magenta = new FlxSprite(Paths.image('menuBGMagenta'));
|
||||
|
||||
Reference in New Issue
Block a user