1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-23 13:48:23 +00:00

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 bfShit:Null<FlxAtlasSprite> = null;
var rankBg:FunkinSprite;
public function new(params:ResultsStateParams)
{
super();
@ -95,6 +97,8 @@ class ResultState extends MusicBeatSubState
highscoreNew = new FlxSprite(310, 570);
score = new ResultScore(35, 305, 10, params.scoreData.score);
rankBg = new FunkinSprite(0, 0);
}
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();
super.create();
@ -654,18 +664,47 @@ class ResultState extends MusicBeatSubState
}
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,
{
fromResults:
{
oldRank: Scoring.calculateRank(params?.prevScoreData),
newRank: rank,
songId: params.songId,
difficultyId: params.difficultyId
}
}
}, sticker)));
ease: FlxEase.expoOut,
onComplete: function(_) {
FlxG.switchState(FreeplayState.build(
{
{
fromResults:
{
oldRank: Scoring.calculateRank(params?.prevScoreData),
newRank: rank,
songId: params.songId,
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)));
}
}
}

View file

@ -349,7 +349,7 @@ class Scoring
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
var isPerfectGold = scoreData.tallies.sick == scoreData.tallies.totalNotes;
@ -394,6 +394,62 @@ enum abstract ScoringRank(String)
var GOOD;
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
*/

View file

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

View file

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

View file

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

View file

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

View file

@ -42,6 +42,15 @@ class MainMenuState extends MusicBeatState
var magenta:FlxSprite;
var camFollow:FlxObject;
var overrideMusic:Bool = false;
public function new(?_overrideMusic:Bool = false)
{
super();
overrideMusic = _overrideMusic;
}
override function create():Void
{
#if discord_rpc
@ -54,7 +63,7 @@ class MainMenuState extends MusicBeatState
transIn = FlxTransitionableState.defaultTransIn;
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.
persistentUpdate = true;
@ -163,7 +172,7 @@ class MainMenuState extends MusicBeatState
function playMenuMusic():Void
{
FunkinSound.playMusic('freakyMenu',
FunkinSound.playMusic('freakyMenu',
{
overrideExisting: true,
restartTrack: false