Merge branch 'rewrite/master' into bugfix/html5-save-data

This commit is contained in:
EliteMasterEric 2024-05-28 01:34:16 -04:00
commit 3f9d8ccda9
11 changed files with 309 additions and 160 deletions

9
.vscode/launch.json vendored
View file

@ -3,10 +3,17 @@
"configurations": [ "configurations": [
{ {
// Launch in native/CPP on Windows/OSX/Linux // Launch in native/CPP on Windows/OSX/Linux
"name": "Lime", "name": "Lime Build+Debug",
"type": "lime", "type": "lime",
"request": "launch" "request": "launch"
}, },
{
// Launch in native/CPP on Windows/OSX/Linux
"name": "Lime Debug (No Build)",
"type": "lime",
"request": "launch",
"preLaunchTask": null
},
{ {
// Launch in browser // Launch in browser
"name": "HTML5 Debug", "name": "HTML5 Debug",

View file

@ -155,6 +155,11 @@
"target": "hl", "target": "hl",
"args": ["-debug", "-DDIALOGUE"] "args": ["-debug", "-DDIALOGUE"]
}, },
{
"label": "Windows / Debug (Results Screen Test)",
"target": "windows",
"args": ["-debug", "-DRESULTS"]
},
{ {
"label": "Windows / Debug (Straight to Chart Editor)", "label": "Windows / Debug (Straight to Chart Editor)",
"target": "windows", "target": "windows",

2
assets

@ -1 +1 @@
Subproject commit fd112e293ee0f823ee98d5b8bd8a85e934f772f6 Subproject commit ce7dabffbebc154c9dda1f01e92dbef83e3405ab

View file

@ -214,6 +214,30 @@ class InitState extends FlxState
#elseif STAGEBUILD #elseif STAGEBUILD
// -DSTAGEBUILD // -DSTAGEBUILD
FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState()); FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState());
#elseif RESULTS
// -DRESULTS
FlxG.switchState(() -> new funkin.play.ResultState(
{
storyMode: false,
title: "CUM SONG",
isNewHighscore: true,
scoreData:
{
score: 1_234_567,
tallies:
{
sick: 130,
good: 69,
bad: 69,
shit: 69,
missed: 69,
combo: 69,
maxCombo: 69,
totalNotesHit: 140,
totalNotes: 2000,
}
},
}));
#elseif ANIMDEBUG #elseif ANIMDEBUG
// -DANIMDEBUG // -DANIMDEBUG
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState()); FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());

View file

