diff --git a/source/Main.hx b/source/Main.hx index a09c90d..8f0c8b0 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -20,7 +20,7 @@ class Main extends Sprite { var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom). var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). - var initialState:Class = TitleState; // The FlxState the game starts with. + var initialState:Class = InitialState; // The FlxState the game starts with. var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. var framerate:Int = 60; // How many frames per second the game should run at. diff --git a/source/backend/FunkinData.hx b/source/backend/FunkinData.hx index 7d4d523..e741cf9 100644 --- a/source/backend/FunkinData.hx +++ b/source/backend/FunkinData.hx @@ -3,24 +3,35 @@ package backend; import flixel.input.gamepad.FlxGamepadInputID; import flixel.input.keyboard.FlxKey; -@:structInit class DataVariables { - public var downScroll:Bool = false; - public var ghostTapping:Bool = false; - public var flashingLights:Bool = true; - public var cameraZoom:Bool = true; - public var unfocusPause:Bool = true; - public var globalAntialiasing:Bool = true; - public var maxFramerate:Int = 60; -} - class FunkinData { - public static var data:DataVariables; + public static var dataVars:Map = [ + 'downScroll' => false, + 'ghostTapping' => false, + 'flashingLights' => true, + 'cameraZoom' => true, + 'unfocusPause' => true, + 'globalAntialiasing' => true, + 'maxFramerate' => 60 + ]; public function loadData() { - Reflect; + var nullData:Bool = false; + for (key => value in dataVars) { + if (Reflect.getProperty(FlxG.save.data, key) == null && !nullData) { + nullData = true; + } + + if (nullData) { + Reflect.setProperty(FlxG.save.data, key, value); + } else { + dataVars[key] = Reflect.getProperty(FlxG.save.data, key); + } + } } - public function setDataValue(data:String, value:Dynamic) { - Reflect.setProperty(FlxG.save.data, data, value); + public function saveData() { + for (key => value in dataVars) { + Reflect.setProperty(FlxG.save.data, key, value); + } } } \ No newline at end of file diff --git a/source/funkin/states/InitialState.hx b/source/funkin/states/InitialState.hx index ba9d98f..c62aa62 100644 --- a/source/funkin/states/InitialState.hx +++ b/source/funkin/states/InitialState.hx @@ -2,11 +2,27 @@ package funkin.states; class InitialState extends MusicBeatState { + var nextState:Class = TitleState; override function create() { - super.create(); - } + #if MODS + ModUtil.init(); + #end + + FlxG.save.bind('prototype', 'fyridev'); + FunkinData.loadData(); + Highscore.load(); + + #if DISCORD + DiscordRPC.initialize(); - override function update(elapsed:Float) { - super.update(elapsed); + Application.current.onExit.add(function(exitCode) + { + DiscordRPC.shutdown(); + }); + #end + + switchState(nextState); + + super.create(); } } \ No newline at end of file diff --git a/source/funkin/states/TitleState.hx b/source/funkin/states/TitleState.hx index dd751af..6cf6aa6 100644 --- a/source/funkin/states/TitleState.hx +++ b/source/funkin/states/TitleState.hx @@ -49,10 +49,6 @@ class TitleState extends MusicBeatState override public function create():Void { - #if MODS - ModUtil.init(); - #end - startedIntro = false; FlxG.game.focusLostFramerate = 60; @@ -68,10 +64,6 @@ class TitleState extends MusicBeatState super.create(); - FlxG.save.bind('prototype', 'fyridev'); - FunkinData.loadData(); - Highscore.load(); - if (FlxG.save.data.weekUnlocked != null) { // FIX LATER!!! diff --git a/source/utils/SoundUtil.hx b/source/utils/SoundUtil.hx deleted file mode 100644 index 89a161f..0000000 --- a/source/utils/SoundUtil.hx +++ /dev/null @@ -1,5 +0,0 @@ -package utils; - -class SoundUtil { - -} \ No newline at end of file