fix preloaded versions
This commit is contained in:
parent
8b53e0c0b9
commit
da69d16d80
13
Project.xml
13
Project.xml
|
@ -40,12 +40,14 @@
|
|||
|
||||
<classpath name="source" />
|
||||
|
||||
<assets path="assets/preload" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/preload" exclude="*.mp3" unless="web"/>
|
||||
<assets path="assets/preload" rename="assets" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/preload" rename="assets" exclude="*.mp3" unless="web"/>
|
||||
|
||||
<!-- <define name="PRELOAD_ALL" /> -->
|
||||
<define name="PRELOAD_ALL" unless="web" />
|
||||
<define name="NO_PRELOAD_ALL" unless="PRELOAD_ALL"/>
|
||||
|
||||
<section if="PREELOAD_ALL">
|
||||
<section if="PRELOAD_ALL">
|
||||
<library name="songs" preload="true" />
|
||||
<library name="shared" preload="true" />
|
||||
<library name="tutorial" preload="true" />
|
||||
|
@ -57,7 +59,7 @@
|
|||
<library name="week6" preload="true" />
|
||||
</section>
|
||||
|
||||
<section unless="PREELOAD_ALL">
|
||||
<section if="NO_PRELOAD_ALL">
|
||||
<library name="songs" preload="false" />
|
||||
<library name="shared" preload="false" />
|
||||
<library name="tutorial" preload="false" />
|
||||
|
@ -112,7 +114,8 @@
|
|||
<haxelib name="flixel-ui" />
|
||||
<haxelib name="newgrounds"/>
|
||||
<haxelib name="faxe" if='switch'/>
|
||||
<haxelib name="polymod" unless="web"/>
|
||||
<haxelib name="polymod"/>
|
||||
<!-- <haxelib name="hxcpp-debug-server" if="desktop"/> -->
|
||||
|
||||
<!-- <haxelib name="markdown" /> -->
|
||||
<!-- <haxelib name="HtmlParser" /> -->
|
||||
|
|
|
@ -152,7 +152,7 @@ class LoadingState extends MusicBeatState
|
|||
static function getNextState(target:FlxState, stopMusic = false):FlxState
|
||||
{
|
||||
Paths.setCurrentLevel("week" + PlayState.storyWeek);
|
||||
#if js
|
||||
#if NO_PRELOAD_ALL
|
||||
var loaded = isSoundLoaded(getSongPath())
|
||||
&& (!PlayState.SONG.needsVoices || isSoundLoaded(getVocalPath()))
|
||||
&& isLibraryLoaded("shared");
|
||||
|
@ -166,7 +166,7 @@ class LoadingState extends MusicBeatState
|
|||
return target;
|
||||
}
|
||||
|
||||
#if js
|
||||
#if NO_PRELOAD_ALL
|
||||
static function isSoundLoaded(path:String):Bool
|
||||
{
|
||||
return Assets.cache.hasSound(path);
|
||||
|
|
|
@ -17,60 +17,78 @@ class Paths
|
|||
currentLevel = name.toLowerCase();
|
||||
}
|
||||
|
||||
static function getPath(file:String, type:AssetType)
|
||||
static function getPath(file:String, type:AssetType, library:Null<String>)
|
||||
{
|
||||
if (library != null)
|
||||
return getLibraryPath(file, library);
|
||||
|
||||
if (currentLevel != null)
|
||||
{
|
||||
var levelPath = getLibraryPath(currentLevel, file);
|
||||
var levelPath = getLibraryPathForce(file, currentLevel);
|
||||
if (OpenFlAssets.exists(levelPath, type))
|
||||
return levelPath;
|
||||
|
||||
levelPath = getLibraryPath("shared", file);
|
||||
levelPath = getLibraryPathForce(file, "shared");
|
||||
if (OpenFlAssets.exists(levelPath, type))
|
||||
return levelPath;
|
||||
}
|
||||
|
||||
return 'assets/preload/$file';
|
||||
return getPreloadPath(file);
|
||||
}
|
||||
|
||||
inline static function getLibraryPath(library:String, file:String)
|
||||
static public function getLibraryPath(file:String, library = "preload")
|
||||
{
|
||||
return if (library == "preload" || library == "default")
|
||||
getPreloadPath(file);
|
||||
else
|
||||
getLibraryPathForce(file, library);
|
||||
}
|
||||
|
||||
inline static function getLibraryPathForce(file:String, library:String)
|
||||
{
|
||||
|
||||
return '$library:assets/$library/$file';
|
||||
}
|
||||
|
||||
inline static public function file(file:String, type:AssetType = TEXT)
|
||||
inline static function getPreloadPath(file:String)
|
||||
{
|
||||
return getPath(file, type);
|
||||
|
||||
return 'assets/$file';
|
||||
}
|
||||
|
||||
inline static public function txt(key:String)
|
||||
inline static public function file(file:String, type:AssetType = TEXT, ?library:String)
|
||||
{
|
||||
return getPath('data/$key.txt', TEXT);
|
||||
return getPath(file, type, library);
|
||||
}
|
||||
|
||||
inline static public function xml(key:String)
|
||||
inline static public function txt(key:String, ?library:String)
|
||||
{
|
||||
return getPath('data/$key.xml', TEXT);
|
||||
return getPath('data/$key.txt', TEXT, library);
|
||||
}
|
||||
|
||||
inline static public function json(key:String)
|
||||
inline static public function xml(key:String, ?library:String)
|
||||
{
|
||||
return getPath('data/$key.json', TEXT);
|
||||
return getPath('data/$key.xml', TEXT, library);
|
||||
}
|
||||
|
||||
static public function sound(key:String)
|
||||
inline static public function json(key:String, ?library:String)
|
||||
{
|
||||
return getPath('sounds/$key.$SOUND_EXT', SOUND);
|
||||
return getPath('data/$key.json', TEXT, library);
|
||||
}
|
||||
|
||||
inline static public function soundRandom(key:String, min:Int, max:Int)
|
||||
static public function sound(key:String, ?library:String)
|
||||
{
|
||||
return sound(key + FlxG.random.int(min, max));
|
||||
return getPath('sounds/$key.$SOUND_EXT', SOUND, library);
|
||||
}
|
||||
|
||||
inline static public function music(key:String)
|
||||
inline static public function soundRandom(key:String, min:Int, max:Int, ?library:String)
|
||||
{
|
||||
return getPath('music/$key.$SOUND_EXT', MUSIC);
|
||||
return sound(key + FlxG.random.int(min, max), library);
|
||||
}
|
||||
|
||||
inline static public function music(key:String, ?library:String)
|
||||
{
|
||||
return getPath('music/$key.$SOUND_EXT', MUSIC, library);
|
||||
}
|
||||
|
||||
inline static public function voices(song:String)
|
||||
|
@ -83,9 +101,9 @@ class Paths
|
|||
return 'songs:assets/songs/${song.toLowerCase()}/Inst.$SOUND_EXT';
|
||||
}
|
||||
|
||||
inline static public function image(key:String)
|
||||
inline static public function image(key:String, ?library:String)
|
||||
{
|
||||
return getPath('images/$key.png', IMAGE);
|
||||
return getPath('images/$key.png', IMAGE, library);
|
||||
}
|
||||
|
||||
inline static public function font(key:String)
|
||||
|
@ -93,13 +111,13 @@ class Paths
|
|||
return 'assets/fonts/$key';
|
||||
}
|
||||
|
||||
inline static public function getSparrowAtlas(key:String)
|
||||
inline static public function getSparrowAtlas(key:String, ?library:String)
|
||||
{
|
||||
return FlxAtlasFrames.fromSparrow(image(key), file('images/$key.xml'));
|
||||
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
|
||||
}
|
||||
|
||||
inline static public function getPackerAtlas(key:String)
|
||||
inline static public function getPackerAtlas(key:String, ?library:String)
|
||||
{
|
||||
return FlxAtlasFrames.fromSpriteSheetPacker(image(key), file('images/$key.txt'));
|
||||
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue