rank tweaks, favourite changes + rank anim fixes

This commit is contained in:
FabsTheFabs 2024-05-31 10:39:53 +01:00
parent 1e65cacb0e
commit 28444fd478
7 changed files with 220 additions and 36 deletions

View file

@ -59,6 +59,8 @@ class ResultState extends MusicBeatSubState
var gfGood:Null<FlxSprite> = null; var gfGood:Null<FlxSprite> = null;
var bfShit:Null<FlxAtlasSprite> = null; var bfShit:Null<FlxAtlasSprite> = null;
var rankBg:FunkinSprite;
public function new(params:ResultsStateParams) public function new(params:ResultsStateParams)
{ {
super(); super();
@ -95,6 +97,8 @@ class ResultState extends MusicBeatSubState
highscoreNew = new FlxSprite(310, 570); highscoreNew = new FlxSprite(310, 570);
score = new ResultScore(35, 305, 10, params.scoreData.score); score = new ResultScore(35, 305, 10, params.scoreData.score);
rankBg = new FunkinSprite(0, 0);
} }
override function create():Void override function create():Void
@ -356,6 +360,12 @@ class ResultState extends MusicBeatSubState
} }
}); });
rankBg.makeSolidColor(FlxG.width, FlxG.height, 0xFF000000);
rankBg.zIndex = 99999;
add(rankBg);
rankBg.alpha = 0;
refresh(); refresh();
super.create(); super.create();
@ -654,7 +664,17 @@ class ResultState extends MusicBeatSubState
} }
else else
{ {
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> FreeplayState.build( var rigged:Bool = true;
if (rank > Scoring.calculateRank(params?.prevScoreData))
//if (rigged)
{
trace('THE RANK IS Higher.....');
FlxTween.tween(rankBg, {alpha: 1}, 0.5,
{
ease: FlxEase.expoOut,
onComplete: function(_) {
FlxG.switchState(FreeplayState.build(
{ {
{ {
fromResults: fromResults:
@ -665,9 +685,28 @@ class ResultState extends MusicBeatSubState
difficultyId: params.difficultyId difficultyId: params.difficultyId
} }
} }
}));
}
});
}
else
{
trace('rank is lower...... and/or equal');
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> FreeplayState.build(
{
{
fromResults:
{
oldRank: null,
newRank: rank,
songId: params.songId,
difficultyId: params.difficultyId
}
}
}, sticker))); }, sticker)));
} }
} }
}
super.update(elapsed); super.update(elapsed);
} }

View file

