Skip to content

Commit

Permalink
initial state is used now
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrid19 committed May 24, 2024
1 parent ba6c4fb commit eed0008
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 32 deletions.
2 changes: 1 addition & 1 deletion source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlxState> = TitleState; // The FlxState the game starts with.
var initialState:Class<FlxState> = 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.

Expand Down
39 changes: 25 additions & 14 deletions source/backend/FunkinData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Dynamic> = [
'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);
}
}
}
24 changes: 20 additions & 4 deletions source/funkin/states/InitialState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@
package funkin.states;

class InitialState extends MusicBeatState {
var nextState:Class<FlxState> = 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();
}
}
8 changes: 0 additions & 8 deletions source/funkin/states/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class TitleState extends MusicBeatState

override public function create():Void
{
#if MODS
ModUtil.init();
#end

startedIntro = false;

FlxG.game.focusLostFramerate = 60;
Expand All @@ -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!!!
Expand Down
5 changes: 0 additions & 5 deletions source/utils/SoundUtil.hx

This file was deleted.

0 comments on commit eed0008

Please sign in to comment.