@ -2777,6 +2777,7 @@ class PlayState extends MusicBeatSubState
deathCounter = 0; deathCounter = 0;
var isNewHighscore = false; var isNewHighscore = false;
var prevScoreData:Null<SaveScoreData> = Save.instance.getSongScore(currentSong.id, currentDifficulty);
if (currentSong != null && currentSong.validScore) if (currentSong != null && currentSong.validScore)
{ {
@ -2796,7 +2797,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: Highscore.tallies.totalNotesHit, totalNotesHit: Highscore.tallies.totalNotesHit,
totalNotes: Highscore.tallies.totalNotes, totalNotes: Highscore.tallies.totalNotes,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}; };
// adds current song data into the tallies for the level (story levels) // adds current song data into the tallies for the level (story levels)
@ -2833,7 +2833,7 @@ class PlayState extends MusicBeatSubState
score: PlayStatePlaylist.campaignScore, score: PlayStatePlaylist.campaignScore,
tallies: tallies:
{ {
// TODO: Sum up the values for the whole level! // TODO: Sum up the values for the whole week!
sick: 0, sick: 0,
good: 0, good: 0,
bad: 0, bad: 0,
@ -2844,7 +2844,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: 0, totalNotesHit: 0,
totalNotes: 0, totalNotes: 0,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}; };
if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data)) if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data))
@ -2930,11 +2929,11 @@ class PlayState extends MusicBeatSubState
{ {
if (rightGoddamnNow) if (rightGoddamnNow)
{ {
moveToResultsScreen(isNewHighscore); moveToResultsScreen(isNewHighscore, prevScoreData);
} }
else else
{ {
zoomIntoResultsScreen(isNewHighscore); zoomIntoResultsScreen(isNewHighscore, prevScoreData);
} }
} }
} }
@ -3008,7 +3007,7 @@ class PlayState extends MusicBeatSubState
/** /**
* Play the camera zoom animation and then move to the results screen once it's done. * Play the camera zoom animation and then move to the results screen once it's done.
*/ */
function zoomIntoResultsScreen(isNewHighscore:Bool):Void function zoomIntoResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
{ {
trace('WENT TO RESULTS SCREEN!'); trace('WENT TO RESULTS SCREEN!');
@ -3048,7 +3047,7 @@ class PlayState extends MusicBeatSubState
FlxTween.tween(camHUD, {alpha: 0}, 0.6, FlxTween.tween(camHUD, {alpha: 0}, 0.6,
{ {
onComplete: function(_) { onComplete: function(_) {
moveToResultsScreen(isNewHighscore); moveToResultsScreen(isNewHighscore, prevScoreData);
} }
}); });
@ -3081,7 +3080,7 @@ class PlayState extends MusicBeatSubState
/** /**
* Move to the results screen right goddamn now. * Move to the results screen right goddamn now.
*/ */
function moveToResultsScreen(isNewHighscore:Bool):Void function moveToResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
{ {
persistentUpdate = false; persistentUpdate = false;
vocals.stop(); vocals.stop();
@ -3093,6 +3092,8 @@ class PlayState extends MusicBeatSubState
{ {
storyMode: PlayStatePlaylist.isStoryMode, storyMode: PlayStatePlaylist.isStoryMode,
title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'), title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'),
prevScoreData: prevScoreData,
difficultyId: currentDifficulty,
scoreData: scoreData:
{ {
score: PlayStatePlaylist.isStoryMode ? PlayStatePlaylist.campaignScore : songScore, score: PlayStatePlaylist.isStoryMode ? PlayStatePlaylist.campaignScore : songScore,
@ -3108,7 +3109,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: talliesToUse.totalNotesHit, totalNotesHit: talliesToUse.totalNotesHit,
totalNotes: talliesToUse.totalNotes, totalNotes: talliesToUse.totalNotes,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}, },
isNewHighscore: isNewHighscore isNewHighscore: isNewHighscore
}); });

View file

@ -24,6 +24,7 @@ import funkin.save.Save;
import funkin.save.Save.SaveScoreData; import funkin.save.Save.SaveScoreData;
import funkin.graphics.shaders.LeftMaskShader; import funkin.graphics.shaders.LeftMaskShader;
import funkin.play.components.TallyCounter; import funkin.play.components.TallyCounter;
import funkin.play.components.ClearPercentCounter;
/** /**
* The state for the results screen after a song or week is finished. * The state for the results screen after a song or week is finished.
@ -109,7 +110,7 @@ class ResultState extends MusicBeatSubState
var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem'); var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem');
soundSystem.animation.addByPrefix("idle", "sound system", 24, false); soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false; soundSystem.visible = false;
new FlxTimer().start(0.4, _ -> { new FlxTimer().start(0.3, _ -> {
soundSystem.animation.play("idle"); soundSystem.animation.play("idle");
soundSystem.visible = true; soundSystem.visible = true;
}); });
@ -118,7 +119,7 @@ class ResultState extends MusicBeatSubState
switch (rank) switch (rank)
{ {
case PERFECT | PERFECT_GOLD | PERFECT_PLATINUM: case PERFECT | PERFECT_GOLD:
bfPerfect = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared")); bfPerfect = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
bfPerfect.visible = false; bfPerfect.visible = false;
bfPerfect.zIndex = 500; bfPerfect.zIndex = 500;
@ -183,22 +184,7 @@ class ResultState extends MusicBeatSubState
}); });
} }
var diffSpr:String = switch (PlayState.instance.currentDifficulty) var diffSpr:String = 'dif${params?.difficultyId ?? 'Normal'}';
{
case 'easy':
'difEasy';
case 'normal':
'difNormal';
case 'hard':
'difHard';
case 'erect':
'difErect';
case 'nightmare':
'difNightmare';
case _:
'difNormal';
}
difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr)); difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr));
add(difficulty); add(difficulty);
@ -208,7 +194,7 @@ class ResultState extends MusicBeatSubState
speedOfTween.x = -1.0 * Math.cos(angleRad); speedOfTween.x = -1.0 * Math.cos(angleRad);
speedOfTween.y = -1.0 * Math.sin(angleRad); speedOfTween.y = -1.0 * Math.sin(angleRad);
timerThenSongName(); timerThenSongName(1.0);
songName.shader = maskShaderSongName; songName.shader = maskShaderSongName;
difficulty.shader = maskShaderDifficulty; difficulty.shader = maskShaderDifficulty;
@ -218,24 +204,40 @@ class ResultState extends MusicBeatSubState
var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack")); var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack"));
blackTopBar.y = -blackTopBar.height; blackTopBar.y = -blackTopBar.height;
FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut, startDelay: 0.5}); FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut});
blackTopBar.zIndex = 1010; blackTopBar.zIndex = 1010;
add(blackTopBar); add(blackTopBar);
resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false); resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false);
resultsAnim.animation.play("result"); resultsAnim.visible = false;
resultsAnim.zIndex = 1200; resultsAnim.zIndex = 1200;
add(resultsAnim); add(resultsAnim);
new FlxTimer().start(0.3, _ -> {
resultsAnim.visible = true;
resultsAnim.animation.play("result");
});
ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false); ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false);
ratingsPopin.visible = false; ratingsPopin.visible = false;
ratingsPopin.zIndex = 1200; ratingsPopin.zIndex = 1200;
add(ratingsPopin); add(ratingsPopin);
new FlxTimer().start(1.0, _ -> {
ratingsPopin.visible = true;
ratingsPopin.animation.play("idle");
});
scorePopin.animation.addByPrefix("score", "tally score", 24, false); scorePopin.animation.addByPrefix("score", "tally score", 24, false);
scorePopin.visible = false; scorePopin.visible = false;
scorePopin.zIndex = 1200; scorePopin.zIndex = 1200;
add(scorePopin); add(scorePopin);
new FlxTimer().start(1.0, _ -> {
scorePopin.visible = true;
scorePopin.animation.play("score");
scorePopin.animation.finishCallback = anim -> {
score.visible = true;
score.animateNumbers();
};
});
highscoreNew.frames = Paths.getSparrowAtlas("resultScreen/highscoreNew"); highscoreNew.frames = Paths.getSparrowAtlas("resultScreen/highscoreNew");
highscoreNew.animation.addByPrefix("new", "NEW HIGHSCORE", 24); highscoreNew.animation.addByPrefix("new", "NEW HIGHSCORE", 24);
@ -285,13 +287,26 @@ class ResultState extends MusicBeatSubState
for (ind => rating in ratingGrp.members) for (ind => rating in ratingGrp.members)
{ {
rating.visible = false; rating.visible = false;
new FlxTimer().start((0.3 * ind) + 0.55, _ -> { new FlxTimer().start((0.3 * ind) + 1.20, _ -> {
rating.visible = true; rating.visible = true;
FlxTween.tween(rating, {curNumber: rating.neededNumber}, 0.5, {ease: FlxEase.quartOut}); FlxTween.tween(rating, {curNumber: rating.neededNumber}, 0.5, {ease: FlxEase.quartOut});
}); });
} }
startRankTallySequence(); ratingsPopin.animation.finishCallback = anim -> {
startRankTallySequence();
if (params.isNewHighscore ?? false)
{
highscoreNew.visible = true;
highscoreNew.animation.play("new");
FlxTween.tween(highscoreNew, {y: highscoreNew.y + 10}, 0.8, {ease: FlxEase.quartOut});
}
else
{
highscoreNew.visible = false;
}
};
refresh(); refresh();
@ -304,48 +319,43 @@ class ResultState extends MusicBeatSubState
function startRankTallySequence():Void function startRankTallySequence():Void
{ {
clearPercentTarget = Math.floor((params.scoreData.tallies.totalNotesHit) / params.scoreData.tallies.totalNotes * 100); clearPercentTarget = Math.floor((params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes * 100);
// clearPercentTarget = 97; clearPercentTarget = 100;
var clearPercentText = new FlxText(FlxG.width / 2, FlxG.height / 2, 0, 'CLEAR: ${clearPercentLerp}%'); clearPercentLerp = Std.int(Math.max(0, clearPercentTarget - 36));
clearPercentText.setFormat(Paths.font('vcr.ttf'), 64, FlxColor.BLACK, FlxTextAlign.RIGHT);
clearPercentText.zIndex = 1000;
add(clearPercentText);
rankTallyTimer = new FlxTimer().start(1 / 24, _ -> { var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, clearPercentTarget);
// Tick up. clearPercentCounter.curNumber = clearPercentLerp;
if (clearPercentLerp < clearPercentTarget) FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 1.5,
{ {
clearPercentLerp++; ease: FlxEase.quartOut,
onUpdate: _ -> {
// Only play the tick sound if the number increased.
if (clearPercentLerp != clearPercentCounter.curNumber)
{
clearPercentLerp = clearPercentCounter.curNumber;
FunkinSound.playOnce(Paths.sound('scrollMenu'));
}
},
onComplete: _ -> {
// Play confirm sound.
FunkinSound.playOnce(Paths.sound('confirmMenu'));
clearPercentText.text = 'CLEAR: ${clearPercentLerp}%'; // Flash background.
FunkinSound.playOnce(Paths.sound('scrollMenu')); bgFlash.visible = true;
} FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
// Don't overshoot. displayRankText();
if (clearPercentLerp > clearPercentTarget)
{
clearPercentLerp = clearPercentTarget;
}
if (clearPercentLerp == clearPercentTarget) new FlxTimer().start(2.0, _ -> {
{ // remove(clearPercentCounter);
if (rankTallyTimer != null)
{ afterRankTallySequence();
rankTallyTimer.destroy(); });
rankTallyTimer = null;
} }
});
// Play confirm sound. clearPercentCounter.zIndex = 450;
FunkinSound.playOnce(Paths.sound('confirmMenu')); add(clearPercentCounter);
new FlxTimer().start(1.0, _ -> {
remove(clearPercentText);
afterRankTallySequence();
});
}
}, 0); // 0 = Loop until stopped
if (ratingsPopin == null) if (ratingsPopin == null)
{ {
@ -353,18 +363,15 @@ class ResultState extends MusicBeatSubState
} }
else else
{ {
ratingsPopin.animation.play("idle"); // ratingsPopin.animation.play("idle");
ratingsPopin.visible = true; // ratingsPopin.visible = true;
ratingsPopin.animation.finishCallback = anim -> { ratingsPopin.animation.finishCallback = anim -> {
scorePopin.animation.play("score"); // scorePopin.animation.play("score");
scorePopin.animation.finishCallback = anim -> {
score.visible = true;
score.animateNumbers();
};
scorePopin.visible = true;
if (params.isNewHighscore) // scorePopin.visible = true;
if (params.isNewHighscore ?? false)
{ {
highscoreNew.visible = true; highscoreNew.visible = true;
highscoreNew.animation.play("new"); highscoreNew.animation.play("new");
@ -380,6 +387,23 @@ class ResultState extends MusicBeatSubState
refresh(); refresh();
} }
function displayRankText():Void
{
var rankTextVert:FunkinSprite = FunkinSprite.create(FlxG.width - 64, 100, rank.getVerTextAsset());
rankTextVert.zIndex = 2000;
add(rankTextVert);
for (i in 0...10)
{
var rankTextBack:FunkinSprite = FunkinSprite.create(FlxG.width / 2 - 80, 50, rank.getHorTextAsset());
rankTextBack.y += (rankTextBack.height * i / 2) + 10;
rankTextBack.zIndex = 100;
add(rankTextBack);
}
refresh();
}
function afterRankTallySequence():Void function afterRankTallySequence():Void
{ {
FunkinSound.playMusic(rank.getMusicPath(), FunkinSound.playMusic(rank.getMusicPath(),
@ -406,7 +430,7 @@ class ResultState extends MusicBeatSubState
switch (rank) switch (rank)
{ {
case PERFECT | PERFECT_GOLD | PERFECT_PLATINUM: case PERFECT | PERFECT_GOLD:
if (bfPerfect == null) if (bfPerfect == null)
{ {
trace("Could not build PERFECT animation!"); trace("Could not build PERFECT animation!");
@ -415,17 +439,6 @@ class ResultState extends MusicBeatSubState
{ {
bfPerfect.visible = true; bfPerfect.visible = true;
bfPerfect.playAnimation(''); bfPerfect.playAnimation('');
new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
new FlxTimer().start((1 / 24) * 2, _ ->
{
// bgFlash.alpha = 0.5;
// bgFlash.visible = false;
});
});
} }
case EXCELLENT: case EXCELLENT:
@ -437,17 +450,6 @@ class ResultState extends MusicBeatSubState
{ {
bfExcellent.visible = true; bfExcellent.visible = true;
bfExcellent.playAnimation('Intro'); bfExcellent.playAnimation('Intro');
new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
new FlxTimer().start((1 / 24) * 2, _ ->
{
// bgFlash.alpha = 0.5;
// bgFlash.visible = false;
});
});
} }
case SHIT: case SHIT:
@ -459,17 +461,6 @@ class ResultState extends MusicBeatSubState
{ {
bfShit.visible = true; bfShit.visible = true;
bfShit.playAnimation('Intro'); bfShit.playAnimation('Intro');
new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
new FlxTimer().start((1 / 24) * 2, _ ->
{
// bgFlash.alpha = 0.5;
// bgFlash.visible = false;
});
});
} }
case GREAT | GOOD: case GREAT | GOOD:
@ -482,17 +473,6 @@ class ResultState extends MusicBeatSubState
bfGood.animation.play('fall'); bfGood.animation.play('fall');
bfGood.visible = true; bfGood.visible = true;
new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
new FlxTimer().start((1 / 24) * 2, _ ->
{
// bgFlash.alpha = 0.5;
// bgFlash.visible = false;
});
});
new FlxTimer().start((1 / 24) * 22, _ -> { new FlxTimer().start((1 / 24) * 22, _ -> {
// plays about 22 frames (at 24fps timing) after bf spawns in // plays about 22 frames (at 24fps timing) after bf spawns in
if (gfGood != null) if (gfGood != null)
@ -510,7 +490,7 @@ class ResultState extends MusicBeatSubState
} }
} }
function timerThenSongName():Void function timerThenSongName(timerLength:Float = 3.0):Void
{ {
movingSongStuff = false; movingSongStuff = false;
@ -526,7 +506,7 @@ class ResultState extends MusicBeatSubState
FlxTween.tween(songName, {y: diffYTween - 35 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9}); FlxTween.tween(songName, {y: diffYTween - 35 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9});
songName.x = (difficulty.x + difficulty.width) + 20; songName.x = (difficulty.x + difficulty.width) + 20;
new FlxTimer().start(3, _ -> { new FlxTimer().start(timerLength, _ -> {
var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y); var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y);
speedOfTween.set(0, 0); speedOfTween.set(0, 0);
@ -600,33 +580,29 @@ class ResultState extends MusicBeatSubState
public static function calculateRank(params:ResultsStateParams):ResultRank public static function calculateRank(params:ResultsStateParams):ResultRank
{ {
// Perfect (Platinum) is a Sick Full Clear // Perfect (Platinum) is a Sick Full Clear
var isPerfectPlat = (params.scoreData.tallies.sick + params.scoreData.tallies.good) == params.scoreData.tallies.totalNotes var isPerfectGold = params.scoreData.tallies.sick == params.scoreData.tallies.totalNotes;
&& params.scoreData.tallies.sick / params.scoreData.tallies.totalNotes >= Constants.RANK_PERFECT_PLAT_THRESHOLD;
if (isPerfectPlat) return ResultRank.PERFECT_PLATINUM;
// Perfect (Gold) is an 85% Sick Full Clear
var isPerfectGold = (params.scoreData.tallies.sick + params.scoreData.tallies.good) == params.scoreData.tallies.totalNotes
&& params.scoreData.tallies.sick / params.scoreData.tallies.totalNotes >= Constants.RANK_PERFECT_GOLD_THRESHOLD;
if (isPerfectGold) return ResultRank.PERFECT_GOLD; if (isPerfectGold) return ResultRank.PERFECT_GOLD;
// Else, use the standard grades // Else, use the standard grades
// Grade % (only good and sick), 1.00 is a full combo
var grade = (params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes;
// Clear % (including bad and shit). 1.00 is a full clear but not a full combo // Clear % (including bad and shit). 1.00 is a full clear but not a full combo
var clear = (params.scoreData.tallies.totalNotesHit) / params.scoreData.tallies.totalNotes; var clear = (params.scoreData.tallies.totalNotesHit) / params.scoreData.tallies.totalNotes;
if (clear == Constants.RANK_PERFECT_THRESHOLD) if (grade == Constants.RANK_PERFECT_THRESHOLD)
{ {
return ResultRank.PERFECT; return ResultRank.PERFECT;
} }
else if (clear >= Constants.RANK_EXCELLENT_THRESHOLD) else if (grade >= Constants.RANK_EXCELLENT_THRESHOLD)
{ {
return ResultRank.EXCELLENT; return ResultRank.EXCELLENT;
} }
else if (clear >= Constants.RANK_GREAT_THRESHOLD) else if (grade >= Constants.RANK_GREAT_THRESHOLD)
{ {
return ResultRank.GREAT; return ResultRank.GREAT;
} }
else if (clear >= Constants.RANK_GOOD_THRESHOLD) else if (grade >= Constants.RANK_GOOD_THRESHOLD)
{ {
return ResultRank.GOOD; return ResultRank.GOOD;
} }
@ -639,7 +615,6 @@ class ResultState extends MusicBeatSubState
enum abstract ResultRank(String) enum abstract ResultRank(String)
{ {
var PERFECT_PLATINUM;
var PERFECT_GOLD; var PERFECT_GOLD;
var PERFECT; var PERFECT;
var EXCELLENT; var EXCELLENT;
@ -651,8 +626,6 @@ enum abstract ResultRank(String)
{ {
switch (abstract) switch (abstract)
{ {
case PERFECT_PLATINUM:
return 'resultsPERFECT';
case PERFECT_GOLD: case PERFECT_GOLD:
return 'resultsPERFECT'; return 'resultsPERFECT';
case PERFECT: case PERFECT:
@ -665,6 +638,8 @@ enum abstract ResultRank(String)
return 'resultsNORMAL'; return 'resultsNORMAL';
case SHIT: case SHIT:
return 'resultsSHIT'; return 'resultsSHIT';
default:
return 'resultsNORMAL';
} }
} }
@ -672,8 +647,6 @@ enum abstract ResultRank(String)
{ {
switch (abstract) switch (abstract)
{ {
case PERFECT_PLATINUM:
return true;
case PERFECT_GOLD: case PERFECT_GOLD:
return true; return true;
case PERFECT: case PERFECT:
@ -690,6 +663,48 @@ enum abstract ResultRank(String)
return false; return false;
} }
} }
public function getHorTextAsset()
{
switch (abstract)
{
case PERFECT_GOLD:
return 'resultScreen/rankText/rankScrollPERFECT';
case PERFECT:
return 'resultScreen/rankText/rankScrollPERFECT';
case EXCELLENT:
return 'resultScreen/rankText/rankScrollEXCELLENT';
case GREAT:
return 'resultScreen/rankText/rankScrollGREAT';
case GOOD:
return 'resultScreen/rankText/rankScrollGOOD';
case SHIT:
return 'resultScreen/rankText/rankScrollLOSS';
default:
return 'resultScreen/rankText/rankScrollGOOD';
}
}
public function getVerTextAsset()
{
switch (abstract)
{
case PERFECT_GOLD:
return 'resultScreen/rankText/rankTextPERFECT';
case PERFECT:
return 'resultScreen/rankText/rankTextPERFECT';
case EXCELLENT:
return 'resultScreen/rankText/rankTextEXCELLENT';
case GREAT:
return 'resultScreen/rankText/rankTextGREAT';
case GOOD:
return 'resultScreen/rankText/rankTextGOOD';
case SHIT:
return 'resultScreen/rankText/rankTextLOSS';
default:
return 'resultScreen/rankText/rankTextGOOD';
}
}
} }
typedef ResultsStateParams = typedef ResultsStateParams =
@ -707,10 +722,21 @@ typedef ResultsStateParams =
/** /**
* Whether the displayed score is a new highscore * Whether the displayed score is a new highscore
*/ */
var isNewHighscore:Bool; var ?isNewHighscore:Bool;
/**
* The difficulty ID of the song/week we just played.
* @default Normal
*/
var ?difficultyId:String;
/** /**
* The score, accuracy, and judgements. * The score, accuracy, and judgements.
*/ */
var scoreData:SaveScoreData; var scoreData:SaveScoreData;
/**
* The previous score data, used for rank comparision.
*/
var ?prevScoreData:SaveScoreData;
}; };