@ -349,7 +349,7 @@ class Scoring
public static function calculateRank(scoreData:Null<SaveScoreData>):Null<ScoringRank> public static function calculateRank(scoreData:Null<SaveScoreData>):Null<ScoringRank>
{ {
if (scoreData == null) return null; if (scoreData?.tallies.totalNotes == 0 || scoreData == null) return null;
// Perfect (Platinum) is a Sick Full Clear // Perfect (Platinum) is a Sick Full Clear
var isPerfectGold = scoreData.tallies.sick == scoreData.tallies.totalNotes; var isPerfectGold = scoreData.tallies.sick == scoreData.tallies.totalNotes;
@ -394,6 +394,62 @@ enum abstract ScoringRank(String)
var GOOD; var GOOD;
var SHIT; var SHIT;
@:op(A > B) static function compare(a:Null<ScoringRank>, b:Null<ScoringRank>):Bool
{
if (a != null && b == null) return true;
if (a == null || b == null) return false;
var temp1:Int = 0;
var temp2:Int = 0;
// temp 1
switch (a)
{
case PERFECT_GOLD:
temp1 = 5;
case PERFECT:
temp1 = 4;
case EXCELLENT:
temp1 = 3;
case GREAT:
temp1 = 2;
case GOOD:
temp1 = 1;
case SHIT:
temp1 = 0;
default:
temp1 = -1;
}
// temp 2
switch (b)
{
case PERFECT_GOLD:
temp2 = 5;
case PERFECT:
temp2 = 4;
case EXCELLENT:
temp2 = 3;
case GREAT:
temp2 = 2;
case GOOD:
temp2 = 1;
case SHIT:
temp2 = 0;
default:
temp2 = -1;
}
if (temp1 > temp2)
{
return true;
}
else
{
return false;
}
}
/** /**
* Delay in seconds * Delay in seconds
*/ */

View file

@ -4,6 +4,7 @@ import flixel.text.FlxText;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import funkin.audio.FunkinSound; import funkin.audio.FunkinSound;
import flixel.FlxSprite; import flixel.FlxSprite;
import funkin.ui.mainmenu.MainMenuState;
import flixel.group.FlxSpriteGroup; import flixel.group.FlxSpriteGroup;
/** /**
@ -199,7 +200,7 @@ class CreditsState extends MusicBeatState
function exit():Void function exit():Void
{ {
FlxG.switchState(funkin.ui.mainmenu.MainMenuState.new); FlxG.switchState(() -> new MainMenuState());
} }
public override function destroy():Void public override function destroy():Void

View file

@ -131,7 +131,7 @@ class AlbumRoll extends FlxSpriteGroup
if (exitMovers == null) return; if (exitMovers == null) return;
exitMovers.set([newAlbumArt], exitMovers.set([newAlbumArt, difficultyStars],
{ {
x: FlxG.width, x: FlxG.width,
speed: 0.4, speed: 0.4,

View file

@ -193,12 +193,18 @@ class FreeplayState extends MusicBeatSubState
var fromResultsParams:Null<FromResultsParams> = null; var fromResultsParams:Null<FromResultsParams> = null;
var prepForNewRank:Bool = false;
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState) public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
{ {
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER; currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
fromResultsParams = params?.fromResults; fromResultsParams = params?.fromResults;
if(fromResultsParams?.oldRank != null){
prepForNewRank = true;
}
if (stickers != null) if (stickers != null)
{ {
stickerSubState = stickers; stickerSubState = stickers;
@ -235,11 +241,14 @@ class FreeplayState extends MusicBeatSubState
isDebug = true; isDebug = true;
#end #end
if (prepForNewRank == false)
{
FunkinSound.playMusic('freakyMenu', FunkinSound.playMusic('freakyMenu',
{ {
overrideExisting: true, overrideExisting: true,
restartTrack: false restartTrack: false
}); });
}
// Add a null entry that represents the RANDOM option // Add a null entry that represents the RANDOM option
songs.push(null); songs.push(null);
@ -637,7 +646,7 @@ class FreeplayState extends MusicBeatSubState
cardGlow.visible = true; cardGlow.visible = true;
FlxTween.tween(cardGlow, {alpha: 0, "scale.x": 1.2, "scale.y": 1.2}, 0.45, {ease: FlxEase.sineOut}); FlxTween.tween(cardGlow, {alpha: 0, "scale.x": 1.2, "scale.y": 1.2}, 0.45, {ease: FlxEase.sineOut});
if (fromResultsParams != null) if (prepForNewRank == true)
{ {
rankAnimStart(fromResultsParams); rankAnimStart(fromResultsParams);
} }
@ -667,6 +676,11 @@ class FreeplayState extends MusicBeatSubState
FlxG.cameras.add(rankCamera, false); FlxG.cameras.add(rankCamera, false);
rankBg.cameras = [rankCamera]; rankBg.cameras = [rankCamera];
rankBg.alpha = 0; rankBg.alpha = 0;
if (prepForNewRank == true)
{
rankCamera.fade(0xFF000000, 0, false, null, true);
}
} }
var currentFilter:SongFilter = null; var currentFilter:SongFilter = null;
@ -826,6 +840,7 @@ class FreeplayState extends MusicBeatSubState
function rankAnimStart(fromResults:Null<FromResultsParams>):Void function rankAnimStart(fromResults:Null<FromResultsParams>):Void
{ {
busy = true; busy = true;
// grpCapsules.members[curSelected].forcePosition();
dj.fistPump(); dj.fistPump();
// rankCamera.fade(FlxColor.BLACK, 0.5, true); // rankCamera.fade(FlxColor.BLACK, 0.5, true);
@ -833,8 +848,14 @@ class FreeplayState extends MusicBeatSubState
FlxG.sound.music.volume = 0; FlxG.sound.music.volume = 0;
rankBg.alpha = 1; rankBg.alpha = 1;
originalPos.x = grpCapsules.members[curSelected].x; grpCapsules.members[curSelected].doLerp = false;
originalPos.y = grpCapsules.members[curSelected].y;
// originalPos.x = grpCapsules.members[curSelected].x;
// originalPos.y = grpCapsules.members[curSelected].y;
originalPos.x = 320.488;
originalPos.y = 235.6;
trace(originalPos);
grpCapsules.members[curSelected].ranking.alpha = 0; grpCapsules.members[curSelected].ranking.alpha = 0;
grpCapsules.members[curSelected].blurredRanking.alpha = 0; grpCapsules.members[curSelected].blurredRanking.alpha = 0;
@ -846,11 +867,13 @@ class FreeplayState extends MusicBeatSubState
FlxTween.tween(funnyCam, {"zoom": 1.1}, 0.6, {ease: FlxEase.sineIn}); FlxTween.tween(funnyCam, {"zoom": 1.1}, 0.6, {ease: FlxEase.sineIn});
grpCapsules.members[curSelected].cameras = [rankCamera]; grpCapsules.members[curSelected].cameras = [rankCamera];
grpCapsules.members[curSelected].targetPos.set((FlxG.width / 2) - (grpCapsules.members[curSelected].width / 2), // grpCapsules.members[curSelected].targetPos.set((FlxG.width / 2) - (grpCapsules.members[curSelected].width / 2),
// (FlxG.height / 2) - (grpCapsules.members[curSelected].height / 2));
grpCapsules.members[curSelected].setPosition((FlxG.width / 2) - (grpCapsules.members[curSelected].width / 2),
(FlxG.height / 2) - (grpCapsules.members[curSelected].height / 2)); (FlxG.height / 2) - (grpCapsules.members[curSelected].height / 2));
new FlxTimer().start(0.5, _ -> { new FlxTimer().start(0.5, _ -> {
grpCapsules.members[curSelected].doLerp = false;
rankDisplayNew(fromResults); rankDisplayNew(fromResults);
}); });
} }
@ -1028,6 +1051,12 @@ class FreeplayState extends MusicBeatSubState
new FlxTimer().start(2, _ -> { new FlxTimer().start(2, _ -> {
// dj.fistPump(); // dj.fistPump();
prepForNewRank = false;
FunkinSound.playMusic('freakyMenu',
{
overrideExisting: true,
restartTrack: false
});
FlxG.sound.music.fadeIn(4.0, 0.0, 1.0); FlxG.sound.music.fadeIn(4.0, 0.0, 1.0);
}); });
} }
@ -1095,7 +1124,7 @@ class FreeplayState extends MusicBeatSubState
} }
#end #end
if (FlxG.keys.justPressed.F) if (FlxG.keys.justPressed.F && !busy)
{ {
var targetSong = grpCapsules.members[curSelected]?.songData; var targetSong = grpCapsules.members[curSelected]?.songData;
if (targetSong != null) if (targetSong != null)
@ -1104,23 +1133,44 @@ class FreeplayState extends MusicBeatSubState
var isFav = targetSong.toggleFavorite(); var isFav = targetSong.toggleFavorite();
if (isFav) if (isFav)
{ {
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4,
{
ease: FlxEase.elasticOut,
onComplete: _ -> {
grpCapsules.members[realShit].favIcon.visible = true; grpCapsules.members[realShit].favIcon.visible = true;
grpCapsules.members[realShit].favIcon.animation.play('fav'); grpCapsules.members[realShit].favIcon.animation.play('fav');
FunkinSound.playOnce(Paths.sound('fav'), 1);
busy = true;
grpCapsules.members[realShit].doLerp = false;
FlxTween.tween(grpCapsules.members[realShit], {y: grpCapsules.members[realShit].y - 5}, 0.1, {ease: FlxEase.expoOut});
FlxTween.tween(grpCapsules.members[realShit], {y: grpCapsules.members[realShit].y + 5}, 0.1,
{
ease: FlxEase.expoIn,
startDelay: 0.1,
onComplete: function(_) {
grpCapsules.members[realShit].doLerp = true;
busy = false;
} }
}); });
} }
else else
{ {
grpCapsules.members[realShit].favIcon.animation.play('fav', false, true); grpCapsules.members[realShit].favIcon.animation.play('fav', true, true, 9);
new FlxTimer().start((1 / 24) * 14, _ -> { FunkinSound.playOnce(Paths.sound('unfav'), 1);
new FlxTimer().start(0.2, _ -> {
grpCapsules.members[realShit].favIcon.visible = false; grpCapsules.members[realShit].favIcon.visible = false;
}); });
new FlxTimer().start((1 / 24) * 24, _ -> {
FlxTween.tween(grpCapsules.members[realShit], {angle: 0}, 0.4, {ease: FlxEase.elasticOut}); busy = true;
grpCapsules.members[realShit].doLerp = false;
FlxTween.tween(grpCapsules.members[realShit], {y: grpCapsules.members[realShit].y + 5}, 0.1, {ease: FlxEase.expoOut});
FlxTween.tween(grpCapsules.members[realShit], {y: grpCapsules.members[realShit].y - 5}, 0.1,
{
ease: FlxEase.expoIn,
startDelay: 0.1,
onComplete: function(_) {
grpCapsules.members[realShit].doLerp = true;
busy = false;
}
}); });
} }
} }
@ -1325,6 +1375,24 @@ class FreeplayState extends MusicBeatSubState
var longestTimer:Float = 0; var longestTimer:Float = 0;
// FlxTween.color(bgDad, 0.33, 0xFFFFFFFF, 0xFF555555, {ease: FlxEase.quadOut});
FlxTween.color(pinkBack, 0.25, 0xFFFFD863, 0xFFFFD0D5, {ease: FlxEase.quadOut});
cardGlow.visible = true;
cardGlow.alpha = 1;
cardGlow.scale.set(1, 1);
FlxTween.tween(cardGlow, {alpha: 0, "scale.x": 1.2, "scale.y": 1.2}, 0.25, {ease: FlxEase.sineOut});
orangeBackShit.visible = false;
alsoOrangeLOL.visible = false;
moreWays.visible = false;
funnyScroll.visible = false;
txtNuts.visible = false;
funnyScroll2.visible = false;
moreWays2.visible = false;
funnyScroll3.visible = false;
for (grpSpr in exitMovers.keys()) for (grpSpr in exitMovers.keys())
{ {
var moveData:MoveData = exitMovers.get(grpSpr); var moveData:MoveData = exitMovers.get(grpSpr);
@ -1555,6 +1623,7 @@ class FreeplayState extends MusicBeatSubState
FunkinSound.playOnce(Paths.sound('confirmMenu')); FunkinSound.playOnce(Paths.sound('confirmMenu'));
dj.confirm(); dj.confirm();
grpCapsules.members[curSelected].forcePosition();
grpCapsules.members[curSelected].songText.flickerText(); grpCapsules.members[curSelected].songText.flickerText();
// FlxTween.color(bgDad, 0.33, 0xFFFFFFFF, 0xFF555555, {ease: FlxEase.quadOut}); // FlxTween.color(bgDad, 0.33, 0xFFFFFFFF, 0xFF555555, {ease: FlxEase.quadOut});
@ -1689,6 +1758,7 @@ class FreeplayState extends MusicBeatSubState
} }
else else
{ {
if(prepForNewRank == false){
var potentiallyErect:String = (currentDifficulty == "erect") || (currentDifficulty == "nightmare") ? "-erect" : ""; var potentiallyErect:String = (currentDifficulty == "erect") || (currentDifficulty == "nightmare") ? "-erect" : "";
// TODO: Stream the instrumental of the selected song? // TODO: Stream the instrumental of the selected song?
FunkinSound.playMusic(daSongCapsule.songData.songId, FunkinSound.playMusic(daSongCapsule.songData.songId,
@ -1709,6 +1779,7 @@ class FreeplayState extends MusicBeatSubState
} }
}); });
} }
}
grpCapsules.members[curSelected].selected = true; grpCapsules.members[curSelected].selected = true;
} }
} }
@ -1719,7 +1790,12 @@ class FreeplayState extends MusicBeatSubState
*/ */
public static function build(?params:FreeplayStateParams, ?stickers:StickerSubState):MusicBeatState public static function build(?params:FreeplayStateParams, ?stickers:StickerSubState):MusicBeatState
{ {
var result = new MainMenuState(); var result:MainMenuState;
if(params?.fromResults.oldRank != null){
result = new MainMenuState(true);
}else{
result = new MainMenuState(false);
}
result.openSubState(new FreeplayState(params, stickers)); result.openSubState(new FreeplayState(params, stickers));
result.persistentUpdate = false; result.persistentUpdate = false;

View file

@ -371,7 +371,7 @@ class SongMenuItem extends FlxSpriteGroup
switch (i) switch (i)
{ {
case 0: case 0:
if (newRating > 10) if (newRating < 10)
{ {
bigNumbers[i].digit = 0; bigNumbers[i].digit = 0;
} }
@ -677,7 +677,7 @@ class FreeplayRank extends FlxSprite
{ {
rank = val; rank = val;
if (rank == null) if (rank == null || val == null)
{ {
this.visible = false; this.visible = false;
} }
@ -687,6 +687,8 @@ class FreeplayRank extends FlxSprite
animation.play(val.getFreeplayRankIconAsset(), true, false); animation.play(val.getFreeplayRankIconAsset(), true, false);
trace(val.getFreeplayRankIconAsset());
centerOffsets(false); centerOffsets(false);
switch (val) switch (val)
@ -707,6 +709,7 @@ class FreeplayRank extends FlxSprite
// offset.y += 5; // offset.y += 5;
default: default:
centerOffsets(false); centerOffsets(false);
this.visible = false;
} }
updateHitbox(); updateHitbox();
} }

View file

@ -42,6 +42,15 @@ class MainMenuState extends MusicBeatState
var magenta:FlxSprite; var magenta:FlxSprite;
var camFollow:FlxObject; var camFollow:FlxObject;
var overrideMusic:Bool = false;
public function new(?_overrideMusic:Bool = false)
{
super();
overrideMusic = _overrideMusic;
}
override function create():Void override function create():Void
{ {
#if discord_rpc #if discord_rpc
@ -54,7 +63,7 @@ class MainMenuState extends MusicBeatState
transIn = FlxTransitionableState.defaultTransIn; transIn = FlxTransitionableState.defaultTransIn;
transOut = FlxTransitionableState.defaultTransOut; transOut = FlxTransitionableState.defaultTransOut;
playMenuMusic(); if(overrideMusic == false) playMenuMusic();
// We want the state to always be able to begin with being able to accept inputs and show the anims of the menu items. // We want the state to always be able to begin with being able to accept inputs and show the anims of the menu items.
persistentUpdate = true; persistentUpdate = true;