Skip to content

Commit

Permalink
This should fix the squashed capsule text, right?
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasercar committed Feb 25, 2025
1 parent 85608bc commit 2ac8a5a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
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
12 changes: 8 additions & 4 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 @@ -2065,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
26 changes: 22 additions & 4 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 @@ -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

0 comments on commit 2ac8a5a

Please sign in to comment.