View file

@ -0,0 +1,96 @@
package funkin.play.components;
import funkin.graphics.FunkinSprite;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.math.FlxMath;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.text.FlxText.FlxTextAlign;
import funkin.util.MathUtil;
/**
* Numerical counters used to display the clear percent.
*/
class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
{
public var curNumber:Int = 0;
public var neededNumber:Int = 0;
public function new(x:Float, y:Float, neededNumber:Int = 0)
{
super(x, y);
this.neededNumber = neededNumber;
var clearPercentText:FunkinSprite = FunkinSprite.create(0, 0, 'resultScreen/clearPercent/clearPercentText');
add(clearPercentText);
if (curNumber == neededNumber) drawNumbers();
}
var tmr:Float = 0;
override function update(elapsed:Float)
{
super.update(elapsed);
if (curNumber < neededNumber) drawNumbers();
}
function drawNumbers()
{
var seperatedScore:Array<Int> = [];
var tempCombo:Int = Math.round(curNumber);
var fullNumberDigits:Int = Std.int(Math.max(1, Math.ceil(MathUtil.logBase(10, neededNumber))));
while (tempCombo != 0)
{
seperatedScore.push(tempCombo % 10);
tempCombo = Math.floor(tempCombo / 10);
}
if (seperatedScore.length == 0) seperatedScore.push(0);
seperatedScore.reverse();
for (ind => num in seperatedScore)
{
var digitIndex = ind + 1;
if (digitIndex >= members.length)
{
var xPos = (digitIndex - 1) * (72 * this.scale.x);
var yPos = 72;
// Three digits = LRL so two different numbers aren't adjacent to each other.
var variant:Bool = (fullNumberDigits % 2 != 0) ? (digitIndex % 2 == 0) : (digitIndex % 2 == 1);
var numb:ClearPercentNumber = new ClearPercentNumber(xPos, yPos, num);
numb.scale.set(this.scale.x, this.scale.y);
add(numb);
}
else
{
members[digitIndex].animation.play(Std.string(num));
}
}
}
}
class ClearPercentNumber extends FlxSprite
{
public function new(x:Float, y:Float, digit:Int, variant:Bool = false)
{
super(x, y);
frames = Paths.getSparrowAtlas('resultScreen/clearPercent/clearPercentNumber${variant ? 'Right' : 'Left'}');
for (i in 0...10)
{
animation.addByPrefix('$i', 'number $i 0', 24, false);
}
animation.play('$digit');
updateHitbox();
}
}

