From 897c29c16c1e65d8f74a642036db54d0c49d25a9 Mon Sep 17 00:00:00 2001 From: Vortex <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:12:12 -0500 Subject: [PATCH] minor optimization --- source/Main.hx | 1 + source/states/MusicBeatState.hx | 3 --- source/states/TitleState.hx | 15 +++++++++------ source/substates/MaxFPSMenu.hx | 2 ++ source/substates/MusicBeatSubstate.hx | 2 -- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index 92d5244d83..e623512ac8 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -38,6 +38,7 @@ class Main extends Sprite { game = new FlxGame(1280, 720, TitleState, 60, 60, true); + // FlxG.game._customSoundTray wants just the class, it calls new from // create() in there, which gets called when it's added to stage // which is why it needs to be added before addChild(game) here diff --git a/source/states/MusicBeatState.hx b/source/states/MusicBeatState.hx index 8d094b264c..6a1bde0357 100644 --- a/source/states/MusicBeatState.hx +++ b/source/states/MusicBeatState.hx @@ -128,9 +128,6 @@ class MusicBeatState extends #if MODCHARTING_TOOLS modcharting.ModchartMusicBeat super.update(elapsed); - if (FlxG.stage != null) - FlxG.stage.frameRate = FlxMath.bound(Options.getData("maxFPS"), 0.1, 1000); - if (!Options.getData("antialiasing")) { forEachAlive(function(basic:FlxBasic) { if (!(basic is FlxSprite)) { diff --git a/source/states/TitleState.hx b/source/states/TitleState.hx index 7236840637..de1dfa785f 100644 --- a/source/states/TitleState.hx +++ b/source/states/TitleState.hx @@ -88,7 +88,8 @@ class TitleState extends MusicBeatState { #end MusicBeatState.windowNamePrefix = Options.getData("curMod"); CoolUtil.setWindowIcon("mods/" + Options.getData("curMod") + "/_polymod_icon.png"); - + FlxG.drawFramerate = Options.getData("maxFPS"); + #if FLX_NO_DEBUG if (Options.getData("flixelStartupScreen") && !doneFlixelSplash) { doneFlixelSplash = true; @@ -96,12 +97,12 @@ class TitleState extends MusicBeatState { return; } #end - + if (Options.getData("flashingLights") == null) FlxG.switchState(new FlashingLightsMenu()); - + curWacky = FlxG.random.getObject(getIntroTextShit()); - + super.create(); #if DISCORD_ALLOWED @@ -411,10 +412,12 @@ class TitleState extends MusicBeatState { textDataText(2); case 7: textDataText(3); - newgrounds.visible = true; + if(newgrounds != null) + newgrounds.visible = true; case 8: deleteCoolText(); - newgrounds.visible = false; + if(newgrounds != null) + newgrounds.visible = false; case 9: if (curWacky[0] != null) { createCoolText([curWacky[0]]); diff --git a/source/substates/MaxFPSMenu.hx b/source/substates/MaxFPSMenu.hx index 2979cf0002..a3602b45ca 100644 --- a/source/substates/MaxFPSMenu.hx +++ b/source/substates/MaxFPSMenu.hx @@ -36,6 +36,8 @@ class MaxFPSMenu extends MusicBeatSubstate override function update(elapsed:Float) { super.update(elapsed); + FlxG.stage.frameRate = flixel.math.FlxMath.bound(fps, 0.1, 1000); + var leftP = controls.LEFT_P; var rightP = controls.RIGHT_P; diff --git a/source/substates/MusicBeatSubstate.hx b/source/substates/MusicBeatSubstate.hx index fc22451064..c5ae4c1033 100644 --- a/source/substates/MusicBeatSubstate.hx +++ b/source/substates/MusicBeatSubstate.hx @@ -47,8 +47,6 @@ class MusicBeatSubstate extends FlxSubState { super.update(elapsed); - if (FlxG.stage != null) - FlxG.stage.frameRate = flixel.math.FlxMath.bound(Options.getData("maxFPS"), 0.1, 1000); if (!Options.getData("antialiasing")) { forEachAlive(function(basic:FlxBasic) {