diff --git a/source/funkin/backend/assets/AssetPaths.hx b/source/funkin/backend/assets/AssetPaths.hx deleted file mode 100644 index 01cdcaac..00000000 --- a/source/funkin/backend/assets/AssetPaths.hx +++ /dev/null @@ -1,71 +0,0 @@ -// UNUSED - -package funkin.backend.assets; - -/** - * { - "characterXML": "data/characters/{0}.xml", - "characterScript": "data/characters/{0}", - "config": "data/config/", - "dialogueBoxes": "data/dialogue/boxes/", - "dialogueCharacters": "data/dialogue/characters/", - "globalChartScripts": "data/charts/", - "splashData": "data/splashes/{0}.xml", - "stageXML": "data/stages/{0}.xml", - "stageScript": "data/stages/{0}", - "titleIntroText": "data/titlescreen/introText.txt", - "weekList": "data/weeks/weeks.txt", - "weekData": "data/weeks/weeks/{0}.xml", - "weekCharacterData": "data/weeks/characters/{0}.xml", - "noteTypeScript": "data/notes/{0}", - "stateScript": "data/states/{0}", - "globalScript": "data/global", - - "txt": "data/{0}.txt", - "ini": "data/{0}.ini", - "fragShader": "shaders/{0}.frag", - "vertShader": "shaders/{0}.vert", - "xml": "data/{0}.xml", - "json": "data/{0}.json", - "ps1": "data/{0}.ps1", - "sound": "sounds/{0}.{1}", - "music": "music/{0}.{1}", - "image": "images/{0}", - - "instDefault": "songs/{0}/song/Inst.{1}", - "instDifficulty": "songs/{0}/song/Inst-{1}.{2}", - "voicesDefault": "songs/{0}/song/Voices.{1}", - "voicesDifficulty": "songs/{0}/song/Voices-{1}.{2}" - } - */ -/** - Static class containing all of the paths for every different feature of the engine. -**/ -@:final -class AssetPaths { - /**ยจ - Path to the data folder. Used by Paths functions. - **/ - public static final data:AssetString = "assets/data/"; - public static final characters:AssetString = "assets/data/characters/"; - public static final config:AssetString = "assets/data/config/"; - public static final dialogueBoxes:AssetString = "assets/data/dialogue/boxes/"; - public static final dialogueCharacters:AssetString = "assets/data/dialogue/characters/"; - public static final globalChartScripts:AssetString = "assets/data/charts/"; - public static final splashes:AssetString = "assets/data/splashes/"; - public static final stages:AssetString = "assets/data/stages/"; - public static final titleIntroText:AssetString = "assets/data/titlescreen/introText.txt"; - public static final weeksData:AssetString = "assets/data/weeks/weeks.txt"; -} - -abstract AssetString(String) from String to String { - public inline function format(values:Array) { - var str = this; - var i = 0; - while(str.contains('{$i}')) { - str = str.replace('{$i}', values[i]); - i++; - } - return str; - } -} \ No newline at end of file diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index b284258d..2d7c0c75 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -161,6 +161,8 @@ class Paths inline static public function getPackerAtlasAlt(key:String) return FlxAtlasFrames.fromSpriteSheetPacker('$key.png', '$key.txt'); + inline static public function getAssetsRoot():String + return ModsFolder.currentModFolder != null ? '${ModsFolder.modsPath}${ModsFolder.currentModFolder}' : './assets'; /** * Gets frames at specified path. diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index a1c2ae60..4f9ade4f 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -462,7 +462,6 @@ class Charter extends UIState { super.destroy(); } - var instPath:String; public function loadSong() { if (__reload) { EventsData.reloadEvents(); @@ -471,7 +470,7 @@ class Charter extends UIState { Conductor.setupSong(PlayState.SONG); - FlxG.sound.setMusic(FlxG.sound.load(instPath = Paths.inst(__song, __diff))); + FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(__song, __diff))); vocals = FlxG.sound.load(Paths.voices(__song, __diff)); vocals.group = FlxG.sound.defaultMusicGroup; @@ -1020,12 +1019,8 @@ class Charter extends UIState { function _file_save(_) { #if sys - for(assetPath in [Paths.chart(__song, __diff.toLowerCase()), instPath]) { - var path = Assets.getPath(assetPath); - var filteredPath = path.substr(0, path.lastIndexOf(assetPath == instPath ? '/song/' : '/charts/')); - saveTo(filteredPath); - return; - } + saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase().replace("-", " ")}'); + return; #end _file_saveas(_); } @@ -1038,11 +1033,8 @@ class Charter extends UIState { function _file_meta_save(_) { #if sys - var metaPath = Paths.file('songs/${__song.toLowerCase()}/meta.json'); - var metaDiffPath = Paths.file('songs/${__song.toLowerCase()}/meta-${__diff.toLowerCase()}.json'); - sys.io.File.saveContent( - Assets.getPath(Assets.exists(metaDiffPath) ? metaDiffPath : metaPath), + '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase().replace("-", " ")}/meta.json', Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t") ); return; diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index 9f5d3d78..e7d2277f 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -92,7 +92,7 @@ class CharterSelection extends EditorTreeMenu { public function saveSong(creation:SongCreationData) { // Paths - var songsDir:String = ModsFolder.currentModFolder != null ? '${ModsFolder.modsPath}${ModsFolder.currentModFolder}/songs/' : './assets/songs/'; + var songsDir:String = '${Paths.getAssetsRoot()}/songs/'; var songFolder:String = '$songsDir${creation.meta.name.replace("-", " ")}'; #if sys