diff --git a/Project.xml b/Project.xml
index 7e61c7e09..80f5bc764 100644
--- a/Project.xml
+++ b/Project.xml
@@ -43,86 +43,40 @@
-
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/assets/monster/music/Monster.mp3 b/assets/exclude/Monster.mp3
similarity index 100%
rename from assets/monster/music/Monster.mp3
rename to assets/exclude/Monster.mp3
diff --git a/assets/monster/music/Monster.ogg b/assets/exclude/Monster.ogg
similarity index 100%
rename from assets/monster/music/Monster.ogg
rename to assets/exclude/Monster.ogg
diff --git a/assets/spookeez/music/Spookeez.mp3 b/assets/exclude/Spookeez.mp3
similarity index 100%
rename from assets/spookeez/music/Spookeez.mp3
rename to assets/exclude/Spookeez.mp3
diff --git a/assets/spookeez/music/Spookeez.ogg b/assets/exclude/Spookeez.ogg
similarity index 100%
rename from assets/spookeez/music/Spookeez.ogg
rename to assets/exclude/Spookeez.ogg
diff --git a/assets/blammed/music/Inst.mp3 b/assets/songs/blammed/Inst.mp3
similarity index 100%
rename from assets/blammed/music/Inst.mp3
rename to assets/songs/blammed/Inst.mp3
diff --git a/assets/blammed/music/Inst.ogg b/assets/songs/blammed/Inst.ogg
similarity index 100%
rename from assets/blammed/music/Inst.ogg
rename to assets/songs/blammed/Inst.ogg
diff --git a/assets/blammed/music/Voices.mp3 b/assets/songs/blammed/Voices.mp3
similarity index 100%
rename from assets/blammed/music/Voices.mp3
rename to assets/songs/blammed/Voices.mp3
diff --git a/assets/blammed/music/Voices.ogg b/assets/songs/blammed/Voices.ogg
similarity index 100%
rename from assets/blammed/music/Voices.ogg
rename to assets/songs/blammed/Voices.ogg
diff --git a/assets/bopeebo/music/Inst.mp3 b/assets/songs/bopeebo/Inst.mp3
similarity index 100%
rename from assets/bopeebo/music/Inst.mp3
rename to assets/songs/bopeebo/Inst.mp3
diff --git a/assets/bopeebo/music/Inst.ogg b/assets/songs/bopeebo/Inst.ogg
similarity index 100%
rename from assets/bopeebo/music/Inst.ogg
rename to assets/songs/bopeebo/Inst.ogg
diff --git a/assets/bopeebo/music/Voices.mp3 b/assets/songs/bopeebo/Voices.mp3
similarity index 100%
rename from assets/bopeebo/music/Voices.mp3
rename to assets/songs/bopeebo/Voices.mp3
diff --git a/assets/bopeebo/music/Voices.ogg b/assets/songs/bopeebo/Voices.ogg
similarity index 100%
rename from assets/bopeebo/music/Voices.ogg
rename to assets/songs/bopeebo/Voices.ogg
diff --git a/assets/cocoa/music/Inst.mp3 b/assets/songs/cocoa/Inst.mp3
similarity index 100%
rename from assets/cocoa/music/Inst.mp3
rename to assets/songs/cocoa/Inst.mp3
diff --git a/assets/cocoa/music/Inst.ogg b/assets/songs/cocoa/Inst.ogg
similarity index 100%
rename from assets/cocoa/music/Inst.ogg
rename to assets/songs/cocoa/Inst.ogg
diff --git a/assets/cocoa/music/Voices.mp3 b/assets/songs/cocoa/Voices.mp3
similarity index 100%
rename from assets/cocoa/music/Voices.mp3
rename to assets/songs/cocoa/Voices.mp3
diff --git a/assets/cocoa/music/Voices.ogg b/assets/songs/cocoa/Voices.ogg
similarity index 100%
rename from assets/cocoa/music/Voices.ogg
rename to assets/songs/cocoa/Voices.ogg
diff --git a/assets/dadbattle/music/Inst.mp3 b/assets/songs/dadbattle/Inst.mp3
similarity index 100%
rename from assets/dadbattle/music/Inst.mp3
rename to assets/songs/dadbattle/Inst.mp3
diff --git a/assets/dadbattle/music/Inst.ogg b/assets/songs/dadbattle/Inst.ogg
similarity index 100%
rename from assets/dadbattle/music/Inst.ogg
rename to assets/songs/dadbattle/Inst.ogg
diff --git a/assets/dadbattle/music/Voices.mp3 b/assets/songs/dadbattle/Voices.mp3
similarity index 100%
rename from assets/dadbattle/music/Voices.mp3
rename to assets/songs/dadbattle/Voices.mp3
diff --git a/assets/dadbattle/music/Voices.ogg b/assets/songs/dadbattle/Voices.ogg
similarity index 100%
rename from assets/dadbattle/music/Voices.ogg
rename to assets/songs/dadbattle/Voices.ogg
diff --git a/assets/eggnog/music/Inst.mp3 b/assets/songs/eggnog/Inst.mp3
similarity index 100%
rename from assets/eggnog/music/Inst.mp3
rename to assets/songs/eggnog/Inst.mp3
diff --git a/assets/eggnog/music/Inst.ogg b/assets/songs/eggnog/Inst.ogg
similarity index 100%
rename from assets/eggnog/music/Inst.ogg
rename to assets/songs/eggnog/Inst.ogg
diff --git a/assets/eggnog/music/Voices.mp3 b/assets/songs/eggnog/Voices.mp3
similarity index 100%
rename from assets/eggnog/music/Voices.mp3
rename to assets/songs/eggnog/Voices.mp3
diff --git a/assets/eggnog/music/Voices.ogg b/assets/songs/eggnog/Voices.ogg
similarity index 100%
rename from assets/eggnog/music/Voices.ogg
rename to assets/songs/eggnog/Voices.ogg
diff --git a/assets/fresh/music/Inst.mp3 b/assets/songs/fresh/Inst.mp3
similarity index 100%
rename from assets/fresh/music/Inst.mp3
rename to assets/songs/fresh/Inst.mp3
diff --git a/assets/fresh/music/Inst.ogg b/assets/songs/fresh/Inst.ogg
similarity index 100%
rename from assets/fresh/music/Inst.ogg
rename to assets/songs/fresh/Inst.ogg
diff --git a/assets/fresh/music/Voices.mp3 b/assets/songs/fresh/Voices.mp3
similarity index 100%
rename from assets/fresh/music/Voices.mp3
rename to assets/songs/fresh/Voices.mp3
diff --git a/assets/fresh/music/Voices.ogg b/assets/songs/fresh/Voices.ogg
similarity index 100%
rename from assets/fresh/music/Voices.ogg
rename to assets/songs/fresh/Voices.ogg
diff --git a/assets/high/music/Inst.mp3 b/assets/songs/high/Inst.mp3
similarity index 100%
rename from assets/high/music/Inst.mp3
rename to assets/songs/high/Inst.mp3
diff --git a/assets/high/music/Inst.ogg b/assets/songs/high/Inst.ogg
similarity index 100%
rename from assets/high/music/Inst.ogg
rename to assets/songs/high/Inst.ogg
diff --git a/assets/high/music/Voices.mp3 b/assets/songs/high/Voices.mp3
similarity index 100%
rename from assets/high/music/Voices.mp3
rename to assets/songs/high/Voices.mp3
diff --git a/assets/high/music/Voices.ogg b/assets/songs/high/Voices.ogg
similarity index 100%
rename from assets/high/music/Voices.ogg
rename to assets/songs/high/Voices.ogg
diff --git a/assets/milf/music/Inst.mp3 b/assets/songs/milf/Inst.mp3
similarity index 100%
rename from assets/milf/music/Inst.mp3
rename to assets/songs/milf/Inst.mp3
diff --git a/assets/milf/music/Inst.ogg b/assets/songs/milf/Inst.ogg
similarity index 100%
rename from assets/milf/music/Inst.ogg
rename to assets/songs/milf/Inst.ogg
diff --git a/assets/milf/music/Voices.mp3 b/assets/songs/milf/Voices.mp3
similarity index 100%
rename from assets/milf/music/Voices.mp3
rename to assets/songs/milf/Voices.mp3
diff --git a/assets/milf/music/Voices.ogg b/assets/songs/milf/Voices.ogg
similarity index 100%
rename from assets/milf/music/Voices.ogg
rename to assets/songs/milf/Voices.ogg
diff --git a/assets/monster/music/Inst.mp3 b/assets/songs/monster/Inst.mp3
similarity index 100%
rename from assets/monster/music/Inst.mp3
rename to assets/songs/monster/Inst.mp3
diff --git a/assets/monster/music/Inst.ogg b/assets/songs/monster/Inst.ogg
similarity index 100%
rename from assets/monster/music/Inst.ogg
rename to assets/songs/monster/Inst.ogg
diff --git a/assets/monster/music/Voices.mp3 b/assets/songs/monster/Voices.mp3
similarity index 100%
rename from assets/monster/music/Voices.mp3
rename to assets/songs/monster/Voices.mp3
diff --git a/assets/monster/music/Voices.ogg b/assets/songs/monster/Voices.ogg
similarity index 100%
rename from assets/monster/music/Voices.ogg
rename to assets/songs/monster/Voices.ogg
diff --git a/assets/philly/music/Inst.mp3 b/assets/songs/philly/Inst.mp3
similarity index 100%
rename from assets/philly/music/Inst.mp3
rename to assets/songs/philly/Inst.mp3
diff --git a/assets/philly/music/Inst.ogg b/assets/songs/philly/Inst.ogg
similarity index 100%
rename from assets/philly/music/Inst.ogg
rename to assets/songs/philly/Inst.ogg
diff --git a/assets/philly/music/Voices.mp3 b/assets/songs/philly/Voices.mp3
similarity index 100%
rename from assets/philly/music/Voices.mp3
rename to assets/songs/philly/Voices.mp3
diff --git a/assets/philly/music/Voices.ogg b/assets/songs/philly/Voices.ogg
similarity index 100%
rename from assets/philly/music/Voices.ogg
rename to assets/songs/philly/Voices.ogg
diff --git a/assets/pico/music/Inst.mp3 b/assets/songs/pico/Inst.mp3
similarity index 100%
rename from assets/pico/music/Inst.mp3
rename to assets/songs/pico/Inst.mp3
diff --git a/assets/pico/music/Inst.ogg b/assets/songs/pico/Inst.ogg
similarity index 100%
rename from assets/pico/music/Inst.ogg
rename to assets/songs/pico/Inst.ogg
diff --git a/assets/pico/music/Voices.mp3 b/assets/songs/pico/Voices.mp3
similarity index 100%
rename from assets/pico/music/Voices.mp3
rename to assets/songs/pico/Voices.mp3
diff --git a/assets/pico/music/Voices.ogg b/assets/songs/pico/Voices.ogg
similarity index 100%
rename from assets/pico/music/Voices.ogg
rename to assets/songs/pico/Voices.ogg
diff --git a/assets/roses/music/Inst.mp3 b/assets/songs/roses/Inst.mp3
similarity index 100%
rename from assets/roses/music/Inst.mp3
rename to assets/songs/roses/Inst.mp3
diff --git a/assets/roses/music/Inst.ogg b/assets/songs/roses/Inst.ogg
similarity index 100%
rename from assets/roses/music/Inst.ogg
rename to assets/songs/roses/Inst.ogg
diff --git a/assets/roses/music/Voices.mp3 b/assets/songs/roses/Voices.mp3
similarity index 100%
rename from assets/roses/music/Voices.mp3
rename to assets/songs/roses/Voices.mp3
diff --git a/assets/roses/music/Voices.ogg b/assets/songs/roses/Voices.ogg
similarity index 100%
rename from assets/roses/music/Voices.ogg
rename to assets/songs/roses/Voices.ogg
diff --git a/assets/satin-panties/music/Inst.mp3 b/assets/songs/satin-panties/Inst.mp3
similarity index 100%
rename from assets/satin-panties/music/Inst.mp3
rename to assets/songs/satin-panties/Inst.mp3
diff --git a/assets/satin-panties/music/Inst.ogg b/assets/songs/satin-panties/Inst.ogg
similarity index 100%
rename from assets/satin-panties/music/Inst.ogg
rename to assets/songs/satin-panties/Inst.ogg
diff --git a/assets/satin-panties/music/Voices.mp3 b/assets/songs/satin-panties/Voices.mp3
similarity index 100%
rename from assets/satin-panties/music/Voices.mp3
rename to assets/songs/satin-panties/Voices.mp3
diff --git a/assets/satin-panties/music/Voices.ogg b/assets/songs/satin-panties/Voices.ogg
similarity index 100%
rename from assets/satin-panties/music/Voices.ogg
rename to assets/songs/satin-panties/Voices.ogg
diff --git a/assets/senpai/music/Inst.mp3 b/assets/songs/senpai/Inst.mp3
similarity index 100%
rename from assets/senpai/music/Inst.mp3
rename to assets/songs/senpai/Inst.mp3
diff --git a/assets/senpai/music/Inst.ogg b/assets/songs/senpai/Inst.ogg
similarity index 100%
rename from assets/senpai/music/Inst.ogg
rename to assets/songs/senpai/Inst.ogg
diff --git a/assets/senpai/music/Voices.mp3 b/assets/songs/senpai/Voices.mp3
similarity index 100%
rename from assets/senpai/music/Voices.mp3
rename to assets/songs/senpai/Voices.mp3
diff --git a/assets/senpai/music/Voices.ogg b/assets/songs/senpai/Voices.ogg
similarity index 100%
rename from assets/senpai/music/Voices.ogg
rename to assets/songs/senpai/Voices.ogg
diff --git a/assets/south/music/Inst.mp3 b/assets/songs/south/Inst.mp3
similarity index 100%
rename from assets/south/music/Inst.mp3
rename to assets/songs/south/Inst.mp3
diff --git a/assets/south/music/Inst.ogg b/assets/songs/south/Inst.ogg
similarity index 100%
rename from assets/south/music/Inst.ogg
rename to assets/songs/south/Inst.ogg
diff --git a/assets/south/music/Voices.mp3 b/assets/songs/south/Voices.mp3
similarity index 100%
rename from assets/south/music/Voices.mp3
rename to assets/songs/south/Voices.mp3
diff --git a/assets/south/music/Voices.ogg b/assets/songs/south/Voices.ogg
similarity index 100%
rename from assets/south/music/Voices.ogg
rename to assets/songs/south/Voices.ogg
diff --git a/assets/spookeez/music/Inst.mp3 b/assets/songs/spookeez/Inst.mp3
similarity index 100%
rename from assets/spookeez/music/Inst.mp3
rename to assets/songs/spookeez/Inst.mp3
diff --git a/assets/spookeez/music/Inst.ogg b/assets/songs/spookeez/Inst.ogg
similarity index 100%
rename from assets/spookeez/music/Inst.ogg
rename to assets/songs/spookeez/Inst.ogg
diff --git a/assets/spookeez/music/Voices.mp3 b/assets/songs/spookeez/Voices.mp3
similarity index 100%
rename from assets/spookeez/music/Voices.mp3
rename to assets/songs/spookeez/Voices.mp3
diff --git a/assets/spookeez/music/Voices.ogg b/assets/songs/spookeez/Voices.ogg
similarity index 100%
rename from assets/spookeez/music/Voices.ogg
rename to assets/songs/spookeez/Voices.ogg
diff --git a/assets/test/music/Inst.mp3 b/assets/songs/test/Inst.mp3
similarity index 100%
rename from assets/test/music/Inst.mp3
rename to assets/songs/test/Inst.mp3
diff --git a/assets/test/music/Inst.ogg b/assets/songs/test/Inst.ogg
similarity index 100%
rename from assets/test/music/Inst.ogg
rename to assets/songs/test/Inst.ogg
diff --git a/assets/test/music/Voices.mp3 b/assets/songs/test/Voices.mp3
similarity index 100%
rename from assets/test/music/Voices.mp3
rename to assets/songs/test/Voices.mp3
diff --git a/assets/test/music/Voices.ogg b/assets/songs/test/Voices.ogg
similarity index 100%
rename from assets/test/music/Voices.ogg
rename to assets/songs/test/Voices.ogg
diff --git a/assets/thorns/music/Inst.mp3 b/assets/songs/thorns/Inst.mp3
similarity index 100%
rename from assets/thorns/music/Inst.mp3
rename to assets/songs/thorns/Inst.mp3
diff --git a/assets/thorns/music/Inst.ogg b/assets/songs/thorns/Inst.ogg
similarity index 100%
rename from assets/thorns/music/Inst.ogg
rename to assets/songs/thorns/Inst.ogg
diff --git a/assets/thorns/music/Voices.mp3 b/assets/songs/thorns/Voices.mp3
similarity index 100%
rename from assets/thorns/music/Voices.mp3
rename to assets/songs/thorns/Voices.mp3
diff --git a/assets/thorns/music/Voices.ogg b/assets/songs/thorns/Voices.ogg
similarity index 100%
rename from assets/thorns/music/Voices.ogg
rename to assets/songs/thorns/Voices.ogg
diff --git a/assets/tutorial/music/Inst.mp3 b/assets/songs/tutorial/Inst.mp3
similarity index 100%
rename from assets/tutorial/music/Inst.mp3
rename to assets/songs/tutorial/Inst.mp3
diff --git a/assets/tutorial/music/Inst.ogg b/assets/songs/tutorial/Inst.ogg
similarity index 100%
rename from assets/tutorial/music/Inst.ogg
rename to assets/songs/tutorial/Inst.ogg
diff --git a/assets/winter-horrorland/music/Inst.mp3 b/assets/songs/winter-horrorland/Inst.mp3
similarity index 100%
rename from assets/winter-horrorland/music/Inst.mp3
rename to assets/songs/winter-horrorland/Inst.mp3
diff --git a/assets/winter-horrorland/music/Inst.ogg b/assets/songs/winter-horrorland/Inst.ogg
similarity index 100%
rename from assets/winter-horrorland/music/Inst.ogg
rename to assets/songs/winter-horrorland/Inst.ogg
diff --git a/assets/winter-horrorland/music/Voices.mp3 b/assets/songs/winter-horrorland/Voices.mp3
similarity index 100%
rename from assets/winter-horrorland/music/Voices.mp3
rename to assets/songs/winter-horrorland/Voices.mp3
diff --git a/assets/winter-horrorland/music/Voices.ogg b/assets/songs/winter-horrorland/Voices.ogg
similarity index 100%
rename from assets/winter-horrorland/music/Voices.ogg
rename to assets/songs/winter-horrorland/Voices.ogg
diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx
index a51c0c65a..c1f02ce07 100644
--- a/source/FreeplayState.hx
+++ b/source/FreeplayState.hx
@@ -198,9 +198,7 @@ class FreeplayState extends MusicBeatState
PlayState.SONG = Song.loadFromJson(poop, songs[curSelected].toLowerCase());
PlayState.isStoryMode = false;
PlayState.storyDifficulty = curDifficulty;
- FlxG.switchState(new PlayState());
- if (FlxG.sound.music != null)
- FlxG.sound.music.stop();
+ LoadingState.loadAndSwitchState(new PlayState());
}
}
diff --git a/source/GameOverState.hx b/source/GameOverState.hx
index ba7cb3472..57c60d1f9 100644
--- a/source/GameOverState.hx
+++ b/source/GameOverState.hx
@@ -74,7 +74,7 @@ class GameOverState extends FlxTransitionableState
FlxG.sound.music.fadeOut(0.5, 0, function(twn:FlxTween)
{
FlxG.sound.music.stop();
- FlxG.switchState(new PlayState());
+ LoadingState.loadAndSwitchState(new PlayState());
});
}
super.update(elapsed);
diff --git a/source/GameOverSubstate.hx b/source/GameOverSubstate.hx
index b403296eb..1d672dbf4 100644
--- a/source/GameOverSubstate.hx
+++ b/source/GameOverSubstate.hx
@@ -107,7 +107,7 @@ class GameOverSubstate extends MusicBeatSubstate
{
FlxG.camera.fade(FlxColor.BLACK, 2, false, function()
{
- FlxG.switchState(new PlayState());
+ LoadingState.loadAndSwitchState(new PlayState());
});
});
}
diff --git a/source/LoadingState.hx b/source/LoadingState.hx
new file mode 100644
index 000000000..64fb3c87f
--- /dev/null
+++ b/source/LoadingState.hx
@@ -0,0 +1,341 @@
+package;
+
+import flixel.FlxG;
+import flixel.FlxState;
+import flixel.FlxSprite;
+import flixel.graphics.frames.FlxAtlasFrames;
+import flixel.util.FlxTimer;
+
+import openfl.utils.Assets;
+import lime.utils.Assets as LimeAssets;
+import lime.utils.AssetBundle;
+import lime.utils.AssetLibrary;
+import lime.utils.AssetManifest;
+import lime.app.Future;
+import lime.app.Promise;
+
+import haxe.io.Path;
+
+class LoadingState extends MusicBeatState
+{
+ inline static var MIN_TIME = 1.0;
+
+ var target:FlxState;
+ var stopMusic = false;
+ var callbacks:MultiCallback;
+
+ var logo:FlxSprite;
+ var gfDance:FlxSprite;
+ var danceLeft = false;
+
+ function new(target:FlxState, stopMusic:Bool)
+ {
+ super();
+ this.target = target;
+ this.stopMusic = stopMusic;
+ }
+
+ override function create()
+ {
+ logo = new FlxSprite(-150, -100);
+ logo.frames = FlxAtlasFrames.fromSparrow('assets/images/logoBumpin.png', 'assets/images/logoBumpin.xml');
+ logo.antialiasing = true;
+ logo.animation.addByPrefix('bump', 'logo bumpin', 24);
+ logo.animation.play('bump');
+ logo.updateHitbox();
+ // logoBl.screenCenter();
+ // logoBl.color = FlxColor.BLACK;
+
+ gfDance = new FlxSprite(FlxG.width * 0.4, FlxG.height * 0.07);
+ gfDance.frames = FlxAtlasFrames.fromSparrow('assets/images/gfDanceTitle.png', 'assets/images/gfDanceTitle.xml');
+ gfDance.animation.addByIndices('danceLeft', 'gfDance', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
+ gfDance.animation.addByIndices('danceRight', 'gfDance', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
+ gfDance.antialiasing = true;
+ add(gfDance);
+ add(logo);
+
+ // function onSongsManifestInit()
+ // {
+ callbacks = new MultiCallback(onLoad);
+ var introComplete = callbacks.add("introComplete");
+ checkLoadSong(getSongPath());
+ checkLoadSong(getVocalPath());
+ checkLibrary("shared");
+ if (PlayState.storyWeek > 0)
+ checkLibrary("week" + PlayState.storyWeek);
+ else
+ checkLibrary("tutorial");
+
+ var fadeTime = 0.5;
+ FlxG.camera.fade(FlxG.camera.bgColor, fadeTime, true);
+ new FlxTimer().start(fadeTime + MIN_TIME, function(_) introComplete());
+ // }
+
+ // initSongsManifest(onSongsManifestInit);
+ }
+
+ function checkLoadSong(path:String)
+ {
+ if (!Assets.cache.hasSound(path))
+ {
+ var library = Assets.getLibrary("songs");
+ final symbolPath = path.split(":").pop();
+ @:privateAccess
+ library.types.set(symbolPath, SOUND);
+ @:privateAccess
+ library.pathGroups.set(symbolPath, [library.__cacheBreak(symbolPath)]);
+ var callback = callbacks.add("song:" + path);
+ Assets.loadSound(path).onComplete(function (_) { callback(); });
+ }
+ }
+
+ function checkLibrary(library:String)
+ {
+ if (Assets.getLibrary(library) == null)
+ {
+ var callback = callbacks.add("library:" + library);
+ Assets.loadLibrary(library).onComplete(function (_) { callback(); });
+ }
+ }
+
+ override function beatHit()
+ {
+ super.beatHit();
+
+ logo.animation.play('bump');
+ danceLeft = !danceLeft;
+
+ if (danceLeft)
+ gfDance.animation.play('danceRight');
+ else
+ gfDance.animation.play('danceLeft');
+ }
+
+ override function update(elapsed:Float)
+ {
+ super.update(elapsed);
+ }
+
+ function onLoad()
+ {
+ if (stopMusic && FlxG.sound.music != null)
+ FlxG.sound.music.stop();
+
+ FlxG.switchState(target);
+ }
+
+ static function getSongPath()
+ {
+ return Paths.inst(PlayState.SONG.song);
+ }
+
+ static function getVocalPath()
+ {
+ return Paths.voices(PlayState.SONG.song);
+ }
+
+ inline static public function loadAndSwitchState(target:FlxState, stopMusic = false)
+ {
+ FlxG.switchState(getNextState(target, stopMusic));
+ }
+
+ static function getNextState(target:FlxState, stopMusic = false):FlxState
+ {
+ #if js
+ var loaded = isSoundLoaded(getSongPath())
+ && (!PlayState.SONG.needsVoices || isSoundLoaded(getVocalPath()))
+ && isLibraryLoaded("shared");
+
+ if (!loaded)
+ return new LoadingState(target, stopMusic);
+ #end
+ if (stopMusic && FlxG.sound.music != null)
+ FlxG.sound.music.stop();
+
+ return target;
+ }
+
+ #if js
+ static function isSoundLoaded(path:String):Bool
+ {
+ return Assets.cache.hasSound(path);
+ }
+
+ static function isLibraryLoaded(library:String):Bool
+ {
+ return Assets.getLibrary(library) != null;
+ }
+ #end
+
+ override function destroy()
+ {
+ super.destroy();
+
+ callbacks = null;
+ }
+
+
+ /**
+ * creates the song manifest without loading all the songs so we can load them individually
+ * @param onComplete called on load
+ * @return Future
+ */
+ static function initSongsManifest(onComplete:Void->Void):Future
+ {
+ final id = "songs";
+ var promise = new Promise();
+
+ // #if (tools && !display && !macro)
+ var library = LimeAssets.getLibrary(id);
+
+ if (library != null)
+ {
+ onComplete();
+ return Future.withValue(library);
+ }
+
+ var path = id;
+ var rootPath = null;
+
+ // @:privateAccess
+ // if (LimeAssets.bundlePaths.exists(id))
+ // {
+ // AssetBundle.loadFromFile(bundlePaths.get(id)).onComplete(function(bundle)
+ // {
+ // if (bundle == null)
+ // {
+ // promise.error("Cannot load bundle for library \"" + id + "\"");
+ // return;
+ // }
+
+ // var library = AssetLibrary.fromBundle(bundle);
+
+ // if (library == null)
+ // {
+ // promise.error("Cannot open library \"" + id + "\"");
+ // }
+ // else
+ // {
+ // libraries.set(id, library);
+ // library.onChange.add(LimeAssets.onChange.dispatch);
+ // promise.completeWith(Future.withValue(library));
+ // onComplete();
+ // }
+ // }).onError(function(_)
+ // {
+ // promise.error("There is no asset library with an ID of \"" + id + "\"");
+ // });
+ // }
+ // else
+ // {
+ @:privateAccess
+ final libraryPaths = LimeAssets.libraryPaths;
+ if (libraryPaths.exists(id))
+ {
+ path = libraryPaths[id];
+ rootPath = Path.directory(path);
+ }
+ else
+ {
+ if (StringTools.endsWith(path, ".bundle"))
+ {
+ rootPath = path;
+ path += "/library.json";
+ }
+ else
+ {
+ rootPath = Path.directory(path);
+ }
+ @:privateAccess
+ path = LimeAssets.__cacheBreak(path);
+ }
+
+ AssetManifest.loadFromFile(path, rootPath).onComplete(function(manifest)
+ {
+ if (manifest == null)
+ {
+ promise.error("Cannot parse asset manifest for library \"" + id + "\"");
+ return;
+ }
+
+ var library = AssetLibrary.fromManifest(manifest);
+
+ if (library == null)
+ {
+ promise.error("Cannot open library \"" + id + "\"");
+ }
+ else
+ {
+ @:privateAccess
+ LimeAssets.libraries.set(id, library);
+ library.onChange.add(LimeAssets.onChange.dispatch);
+ promise.completeWith(Future.withValue(library));
+ onComplete();
+ }
+ }).onError(function(_)
+ {
+ promise.error("There is no asset library with an ID of \"" + id + "\"");
+ });
+ // }
+ // #end
+
+ return promise.future;
+ }
+}
+
+class MultiCallback
+{
+ public var callback:Void->Void;
+ public var logId:String = null;
+ public var length(default, null) = 0;
+ public var numRemaining(default, null) = 0;
+
+ var unfired = new MapVoid>();
+ var fired = new Array();
+
+ public function new (callback:Void->Void, logId:String = null)
+ {
+ this.callback = callback;
+ this.logId = logId;
+ }
+
+ public function add(id = "untitled")
+ {
+ id = '$length:$id';
+ length++;
+ numRemaining++;
+ var func:Void->Void = null;
+ func = function ()
+ {
+ if (unfired.exists(id))
+ {
+ unfired.remove(id);
+ fired.push(id);
+ numRemaining--;
+
+ if (logId != null)
+ log('fired $id, $numRemaining remaining');
+
+ if (numRemaining == 0)
+ {
+ if (logId != null)
+ log('all callbacks fired');
+ callback();
+ }
+ }
+ else
+ log('already fired $id');
+ }
+ unfired[id] = func;
+ return func;
+ }
+
+ inline function log(msg):Void
+ {
+ if (logId != null)
+ trace('$logId: $msg');
+ }
+
+ public function getFired() return fired.copy();
+ public function getUnfired() return [for (id in unfired) id];
+}
\ No newline at end of file
diff --git a/source/NGio.hx b/source/NGio.hx
index 96ced6257..3cf18cd23 100644
--- a/source/NGio.hx
+++ b/source/NGio.hx
@@ -41,7 +41,7 @@ class NGio
{
var call = NG.core.calls.app.getCurrentVersion(GAME_VER).addDataHandler(function(response:Response)
{
- GAME_VER = response.result.data.current_version;
+ GAME_VER = response.result.data.currentVersion;
trace('CURRENT NG VERSION: ' + GAME_VER);
gotOnlineVer = true;
});
diff --git a/source/Paths.hx b/source/Paths.hx
index 8ec0fc46e..4e2094c42 100644
--- a/source/Paths.hx
+++ b/source/Paths.hx
@@ -58,6 +58,16 @@ class Paths
return getPath('music/$key.$SOUND_EXT', MUSIC);
}
+ inline static public function voices(song:String)
+ {
+ return "songs:" + getPath('songs/${song.toLowerCase()}/Voices.$SOUND_EXT', MUSIC);
+ }
+
+ inline static public function inst(song:String)
+ {
+ return "songs:" + getPath('songs/${song.toLowerCase()}/Inst.$SOUND_EXT', MUSIC);
+ }
+
inline static public function image(key:String)
{
return getPath('images/$key.png', IMAGE);
diff --git a/source/PlayState.hx b/source/PlayState.hx
index 733bc158c..45149110e 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -969,7 +969,7 @@ class PlayState extends MusicBeatState
lastReportedPlayheadPosition = 0;
if (!paused)
- FlxG.sound.playMusic(Paths.music("Inst"), 1, false);
+ FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
FlxG.sound.music.onComplete = endSong;
vocals.play();
}
@@ -986,7 +986,7 @@ class PlayState extends MusicBeatState
curSong = songData.song;
if (SONG.needsVoices)
- vocals = new FlxSound().loadEmbedded(Paths.music("Voices"));
+ vocals = new FlxSound().loadEmbedded(Paths.voices(PlayState.SONG.song));
else
vocals = new FlxSound();
@@ -1675,7 +1675,7 @@ class PlayState extends MusicBeatState
PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + difficulty, PlayState.storyPlaylist[0]);
FlxG.sound.music.stop();
- FlxG.switchState(new PlayState());
+ LoadingState.loadAndSwitchState(new PlayState());
transIn = FlxTransitionableState.defaultTransIn;
transOut = FlxTransitionableState.defaultTransOut;
diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx
index 73f2d2c87..bd5f13e51 100644
--- a/source/StoryMenuState.hx
+++ b/source/StoryMenuState.hx
@@ -313,9 +313,7 @@ class StoryMenuState extends MusicBeatState
PlayState.campaignScore = 0;
new FlxTimer().start(1, function(tmr:FlxTimer)
{
- if (FlxG.sound.music != null)
- FlxG.sound.music.stop();
- FlxG.switchState(new PlayState());
+ LoadingState.loadAndSwitchState(new PlayState(), true);
});
}
}