Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeplay UI fixes #4214

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/funkin/ui/freeplay/CapsuleText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class CapsuleText extends FlxSpriteGroup

public function resetText():Void
{
scale.x = 1;
scale.y = 1;
if (moveTween != null) moveTween.cancel();
if (moveTimer != null) moveTimer.cancel();
whiteText.offset.x = 0;
Expand Down
34 changes: 22 additions & 12 deletions source/funkin/ui/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ 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.init(FlxG.width, 0, null, styleData);
randomCapsule.init(FlxG.width, 0, null, styleData, 0);
randomCapsule.y = randomCapsule.intendedY(0) + 10;
randomCapsule.targetPos.x = randomCapsule.x;
randomCapsule.alpha = 0;
Expand Down Expand Up @@ -751,7 +751,7 @@ class FreeplayState extends MusicBeatSubState

var funnyMenu:SongMenuItem = grpCapsules.recycle(SongMenuItem);

funnyMenu.init(FlxG.width, 0, tempSong, styleData);
funnyMenu.init(FlxG.width, 0, tempSong, styleData, i + 1);
funnyMenu.onConfirm = function() {
capsuleOnOpenDefault(funnyMenu);
};
Expand All @@ -761,7 +761,11 @@ class FreeplayState extends MusicBeatSubState
funnyMenu.capsule.alpha = 0.5;
funnyMenu.hsvShader = hsvShader;
funnyMenu.newText.animation.curAnim.curFrame = 45 - ((i * 4) % 45);
funnyMenu.forcePosition();
// I would like to use to use the jump in now that it looks better,
// but I still can't because switching from harder to normal difficulties causes the x positions to mess up
/*if (fromCharSelect)*/ funnyMenu.forcePosition();
/*else
funnyMenu.initJumpIn(0, force); */

grpCapsules.add(funnyMenu);
}
Expand Down Expand Up @@ -1744,7 +1748,7 @@ class FreeplayState extends MusicBeatSubState
intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedDifficulty = currentDifficulty;
grpCapsules.members[curSelected].refreshDisplay();
grpCapsules.members[curSelected].refreshDisplay((prepForNewRank == true) ? false : true);
}
else
{
Expand Down Expand Up @@ -1850,11 +1854,15 @@ class FreeplayState extends MusicBeatSubState
*/
function capsuleOnOpenDefault(cap:SongMenuItem):Void
{
busy = true;
letterSort.inputEnabled = false;
var targetSongId:String = cap?.freeplayData?.data.id ?? 'unknown';
var targetSongNullable:Null<Song> = SongRegistry.instance.fetchEntry(targetSongId);
if (targetSongNullable == null)
{
FlxG.log.warn('WARN: could not find song with id (${targetSongId})');
busy = false;
letterSort.inputEnabled = true;
return;
}
var targetSong:Song = targetSongNullable;
Expand All @@ -1868,6 +1876,8 @@ class FreeplayState extends MusicBeatSubState
if (targetDifficulty == null)
{
FlxG.log.warn('WARN: could not find difficulty with id (${targetDifficultyId})');
busy = false;
letterSort.inputEnabled = true;
return;
}

Expand Down Expand Up @@ -1897,9 +1907,7 @@ class FreeplayState extends MusicBeatSubState

function openInstrumentalList(cap:SongMenuItem, instrumentalIds:Array<String>):Void
{
busy = true;

capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.x + 175, cap.y + 115, instrumentalIds);
capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.targetPos.x + 175, cap.targetPos.y + 115, instrumentalIds);
capsuleOptionsMenu.cameras = [funnyCam];
capsuleOptionsMenu.zIndex = 10000;
add(capsuleOptionsMenu);
Expand All @@ -1914,6 +1922,7 @@ class FreeplayState extends MusicBeatSubState
public function cleanupCapsuleOptionsMenu():Void
{
this.busy = false;
letterSort.inputEnabled = true;

if (capsuleOptionsMenu != null)
{
Expand All @@ -1927,16 +1936,15 @@ class FreeplayState extends MusicBeatSubState
*/
function capsuleOnConfirmDefault(cap:SongMenuItem, ?targetInstId:String):Void
{
busy = true;
letterSort.inputEnabled = false;

PlayStatePlaylist.isStoryMode = false;

var targetSongId:String = cap?.freeplayData?.data.id ?? 'unknown';
var targetSongNullable:Null<Song> = SongRegistry.instance.fetchEntry(targetSongId);
if (targetSongNullable == null)
{
FlxG.log.warn('WARN: could not find song with id (${targetSongId})');
busy = false;
letterSort.inputEnabled = true;
return;
}
var targetSong:Song = targetSongNullable;
Expand All @@ -1948,6 +1956,8 @@ class FreeplayState extends MusicBeatSubState
if (targetDifficulty == null)
{
FlxG.log.warn('WARN: could not find difficulty with id (${currentDifficulty})');
busy = false;
letterSort.inputEnabled = true;
return;
}

Expand Down Expand Up @@ -2041,7 +2051,7 @@ class FreeplayState extends MusicBeatSubState
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedSongId = daSongCapsule.freeplayData.data.id;
changeDiff();
daSongCapsule.refreshDisplay();
daSongCapsule.refreshDisplay((prepForNewRank == true) ? false : true);
}
else
{
Expand All @@ -2059,7 +2069,7 @@ class FreeplayState extends MusicBeatSubState
capsule.selected = index == curSelected + 1;

capsule.targetPos.y = capsule.intendedY(index - curSelected);
capsule.targetPos.x = 270 + (60 * (Math.sin(index - curSelected)));
capsule.targetPos.x = capsule.intendedX(index - curSelected);

if (index < curSelected) capsule.targetPos.y -= 100; // another 100 for good measure
}
Expand Down
5 changes: 4 additions & 1 deletion source/funkin/ui/freeplay/LetterSort.hx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class FreeplayLetter extends FlxAtlasSprite
this.anim.play(animLetters[letterInd] + " move");
this.anim.pause();
curLetter = letterInd;
this.anim.onComplete.add(function() {
this.anim.play(animLetters[curLetter] + " move");
});
}
}

Expand Down Expand Up @@ -236,7 +239,7 @@ class FreeplayLetter extends FlxAtlasSprite
animName = "T move";
}

this.anim.play(animName);
this.anim.play(animName, true);
if (curSelection != curLetter)
{
this.anim.pause();
Expand Down
30 changes: 24 additions & 6 deletions source/funkin/ui/freeplay/SongMenuItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class SongMenuItem extends FlxSpriteGroup

var sparkleTimer:FlxTimer;

var index:Int;

public function new(x:Float, y:Float)
{
super(x, y);
Expand Down Expand Up @@ -422,7 +424,7 @@ class SongMenuItem extends FlxSpriteGroup
return evilTrail.color;
}

public function refreshDisplay():Void
public function refreshDisplay(updateRank:Bool = true):Void
{
if (freeplayData == null)
{
Expand All @@ -441,7 +443,7 @@ class SongMenuItem extends FlxSpriteGroup
pixelIcon.visible = true;
updateBPM(Std.int(freeplayData.songStartingBpm) ?? 0);
updateDifficultyRating(freeplayData.difficultyRating ?? 0);
updateScoringRank(freeplayData.scoringRank);
if (updateRank) updateScoringRank(freeplayData.scoringRank);
newText.visible = freeplayData.isNew;
favIcon.visible = freeplayData.isFav;
favIconBlurred.visible = freeplayData.isFav;
Expand Down Expand Up @@ -523,17 +525,19 @@ class SongMenuItem extends FlxSpriteGroup
spr.visible = value;
}

if (value) textAppear();
textAppear();

updateSelected();
}

public function init(?x:Float, ?y:Float, freeplayData:Null<FreeplaySongData>, ?styleData:FreeplayStyle = null):Void
public function init(?x:Float, ?y:Float, freeplayData:Null<FreeplaySongData>, ?styleData:FreeplayStyle = null, index:Int = null):Void
{
if (x != null) this.x = x;
if (y != null) this.y = y;
this.freeplayData = freeplayData;

if (index != null) this.index = index;

// im so mad i have to do this but im pretty sure with the capsules recycling i cant call the new function properly :/
// if thats possible someone Please change the new function to be something like
// capsule.frames = Paths.getSparrowAtlas(styleData == null ? 'freeplay/freeplayCapsule/capsule/freeplayCapsule' : styleData.getCapsuleAssetKey()); thank u luv u
Expand Down Expand Up @@ -655,13 +659,18 @@ class SongMenuItem extends FlxSpriteGroup

capsule.scale.x = xFrames[frameInTypeBeat];
capsule.scale.y = 1 / xFrames[frameInTypeBeat];
x = FlxG.width * xPosLerpLol[Std.int(Math.min(frameInTypeBeat, xPosLerpLol.length - 1))];
targetPos.x = FlxG.width * xPosLerpLol[Std.int(Math.min(frameInTypeBeat, xPosLerpLol.length - 1))];

capsule.scale.x *= realScaled;
capsule.scale.y *= realScaled;

frameInTypeBeat += 1;
}
else if (frameInTypeBeat == xFrames.length)
{
doJumpIn = false;
targetPos.x = intendedX(index);
}
}

if (doJumpOut)
Expand All @@ -674,13 +683,17 @@ class SongMenuItem extends FlxSpriteGroup

capsule.scale.x = xFrames[frameOutTypeBeat];
capsule.scale.y = 1 / xFrames[frameOutTypeBeat];
x = FlxG.width * xPosOutLerpLol[Std.int(Math.min(frameOutTypeBeat, xPosOutLerpLol.length - 1))];
this.x = FlxG.width * xPosOutLerpLol[Std.int(Math.min(frameOutTypeBeat, xPosOutLerpLol.length - 1))];

capsule.scale.x *= realScaled;
capsule.scale.y *= realScaled;

frameOutTypeBeat += 1;
}
else if (frameOutTypeBeat == xFrames.length)
{
doJumpOut = false;
}
}

if (doLerp)
Expand All @@ -704,6 +717,11 @@ class SongMenuItem extends FlxSpriteGroup
}
}

public function intendedX(index:Int):Float
{
return 270 + (60 * (Math.sin(index)));
}

public function intendedY(index:Int):Float
{
return (index * ((height * realScaled) + 10)) + 120;
Expand Down