From 077bf8e116d54fa44906420f5d4829fb78c57b14 Mon Sep 17 00:00:00 2001 From: Chronic x3 <126361810+chronicsilly@users.noreply.github.com> Date: Fri, 25 Jul 2025 20:46:55 +0100 Subject: [PATCH] Debug options are now in the options menu Also disappear/reappear depending on the devMode bool's state --- source/funkin/editors/EditorPicker.hx | 5 --- source/funkin/options/OptionsMenu.hx | 28 +++++++++++++++ source/funkin/options/OptionsScreen.hx | 4 +++ .../categories}/DebugOptions.hx | 36 +++---------------- 4 files changed, 37 insertions(+), 36 deletions(-) rename source/funkin/{editors => options/categories}/DebugOptions.hx (65%) diff --git a/source/funkin/editors/EditorPicker.hx b/source/funkin/editors/EditorPicker.hx index 7ddd06f8..ea751908 100644 --- a/source/funkin/editors/EditorPicker.hx +++ b/source/funkin/editors/EditorPicker.hx @@ -42,11 +42,6 @@ class EditorPicker extends MusicBeatSubstate { onClick: function() { CoolUtil.openURL(Flags.URL_WIKI); } - }, - { - name: "Debug Options", - id: "debugOptions", - state: DebugOptions } ]; diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index ace34aad..cba1c9af 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -42,11 +42,21 @@ class OptionsMenu extends TreeMenu { desc: 'optionsTree.miscellaneous-desc', suffix: " >", state: MiscOptions + }, + { + name: "Debug Options", + desc: "debugOptions", + suffix: " >", + state: DebugOptions } ]; var bg:FlxSprite; + var addedDebugOptions:Bool = !Options.devMode; + var debugModeButton:OptionType; + var debugModeIndex:Int = mainOptions.length - 1; + public override function create() { super.create(); @@ -99,6 +109,12 @@ class OptionsMenu extends TreeMenu { if (access != null) for (o in parseOptionsFromXML(access)) main.add(o); } } + + doDebugOptionThing(); + } + + public override function onMenuClose(m:OptionsScreen) { + doDebugOptionThing(); } public function reloadStrings() { @@ -115,6 +131,18 @@ class OptionsMenu extends TreeMenu { super.exit(); } + function doDebugOptionThing() { + if ((Options.devMode && !addedDebugOptions) || (!Options.devMode && addedDebugOptions)) { + trace((addedDebugOptions ? "remove" : "add") + " option"); + addedDebugOptions = !addedDebugOptions; + if (debugModeButton == null) debugModeButton = main.members[debugModeIndex]; + if (addedDebugOptions) + main.add(debugModeButton); + else + main.remove(debugModeButton); + } + } + /** * XML STUFF */ diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index 53dd5b06..bb71aec9 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -113,6 +113,10 @@ class OptionsScreen extends FlxTypedSpriteGroup { CoolUtil.playMenuSFX(SCROLL); curSelected = FlxMath.wrap(curSelected + sel, 0, members.length-1); + if (members[curSelected] == null) { + changeSelection(sel, true); + return; + } members[curSelected].selected = true; updateMenuDesc(); } diff --git a/source/funkin/editors/DebugOptions.hx b/source/funkin/options/categories/DebugOptions.hx similarity index 65% rename from source/funkin/editors/DebugOptions.hx rename to source/funkin/options/categories/DebugOptions.hx index 25375a3b..16676890 100644 --- a/source/funkin/editors/DebugOptions.hx +++ b/source/funkin/options/categories/DebugOptions.hx @@ -1,41 +1,15 @@ -package funkin.editors; +package funkin.options.categories; import funkin.backend.utils.NativeAPI; -import funkin.options.OptionsScreen; -import funkin.options.TreeMenu; -import funkin.options.type.*; -class DebugOptions extends TreeMenu { - public override function create() { - super.create(); +class DebugOptions extends OptionsScreen { + public override function new(title:String, desc:String) { + super(title, desc, "DebugOptions."); - FlxG.camera.fade(0xFF000000, 0.5, true); - - var bg:FlxSprite = new FlxSprite(-80).loadAnimatedGraphic(Paths.image('menus/menuBGBlue')); - // bg.scrollFactor.set(); - bg.scale.set(1.15, 1.15); - bg.updateHitbox(); - bg.screenCenter(); - bg.scrollFactor.set(); - bg.antialiasing = true; - add(bg); - - main = new DebugOptionsScreen(); - } -} - -class DebugOptionsScreen extends OptionsScreen { - public override function new() { - prefix = "DebugOptions."; - super(translate("title"), translate("desc"), prefix); - #if windows add(new TextOption( getName("showConsole"), getDesc("showConsole"), - function() { - NativeAPI.allocConsole(); - })); - #end + function() NativeAPI.allocConsole())); add(new Checkbox( getName("editorsResizable"), getDesc("editorsResizable"),