diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index 125d4d93..174e758e 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -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; } diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index e801f18f..9527c1b1 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -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") { diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index d286d347..ecfd6156 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -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, ?lowercase:Bool=false) { array.sort(function(a1, a2):Int { if(lowercase) { diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 7639c367..1a5ad6c6 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -544,7 +544,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public static function getList(?mods:Bool = false):Array { 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) ]; } } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index a4de7511..790ce116 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -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); }