mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-05 06:14:36 +00:00
regexp filter
This commit is contained in:
parent
ce2e6a3993
commit
c469d4b7c0
|
@ -393,7 +393,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
case "ALL":
|
||||
generateSongList(null, true);
|
||||
default:
|
||||
generateSongList({filterType: STARTSWITH, filterData: str}, true);
|
||||
generateSongList({filterType: REGEXP, filterData: str}, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -477,6 +477,13 @@ class FreeplayState extends MusicBeatSubState
|
|||
{
|
||||
switch (filterStuff.filterType)
|
||||
{
|
||||
case REGEXP:
|
||||
// filterStuff.filterData has a string with the first letter of the sorting range, and the second one
|
||||
// this creates a filter to return all the songs that start with a letter between those two
|
||||
var filterRegexp = new EReg("^[" + filterStuff.filterData + "].*", "i");
|
||||
tempSongs = tempSongs.filter(str -> {
|
||||
return filterRegexp.match(str.songName);
|
||||
});
|
||||
case STARTSWITH:
|
||||
tempSongs = tempSongs.filter(str -> {
|
||||
return str.songName.toLowerCase().startsWith(filterStuff.filterData);
|
||||
|
@ -1045,6 +1052,7 @@ typedef SongFilter =
|
|||
enum abstract FilterType(String)
|
||||
{
|
||||
var STARTSWITH;
|
||||
var REGEXP;
|
||||
var FAVORITE;
|
||||
var ALL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue