mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-28 07:56:46 +00:00
Additional cleanup on difficulty sort order (tested and working!)
This commit is contained in:
parent
6888e7b122
commit
6cb8a719af
|
@ -1,5 +1,6 @@
|
|||
package funkin.play.song;
|
||||
|
||||
import funkin.util.SortUtil;
|
||||
import flixel.sound.FlxSound;
|
||||
import openfl.utils.Assets;
|
||||
import funkin.modding.events.ScriptEvent;
|
||||
|
@ -252,32 +253,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
|||
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);
|
||||
});
|
||||
diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST));
|
||||
|
||||
return diffFiltered;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package funkin.ui.story;
|
||||
|
||||
import funkin.util.SortUtil;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.play.song.Song;
|
||||
|
@ -155,31 +156,7 @@ 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);
|
||||
});
|
||||
difficulties.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST));
|
||||
|
||||
// Filter to only include difficulties that are present in all songs
|
||||
for (songIndex in 1...songList.length)
|
||||
|
|
|
@ -121,6 +121,11 @@ class Constants
|
|||
*/
|
||||
public static final DEFAULT_DIFFICULTY:String = 'normal';
|
||||
|
||||
/**
|
||||
* Default list of difficulties for charts.
|
||||
*/
|
||||
public static final DEFAULT_DIFFICULTY_LIST:Array<String> = ['easy', 'normal', 'hard'];
|
||||
|
||||
/**
|
||||
* Default player character for charts.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue