move songs to song folder and create libraries for each week
This commit is contained in:
parent
9005386825
commit
33a89712f8
98
Project.xml
98
Project.xml
|
@ -43,86 +43,40 @@
|
|||
<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" />
|
||||
<library name="songs" preload="false" />
|
||||
<assets path="assets/songs" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/songs" exclude="*.mp3" unless="web"/>
|
||||
|
||||
<library name="shared" preload="false" />
|
||||
<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="week1" preload="false" />
|
||||
<assets path="assets/week1" library="week1" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week1" library="week1" 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="week2" preload="false" />
|
||||
<assets path="assets/week2" library="week2" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week2" library="week2" 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="week3" preload="false" />
|
||||
<assets path="assets/week3" library="week3" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week3" library="week3" 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="week4" preload="false" />
|
||||
<assets path="assets/week4" library="week4" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week4" library="week4" 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"/>
|
||||
<!-- <library name="week5" preload="false" />
|
||||
<assets path="assets/week5" library="week5" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week5" library="week5" exclude="*.mp3" unless="web"/> -->
|
||||
|
||||
<!-- <library name="week6" preload="false" />
|
||||
<assets path="assets/week6" library="week6" exclude="*.ogg" if="web"/>
|
||||
<assets path="assets/week6" library="week6" exclude="*.mp3" unless="web"/> -->
|
||||
|
||||
|
||||
|
||||
<assets path='example_mods' rename='mods' embed='false'/>
|
||||
<!-- <template path='mods' /> -->
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -107,7 +107,7 @@ class GameOverSubstate extends MusicBeatSubstate
|
|||
{
|
||||
FlxG.camera.fade(FlxColor.BLACK, 2, false, function()
|
||||
{
|
||||
FlxG.switchState(new PlayState());
|
||||
LoadingState.loadAndSwitchState(new PlayState());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<AssetLibrary>
|
||||
*/
|
||||
static function initSongsManifest(onComplete:Void->Void):Future<AssetLibrary>
|
||||
{
|
||||
final id = "songs";
|
||||
var promise = new Promise<AssetLibrary>();
|
||||
|
||||
// #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 Map<String, Void->Void>();
|
||||
var fired = new Array<String>();
|
||||
|
||||
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];
|
||||
}
|
|
@ -41,7 +41,7 @@ class NGio
|
|||
{
|
||||
var call = NG.core.calls.app.getCurrentVersion(GAME_VER).addDataHandler(function(response:Response<GetCurrentVersionResult>)
|
||||
{
|
||||
GAME_VER = response.result.data.current_version;
|
||||
GAME_VER = response.result.data.currentVersion;
|
||||
trace('CURRENT NG VERSION: ' + GAME_VER);
|
||||
gotOnlineVer = true;
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue