Small Cleanup

This commit is contained in:
NeeEoo
2024-04-24 03:15:22 +02:00
parent be63e260e2
commit a04d93b7c3
5 changed files with 15 additions and 6 deletions
+2 -3
View File
@@ -97,13 +97,12 @@ class Paths
return getPath('images/$key.$ext', library);
}
inline static public function script(key:String, ?library:String, isAssetsPath:Bool = false) {
static public function script(key:String, ?library:String, isAssetsPath:Bool = false) {
var scriptPath = isAssetsPath ? key : getPath(key, library);
if (!OpenFlAssets.exists(scriptPath)) {
var p:String;
for(ex in Script.scriptExtensions) {
p = '$scriptPath.$ex';
if (OpenFlAssets.exists(p)) {
if (OpenFlAssets.exists(p = scriptPath + '.' + ex)) {
scriptPath = p;
break;
}
+1 -1
View File
@@ -76,7 +76,7 @@ class EventsData {
for (file in Paths.getFolderContent('data/events/', true, BOTH)) {
if (Path.extension(file) != "json" && Path.extension(file) != "pack") continue;
var eventName:String = Path.withoutExtension(Path.withoutDirectory(file));
var eventName:String = CoolUtil.getFilename(file);
var fileTxt:String = Assets.getText(file);
if (Path.extension(file) == "pack") {
+10
View File
@@ -719,6 +719,16 @@ class CoolUtil
@:noUsing public static inline function flxeaseFromString(mainEase:String, suffix:String)
return Reflect.field(FlxEase, mainEase + (mainEase == "linear" ? "" : suffix));
/*
* Returns the filename of a path, without the extension.
* @param path Path to get the filename from
* @return Filename
*/
@:noUsing public static inline function getFilename(file:String) {
var file = new haxe.io.Path(file);
return file.file;
}
public static function sortAlphabetically(array:Array<String>, ?lowercase:Bool=false) {
array.sort(function(a1, a2):Int {
if(lowercase) {
+1 -1
View File
@@ -544,7 +544,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public static function getList(?mods:Bool = false):Array<String> {
return [
for (path in Paths.getFolderContent('data/characters/', true, mods ? MODS : BOTH))
if (Path.extension(path) == "xml") Path.withoutDirectory(Path.withoutExtension(path))
if (Path.extension(path) == "xml") CoolUtil.getFilename(path)
];
}
}
+1 -1
View File
@@ -587,7 +587,7 @@ class PlayState extends MusicBeatState
for (event in SONG.events) songEvents.pushOnce(event.name);
for (file in Paths.getFolderContent('data/events/', true, fromMods ? MODS : BOTH)) {
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
var fileName:String = CoolUtil.getFilename(file);
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) {
addScript(file);
}