1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-21 22:33:26 +00:00

fix: Song.getFirstValidVariation() now properly takes into account multiple variations/difficulty input

freeplay implement for NEW song stuff w/ assets submod

save data crap and crud

rank icon fixes for fixed pico menu
This commit is contained in:
Cameron Taylor 2024-10-02 20:38:47 -04:00
parent 4fa9a0daaa
commit d2e29879fe
4 changed files with 45 additions and 13 deletions

2
assets

@ -1 +1 @@
Subproject commit b2404b6b1cba47da8eef4910f49985d54318186b Subproject commit 7efad31cf80a42600375bf08b397786df5c1037c

View file

@ -98,7 +98,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
} }
// this returns false so that any new song can override this and return true when needed // this returns false so that any new song can override this and return true when needed
public function isSongNew(currentDifficulty:String):Bool public function isSongNew(currentDifficulty:String, currentVariation:String):Bool
{ {
return false; return false;
} }
@ -434,17 +434,25 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
return null; return null;
} }
/**
* Returns the first valid variation that matches both the difficulty id, and the current character / possible input variations
* @param diffId
* @param currentCharacter
* @param possibleVariations
* @return Null<String>
*/
public function getFirstValidVariation(?diffId:String, ?currentCharacter:PlayableCharacter, ?possibleVariations:Array<String>):Null<String> public function getFirstValidVariation(?diffId:String, ?currentCharacter:PlayableCharacter, ?possibleVariations:Array<String>):Null<String>
{ {
if (possibleVariations == null) if (possibleVariations == null)
{ {
possibleVariations = getVariationsByCharacter(currentCharacter); possibleVariations = getVariationsByCharacter(currentCharacter);
} }
if (diffId == null) diffId = listDifficulties(null, possibleVariations)[0]; if (diffId == null) diffId = listDifficulties(null, possibleVariations)[0];
for (variationId in possibleVariations) for (variationId in possibleVariations)
{ {
if (difficulties.exists('$variationId')) return variationId; if (difficulties.get('$variationId')?.exists(diffId) ?? false) return variationId;
} }
return null; return null;

View file

@ -543,22 +543,34 @@ class Save
* *
* @param songId The ID of the song. * @param songId The ID of the song.
* @param difficultyId The difficulty to check. * @param difficultyId The difficulty to check.
* @param variation The variation to check. Defaults to empty string. Appended to difficulty with `-`, e.g. `easy-pico`.
* @return A data structure containing score, judgement counts, and accuracy. Returns `null` if no score is saved. * @return A data structure containing score, judgement counts, and accuracy. Returns `null` if no score is saved.
*/ */
public function getSongScore(songId:String, difficultyId:String = 'normal'):Null<SaveScoreData> public function getSongScore(songId:String, difficultyId:String = 'normal', ?variation:String):Null<SaveScoreData>
{ {
var song = data.scores.songs.get(songId); var song = data.scores.songs.get(songId);
trace('Getting song score for $songId $difficultyId $variation');
if (song == null) if (song == null)
{ {
trace('Could not find song data for $songId $difficultyId $variation');
song = []; song = [];
data.scores.songs.set(songId, song); data.scores.songs.set(songId, song);
} }
// 'default' variations are left with no suffix ('easy', 'normal', 'hard'),
// along with 'erect' variations ('erect', 'nightmare')
// otherwise, we want to add a suffix of our current variation to get the save data.
if (variation != null && variation != '' && variation != 'default' && variation != 'erect')
{
difficultyId = '${difficultyId}-${variation}';
}
return song.get(difficultyId); return song.get(difficultyId);
} }
public function getSongRank(songId:String, difficultyId:String = 'normal'):Null<ScoringRank> public function getSongRank(songId:String, difficultyId:String = 'normal', ?variation:String):Null<ScoringRank>
{ {
return Scoring.calculateRank(getSongScore(songId, difficultyId)); return Scoring.calculateRank(getSongScore(songId, difficultyId, variation));
} }
/** /**

View file

@ -1717,8 +1717,6 @@ class FreeplayState extends MusicBeatSubState
} }
} }
trace('CURRENT VARIATION OF SONG: ${currentVariation}');
var daSong:Null<FreeplaySongData> = grpCapsules.members[curSelected].freeplayData; var daSong:Null<FreeplaySongData> = grpCapsules.members[curSelected].freeplayData;
if (daSong != null) if (daSong != null)
{ {
@ -1729,7 +1727,7 @@ class FreeplayState extends MusicBeatSubState
return; return;
} }
var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSong.data.id, currentDifficulty); var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSong.data.id, currentDifficulty, currentVariation);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes); intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedDifficulty = currentDifficulty; rememberedDifficulty = currentDifficulty;
@ -2025,7 +2023,7 @@ class FreeplayState extends MusicBeatSubState
var daSongCapsule:SongMenuItem = grpCapsules.members[curSelected]; var daSongCapsule:SongMenuItem = grpCapsules.members[curSelected];
if (daSongCapsule.freeplayData != null) if (daSongCapsule.freeplayData != null)
{ {
var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSongCapsule.freeplayData.data.id, currentDifficulty); var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSongCapsule.freeplayData.data.id, currentDifficulty, currentVariation);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes); intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedSongId = daSongCapsule.freeplayData.data.id; rememberedSongId = daSongCapsule.freeplayData.data.id;
@ -2260,7 +2258,7 @@ class FreeplaySongData
/** /**
* Whether the player has seen/played this song before within freeplay * Whether the player has seen/played this song before within freeplay
*/ */
public var isNew:Bool = false; public var isNew(get, never):Bool;
/** /**
* The default opponent for the song. * The default opponent for the song.
@ -2312,6 +2310,18 @@ class FreeplaySongData
// this.isNew = song.isSongNew(suffixedDifficulty); // this.isNew = song.isSongNew(suffixedDifficulty);
} }
function get_isNew():Bool
{
// We use a slightly different manner to get the new status of a song than the other getters here
// `isSongNew()` only takes a single variation, and it's data that isn't accessible via the Song data/metadata
// it's stored in the song .hxc script in a function that overrides `isSongNew()`
// and is only accessible with the correct valid variation inputs
var variations:Array<String> = data.getVariationsByCharacterId(FreeplayState.rememberedCharacterId);
var variation:String = data.getFirstValidVariation(FreeplayState.rememberedDifficulty, null, variations);
return data.isSongNew(FreeplayState.rememberedDifficulty, variation);
}
function get_songCharacter():String function get_songCharacter():String
{ {
var variations:Array<String> = data.getVariationsByCharacterId(FreeplayState.rememberedCharacterId); var variations:Array<String> = data.getVariationsByCharacterId(FreeplayState.rememberedCharacterId);
@ -2340,8 +2350,10 @@ class FreeplaySongData
function get_scoringRank():Null<ScoringRank> function get_scoringRank():Null<ScoringRank>
{ {
// TODO: Properly get/migrate the save data from the suffixed difficulty version to our new unsuffixed version var variations:Array<String> = data.getVariationsByCharacterId(FreeplayState.rememberedCharacterId);
return Save.instance.getSongRank(data.songName, FreeplayState.rememberedDifficulty); var variation:String = data.getFirstValidVariation(FreeplayState.rememberedDifficulty, null, variations);
return Save.instance.getSongRank(data.id, FreeplayState.rememberedDifficulty, variation);
} }
} }