move files to libraries

This commit is contained in:
George FunBook
2021-02-08 20:43:17 -06:00
parent d16091dc24
commit 2a559f1750
428 changed files with 118 additions and 20 deletions

View File

@ -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)

View File

@ -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();