Small Cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user