From b3ebc4365f494e45c61a3fd8211661d59773a290 Mon Sep 17 00:00:00 2001 From: George FunBook <gkurelic@gmail.com> Date: Mon, 8 Feb 2021 20:43:17 -0600 Subject: [PATCH] move files to libraries --- Project.xml | 92 ++++++++++++++++++++++++++++++++++++++++----- source/Paths.hx | 41 +++++++++++++++----- source/PlayState.hx | 5 ++- 3 files changed, 118 insertions(+), 20 deletions(-) diff --git a/Project.xml b/Project.xml index 498368897..7e61c7e09 100644 --- a/Project.xml +++ b/Project.xml @@ -40,18 +40,92 @@ <classpath name="source" /> - <assets path="assets/images" /> - <assets path="assets/data" /> + <assets path="assets/preload" rename="assets" exclude="*.ogg" if="web"/> + <assets path="assets/preload" rename="assets" exclude="*.mp3" unless="web"/> + + <library name="shared" preload="true" /> + <assets path="assets/shared" library="shared" exclude="*.ogg" if="web"/> + <assets path="assets/shared" library="shared" exclude="*.mp3" unless="web"/> + + <library name="blammed" preload="true" /> + <assets path="assets/blammed" library="blammed" exclude="*.ogg" if="web"/> + <assets path="assets/blammed" library="blammed" exclude="*.mp3" unless="web"/> + + <library name="bopeebo" preload="true" /> + <assets path="assets/bopeebo" library="bopeebo" exclude="*.ogg" if="web"/> + <assets path="assets/bopeebo" library="bopeebo" exclude="*.mp3" unless="web"/> + + <library name="cocoa" preload="true" /> + <assets path="assets/cocoa" library="cocoa" exclude="*.ogg" if="web"/> + <assets path="assets/cocoa" library="cocoa" exclude="*.mp3" unless="web"/> + + <library name="dadbattle" preload="true" /> + <assets path="assets/dadbattle" library="dadbattle" exclude="*.ogg" if="web"/> + <assets path="assets/dadbattle" library="dadbattle" exclude="*.mp3" unless="web"/> + + <library name="eggnog" preload="true" /> + <assets path="assets/eggnog" library="eggnog" exclude="*.ogg" if="web"/> + <assets path="assets/eggnog" library="eggnog" exclude="*.mp3" unless="web"/> + + <library name="fresh" preload="true" /> + <assets path="assets/fresh" library="fresh" exclude="*.ogg" if="web"/> + <assets path="assets/fresh" library="fresh" exclude="*.mp3" unless="web"/> + + <library name="high" preload="true" /> + <assets path="assets/high" library="high" exclude="*.ogg" if="web"/> + <assets path="assets/high" library="high" exclude="*.mp3" unless="web"/> + + <library name="milf" preload="true" /> + <assets path="assets/milf" library="milf" exclude="*.ogg" if="web"/> + <assets path="assets/milf" library="milf" exclude="*.mp3" unless="web"/> + + <library name="monster" preload="true" /> + <assets path="assets/monster" library="monster" exclude="*.ogg" if="web"/> + <assets path="assets/monster" library="monster" exclude="*.mp3" unless="web"/> + + <library name="pico" preload="true" /> + <assets path="assets/pico" library="pico" exclude="*.ogg" if="web"/> + <assets path="assets/pico" library="pico" exclude="*.mp3" unless="web"/> + + <library name="roses" preload="true" /> + <assets path="assets/roses" library="roses" exclude="*.ogg" if="web"/> + <assets path="assets/roses" library="roses" exclude="*.mp3" unless="web"/> + + <library name="satin-panties" preload="true" /> + <assets path="assets/satin-panties" library="satin-panties" exclude="*.ogg" if="web"/> + <assets path="assets/satin-panties" library="satin-panties" exclude="*.mp3" unless="web"/> + + <library name="senpai" preload="true" /> + <assets path="assets/senpai" library="senpai" exclude="*.ogg" if="web"/> + <assets path="assets/senpai" library="senpai" exclude="*.mp3" unless="web"/> + + <library name="south" preload="true" /> + <assets path="assets/south" library="south" exclude="*.ogg" if="web"/> + <assets path="assets/south" library="south" exclude="*.mp3" unless="web"/> + + <library name="spookeez" preload="true" /> + <assets path="assets/spookeez" library="spookeez" exclude="*.ogg" if="web"/> + <assets path="assets/spookeez" library="spookeez" exclude="*.mp3" unless="web"/> + + <library name="test" preload="true" /> + <assets path="assets/test" library="test" exclude="*.ogg" if="web"/> + <assets path="assets/test" library="test" exclude="*.mp3" unless="web"/> + + <library name="thorns" preload="true" /> + <assets path="assets/thorns" library="thorns" exclude="*.ogg" if="web"/> + <assets path="assets/thorns" library="thorns" exclude="*.mp3" unless="web"/> + + <library name="tutorial" preload="true" /> + <assets path="assets/tutorial" library="tutorial" exclude="*.ogg" if="web"/> + <assets path="assets/tutorial" library="tutorial" exclude="*.mp3" unless="web"/> + + <library name="winter-horrorland" preload="true" /> + <assets path="assets/winter-horrorland" library="winter-horrorland" exclude="*.ogg" if="web"/> + <assets path="assets/winter-horrorland" library="winter-horrorland" exclude="*.mp3" unless="web"/> + <assets path='example_mods' rename='mods' embed='false'/> <!-- <template path='mods' /> --> - <!-- <library name="noPreload" preload='false'/> --> - <!-- <library name="noPreload"/> --> - <assets path="assets/music" include="*.mp3" if="web"/> - <assets path="assets/music" include="*.ogg" unless="web"/> - <assets path="assets/sounds" include="*.mp3" if="web" /> - <assets path="assets/sounds" include="*.ogg" unless="web" /> - <assets path="CHANGELOG.md"/> <!-- NOTE FOR FUTURE SELF SINCE FONTS ARE ALWAYS FUCKY diff --git a/source/Paths.hx b/source/Paths.hx index 90f3f914d..8ec0fc46e 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -1,6 +1,7 @@ package; import openfl.utils.Assets as OpenFlAssets; +import openfl.utils.AssetType; import flixel.FlxG; import flixel.graphics.frames.FlxAtlasFrames; @@ -11,33 +12,55 @@ class Paths static var currentLevel:String; - static public function file(file:String) + static public function setCurrentLevel(name:String) { - var path = 'assets/$file'; - if (currentLevel != null && OpenFlAssets.exists('$currentLevel:$path')) - return '$currentLevel:$path'; + currentLevel = name.toLowerCase(); + } + + static function getPath(file:String, type:AssetType) + { + if (currentLevel != null) + { + var levelPath = getLibraryPath(currentLevel, file); + if (OpenFlAssets.exists(levelPath, type)) + return levelPath; + + levelPath = getLibraryPath("shared", file); + if (OpenFlAssets.exists(levelPath, type)) + return levelPath; + } - return path; + return 'assets/$file'; + } + + inline static function getLibraryPath(library:String, file:String) + { + return '$library:assets/$library/$file'; + } + + inline static public function file(file:String, type:AssetType = TEXT) + { + return getPath(file, type); } inline static public function sound(key:String) { - return file('sounds/$key.$SOUND_EXT'); + return getPath('sounds/$key.$SOUND_EXT', SOUND); } inline static public function soundRandom(key:String, min:Int, max:Int) { - return file('sounds/$key${FlxG.random.int(min, max)}.$SOUND_EXT'); + return getPath('sounds/$key${FlxG.random.int(min, max)}.$SOUND_EXT', SOUND); } inline static public function music(key:String) { - return file('music/$key.$SOUND_EXT'); + return getPath('music/$key.$SOUND_EXT', MUSIC); } inline static public function image(key:String) { - return file('images/$key.png'); + return getPath('images/$key.png', IMAGE); } inline static public function getSparrowAtlas(key:String) diff --git a/source/PlayState.hx b/source/PlayState.hx index 5536c9225..733bc158c 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -139,6 +139,7 @@ class PlayState extends MusicBeatState if (SONG == null) SONG = Song.loadFromJson('tutorial'); + Paths.setCurrentLevel(SONG.song); Conductor.changeBPM(SONG.bpm); @@ -968,7 +969,7 @@ class PlayState extends MusicBeatState lastReportedPlayheadPosition = 0; if (!paused) - FlxG.sound.playMusic(Paths.music(SONG.song + "_Inst"), 1, false); + FlxG.sound.playMusic(Paths.music("Inst"), 1, false); FlxG.sound.music.onComplete = endSong; vocals.play(); } @@ -985,7 +986,7 @@ class PlayState extends MusicBeatState curSong = songData.song; if (SONG.needsVoices) - vocals = new FlxSound().loadEmbedded(Paths.music(curSong + "_Voices")); + vocals = new FlxSound().loadEmbedded(Paths.music("Voices")); else vocals = new FlxSound();