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

Merge pull request #403 from FunkinCrew/bugfix/pause-menu-stress-diff

Fix an issue where hidden difficulties could end up in the difficulty list.
This commit is contained in:
Cameron Taylor 2024-03-21 21:48:15 -04:00 committed by GitHub
commit 407df10929

View file

@ -367,11 +367,14 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
/**
* List all the difficulties in this song.
*
* @param variationId Optionally filter by a single variation.
* @param variationIds Optionally filter by multiple variations.
* @param showHidden Include charts which are not accessible to the player.
*
* @return The list of difficulties.
*/
public function listDifficulties(?variationId:String, ?variationIds:Array<String>):Array<String>
public function listDifficulties(?variationId:String, ?variationIds:Array<String>, showHidden:Bool = false):Array<String>
{
if (variationIds == null) variationIds = [];
if (variationId != null) variationIds.push(variationId);
@ -387,6 +390,15 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
return difficulty.difficulty;
}).nonNull().unique();
diffFiltered = diffFiltered.filter(function(diffId:String):Bool {
if (showHidden) return true;
for (targetVariation in variationIds)
{
if (isDifficultyVisible(diffId, targetVariation)) return true;
}
return false;
});
diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST));
return diffFiltered;
@ -405,6 +417,13 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
return false;
}
public function isDifficultyVisible(diffId:String, variationId:String):Bool
{
var variation = _metadata.get(variationId);
if (variation == null) return false;
return variation.playData.difficulties.contains(diffId);
}
/**
* Purge the cached chart data for each difficulty of this song.
*/