View file

@ -809,11 +809,6 @@ typedef SaveScoreData =
* The count of each judgement hit. * The count of each judgement hit.
*/ */
var tallies:SaveScoreTallyData; var tallies:SaveScoreTallyData;
/**
* The accuracy percentage.
*/
var accuracy:Float;
} }
typedef SaveScoreTallyData = typedef SaveScoreTallyData =

View file

@ -121,7 +121,7 @@ class SaveDataMigrator
var scoreDataEasy:SaveScoreData = var scoreDataEasy:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}-easy') ?? 0, score: inputSaveData.songScores.get('${levelId}-easy') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}-easy') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}-easy') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -140,7 +140,7 @@ class SaveDataMigrator
var scoreDataNormal:SaveScoreData = var scoreDataNormal:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}') ?? 0, score: inputSaveData.songScores.get('${levelId}') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -159,7 +159,7 @@ class SaveDataMigrator
var scoreDataHard:SaveScoreData = var scoreDataHard:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}-hard') ?? 0, score: inputSaveData.songScores.get('${levelId}-hard') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}-hard') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}-hard') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -181,7 +181,6 @@ class SaveDataMigrator
var scoreDataEasy:SaveScoreData = var scoreDataEasy:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -199,14 +198,13 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataEasy.score = Std.int(Math.max(scoreDataEasy.score, inputSaveData.songScores.get('${songId}-easy') ?? 0)); scoreDataEasy.score = Std.int(Math.max(scoreDataEasy.score, inputSaveData.songScores.get('${songId}-easy') ?? 0));
scoreDataEasy.accuracy = Math.max(scoreDataEasy.accuracy, inputSaveData.songCompletion.get('${songId}-easy') ?? 0.0); // scoreDataEasy.accuracy = Math.max(scoreDataEasy.accuracy, inputSaveData.songCompletion.get('${songId}-easy') ?? 0.0);
} }
result.setSongScore(songIds[0], 'easy', scoreDataEasy); result.setSongScore(songIds[0], 'easy', scoreDataEasy);
var scoreDataNormal:SaveScoreData = var scoreDataNormal:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -224,14 +222,13 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataNormal.score = Std.int(Math.max(scoreDataNormal.score, inputSaveData.songScores.get('${songId}') ?? 0)); scoreDataNormal.score = Std.int(Math.max(scoreDataNormal.score, inputSaveData.songScores.get('${songId}') ?? 0));
scoreDataNormal.accuracy = Math.max(scoreDataNormal.accuracy, inputSaveData.songCompletion.get('${songId}') ?? 0.0); // scoreDataNormal.accuracy = Math.max(scoreDataNormal.accuracy, inputSaveData.songCompletion.get('${songId}') ?? 0.0);
} }
result.setSongScore(songIds[0], 'normal', scoreDataNormal); result.setSongScore(songIds[0], 'normal', scoreDataNormal);
var scoreDataHard:SaveScoreData = var scoreDataHard:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -249,7 +246,7 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataHard.score = Std.int(Math.max(scoreDataHard.score, inputSaveData.songScores.get('${songId}-hard') ?? 0)); scoreDataHard.score = Std.int(Math.max(scoreDataHard.score, inputSaveData.songScores.get('${songId}-hard') ?? 0));
scoreDataHard.accuracy = Math.max(scoreDataHard.accuracy, inputSaveData.songCompletion.get('${songId}-hard') ?? 0.0); // scoreDataHard.accuracy = Math.max(scoreDataHard.accuracy, inputSaveData.songCompletion.get('${songId}-hard') ?? 0.0);
} }
result.setSongScore(songIds[0], 'hard', scoreDataHard); result.setSongScore(songIds[0], 'hard', scoreDataHard);
} }

View file

@ -998,7 +998,7 @@ class FreeplayState extends MusicBeatSubState
{ {
var songScore:SaveScoreData = Save.instance.getSongScore(grpCapsules.members[curSelected].songData.songId, currentDifficulty); var songScore:SaveScoreData = Save.instance.getSongScore(grpCapsules.members[curSelected].songData.songId, currentDifficulty);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore?.accuracy ?? 0.0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedDifficulty = currentDifficulty; rememberedDifficulty = currentDifficulty;
} }
else else
@ -1196,7 +1196,7 @@ class FreeplayState extends MusicBeatSubState
{ {
var songScore:SaveScoreData = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty); var songScore:SaveScoreData = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore?.accuracy ?? 0.0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
diffIdsCurrent = daSongCapsule.songData.songDifficulties; diffIdsCurrent = daSongCapsule.songData.songDifficulties;
rememberedSongId = daSongCapsule.songData.songId; rememberedSongId = daSongCapsule.songData.songId;
changeDiff(); changeDiff();

View file

@ -355,8 +355,7 @@ class MainMenuState extends MusicBeatState
maxCombo: 0, maxCombo: 0,
totalNotesHit: 0, totalNotesHit: 0,
totalNotes: 0, totalNotes: 0,
}, }
accuracy: 0,
}); });
} }
#end #end