diff --git a/Project.xml b/Project.xml
index e14e0ae0a..2d9dd802b 100644
--- a/Project.xml
+++ b/Project.xml
@@ -105,7 +105,7 @@
-
+
diff --git a/hmm.json b/hmm.json
index 9652d9440..f45a94b08 100644
--- a/hmm.json
+++ b/hmm.json
@@ -65,7 +65,7 @@
"version": "2.5.0"
},
{
- "name": "hxcodec",
+ "name": "hxCodec",
"type": "git",
"dir": null,
"ref": "c42ab99",
diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx
index 77af6b7f6..e31b6d501 100644
--- a/source/funkin/Conductor.hx
+++ b/source/funkin/Conductor.hx
@@ -50,6 +50,16 @@ class Conductor
// OLD, replaced with timeChanges.
public static var bpmChangeMap:Array = [];
+ /**
+ * Duration of a measure in milliseconds. Calculated based on bpm.
+ */
+ public static var measureLengthMs(get, null):Float;
+
+ static function get_measureLengthMs():Float
+ {
+ return crochet * timeSignatureNumerator;
+ }
+
/**
* Duration of a beat in millisecond. Calculated based on bpm.
*/
diff --git a/source/funkin/CoolUtil.hx b/source/funkin/CoolUtil.hx
index 7d7201029..93fa937da 100644
--- a/source/funkin/CoolUtil.hx
+++ b/source/funkin/CoolUtil.hx
@@ -20,13 +20,6 @@ import openfl.filters.ShaderFilter;
class CoolUtil
{
- public static var difficultyArray:Array = ['EASY', "NORMAL", "HARD"];
-
- public static function difficultyString():String
- {
- return difficultyArray[PlayState.storyDifficulty];
- }
-
public static function coolBaseLog(base:Float, fin:Float):Float
{
return Math.log(fin) / Math.log(base);
diff --git a/source/funkin/CutsceneAnimTestState.hx b/source/funkin/CutsceneAnimTestState.hx
deleted file mode 100644
index 7d6369c12..000000000
--- a/source/funkin/CutsceneAnimTestState.hx
+++ /dev/null
@@ -1,80 +0,0 @@
-package funkin;
-
-import flixel.FlxSprite;
-import flixel.FlxState;
-import flixel.addons.display.FlxGridOverlay;
-import flixel.group.FlxGroup.FlxTypedGroup;
-import flixel.math.FlxPoint;
-import flixel.text.FlxText;
-import flixel.util.FlxColor;
-import openfl.Assets;
-import openfl.display.BitmapData;
-import openfl.display.MovieClip;
-import openfl.display.Timeline;
-import openfl.geom.Matrix;
-import openfl.geom.Rectangle;
-
-class CutsceneAnimTestState extends FlxState
-{
- var cutsceneGroup:CutsceneCharacter;
-
- var curSelected:Int = 0;
- var debugTxt:FlxText;
-
- var funnySprite:FlxSprite = new FlxSprite();
- var clip:MovieClip;
-
- public function new()
- {
- super();
-
- var gridBG:FlxSprite = FlxGridOverlay.create(10, 10);
- gridBG.scrollFactor.set(0.5, 0.5);
- add(gridBG);
-
- debugTxt = new FlxText(900, 20, 0, "", 20);
- debugTxt.color = FlxColor.BLUE;
- add(debugTxt);
-
- clip = Assets.getMovieClip("tanky:");
- // clip.x = FlxG.width/2;
- // clip.y = FlxG.height/2;
- FlxG.stage.addChild(clip);
-
- var swagShit:MovieClip = Assets.getMovieClip('tankBG:');
- // swagShit.scaleX = 5;
-
- FlxG.stage.addChild(swagShit);
- swagShit.gotoAndStop(13);
-
- var swfMountain = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000);
- swfMountain.draw(swagShit, swagShit.transform.matrix);
-
- var mountains:FlxSprite = new FlxSprite().loadGraphic(swfMountain);
- // add(mountains);
-
- FlxG.stage.removeChild(swagShit);
-
- funnySprite.x = FlxG.width / 2;
- funnySprite.y = FlxG.height / 2;
- add(funnySprite);
- }
-
- override function update(elapsed:Float)
- {
- super.update(elapsed);
-
- // jam sprite into top left corner
- var drawMatrix:Matrix = clip.transform.matrix;
- var bounds:Rectangle = clip.getBounds(null);
- drawMatrix.tx = -bounds.x;
- drawMatrix.ty = -bounds.y;
- // make bitmapdata only as big as it needs to be
- var funnyBmp:BitmapData = new BitmapData(Math.ceil(bounds.width), Math.ceil(bounds.height), true, 0x00000000);
- funnyBmp.draw(clip, drawMatrix, true);
- funnySprite.loadGraphic(funnyBmp);
- // jam sprite back into place lol
- funnySprite.offset.x = -bounds.x;
- funnySprite.offset.y = -bounds.y;
- }
-}
diff --git a/source/funkin/CutsceneCharacter.hx b/source/funkin/CutsceneCharacter.hx
deleted file mode 100644
index 7df3eb91c..000000000
--- a/source/funkin/CutsceneCharacter.hx
+++ /dev/null
@@ -1,74 +0,0 @@
-package funkin;
-
-import flixel.FlxSprite;
-import flixel.group.FlxGroup.FlxTypedGroup;
-import flixel.math.FlxPoint;
-
-class CutsceneCharacter extends FlxTypedGroup
-{
- public var coolPos:FlxPoint = FlxPoint.get();
- public var animShit:Map = new Map();
-
- var imageShit:String;
-
- public function new(x:Float, y:Float, imageShit:String)
- {
- super();
-
- coolPos.set(x, y);
-
- this.imageShit = imageShit;
- parseOffsets();
- createCutscene(0);
- }
-
- // shitshow, oh well
- var arrayLMFAOOOO:Array = [];
-
- function parseOffsets()
- {
- var splitShit:Array = CoolUtil.coolTextFile(Paths.file('images/cutsceneStuff/' + imageShit + "CutsceneOffsets.txt"));
-
- for (i in splitShit)
- {
- var xAndY:FlxPoint = FlxPoint.get();
- var dumbSplit:Array = i.split('---')[1].trim().split(' ');
- trace('cool split: ' + i.split('---')[1]);
- trace(dumbSplit);
- xAndY.set(Std.parseFloat(dumbSplit[0]), Std.parseFloat(dumbSplit[1]));
-
- animShit.set(i.split('---')[0].trim(), xAndY);
- arrayLMFAOOOO.push(i.split('---')[0].trim());
- }
-
- trace(animShit);
- }
-
- public function createCutscene(daNum:Int = 0)
- {
- var cutScene:FlxSprite = new FlxSprite(coolPos.x + animShit.get(arrayLMFAOOOO[daNum]).x, coolPos.y + animShit.get(arrayLMFAOOOO[daNum]).y);
- cutScene.frames = Paths.getSparrowAtlas('cutsceneStuff/' + imageShit + "-" + daNum);
- cutScene.animation.addByPrefix('weed', arrayLMFAOOOO[daNum], 24, false);
- cutScene.animation.play('weed');
- cutScene.antialiasing = true;
-
- cutScene.animation.finishCallback = function(anim:String) {
- cutScene.kill();
- cutScene.destroy();
- cutScene = null;
-
- if (daNum + 1 < arrayLMFAOOOO.length) createCutscene(daNum + 1);
- else
- ended();
- };
-
- add(cutScene);
- }
-
- public var onFinish:Void->Void;
-
- public function ended():Void
- {
- if (onFinish != null) onFinish();
- }
-}
diff --git a/source/funkin/DialogueBox.hx b/source/funkin/DialogueBox.hx
index 945c9fe96..4258f71ce 100644
--- a/source/funkin/DialogueBox.hx
+++ b/source/funkin/DialogueBox.hx
@@ -38,7 +38,7 @@ class DialogueBox extends FlxSpriteGroup
{
super();
- switch (PlayState.currentSong.song.toLowerCase())
+ switch (PlayState.instance.currentSong.songId.toLowerCase())
{
case 'senpai':
FlxG.sound.playMusic(Paths.music('Lunchbox'), 0);
@@ -79,7 +79,7 @@ class DialogueBox extends FlxSpriteGroup
box = new FlxSprite(-20, 45);
var hasDialog:Bool = false;
- switch (PlayState.currentSong.song.toLowerCase())
+ switch (PlayState.instance.currentSong.songId.toLowerCase())
{
case 'senpai':
hasDialog = true;
@@ -151,8 +151,8 @@ class DialogueBox extends FlxSpriteGroup
override function update(elapsed:Float):Void
{
// HARD CODING CUZ IM STUPDI
- if (PlayState.currentSong.song.toLowerCase() == 'roses') portraitLeft.visible = false;
- if (PlayState.currentSong.song.toLowerCase() == 'thorns')
+ if (PlayState.instance.currentSong.songId.toLowerCase() == 'roses') portraitLeft.visible = false;
+ if (PlayState.instance.currentSong.songId.toLowerCase() == 'thorns')
{
portraitLeft.color = FlxColor.BLACK;
swagDialogue.color = FlxColor.WHITE;
@@ -188,8 +188,8 @@ class DialogueBox extends FlxSpriteGroup
{
isEnding = true;
- if (PlayState.currentSong.song.toLowerCase() == 'senpai'
- || PlayState.currentSong.song.toLowerCase() == 'thorns') FlxG.sound.music.fadeOut(2.2, 0);
+ if (PlayState.instance.currentSong.songId.toLowerCase() == 'senpai'
+ || PlayState.instance.currentSong.songId.toLowerCase() == 'thorns') FlxG.sound.music.fadeOut(2.2, 0);
new FlxTimer().start(0.2, function(tmr:FlxTimer) {
box.alpha -= 1 / 5;
diff --git a/source/funkin/FreeplayState.hx b/source/funkin/FreeplayState.hx
index bcf6bfc18..322e79e31 100644
--- a/source/funkin/FreeplayState.hx
+++ b/source/funkin/FreeplayState.hx
@@ -34,12 +34,14 @@ import funkin.play.song.SongData.SongDataParser;
import funkin.shaderslmfao.AngleMask;
import funkin.shaderslmfao.PureColor;
import funkin.shaderslmfao.StrokeShader;
+import funkin.play.PlayStatePlaylist;
+import funkin.play.song.Song;
import lime.app.Future;
import lime.utils.Assets;
class FreeplayState extends MusicBeatSubState
{
- var songs:Array = [];
+ var songs:Array = [];
// var selector:FlxText;
var curSelected:Int = 0;
@@ -112,15 +114,15 @@ class FreeplayState extends MusicBeatSubState
#if debug
isDebug = true;
- addSong('Test', 1, 'bf-pixel');
- addSong('Pyro', 8, 'darnell');
+ addSong('Test', 'tutorial', 'bf-pixel');
+ addSong('Pyro', 'weekend1', 'darnell');
#end
var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist'));
for (i in 0...initSonglist.length)
{
- songs.push(new SongMetadata(initSonglist[i], 1, 'gf'));
+ songs.push(new FreeplaySongData(initSonglist[i], 'tutorial', 'gf'));
}
if (FlxG.sound.music != null)
@@ -128,22 +130,28 @@ class FreeplayState extends MusicBeatSubState
if (!FlxG.sound.music.playing) FlxG.sound.playMusic(Paths.music('freakyMenu'));
}
- if (StoryMenuState.weekUnlocked[2] || isDebug) addWeek(['Bopeebo', 'Fresh', 'Dadbattle'], 1, ['dad']);
+ // if (StoryMenuState.weekUnlocked[2] || isDebug)
+ addWeek(['Bopeebo', 'Fresh', 'Dadbattle'], 'week1', ['dad']);
- if (StoryMenuState.weekUnlocked[2] || isDebug) addWeek(['Spookeez', 'South', 'Monster'], 2, ['spooky', 'spooky', 'monster']);
+ // if (StoryMenuState.weekUnlocked[2] || isDebug)
+ addWeek(['Spookeez', 'South', 'Monster'], 'week2', ['spooky', 'spooky', 'monster']);
- if (StoryMenuState.weekUnlocked[3] || isDebug) addWeek(['Pico', 'Philly', 'Blammed'], 3, ['pico']);
+ // if (StoryMenuState.weekUnlocked[3] || isDebug)
+ addWeek(['Pico', 'Philly-Nice', 'Blammed'], 'week3', ['pico']);
- if (StoryMenuState.weekUnlocked[4] || isDebug) addWeek(['Satin-Panties', 'High', 'Milf'], 4, ['mom']);
+ // if (StoryMenuState.weekUnlocked[4] || isDebug)
+ addWeek(['Satin-Panties', 'High', 'MILF'], 'week4', ['mom']);
- if (StoryMenuState.weekUnlocked[5] || isDebug) addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 5,
- ['parents-christmas', 'parents-christmas', 'monster-christmas']);
+ // if (StoryMenuState.weekUnlocked[5] || isDebug)
+ addWeek(['Cocoa', 'Eggnog', 'Winter-Horrorland'], 'week5', ['parents-christmas', 'parents-christmas', 'monster-christmas']);
- if (StoryMenuState.weekUnlocked[6] || isDebug) addWeek(['Senpai', 'Roses', 'Thorns'], 6, ['senpai', 'senpai', 'spirit']);
+ // if (StoryMenuState.weekUnlocked[6] || isDebug)
+ addWeek(['Senpai', 'Roses', 'Thorns'], 'week6', ['senpai', 'senpai', 'spirit']);
- if (StoryMenuState.weekUnlocked[7] || isDebug) addWeek(['Ugh', 'Guns', 'Stress'], 7, ['tankman']);
+ // if (StoryMenuState.weekUnlocked[7] || isDebug)
+ addWeek(['Ugh', 'Guns', 'Stress'], 'week7', ['tankman']);
- addWeek(["Darnell", "lit-up", "2hot", "blazin"], 8, ['darnell']);
+ addWeek(["Darnell", "lit-up", "2hot", "blazin"], 'weekend1', ['darnell']);
// LOAD MUSIC
@@ -464,7 +472,7 @@ class FreeplayState extends MusicBeatSubState
grpCapsules.clear();
// var regexp:EReg = regexp;
- var tempSongs:Array = songs;
+ var tempSongs:Array = songs;
if (filterStuff != null)
{
@@ -553,19 +561,19 @@ class FreeplayState extends MusicBeatSubState
changeDiff();
}
- public function addSong(songName:String, weekNum:Int, songCharacter:String)
+ public function addSong(songName:String, levelId:String, songCharacter:String)
{
- songs.push(new SongMetadata(songName, weekNum, songCharacter));
+ songs.push(new FreeplaySongData(songName, levelId, songCharacter));
}
- public function addWeek(songs:Array, weekNum:Int, ?songCharacters:Array)
+ public function addWeek(songs:Array, levelId:String, ?songCharacters:Array)
{
if (songCharacters == null) songCharacters = ['bf'];
var num:Int = 0;
for (song in songs)
{
- addSong(song, weekNum, songCharacters[num]);
+ addSong(song, levelId, songCharacters[num]);
if (songCharacters.length != 1) num++;
}
@@ -851,11 +859,9 @@ class FreeplayState extends MusicBeatSubState
curDifficulty = 1;
}*/
- PlayState.currentSong = SongLoad.loadFromJson(poop, songs[curSelected].songName.toLowerCase());
- PlayState.currentSong_NEW = SongDataParser.fetchSong(songs[curSelected].songName.toLowerCase());
- PlayState.isStoryMode = false;
- PlayState.storyDifficulty = curDifficulty;
- PlayState.storyDifficulty_NEW = switch (curDifficulty)
+ PlayStatePlaylist.isStoryMode = false;
+ var targetSong:Song = SongDataParser.fetchSong(songs[curSelected].songName.toLowerCase());
+ var targetDifficulty:String = switch (curDifficulty)
{
case 0:
'easy';
@@ -865,27 +871,41 @@ class FreeplayState extends MusicBeatSubState
'hard';
default: 'normal';
};
- // SongLoad.curDiff = Highscore.formatSong()
- SongLoad.curDiff = PlayState.storyDifficulty_NEW;
+ // TODO: Implement additional difficulties into the interface properly.
+ if (FlxG.keys.pressed.E)
+ {
+ targetDifficulty = 'erect';
+ }
- PlayState.storyWeek = songs[curSelected].week;
- // trace(' CUR WEEK ' + PlayState.storyWeek);
+ // TODO: Implement Pico into the interface properly.
+ var targetCharacter:String = 'bf';
+ if (FlxG.keys.pressed.P)
+ {
+ targetCharacter = 'pico';
+ }
+
+ PlayStatePlaylist.campaignId = songs[curSelected].levelId;
// Visual and audio effects.
FlxG.sound.play(Paths.sound('confirmMenu'));
dj.confirm();
new FlxTimer().start(1, function(tmr:FlxTimer) {
- LoadingState.loadAndSwitchState(new PlayState(), true);
+ LoadingState.loadAndSwitchState(new PlayState(
+ {
+ targetSong: targetSong,
+ targetDifficulty: targetDifficulty,
+ targetCharacter: targetCharacter,
+ }), true);
});
}
}
- override function startOutro(onComplete:() -> Void):Void
+ override function switchTo(nextState:FlxState):Bool
{
clearDaCache(songs[curSelected].songName);
- super.startOutro(onComplete);
+ return super.switchTo(nextState);
}
function changeDiff(change:Int = 0)
@@ -901,19 +921,6 @@ class FreeplayState extends MusicBeatSubState
intendedScore = Highscore.getScore(songs[curSelected].songName, curDifficulty);
intendedCompletion = Highscore.getCompletion(songs[curSelected].songName, curDifficulty);
- PlayState.storyDifficulty = curDifficulty;
- PlayState.storyDifficulty_NEW = switch (curDifficulty)
- {
- case 0:
- 'easy';
- case 1:
- 'normal';
- case 2:
- 'hard';
- default:
- 'normal';
- };
-
grpDifficulties.group.forEach(function(spr) {
spr.visible = false;
});
@@ -1040,17 +1047,17 @@ enum abstract FilterType(String)
var ALL;
}
-class SongMetadata
+class FreeplaySongData
{
public var songName:String = "";
- public var week:Int = 0;
+ public var levelId:String = "";
public var songCharacter:String = "";
public var isFav:Bool = false;
- public function new(song:String, week:Int, songCharacter:String, ?isFav:Bool = false)
+ public function new(song:String, levelId:String, songCharacter:String, ?isFav:Bool = false)
{
this.songName = song;
- this.week = week;
+ this.levelId = levelId;
this.songCharacter = songCharacter;
this.isFav = isFav;
}
diff --git a/source/funkin/GitarooPause.hx b/source/funkin/GitarooPause.hx
index fda809548..5747de5e5 100644
--- a/source/funkin/GitarooPause.hx
+++ b/source/funkin/GitarooPause.hx
@@ -11,12 +11,16 @@ class GitarooPause extends MusicBeatState
var replaySelect:Bool = false;
- public function new():Void
+ var previousParams:PlayStateParams;
+
+ public function new(previousParams:PlayStateParams):Void
{
super();
+
+ this.previousParams = previousParams;
}
- override function create()
+ override function create():Void
{
if (FlxG.sound.music != null) FlxG.sound.music.stop();
@@ -49,7 +53,7 @@ class GitarooPause extends MusicBeatState
super.create();
}
- override function update(elapsed:Float)
+ override function update(elapsed:Float):Void
{
if (controls.UI_LEFT_P || controls.UI_RIGHT_P) changeThing();
@@ -57,7 +61,7 @@ class GitarooPause extends MusicBeatState
{
if (replaySelect)
{
- FlxG.switchState(new PlayState());
+ FlxG.switchState(new PlayState(previousParams));
}
else
{
diff --git a/source/funkin/Highscore.hx b/source/funkin/Highscore.hx
index 08ad7dcba..904d2cb45 100644
--- a/source/funkin/Highscore.hx
+++ b/source/funkin/Highscore.hx
@@ -39,7 +39,17 @@ class Highscore
return false;
}
- public static function saveCompletion(song:String, completion:Float, ?diff:Int = 0):Bool
+ public static function saveScoreForDifficulty(song:String, score:Int = 0, diff:String = 'normal'):Bool
+ {
+ var diffInt:Int = 1;
+
+ if (diff == 'easy') diffInt = 0;
+ else if (diff == 'hard') diffInt = 2;
+
+ return saveScore(song, score, diffInt);
+ }
+
+ public static function saveCompletion(song:String, completion:Float, diff:Int = 0):Bool
{
var formattedSong:String = formatSong(song, diff);
@@ -57,20 +67,42 @@ class Highscore
return false;
}
- public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void
+ public static function saveCompletionForDifficulty(song:String, completion:Float, diff:String = 'normal'):Bool
+ {
+ var diffInt:Int = 1;
+
+ if (diff == 'easy') diffInt = 0;
+ else if (diff == 'hard') diffInt = 2;
+
+ return saveCompletion(song, completion, diffInt);
+ }
+
+ public static function saveWeekScore(week:String, score:Int = 0, diff:Int = 0):Void
{
#if newgrounds
- NGio.postScore(score, "Week " + week);
+ NGio.postScore(score, 'Campaign ID $week');
#end
- var formattedSong:String = formatSong('week' + week, diff);
+ var formattedSong:String = formatSong(week, diff);
if (songScores.exists(formattedSong))
{
if (songScores.get(formattedSong) < score) setScore(formattedSong, score);
}
else
+ {
setScore(formattedSong, score);
+ }
+ }
+
+ public static function saveWeekScoreForDifficulty(week:String, score:Int = 0, diff:String = 'normal'):Void
+ {
+ var diffInt:Int = 1;
+
+ if (diff == 'easy') diffInt = 0;
+ else if (diff == 'hard') diffInt = 2;
+
+ saveWeekScore(week, score, diffInt);
}
static function setCompletion(formattedSong:String, completion:Float):Void
@@ -122,7 +154,7 @@ class Highscore
return songCompletion.get(formatSong(song, diff));
}
- public static function getAllScores()
+ public static function getAllScores():Void
{
trace(songScores.toString());
}
diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx
index 45c2645df..8d7d2d550 100644
--- a/source/funkin/InitState.hx
+++ b/source/funkin/InitState.hx
@@ -12,7 +12,7 @@ import flixel.util.FlxColor;
import funkin.modding.module.ModuleHandler;
import funkin.play.PlayState;
import funkin.play.character.CharacterData.CharacterDataParser;
-import funkin.play.event.SongEvent.SongEventParser;
+import funkin.play.event.SongEventData.SongEventParser;
import funkin.play.song.SongData.SongDataParser;
import funkin.ui.PreferencesMenu;
import funkin.util.WindowUtil;
@@ -140,10 +140,10 @@ class InitState extends FlxTransitionableState
// WEEK UNLOCK PROGRESSION!!
// StoryMenuState.weekUnlocked = FlxG.save.data.weekUnlocked;
- if (StoryMenuState.weekUnlocked.length < 4) StoryMenuState.weekUnlocked.insert(0, true);
+ // if (StoryMenuState.weekUnlocked.length < 4) StoryMenuState.weekUnlocked.insert(0, true);
// QUICK PATCH OOPS!
- if (!StoryMenuState.weekUnlocked[0]) StoryMenuState.weekUnlocked[0] = true;
+ // if (!StoryMenuState.weekUnlocked[0]) StoryMenuState.weekUnlocked[0] = true;
}
if (FlxG.save.data.seenVideo != null) VideoState.seenVideo = FlxG.save.data.seenVideo;
@@ -237,20 +237,18 @@ class InitState extends FlxTransitionableState
{
var dif:Int = getDif();
- PlayState.currentSong = SongLoad.loadFromJson(song, song);
- PlayState.currentSong_NEW = SongDataParser.fetchSong(song);
- PlayState.isStoryMode = isStoryMode;
- PlayState.storyDifficulty = dif;
- PlayState.storyDifficulty_NEW = switch (dif)
+ var targetDifficulty = switch (dif)
{
case 0: 'easy';
case 1: 'normal';
case 2: 'hard';
default: 'normal';
};
- SongLoad.curDiff = PlayState.storyDifficulty_NEW;
- PlayState.storyWeek = week;
- LoadingState.loadAndSwitchState(new PlayState());
+ LoadingState.loadAndSwitchState(new PlayState(
+ {
+ targetSong: SongDataParser.fetchSong(song),
+ targetDifficulty: targetDifficulty,
+ }));
}
}
diff --git a/source/funkin/LoadingState.hx b/source/funkin/LoadingState.hx
index f0e56f602..604e78f79 100644
--- a/source/funkin/LoadingState.hx
+++ b/source/funkin/LoadingState.hx
@@ -1,5 +1,6 @@
package funkin;
+import funkin.play.PlayStatePlaylist;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.math.FlxMath;
@@ -32,7 +33,7 @@ class LoadingState extends MusicBeatState
this.stopMusic = stopMusic;
}
- override function create()
+ override function create():Void
{
var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, 0xFFcaff4d);
add(bg);
@@ -52,57 +53,56 @@ class LoadingState extends MusicBeatState
initSongsManifest().onComplete(function(lib) {
callbacks = new MultiCallback(onLoad);
- var introComplete = callbacks.add("introComplete");
- checkLoadSong(getSongPath());
- if (PlayState.currentSong.needsVoices)
- {
- var files = PlayState.currentSong.voiceList;
+ var introComplete = callbacks.add('introComplete');
+ // checkLoadSong(getSongPath());
+ // if (PlayState.currentSong.needsVoices)
+ // {
+ // var files = PlayState.currentSong.voiceList;
+ //
+ // if (files == null) files = ['']; // loads with no file name assumption, to load 'Voices.ogg' or whatev normally
+ //
+ // for (sndFile in files)
+ // {
+ // checkLoadSong(getVocalPath(sndFile));
+ // }
+ // }
- if (files == null) files = [""]; // loads with no file name assumption, to load "Voices.ogg" or whatev normally
+ checkLibrary('shared');
+ checkLibrary(PlayStatePlaylist.campaignId);
+ checkLibrary('tutorial');
- for (sndFile in files)
- {
- checkLoadSong(getVocalPath(sndFile));
- }
- }
-
- checkLibrary("shared");
- if (PlayState.storyWeek > 0) checkLibrary("week" + PlayState.storyWeek);
- else
- checkLibrary("tutorial");
-
- var fadeTime = 0.5;
+ var fadeTime:Float = 0.5;
FlxG.camera.fade(FlxG.camera.bgColor, fadeTime, true);
new FlxTimer().start(fadeTime + MIN_TIME, function(_) introComplete());
});
}
- function checkLoadSong(path:String)
+ function checkLoadSong(path:String):Void
{
if (!Assets.cache.hasSound(path))
{
- var library = Assets.getLibrary("songs");
- var symbolPath = path.split(":").pop();
+ var library = Assets.getLibrary('songs');
+ var symbolPath = path.split(':').pop();
// @:privateAccess
// library.types.set(symbolPath, SOUND);
// @:privateAccess
// library.pathGroups.set(symbolPath, [library.__cacheBreak(symbolPath)]);
- var callback = callbacks.add("song:" + path);
+ var callback = callbacks.add('song:' + path);
Assets.loadSound(path).onComplete(function(_) {
callback();
});
}
}
- function checkLibrary(library:String)
+ function checkLibrary(library:String):Void
{
trace(Assets.hasLibrary(library));
if (Assets.getLibrary(library) == null)
{
@:privateAccess
- if (!LimeAssets.libraryPaths.exists(library)) throw "Missing library: " + library;
+ if (!LimeAssets.libraryPaths.exists(library)) throw 'Missing library: ' + library;
- var callback = callbacks.add("library:" + library);
+ var callback = callbacks.add('library:' + library);
Assets.loadLibrary(library).onComplete(function(_) {
callback();
});
@@ -121,7 +121,7 @@ class LoadingState extends MusicBeatState
var targetShit:Float = 0;
- override function update(elapsed:Float)
+ override function update(elapsed:Float):Void
{
super.update(elapsed);
@@ -147,57 +147,41 @@ class LoadingState extends MusicBeatState
}
#if debug
- if (FlxG.keys.justPressed.SPACE) trace('fired: ' + callbacks.getFired() + " unfired:" + callbacks.getUnfired());
+ if (FlxG.keys.justPressed.SPACE) trace('fired: ' + callbacks.getFired() + ' unfired:' + callbacks.getUnfired());
#end
}
- function onLoad()
+ function onLoad():Void
{
if (stopMusic && FlxG.sound.music != null) FlxG.sound.music.stop();
FlxG.switchState(target);
}
- static function getSongPath()
+ static function getSongPath():String
{
- return Paths.inst(PlayState.currentSong.song);
+ return Paths.inst(PlayState.instance.currentSong.songId);
}
- static function getVocalPath(?suffix:String)
+ inline static public function loadAndSwitchState(nextState:FlxState, shouldStopMusic = false):Void
{
- return Paths.voices(PlayState.currentSong.song, suffix);
+ FlxG.switchState(getNextState(nextState, shouldStopMusic));
}
- inline static public function loadAndSwitchState(target:FlxState, stopMusic = false)
+ static function getNextState(nextState:FlxState, shouldStopMusic = false):FlxState
{
- FlxG.switchState(getNextState(target, stopMusic));
- }
+ Paths.setCurrentLevel(PlayStatePlaylist.campaignId);
- static function getNextState(target:FlxState, stopMusic = false):FlxState
- {
- if (PlayState.storyWeek == 0)
- {
- Paths.setCurrentLevel('tutorial');
- }
- else if (PlayState.storyWeek == 8)
- {
- // TODO: Refactor this code.
- Paths.setCurrentLevel("weekend1");
- }
- else
- {
- Paths.setCurrentLevel("week" + PlayState.storyWeek);
- }
#if NO_PRELOAD_ALL
- var loaded = isSoundLoaded(getSongPath())
- && (!PlayState.currentSong.needsVoices || isSoundLoaded(getVocalPath()))
- && isLibraryLoaded("shared");
-
- if (!loaded) return new LoadingState(target, stopMusic);
+ // var loaded = isSoundLoaded(getSongPath())
+ // && (!PlayState.currentSong.needsVoices || isSoundLoaded(getVocalPath()))
+ // && isLibraryLoaded('shared');
+ //
+ if (true) return new LoadingState(nextState, shouldStopMusic);
#end
- if (stopMusic && FlxG.sound.music != null) FlxG.sound.music.stop();
+ if (shouldStopMusic && FlxG.sound.music != null) FlxG.sound.music.stop();
- return target;
+ return nextState;
}
#if NO_PRELOAD_ALL
@@ -212,16 +196,16 @@ class LoadingState extends MusicBeatState
}
#end
- override function destroy()
+ override function destroy():Void
{
super.destroy();
callbacks = null;
}
- static function initSongsManifest()
+ static function initSongsManifest():Future
{
- var id = "songs";
+ var id = 'songs';
var promise = new Promise();
var library = LimeAssets.getLibrary(id);
@@ -243,10 +227,10 @@ class LoadingState extends MusicBeatState
}
else
{
- if (path.endsWith(".bundle"))
+ if (path.endsWith('.bundle'))
{
rootPath = path;
- path += "/library.json";
+ path += '/library.json';
}
else
{
@@ -259,7 +243,7 @@ class LoadingState extends MusicBeatState
AssetManifest.loadFromFile(path, rootPath).onComplete(function(manifest) {
if (manifest == null)
{
- promise.error("Cannot parse asset manifest for library \"" + id + "\"");
+ promise.error('Cannot parse asset manifest for library \'' + id + '\'');
return;
}
@@ -267,7 +251,7 @@ class LoadingState extends MusicBeatState
if (library == null)
{
- promise.error("Cannot open library \"" + id + "\"");
+ promise.error('Cannot open library \'' + id + '\'');
}
else
{
@@ -277,7 +261,7 @@ class LoadingState extends MusicBeatState
promise.completeWith(Future.withValue(library));
}
}).onError(function(_) {
- promise.error("There is no asset library with an ID of \"" + id + "\"");
+ promise.error('There is no asset library with an ID of \'' + id + '\'');
});
return promise.future;
@@ -300,7 +284,7 @@ class MultiCallback
this.logId = logId;
}
- public function add(id = "untitled")
+ public function add(id = 'untitled'):Void->Void
{
id = '$length:$id';
length++;
@@ -333,9 +317,9 @@ class MultiCallback
if (logId != null) trace('$logId: $msg');
}
- public function getFired()
+ public function getFired():Array
return fired.copy();
- public function getUnfired()
+ public function getUnfired():ArrayVoid>
return unfired.array();
}
diff --git a/source/funkin/Note.hx b/source/funkin/Note.hx
index 91f45e973..71c63a94e 100644
--- a/source/funkin/Note.hx
+++ b/source/funkin/Note.hx
@@ -1,5 +1,6 @@
package funkin;
+import funkin.play.Strumline.StrumlineArrow;
import flixel.FlxSprite;
import flixel.math.FlxMath;
import funkin.noteStuff.NoteBasic.NoteData;
@@ -215,6 +216,24 @@ class Note extends FlxSprite
}
}
+ public function alignToSturmlineArrow(arrow:StrumlineArrow):Void
+ {
+ x = arrow.x;
+
+ if (isSustainNote && prevNote != null)
+ {
+ if (prevNote.isSustainNote)
+ {
+ x = prevNote.x;
+ }
+ else
+ {
+ x += prevNote.width / 2;
+ x -= width / 2;
+ }
+ }
+ }
+
override function destroy()
{
prevNote = null;
diff --git a/source/funkin/PauseSubState.hx b/source/funkin/PauseSubState.hx
index 890b51cb7..77fdfabf1 100644
--- a/source/funkin/PauseSubState.hx
+++ b/source/funkin/PauseSubState.hx
@@ -1,9 +1,10 @@
package funkin;
+import funkin.play.PlayStatePlaylist;
import flixel.FlxSprite;
import flixel.addons.transition.FlxTransitionableState;
import flixel.group.FlxGroup.FlxTypedGroup;
-import flixel.sound.FlxSound;
+import flixel.system.FlxSound;
import flixel.text.FlxText;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
@@ -20,9 +21,9 @@ class PauseSubState extends MusicBeatSubState
'Restart Song',
'Change Difficulty',
'Toggle Practice Mode',
- 'Exit to menu'
+ 'Exit to Menu'
];
- var difficultyChoices:Array = ['EASY', 'NORMAL', 'HARD', 'BACK'];
+ var difficultyChoices:Array = ['EASY', 'NORMAL', 'HARD', 'ERECT', 'BACK'];
var menuItems:Array = [];
var curSelected:Int = 0;
@@ -41,10 +42,14 @@ class PauseSubState extends MusicBeatSubState
menuItems = pauseOG;
- if (PlayState.storyWeek == 6) // consistent with logic that decides asset lib!!
+ if (PlayStatePlaylist.campaignId == 'week6')
+ {
pauseMusic = new FlxSound().loadEmbedded(Paths.music('breakfast-pixel'), true, true);
+ }
else
+ {
pauseMusic = new FlxSound().loadEmbedded(Paths.music('breakfast'), true, true);
+ }
pauseMusic.volume = 0;
pauseMusic.play(false, FlxG.random.int(0, Std.int(pauseMusic.length / 2)));
@@ -58,43 +63,38 @@ class PauseSubState extends MusicBeatSubState
metaDataGrp = new FlxTypedGroup();
add(metaDataGrp);
- var levelInfo:FlxText = new FlxText(20, 15, 0, "", 32);
+ var levelInfo:FlxText = new FlxText(20, 15, 0, '', 32);
if (PlayState.instance.currentChart != null)
{
levelInfo.text += '${PlayState.instance.currentChart.songName} - ${PlayState.instance.currentChart.songArtist}';
}
- else
- {
- levelInfo.text += PlayState.currentSong.song;
- }
levelInfo.scrollFactor.set();
- levelInfo.setFormat(Paths.font("vcr.ttf"), 32);
+ levelInfo.setFormat(Paths.font('vcr.ttf'), 32);
levelInfo.updateHitbox();
metaDataGrp.add(levelInfo);
- var levelDifficulty:FlxText = new FlxText(20, 15 + 32, 0, "", 32);
- levelDifficulty.text += CoolUtil.difficultyString();
+ var levelDifficulty:FlxText = new FlxText(20, 15 + 32, 0, '', 32);
+ levelDifficulty.text += PlayState.instance.currentDifficulty.toTitleCase();
levelDifficulty.scrollFactor.set();
levelDifficulty.setFormat(Paths.font('vcr.ttf'), 32);
levelDifficulty.updateHitbox();
metaDataGrp.add(levelDifficulty);
- var deathCounter:FlxText = new FlxText(20, 15 + 64, 0, "", 32);
- deathCounter.text = "Blue balled: " + PlayState.deathCounter;
- deathCounter.text += "\n" + Highscore.tallies.totalNotesHit;
- deathCounter.text += "\n" + Highscore.tallies.totalNotes;
- deathCounter.text += "\n" + Std.string(Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes);
+ var deathCounter:FlxText = new FlxText(20, 15 + 64, 0, '', 32);
+ deathCounter.text = 'Blue balled: ${PlayState.instance.deathCounter}';
+ FlxG.watch.addQuick('totalNotesHit', Highscore.tallies.totalNotesHit);
+ FlxG.watch.addQuick('totalNotes', Highscore.tallies.totalNotes);
deathCounter.scrollFactor.set();
deathCounter.setFormat(Paths.font('vcr.ttf'), 32);
deathCounter.updateHitbox();
metaDataGrp.add(deathCounter);
- practiceText = new FlxText(20, 15 + 64 + 32, 0, "PRACTICE MODE", 32);
+ practiceText = new FlxText(20, 15 + 64 + 32, 0, 'PRACTICE MODE', 32);
practiceText.scrollFactor.set();
practiceText.setFormat(Paths.font('vcr.ttf'), 32);
practiceText.updateHitbox();
practiceText.x = FlxG.width - (practiceText.width + 20);
- practiceText.visible = PlayState.isPracticeMode;
+ practiceText.visible = PlayState.instance.isPracticeMode;
metaDataGrp.add(practiceText);
levelDifficulty.alpha = 0;
@@ -137,7 +137,7 @@ class PauseSubState extends MusicBeatSubState
changeSelection();
}
- override function update(elapsed:Float)
+ override function update(elapsed:Float):Void
{
if (pauseMusic.volume < 0.5) pauseMusic.volume += 0.01 * elapsed;
@@ -180,41 +180,39 @@ class PauseSubState extends MusicBeatSubState
{
var daSelected:String = menuItems[curSelected];
+ // TODO: Why is this based on the menu item's name? Make this an enum or something.
switch (daSelected)
{
- case "Resume":
+ case 'Resume':
close();
- case "EASY" | 'NORMAL' | "HARD":
- PlayState.currentSong = SongLoad.loadFromJson(PlayState.currentSong.song.toLowerCase(), PlayState.currentSong.song.toLowerCase());
- PlayState.currentSong_NEW = SongDataParser.fetchSong(PlayState.currentSong.song.toLowerCase());
- SongLoad.curDiff = daSelected.toLowerCase();
-
- PlayState.storyDifficulty = curSelected;
- PlayState.storyDifficulty_NEW = daSelected.toLowerCase();
-
- PlayState.needsReset = true;
-
- close();
-
- case 'Toggle Practice Mode':
- PlayState.isPracticeMode = !PlayState.isPracticeMode;
- practiceText.visible = PlayState.isPracticeMode;
case 'Change Difficulty':
menuItems = difficultyChoices;
regenMenu();
+
+ case 'EASY' | 'NORMAL' | 'HARD' | 'ERECT':
+ PlayState.instance.currentSong = SongDataParser.fetchSong(PlayState.instance.currentSong.songId.toLowerCase());
+
+ PlayState.instance.currentDifficulty = daSelected.toLowerCase();
+
+ PlayState.instance.needsReset = true;
+
+ close();
case 'BACK':
menuItems = pauseOG;
regenMenu();
- case "Restart Song":
- PlayState.needsReset = true;
+ case 'Toggle Practice Mode':
+ PlayState.instance.isPracticeMode = true;
+ practiceText.visible = PlayState.instance.isPracticeMode;
+
+ case 'Restart Song':
+ PlayState.instance.needsReset = true;
close();
- // FlxG.resetState();
- case "Exit to menu":
+
+ case 'Exit to Menu':
exitingToMenu = true;
- PlayState.seenCutscene = false;
- PlayState.deathCounter = 0;
+ PlayState.instance.deathCounter = 0;
for (item in grpMenuShit.members)
{
@@ -225,9 +223,9 @@ class PauseSubState extends MusicBeatSubState
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
- if (PlayState.isStoryMode) openSubState(new funkin.ui.StickerSubState(null, STORY));
+ if (PlayStatePlaylist.isStoryMode) openSubState(new funkin.ui.StickerSubState(null, STORY));
else
- openSubState(new funkin.ui.StickerSubState());
+ openSubState(new funkin.ui.StickerSubState(null, FREEPLAY));
}
}
@@ -239,7 +237,7 @@ class PauseSubState extends MusicBeatSubState
}
}
- override function destroy()
+ override function destroy():Void
{
pauseMusic.destroy();
@@ -260,12 +258,10 @@ class PauseSubState extends MusicBeatSubState
item.targetY = index - curSelected;
item.alpha = 0.6;
- // item.setGraphicSize(Std.int(item.width * 0.8));
if (item.targetY == 0)
{
item.alpha = 1;
- // item.setGraphicSize(Std.int(item.width));
}
}
}
diff --git a/source/funkin/StoryMenuState.hx b/source/funkin/StoryMenuState.hx
deleted file mode 100644
index 89d59de1f..000000000
--- a/source/funkin/StoryMenuState.hx
+++ /dev/null
@@ -1,497 +0,0 @@
-package funkin;
-
-import flixel.FlxSprite;
-import flixel.addons.transition.FlxTransitionableState;
-import flixel.graphics.frames.FlxAtlasFrames;
-import flixel.group.FlxGroup.FlxTypedGroup;
-import flixel.group.FlxGroup;
-import flixel.math.FlxMath;
-import flixel.text.FlxText;
-import flixel.tweens.FlxTween;
-import flixel.util.FlxColor;
-import flixel.util.FlxTimer;
-import funkin.MenuItem.WeekType;
-import funkin.play.PlayState;
-import funkin.play.song.SongData.SongDataParser;
-import lime.net.curl.CURLCode;
-import openfl.Assets;
-import funkin.ui.StickerSubState;
-#if discord_rpc
-import Discord.DiscordClient;
-#end
-
-class StoryMenuState extends MusicBeatState
-{
- var scoreText:FlxText;
-
- var weekData:Array> = [
- ['Tutorial'],
- ['Bopeebo', 'Fresh', 'Dadbattle'],
- ['Spookeez', 'South', "Monster"],
- ['Pico', 'Philly', "Blammed"],
- ['Satin-Panties', "High", "Milf"],
- ['Cocoa', 'Eggnog', 'Winter-Horrorland'],
- ['Senpai', 'Roses', 'Thorns'],
- ['Ugh', 'Guns', 'Stress'],
- ['Darnell', "lit-up", "2hot", "blazin"]
- ];
- var curDifficulty:Int = 1;
-
- // TODO: This info is just hardcoded right now.
- // We should probably make it so that weeks must be completed in order to unlock the next week.
- public static var weekUnlocked:Array = [true, true, true, true, true, true, true, true, true];
-
- var weekCharacters:Array = [
- ['dad', 'bf', 'gf'],
- ['dad', 'bf', 'gf'],
- ['spooky', 'bf', 'gf'],
- ['pico', 'bf', 'gf'],
- ['mom', 'bf', 'gf'],
- ['parents-christmas', 'bf', 'gf'],
- ['senpai', 'bf', 'gf'],
- ['tankman', 'bf', 'gf'],
- ['darnell', 'pico', 'nene']
- ];
-
- var weekNames:Array = [
- "",
- "Daddy Dearest",
- "Spooky Month",
- "PICO",
- "MOMMY MUST MURDER",
- "RED SNOW",
- "hating simulator ft. moawling",
- "TANKMAN",
- "Due Debts"
- ];
-
- var weekType:Array = [WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEKEND];
- var weekTypeInc:Map = new Map();
-
- var txtWeekTitle:FlxText;
-
- var curWeek:Int = 0;
-
- var txtTracklist:FlxText;
-
- var grpWeekText:FlxTypedGroup