2023-11-07 09:04:22 +00:00
|
|
|
package funkin.ui.freeplay;
|
2021-10-21 21:40:53 +00:00
|
|
|
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.ui.freeplay.FreeplayState.FreeplaySongData;
|
|
|
|
import funkin.graphics.shaders.HSVShader;
|
|
|
|
import funkin.graphics.shaders.GaussianBlurShader;
|
2023-08-12 04:31:43 +00:00
|
|
|
import flixel.group.FlxGroup;
|
2021-10-21 21:40:53 +00:00
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
|
|
|
import flixel.group.FlxSpriteGroup;
|
|
|
|
import flixel.math.FlxMath;
|
|
|
|
import flixel.math.FlxPoint;
|
|
|
|
import flixel.text.FlxText;
|
2023-08-06 20:24:34 +00:00
|
|
|
import flixel.util.FlxTimer;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.util.MathUtil;
|
|
|
|
import funkin.graphics.shaders.Grayscale;
|
2024-05-30 03:34:00 +00:00
|
|
|
import funkin.graphics.shaders.GaussianBlurShader;
|
|
|
|
import openfl.display.BlendMode;
|
|
|
|
import funkin.graphics.FunkinSprite;
|
|
|
|
import flixel.tweens.FlxEase;
|
|
|
|
import flixel.tweens.FlxTween;
|
|
|
|
import flixel.addons.effects.FlxTrail;
|
2024-05-30 09:25:51 +00:00
|
|
|
import funkin.play.scoring.Scoring.ScoringRank;
|
2024-05-30 03:34:00 +00:00
|
|
|
import flixel.util.FlxColor;
|
2021-10-21 21:40:53 +00:00
|
|
|
|
|
|
|
class SongMenuItem extends FlxSpriteGroup
|
|
|
|
{
|
2023-09-19 23:10:30 +00:00
|
|
|
public var capsule:FlxSprite;
|
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
var pixelIcon:FlxSprite;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
/**
|
|
|
|
* Modify this by calling `init()`
|
|
|
|
* If `null`, assume this SongMenuItem is for the "Random Song" option.
|
|
|
|
*/
|
|
|
|
public var songData(default, null):Null<FreeplaySongData> = null;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
public var selected(default, set):Bool;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-08-14 06:49:18 +00:00
|
|
|
public var songText:CapsuleText;
|
2024-06-05 03:36:32 +00:00
|
|
|
public var favIconBlurred:FlxSprite;
|
2023-01-23 03:25:45 +00:00
|
|
|
public var favIcon:FlxSprite;
|
2024-06-01 23:25:52 +00:00
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
public var ranking:FreeplayRank;
|
|
|
|
public var blurredRanking:FreeplayRank;
|
2023-08-11 09:20:25 +00:00
|
|
|
|
2024-06-01 23:25:52 +00:00
|
|
|
public var fakeRanking:FreeplayRank;
|
|
|
|
public var fakeBlurredRanking:FreeplayRank;
|
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
var ranks:Array<String> = ["fail", "average", "great", "excellent", "perfect", "perfectsick"];
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
public var targetPos:FlxPoint = new FlxPoint();
|
|
|
|
public var doLerp:Bool = false;
|
|
|
|
public var doJumpIn:Bool = false;
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
public var doJumpOut:Bool = false;
|
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
public var onConfirm:Void->Void;
|
2024-01-11 05:30:00 +00:00
|
|
|
public var grayscaleShader:Grayscale;
|
2023-08-06 20:24:34 +00:00
|
|
|
|
2023-08-28 18:52:03 +00:00
|
|
|
public var hsvShader(default, set):HSVShader;
|
|
|
|
|
2024-04-16 22:43:11 +00:00
|
|
|
// var diffRatingSprite:FlxSprite;
|
2024-05-30 03:34:00 +00:00
|
|
|
public var bpmText:FlxSprite;
|
|
|
|
public var difficultyText:FlxSprite;
|
|
|
|
public var weekType:FlxSprite;
|
|
|
|
|
|
|
|
public var newText:FlxSprite;
|
|
|
|
|
|
|
|
// public var weekType:FlxSprite;
|
|
|
|
public var bigNumbers:Array<CapsuleNumber> = [];
|
|
|
|
|
|
|
|
public var smallNumbers:Array<CapsuleNumber> = [];
|
|
|
|
|
|
|
|
public var weekNumbers:Array<CapsuleNumber> = [];
|
|
|
|
|
|
|
|
var impactThing:FunkinSprite;
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
public function new(x:Float, y:Float)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
capsule = new FlxSprite();
|
|
|
|
capsule.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule');
|
|
|
|
capsule.animation.addByPrefix('selected', 'mp3 capsule w backing0', 24);
|
|
|
|
capsule.animation.addByPrefix('unselected', 'mp3 capsule w backing NOT SELECTED', 24);
|
|
|
|
// capsule.animation
|
|
|
|
add(capsule);
|
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
bpmText = new FlxSprite(144, 87).loadGraphic(Paths.image('freeplay/freeplayCapsule/bpmtext'));
|
|
|
|
bpmText.setGraphicSize(Std.int(bpmText.width * 0.9));
|
|
|
|
add(bpmText);
|
|
|
|
|
|
|
|
difficultyText = new FlxSprite(414, 87).loadGraphic(Paths.image('freeplay/freeplayCapsule/difficultytext'));
|
|
|
|
difficultyText.setGraphicSize(Std.int(difficultyText.width * 0.9));
|
|
|
|
add(difficultyText);
|
|
|
|
|
|
|
|
weekType = new FlxSprite(291, 87);
|
|
|
|
weekType.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/weektypes');
|
|
|
|
|
|
|
|
weekType.animation.addByPrefix('WEEK', 'WEEK text instance 1', 24, false);
|
|
|
|
weekType.animation.addByPrefix('WEEKEND', 'WEEKEND text instance 1', 24, false);
|
|
|
|
|
|
|
|
weekType.setGraphicSize(Std.int(weekType.width * 0.9));
|
|
|
|
add(weekType);
|
|
|
|
|
|
|
|
newText = new FlxSprite(454, 9);
|
|
|
|
newText.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/new');
|
|
|
|
newText.animation.addByPrefix('newAnim', 'NEW notif', 24, true);
|
|
|
|
newText.animation.play('newAnim', true);
|
|
|
|
newText.setGraphicSize(Std.int(newText.width * 0.9));
|
|
|
|
|
|
|
|
newText.visible = false;
|
|
|
|
|
|
|
|
add(newText);
|
|
|
|
|
|
|
|
// var debugNumber2:CapsuleNumber = new CapsuleNumber(0, 0, true, 2);
|
|
|
|
// add(debugNumber2);
|
|
|
|
|
|
|
|
for (i in 0...2)
|
|
|
|
{
|
|
|
|
var bigNumber:CapsuleNumber = new CapsuleNumber(466 + (i * 30), 32, true, 0);
|
|
|
|
add(bigNumber);
|
|
|
|
|
|
|
|
bigNumbers.push(bigNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i in 0...3)
|
|
|
|
{
|
|
|
|
var smallNumber:CapsuleNumber = new CapsuleNumber(185 + (i * 11), 88.5, false, 0);
|
|
|
|
add(smallNumber);
|
|
|
|
|
|
|
|
smallNumbers.push(smallNumber);
|
|
|
|
}
|
|
|
|
|
2023-08-12 04:31:43 +00:00
|
|
|
// doesn't get added, simply is here to help with visibility of things for the pop in!
|
|
|
|
grpHide = new FlxGroup();
|
|
|
|
|
2024-06-01 23:25:52 +00:00
|
|
|
fakeRanking = new FreeplayRank(420, 41);
|
|
|
|
add(fakeRanking);
|
|
|
|
|
|
|
|
fakeBlurredRanking = new FreeplayRank(fakeRanking.x, fakeRanking.y);
|
|
|
|
fakeBlurredRanking.shader = new GaussianBlurShader(1);
|
|
|
|
add(fakeBlurredRanking);
|
|
|
|
|
|
|
|
fakeRanking.visible = false;
|
|
|
|
fakeBlurredRanking.visible = false;
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
ranking = new FreeplayRank(420, 41);
|
2024-05-30 03:34:00 +00:00
|
|
|
add(ranking);
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
blurredRanking = new FreeplayRank(ranking.x, ranking.y);
|
2024-05-30 03:34:00 +00:00
|
|
|
blurredRanking.shader = new GaussianBlurShader(1);
|
|
|
|
add(blurredRanking);
|
2024-06-01 23:25:52 +00:00
|
|
|
|
2024-04-16 22:43:11 +00:00
|
|
|
// ranking.loadGraphic(Paths.image('freeplay/ranks/' + rank));
|
|
|
|
// ranking.scale.x = ranking.scale.y = realScaled;
|
2024-03-20 18:37:24 +00:00
|
|
|
// ranking.alpha = 0.75;
|
2024-04-16 22:43:11 +00:00
|
|
|
// ranking.visible = false;
|
|
|
|
// ranking.origin.set(capsule.origin.x - ranking.x, capsule.origin.y - ranking.y);
|
|
|
|
// add(ranking);
|
|
|
|
// grpHide.add(ranking);
|
2023-08-11 09:20:25 +00:00
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
// switch (rank)
|
|
|
|
// {
|
|
|
|
// case 'perfect':
|
|
|
|
// ranking.x -= 10;
|
|
|
|
// }
|
2023-08-11 09:20:25 +00:00
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
grayscaleShader = new Grayscale(1);
|
|
|
|
|
2024-04-16 22:43:11 +00:00
|
|
|
// diffRatingSprite = new FlxSprite(145, 90).loadGraphic(Paths.image('freeplay/diffRatings/diff00'));
|
|
|
|
// diffRatingSprite.shader = grayscaleShader;
|
|
|
|
// diffRatingSprite.origin.set(capsule.origin.x - diffRatingSprite.x, capsule.origin.y - diffRatingSprite.y);
|
2024-03-20 18:37:24 +00:00
|
|
|
// TODO: Readd once ratings are fully implemented
|
|
|
|
// add(diffRatingSprite);
|
2024-04-04 07:31:03 +00:00
|
|
|
// grpHide.add(diffRatingSprite);
|
2024-01-11 05:30:00 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
songText = new CapsuleText(capsule.width * 0.26, 45, 'Random', Std.int(40 * realScaled));
|
2023-01-23 03:25:45 +00:00
|
|
|
add(songText);
|
2023-08-12 04:31:43 +00:00
|
|
|
grpHide.add(songText);
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2024-01-11 05:30:00 +00:00
|
|
|
// TODO: Use value from metadata instead of random.
|
2024-05-30 03:34:00 +00:00
|
|
|
updateDifficultyRating(FlxG.random.int(0, 20));
|
2024-01-11 05:30:00 +00:00
|
|
|
|
2024-01-11 01:58:29 +00:00
|
|
|
pixelIcon = new FlxSprite(160, 35);
|
2024-01-11 05:30:00 +00:00
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
pixelIcon.makeGraphic(32, 32, 0x00000000);
|
|
|
|
pixelIcon.antialiasing = false;
|
2023-08-09 06:47:22 +00:00
|
|
|
pixelIcon.active = false;
|
2023-08-08 18:35:07 +00:00
|
|
|
add(pixelIcon);
|
2023-08-12 04:31:43 +00:00
|
|
|
grpHide.add(pixelIcon);
|
2023-08-08 18:35:07 +00:00
|
|
|
|
2024-06-05 03:36:32 +00:00
|
|
|
favIconBlurred = new FlxSprite(380, 40);
|
|
|
|
favIconBlurred.frames = Paths.getSparrowAtlas('freeplay/favHeart');
|
|
|
|
favIconBlurred.animation.addByPrefix('fav', 'favorite heart', 24, false);
|
|
|
|
favIconBlurred.animation.play('fav');
|
|
|
|
favIconBlurred.setGraphicSize(50, 50);
|
|
|
|
favIconBlurred.blend = BlendMode.ADD;
|
|
|
|
favIconBlurred.shader = new GaussianBlurShader(1.2);
|
|
|
|
favIconBlurred.visible = false;
|
|
|
|
add(favIconBlurred);
|
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
favIcon = new FlxSprite(380, 40);
|
2023-01-23 03:25:45 +00:00
|
|
|
favIcon.frames = Paths.getSparrowAtlas('freeplay/favHeart');
|
2024-03-20 18:37:24 +00:00
|
|
|
favIcon.animation.addByPrefix('fav', 'favorite heart', 24, false);
|
2023-01-23 03:25:45 +00:00
|
|
|
favIcon.animation.play('fav');
|
2023-08-14 03:22:24 +00:00
|
|
|
favIcon.setGraphicSize(50, 50);
|
|
|
|
favIcon.visible = false;
|
2024-05-30 03:34:00 +00:00
|
|
|
favIcon.blend = BlendMode.ADD;
|
2023-01-23 03:25:45 +00:00
|
|
|
add(favIcon);
|
2024-05-30 03:34:00 +00:00
|
|
|
|
|
|
|
var weekNumber:CapsuleNumber = new CapsuleNumber(355, 88.5, false, 0);
|
|
|
|
add(weekNumber);
|
|
|
|
|
|
|
|
weekNumbers.push(weekNumber);
|
2023-08-12 04:31:43 +00:00
|
|
|
|
|
|
|
setVisibleGrp(false);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
2024-05-30 03:34:00 +00:00
|
|
|
// no way to grab weeks rn, so this needs to be done :/
|
|
|
|
// negative values mean weekends
|
|
|
|
function checkWeek(name:String):Void
|
|
|
|
{
|
|
|
|
// trace(name);
|
|
|
|
var weekNum:Int = 0;
|
|
|
|
switch (name)
|
|
|
|
{
|
|
|
|
case 'bopeebo' | 'fresh' | 'dadbattle':
|
|
|
|
weekNum = 1;
|
|
|
|
case 'spookeez' | 'south' | 'monster':
|
|
|
|
weekNum = 2;
|
|
|
|
case 'pico' | 'philly-nice' | 'blammed':
|
|
|
|
weekNum = 3;
|
|
|
|
case "satin-panties" | 'high' | 'milf':
|
|
|
|
weekNum = 4;
|
|
|
|
case "cocoa" | 'eggnog' | 'winter-horrorland':
|
|
|
|
weekNum = 5;
|
|
|
|
case 'senpai' | 'roses' | 'thorns':
|
|
|
|
weekNum = 6;
|
|
|
|
case 'ugh' | 'guns' | 'stress':
|
|
|
|
weekNum = 7;
|
|
|
|
case 'darnell' | 'lit-up' | '2hot' | 'blazin':
|
|
|
|
weekNum = -1;
|
|
|
|
default:
|
|
|
|
weekNum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
weekNumbers[0].digit = Std.int(Math.abs(weekNum));
|
|
|
|
|
|
|
|
if (weekNum == 0)
|
|
|
|
{
|
|
|
|
weekType.visible = false;
|
|
|
|
weekNumbers[0].visible = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weekType.visible = true;
|
|
|
|
weekNumbers[0].visible = true;
|
|
|
|
}
|
|
|
|
if (weekNum > 0)
|
|
|
|
{
|
|
|
|
weekType.animation.play('WEEK', true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weekType.animation.play('WEEKEND', true);
|
|
|
|
weekNumbers[0].offset.x -= 35;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 255, 27 normal
|
|
|
|
// 220, 27 favourited
|
|
|
|
public function checkClip():Void
|
|
|
|
{
|
|
|
|
var clipSize:Int = 290;
|
|
|
|
var clipType:Int = 0;
|
|
|
|
|
|
|
|
if (ranking.visible == true) clipType += 1;
|
2024-06-02 06:53:07 +00:00
|
|
|
if (favIcon.visible == true) clipType = 2;
|
2024-05-30 03:34:00 +00:00
|
|
|
switch (clipType)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
clipSize = 220;
|
|
|
|
case 1:
|
|
|
|
clipSize = 255;
|
|
|
|
}
|
|
|
|
songText.clipWidth = clipSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateBPM(newBPM:Int):Void
|
|
|
|
{
|
|
|
|
var shiftX:Float = 191;
|
|
|
|
var tempShift:Float = 0;
|
|
|
|
|
|
|
|
if (Math.floor(newBPM / 100) == 1)
|
|
|
|
{
|
|
|
|
shiftX = 186;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i in 0...smallNumbers.length)
|
|
|
|
{
|
|
|
|
smallNumbers[i].x = this.x + (shiftX + (i * 11));
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (newBPM < 100)
|
|
|
|
{
|
|
|
|
smallNumbers[i].digit = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
smallNumbers[i].digit = Math.floor(newBPM / 100) % 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (newBPM < 10)
|
|
|
|
{
|
|
|
|
smallNumbers[i].digit = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
smallNumbers[i].digit = Math.floor(newBPM / 10) % 10;
|
|
|
|
|
|
|
|
if (Math.floor(newBPM / 10) % 10 == 1) tempShift = -4;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
smallNumbers[i].digit = newBPM % 10;
|
|
|
|
default:
|
|
|
|
trace('why the fuck is this being called');
|
|
|
|
}
|
|
|
|
smallNumbers[i].x += tempShift;
|
|
|
|
}
|
|
|
|
// diffRatingSprite.loadGraphic(Paths.image('freeplay/diffRatings/diff${ratingPadded}'));
|
|
|
|
// diffRatingSprite.visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var evilTrail:FlxTrail;
|
|
|
|
|
2024-06-04 20:47:58 +00:00
|
|
|
public function fadeAnim():Void
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
|
|
|
impactThing = new FunkinSprite(0, 0);
|
|
|
|
impactThing.frames = capsule.frames;
|
|
|
|
impactThing.frame = capsule.frame;
|
|
|
|
impactThing.updateHitbox();
|
|
|
|
// impactThing.x = capsule.x;
|
|
|
|
// impactThing.y = capsule.y;
|
|
|
|
// picoFade.stamp(this, 0, 0);
|
|
|
|
impactThing.alpha = 0;
|
|
|
|
impactThing.zIndex = capsule.zIndex - 3;
|
|
|
|
add(impactThing);
|
|
|
|
FlxTween.tween(impactThing.scale, {x: 2.5, y: 2.5}, 0.5);
|
|
|
|
// FlxTween.tween(impactThing, {alpha: 0}, 0.5);
|
|
|
|
|
|
|
|
evilTrail = new FlxTrail(impactThing, null, 15, 2, 0.01, 0.069);
|
|
|
|
evilTrail.blend = BlendMode.ADD;
|
|
|
|
evilTrail.zIndex = capsule.zIndex - 5;
|
|
|
|
FlxTween.tween(evilTrail, {alpha: 0}, 0.6,
|
|
|
|
{
|
|
|
|
ease: FlxEase.quadOut,
|
|
|
|
onComplete: function(_) {
|
|
|
|
remove(evilTrail);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
add(evilTrail);
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
switch (ranking.rank)
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
2024-05-30 09:25:51 +00:00
|
|
|
case SHIT:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFF6044FF;
|
2024-05-30 09:25:51 +00:00
|
|
|
case GOOD:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFFEF8764;
|
2024-05-30 09:25:51 +00:00
|
|
|
case GREAT:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFFEAF6FF;
|
2024-05-30 09:25:51 +00:00
|
|
|
case EXCELLENT:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFFFDCB42;
|
2024-05-30 09:25:51 +00:00
|
|
|
case PERFECT:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFFFF58B4;
|
2024-05-30 09:25:51 +00:00
|
|
|
case PERFECT_GOLD:
|
2024-05-30 03:34:00 +00:00
|
|
|
evilTrail.color = 0xFFFFB619;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTrailColor():FlxColor
|
|
|
|
{
|
|
|
|
return evilTrail.color;
|
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
function updateDifficultyRating(newRating:Int):Void
|
2024-01-11 05:30:00 +00:00
|
|
|
{
|
|
|
|
var ratingPadded:String = newRating < 10 ? '0$newRating' : '$newRating';
|
2024-05-30 03:34:00 +00:00
|
|
|
|
|
|
|
for (i in 0...bigNumbers.length)
|
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
2024-05-31 09:39:53 +00:00
|
|
|
if (newRating < 10)
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
|
|
|
bigNumbers[i].digit = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bigNumbers[i].digit = Math.floor(newRating / 10);
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
bigNumbers[i].digit = newRating % 10;
|
|
|
|
default:
|
|
|
|
trace('why the fuck is this being called');
|
|
|
|
}
|
|
|
|
}
|
2024-04-16 22:43:11 +00:00
|
|
|
// diffRatingSprite.loadGraphic(Paths.image('freeplay/diffRatings/diff${ratingPadded}'));
|
|
|
|
// diffRatingSprite.visible = false;
|
2024-01-11 05:30:00 +00:00
|
|
|
}
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
function updateScoringRank(newRank:Null<ScoringRank>):Void
|
|
|
|
{
|
|
|
|
this.ranking.rank = newRank;
|
|
|
|
this.blurredRanking.rank = newRank;
|
|
|
|
}
|
|
|
|
|
2023-08-28 18:52:03 +00:00
|
|
|
function set_hsvShader(value:HSVShader):HSVShader
|
|
|
|
{
|
|
|
|
this.hsvShader = value;
|
|
|
|
capsule.shader = hsvShader;
|
|
|
|
songText.shader = hsvShader;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
function textAppear():Void
|
2023-08-12 04:42:17 +00:00
|
|
|
{
|
|
|
|
songText.scale.x = 1.7;
|
|
|
|
songText.scale.y = 0.2;
|
|
|
|
|
|
|
|
new FlxTimer().start(1 / 24, function(_) {
|
|
|
|
songText.scale.x = 0.4;
|
|
|
|
songText.scale.y = 1.4;
|
|
|
|
});
|
|
|
|
|
|
|
|
new FlxTimer().start(2 / 24, function(_) {
|
|
|
|
songText.scale.x = songText.scale.y = 1;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
function setVisibleGrp(value:Bool):Void
|
2023-08-12 04:31:43 +00:00
|
|
|
{
|
|
|
|
for (spr in grpHide.members)
|
|
|
|
{
|
|
|
|
spr.visible = value;
|
|
|
|
}
|
2023-08-12 04:42:17 +00:00
|
|
|
|
|
|
|
if (value) textAppear();
|
2023-09-19 23:10:30 +00:00
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
updateSelected();
|
2023-08-12 04:31:43 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
public function init(?x:Float, ?y:Float, songData:Null<FreeplaySongData>):Void
|
2023-08-09 06:47:22 +00:00
|
|
|
{
|
2024-01-11 05:30:00 +00:00
|
|
|
if (x != null) this.x = x;
|
|
|
|
if (y != null) this.y = y;
|
2023-10-17 00:12:40 +00:00
|
|
|
this.songData = songData;
|
|
|
|
|
|
|
|
// Update capsule text.
|
|
|
|
songText.text = songData?.songName ?? 'Random';
|
|
|
|
// Update capsule character.
|
|
|
|
if (songData?.songCharacter != null) setCharacter(songData.songCharacter);
|
2024-05-30 03:34:00 +00:00
|
|
|
updateBPM(Std.int(songData?.songStartingBpm) ?? 0);
|
2024-05-11 05:05:51 +00:00
|
|
|
updateDifficultyRating(songData?.difficultyRating ?? 0);
|
2024-05-30 09:25:51 +00:00
|
|
|
updateScoringRank(songData?.scoringRank);
|
2023-10-17 00:12:40 +00:00
|
|
|
// Update opacity, offsets, etc.
|
|
|
|
updateSelected();
|
2024-05-30 03:34:00 +00:00
|
|
|
|
|
|
|
checkWeek(songData?.songId);
|
2023-08-09 06:47:22 +00:00
|
|
|
}
|
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
/**
|
2023-10-10 00:04:21 +00:00
|
|
|
* Set the character displayed next to this song in the freeplay menu.
|
|
|
|
* @param char The character ID used by this song.
|
|
|
|
* If the character has no freeplay icon, a warning will be thrown and nothing will display.
|
2023-08-08 18:35:07 +00:00
|
|
|
*/
|
2024-03-20 18:37:24 +00:00
|
|
|
public function setCharacter(char:String):Void
|
2023-08-08 18:35:07 +00:00
|
|
|
{
|
|
|
|
var charPath:String = "freeplay/icons/";
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
// TODO: Put this in the character metadata where it belongs.
|
2023-12-11 05:19:33 +00:00
|
|
|
// TODO: Also, can use CharacterDataParser.getCharPixelIconAsset()
|
2023-08-08 18:35:07 +00:00
|
|
|
switch (char)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
case 'monster-christmas':
|
|
|
|
charPath += 'monsterpixel';
|
|
|
|
case 'mom-car':
|
|
|
|
charPath += 'mommypixel';
|
|
|
|
case 'dad':
|
|
|
|
charPath += 'daddypixel';
|
|
|
|
case 'darnell-blazin':
|
|
|
|
charPath += 'darnellpixel';
|
|
|
|
case 'senpai-angry':
|
|
|
|
charPath += 'senpaipixel';
|
2023-08-08 18:35:07 +00:00
|
|
|
default:
|
2024-03-20 18:37:24 +00:00
|
|
|
charPath += '${char}pixel';
|
2023-08-08 18:35:07 +00:00
|
|
|
}
|
|
|
|
|
2023-10-10 00:04:21 +00:00
|
|
|
if (!openfl.utils.Assets.exists(Paths.image(charPath)))
|
|
|
|
{
|
|
|
|
trace('[WARN] Character ${char} has no freeplay icon.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
pixelIcon.loadGraphic(Paths.image(charPath));
|
2023-09-19 05:31:54 +00:00
|
|
|
pixelIcon.scale.x = pixelIcon.scale.y = 2;
|
2024-01-11 05:52:42 +00:00
|
|
|
|
|
|
|
switch (char)
|
|
|
|
{
|
2024-03-20 18:37:24 +00:00
|
|
|
case 'parents-christmas':
|
2024-01-11 05:52:42 +00:00
|
|
|
pixelIcon.origin.x = 140;
|
|
|
|
default:
|
|
|
|
pixelIcon.origin.x = 100;
|
|
|
|
}
|
2023-08-14 03:22:24 +00:00
|
|
|
// pixelIcon.origin.x = capsule.origin.x;
|
|
|
|
// pixelIcon.offset.x -= pixelIcon.origin.x;
|
2023-08-08 18:35:07 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
var frameInTicker:Float = 0;
|
|
|
|
var frameInTypeBeat:Int = 0;
|
|
|
|
|
|
|
|
var frameOutTicker:Float = 0;
|
|
|
|
var frameOutTypeBeat:Int = 0;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
var xFrames:Array<Float> = [1.7, 1.8, 0.85, 0.85, 0.97, 0.97, 1];
|
|
|
|
var xPosLerpLol:Array<Float> = [0.9, 0.4, 0.16, 0.16, 0.22, 0.22, 0.245]; // NUMBERS ARE JANK CUZ THE SCALING OR WHATEVER
|
2023-03-16 01:05:15 +00:00
|
|
|
var xPosOutLerpLol:Array<Float> = [0.245, 0.75, 0.98, 0.98, 1.2]; // NUMBERS ARE JANK CUZ THE SCALING OR WHATEVER
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-08-14 02:12:08 +00:00
|
|
|
public var realScaled:Float = 0.8;
|
2023-08-04 20:19:48 +00:00
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
public function initJumpIn(maxTimer:Float, ?force:Bool):Void
|
|
|
|
{
|
2023-08-09 06:47:22 +00:00
|
|
|
frameInTypeBeat = 0;
|
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
new FlxTimer().start((1 / 24) * maxTimer, function(doShit) {
|
|
|
|
doJumpIn = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
new FlxTimer().start((0.09 * maxTimer) + 0.85, function(lerpTmr) {
|
|
|
|
doLerp = true;
|
|
|
|
});
|
|
|
|
|
2023-08-09 06:47:22 +00:00
|
|
|
if (force)
|
2023-08-06 20:24:34 +00:00
|
|
|
{
|
2023-09-19 23:10:30 +00:00
|
|
|
visible = true;
|
|
|
|
capsule.alpha = 1;
|
2023-08-12 04:31:43 +00:00
|
|
|
setVisibleGrp(true);
|
2023-08-06 20:24:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-09 06:47:22 +00:00
|
|
|
new FlxTimer().start((xFrames.length / 24) * 2.5, function(_) {
|
2023-09-19 23:10:30 +00:00
|
|
|
visible = true;
|
|
|
|
capsule.alpha = 1;
|
2023-08-12 04:31:43 +00:00
|
|
|
setVisibleGrp(true);
|
2023-08-09 06:47:22 +00:00
|
|
|
});
|
2023-08-06 20:24:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-12 04:31:43 +00:00
|
|
|
var grpHide:FlxGroup;
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
public function forcePosition():Void
|
2023-08-09 06:47:22 +00:00
|
|
|
{
|
2023-09-19 23:10:30 +00:00
|
|
|
visible = true;
|
|
|
|
capsule.alpha = 1;
|
2023-10-17 00:12:40 +00:00
|
|
|
updateSelected();
|
2023-08-09 06:47:22 +00:00
|
|
|
doLerp = true;
|
|
|
|
doJumpIn = false;
|
|
|
|
doJumpOut = false;
|
|
|
|
|
|
|
|
frameInTypeBeat = xFrames.length;
|
|
|
|
frameOutTypeBeat = 0;
|
|
|
|
|
|
|
|
capsule.scale.x = xFrames[frameInTypeBeat - 1];
|
|
|
|
capsule.scale.y = 1 / xFrames[frameInTypeBeat - 1];
|
|
|
|
// x = FlxG.width * xPosLerpLol[Std.int(Math.min(frameInTypeBeat - 1, xPosLerpLol.length - 1))];
|
|
|
|
|
|
|
|
x = targetPos.x;
|
|
|
|
y = targetPos.y;
|
|
|
|
|
|
|
|
capsule.scale.x *= realScaled;
|
|
|
|
capsule.scale.y *= realScaled;
|
|
|
|
|
2023-08-12 04:31:43 +00:00
|
|
|
setVisibleGrp(true);
|
2023-08-09 06:47:22 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 18:37:24 +00:00
|
|
|
override function update(elapsed:Float):Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2024-05-30 03:34:00 +00:00
|
|
|
if (impactThing != null) impactThing.angle = capsule.angle;
|
|
|
|
|
|
|
|
// if (FlxG.keys.justPressed.I)
|
|
|
|
// {
|
|
|
|
// newText.y -= 1;
|
|
|
|
// trace(this.x - newText.x, this.y - newText.y);
|
|
|
|
// }
|
|
|
|
// if (FlxG.keys.justPressed.J)
|
|
|
|
// {
|
|
|
|
// newText.x -= 1;
|
|
|
|
// trace(this.x - newText.x, this.y - newText.y);
|
|
|
|
// }
|
|
|
|
// if (FlxG.keys.justPressed.L)
|
|
|
|
// {
|
|
|
|
// newText.x += 1;
|
|
|
|
// trace(this.x - newText.x, this.y - newText.y);
|
|
|
|
// }
|
|
|
|
// if (FlxG.keys.justPressed.K)
|
|
|
|
// {
|
|
|
|
// newText.y += 1;
|
|
|
|
// trace(this.x - newText.x, this.y - newText.y);
|
|
|
|
// }
|
2023-01-23 03:25:45 +00:00
|
|
|
if (doJumpIn)
|
|
|
|
{
|
2023-03-16 01:05:15 +00:00
|
|
|
frameInTicker += elapsed;
|
|
|
|
|
|
|
|
if (frameInTicker >= 1 / 24 && frameInTypeBeat < xFrames.length)
|
|
|
|
{
|
|
|
|
frameInTicker = 0;
|
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
capsule.scale.x = xFrames[frameInTypeBeat];
|
|
|
|
capsule.scale.y = 1 / xFrames[frameInTypeBeat];
|
2023-03-16 01:05:15 +00:00
|
|
|
x = FlxG.width * xPosLerpLol[Std.int(Math.min(frameInTypeBeat, xPosLerpLol.length - 1))];
|
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
capsule.scale.x *= realScaled;
|
|
|
|
capsule.scale.y *= realScaled;
|
2023-08-04 20:19:48 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
frameInTypeBeat += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doJumpOut)
|
|
|
|
{
|
|
|
|
frameOutTicker += elapsed;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
if (frameOutTicker >= 1 / 24 && frameOutTypeBeat < xFrames.length)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-03-16 01:05:15 +00:00
|
|
|
frameOutTicker = 0;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
capsule.scale.x = xFrames[frameOutTypeBeat];
|
|
|
|
capsule.scale.y = 1 / xFrames[frameOutTypeBeat];
|
2023-03-16 01:05:15 +00:00
|
|
|
x = FlxG.width * xPosOutLerpLol[Std.int(Math.min(frameOutTypeBeat, xPosOutLerpLol.length - 1))];
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-08-08 18:35:07 +00:00
|
|
|
capsule.scale.x *= realScaled;
|
|
|
|
capsule.scale.y *= realScaled;
|
2023-08-04 20:19:48 +00:00
|
|
|
|
2023-03-16 01:05:15 +00:00
|
|
|
frameOutTypeBeat += 1;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doLerp)
|
|
|
|
{
|
2023-11-07 09:04:22 +00:00
|
|
|
x = MathUtil.coolLerp(x, targetPos.x, 0.3);
|
|
|
|
y = MathUtil.coolLerp(y, targetPos.y, 0.4);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
2023-08-04 21:10:27 +00:00
|
|
|
public function intendedY(index:Int):Float
|
|
|
|
{
|
2023-08-04 22:09:40 +00:00
|
|
|
return (index * ((height * realScaled) + 10)) + 120;
|
2023-08-04 21:10:27 +00:00
|
|
|
}
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
function set_selected(value:Bool):Bool
|
2023-10-10 00:04:21 +00:00
|
|
|
{
|
2023-10-17 00:12:40 +00:00
|
|
|
// cute one liners, lol!
|
|
|
|
selected = value;
|
|
|
|
updateSelected();
|
|
|
|
return selected;
|
2023-10-10 00:04:21 +00:00
|
|
|
}
|
|
|
|
|
2023-10-17 00:12:40 +00:00
|
|
|
function updateSelected():Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2024-01-11 05:30:00 +00:00
|
|
|
grayscaleShader.setAmount(this.selected ? 0 : 0.8);
|
2023-10-17 00:12:40 +00:00
|
|
|
songText.alpha = this.selected ? 1 : 0.6;
|
|
|
|
songText.blurredText.visible = this.selected ? true : false;
|
|
|
|
capsule.offset.x = this.selected ? 0 : -5;
|
|
|
|
capsule.animation.play(this.selected ? "selected" : "unselected");
|
|
|
|
ranking.alpha = this.selected ? 1 : 0.7;
|
2024-06-05 03:36:32 +00:00
|
|
|
favIcon.alpha = this.selected ? 1 : 0.6;
|
|
|
|
favIconBlurred.alpha = this.selected ? 1 : 0;
|
2023-10-17 00:12:40 +00:00
|
|
|
ranking.color = this.selected ? 0xFFFFFFFF : 0xFFAAAAAA;
|
2024-05-30 03:34:00 +00:00
|
|
|
|
2024-06-04 20:51:27 +00:00
|
|
|
if (songText.tooLong) songText.resetText();
|
|
|
|
|
|
|
|
if (selected && songText.tooLong) songText.initMove();
|
2024-05-30 03:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FreeplayRank extends FlxSprite
|
|
|
|
{
|
2024-05-30 09:25:51 +00:00
|
|
|
public var rank(default, set):Null<ScoringRank> = null;
|
2024-05-30 03:34:00 +00:00
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
function set_rank(val:Null<ScoringRank>):Null<ScoringRank>
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
2024-05-30 09:25:51 +00:00
|
|
|
rank = val;
|
2024-05-30 03:34:00 +00:00
|
|
|
|
2024-05-31 09:39:53 +00:00
|
|
|
if (rank == null || val == null)
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
2024-05-30 09:25:51 +00:00
|
|
|
this.visible = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.visible = true;
|
|
|
|
|
|
|
|
animation.play(val.getFreeplayRankIconAsset(), true, false);
|
|
|
|
|
|
|
|
centerOffsets(false);
|
|
|
|
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case SHIT:
|
2024-05-30 03:34:00 +00:00
|
|
|
// offset.x -= 1;
|
2024-05-30 09:25:51 +00:00
|
|
|
case GOOD:
|
|
|
|
// offset.x -= 1;
|
|
|
|
offset.y -= 8;
|
|
|
|
case GREAT:
|
|
|
|
// offset.x -= 1;
|
|
|
|
offset.y -= 8;
|
|
|
|
case EXCELLENT:
|
|
|
|
// offset.y += 5;
|
|
|
|
case PERFECT:
|
|
|
|
// offset.y += 5;
|
|
|
|
case PERFECT_GOLD:
|
|
|
|
// offset.y += 5;
|
|
|
|
default:
|
|
|
|
centerOffsets(false);
|
2024-05-31 09:39:53 +00:00
|
|
|
this.visible = false;
|
2024-05-30 09:25:51 +00:00
|
|
|
}
|
|
|
|
updateHitbox();
|
2024-05-30 03:34:00 +00:00
|
|
|
}
|
2024-05-30 09:25:51 +00:00
|
|
|
|
|
|
|
return rank = val;
|
2024-05-30 03:34:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public var baseX:Float = 0;
|
2024-05-30 09:25:51 +00:00
|
|
|
public var baseY:Float = 0;
|
2024-05-30 03:34:00 +00:00
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
public function new(x:Float, y:Float)
|
2024-05-30 03:34:00 +00:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
frames = Paths.getSparrowAtlas('freeplay/rankbadges');
|
|
|
|
|
|
|
|
animation.addByPrefix('PERFECT', 'PERFECT rank0', 24, false);
|
|
|
|
animation.addByPrefix('EXCELLENT', 'EXCELLENT rank0', 24, false);
|
|
|
|
animation.addByPrefix('GOOD', 'GOOD rank0', 24, false);
|
|
|
|
animation.addByPrefix('PERFECTSICK', 'PERFECT rank GOLD', 24, false);
|
|
|
|
animation.addByPrefix('GREAT', 'GREAT rank0', 24, false);
|
|
|
|
animation.addByPrefix('LOSS', 'LOSS rank0', 24, false);
|
|
|
|
|
|
|
|
blend = BlendMode.ADD;
|
|
|
|
|
2024-05-30 09:25:51 +00:00
|
|
|
this.rank = null;
|
2024-05-30 03:34:00 +00:00
|
|
|
|
|
|
|
// setGraphicSize(Std.int(width * 0.9));
|
|
|
|
scale.set(0.9, 0.9);
|
|
|
|
updateHitbox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CapsuleNumber extends FlxSprite
|
|
|
|
{
|
|
|
|
public var digit(default, set):Int = 0;
|
|
|
|
|
|
|
|
function set_digit(val):Int
|
|
|
|
{
|
|
|
|
animation.play(numToString[val], true, false, 0);
|
|
|
|
|
|
|
|
centerOffsets(false);
|
|
|
|
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
offset.x -= 4;
|
|
|
|
case 3:
|
|
|
|
offset.x -= 1;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
// offset.y += 5;
|
|
|
|
case 9:
|
|
|
|
// offset.y += 5;
|
|
|
|
default:
|
|
|
|
centerOffsets(false);
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
public var baseY:Float = 0;
|
|
|
|
public var baseX:Float = 0;
|
|
|
|
|
|
|
|
var numToString:Array<String> = ["ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"];
|
|
|
|
|
|
|
|
public function new(x:Float, y:Float, big:Bool = false, ?initDigit:Int = 0)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
if (big)
|
|
|
|
{
|
|
|
|
frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/bignumbers');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/smallnumbers');
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i in 0...10)
|
|
|
|
{
|
|
|
|
var stringNum:String = numToString[i];
|
|
|
|
animation.addByPrefix(stringNum, '$stringNum', 24, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.digit = initDigit;
|
|
|
|
|
|
|
|
animation.play(numToString[initDigit], true);
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * 0.9));
|
|
|
|
updateHitbox();
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2021-10-21 21:40:53 +00:00
|
|
|
}
|