Merge branch 'rewrite/bugfix/pause-and-results-fixes' of https://github.com/FunkinCrew/Funkin-secret into rewrite/bugfix/pause-and-results-fixes

This commit is contained in:
EliteMasterEric 2023-10-17 17:10:16 -04:00
commit 6888e7b122
2 changed files with 56 additions and 1 deletions

View file

@ -245,12 +245,41 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
{
if (variationId == '') variationId = null;
return difficulties.keys().array().filter(function(diffId:String):Bool {
var diffFiltered:Array<String> = difficulties.keys().array().filter(function(diffId:String):Bool {
if (variationId == null) return true;
var difficulty:Null<SongDifficulty> = difficulties.get(diffId);
if (difficulty == null) return false;
return difficulty.variation == variationId;
});
// sort the difficulties, since they may be out of order in the chart JSON
// maybe be careful of lowercase/uppercase?
// also used in Level.listDifficulties()!!
var diffMap:Map<String, Int> = new Map<String, Int>();
for (difficulty in diffFiltered)
{
var num:Int = 0;
switch (difficulty)
{
case 'easy':
num = 0;
case 'normal':
num = 1;
case 'hard':
num = 2;
case 'erect':
num = 3;
case 'nightmare':
num = 4;
}
diffMap.set(difficulty, num);
}
diffFiltered.sort(function(a:String, b:String) {
return (diffMap.get(a) ?? 0) - (diffMap.get(b) ?? 0);
});
return diffFiltered;
}
public function hasDifficulty(diffId:String, ?variationId:String):Bool

View file

@ -155,6 +155,32 @@ class Level implements IRegistryEntry<LevelData>
}
}
// sort the difficulties, since they may be out of order in the chart JSON
// also copy/pasted to Song.listDifficulties()!
var diffMap:Map<String, Int> = new Map<String, Int>();
for (difficulty in difficulties)
{
var num:Int = 0;
switch (difficulty)
{
case 'easy':
num = 0;
case 'normal':
num = 1;
case 'hard':
num = 2;
case 'erect':
num = 3;
case 'nightmare':
num = 4;
}
diffMap.set(difficulty, num);
}
difficulties.sort(function(a:String, b:String) {
return diffMap.get(a) - diffMap.get(b);
});
// Filter to only include difficulties that are present in all songs
for (songIndex in 1...songList.length)
{