From 6d73a9ef4b576217b2b7a33aa37be4137efd2030 Mon Sep 17 00:00:00 2001 From: bctix <51544115+bctix@users.noreply.github.com> Date: Thu, 8 Feb 2024 18:04:41 -0500 Subject: [PATCH 1/3] Add array option type (#241) * Add Array option type * Prevent nulls * add display options * change xml structure --- assets/data/config/options.xml | 6 +- source/funkin/options/OptionsMenu.hx | 17 +++++ source/funkin/options/type/ArrayOption.hx | 77 +++++++++++++++++++++++ 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 source/funkin/options/type/ArrayOption.hx diff --git a/assets/data/config/options.xml b/assets/data/config/options.xml index e14baa09..888288d7 100644 --- a/assets/data/config/options.xml +++ b/assets/data/config/options.xml @@ -4,9 +4,9 @@ - - - + + + diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index b0546bc6..186e3249 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -121,6 +121,23 @@ class OptionsMenu extends TreeMenu { continue; } options.push(new NumOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), Std.parseFloat(node.att.change), node.att.id, null, FlxG.save.data)); + case "choice": + if (!node.has.id) { + Logs.trace("A choice option requires an \"id\" for option saving.", WARNING); + continue; + } + + var optionOptions:Array = []; + var optionDisplayOptions:Array = []; + + for(choice in node.elements) { + optionOptions.push(choice.att.value); + optionDisplayOptions.push(choice.att.name); + } + + if(optionOptions.length > 0) + options.push(new ArrayOption(name, desc, optionOptions, optionDisplayOptions, node.att.id, null, FlxG.save.data)); + case "menu": options.push(new TextOption(name + " >", desc, function() { optionsTree.add(new OptionsScreen(name, desc, parseOptionsFromXML(node))); diff --git a/source/funkin/options/type/ArrayOption.hx b/source/funkin/options/type/ArrayOption.hx new file mode 100644 index 00000000..edbc4e72 --- /dev/null +++ b/source/funkin/options/type/ArrayOption.hx @@ -0,0 +1,77 @@ +package funkin.options.type; + +import flixel.effects.FlxFlicker; + +class ArrayOption extends OptionType { + public var selectCallback:String->Void; + + private var __text:Alphabet; + private var __selectiontext:Alphabet; + + public var options:Array; + public var displayOptions:Array; + + public var currentSelection:Int; + + var optionName:String; + + public var parent:Dynamic; + + public var text(get, set):String; + private function get_text() {return __text.text;} + private function set_text(v:String) {return __text.text = v;} + + public function new(text:String, desc:String, options:Array, displayOptions:Array, optionName:String, ?selectCallback:String->Void = null, ?parent:Dynamic) { + super(desc); + this.selectCallback = selectCallback; + this.displayOptions = displayOptions; + this.options = options; + if (parent == null) + parent = Options; + + this.parent = parent; + + if(Reflect.field(parent, optionName) != null) + { + if(options.indexOf(Reflect.field(parent, optionName)) != -1) + this.currentSelection = options.indexOf(Reflect.field(parent, optionName)); + else + this.currentSelection = 0; + } + + + this.optionName = optionName; + + add(__text = new Alphabet(100, 20, text, true)); + add(__selectiontext = new Alphabet(__text.width + 120, -30, formatTextOption(), false)); + } + + public override function draw() { + super.draw(); + } + + public override function onChangeSelection(change:Float):Void + { + if(currentSelection <= 0 && change == -1 || currentSelection >= options.length - 1 && change == 1 ) return; + currentSelection += Math.round(change); + __selectiontext.text = formatTextOption(); + Reflect.setField(parent, optionName, options[currentSelection]); + if(selectCallback != null) + selectCallback(options[currentSelection]); + } + + private function formatTextOption() { + var currentOptionString = ": "; + if((currentSelection > 0)) + currentOptionString += "< "; + else + currentOptionString += " "; + + currentOptionString += displayOptions[currentSelection]; + + if(!(currentSelection >= options.length - 1)) + currentOptionString += " >"; + + return currentOptionString; + } +} \ No newline at end of file From b46d816e006a51969e022e9e569e0dd517848c64 Mon Sep 17 00:00:00 2001 From: crowplexus <45212377+crowplexus@users.noreply.github.com> Date: Fri, 9 Feb 2024 08:05:45 -0400 Subject: [PATCH 2/3] Change some strings to comply with the newest version (#242) * Update README.md * Update CodenameBuildField.hx * Update MainMenuState.hx * Update CodenameBuildField.hx * Delete unused Main.hx file --- README.md | 2 +- source/Main.hx | 1 - .../system/framerate/CodenameBuildField.hx | 8 ++++++-- source/funkin/menus/MainMenuState.hx | 20 +++++-------------- 4 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 source/Main.hx diff --git a/README.md b/README.md index 24d415c6..0f623784 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## PLEASE NOTE - THIS IS STILL IN A BETA STATE ### Mods created with beta versions of Codename may not be compatible with the release version -Known issues in the alpha: +Known issues in the beta: - Some options are missing - Week 6 still have no dialogue diff --git a/source/Main.hx b/source/Main.hx deleted file mode 100644 index dfea956d..00000000 --- a/source/Main.hx +++ /dev/null @@ -1 +0,0 @@ -typedef Main = funkin.backend.system.Main; \ No newline at end of file diff --git a/source/funkin/backend/system/framerate/CodenameBuildField.hx b/source/funkin/backend/system/framerate/CodenameBuildField.hx index ad783ccb..248adcad 100644 --- a/source/funkin/backend/system/framerate/CodenameBuildField.hx +++ b/source/funkin/backend/system/framerate/CodenameBuildField.hx @@ -6,11 +6,15 @@ import openfl.text.TextField; import funkin.backend.system.macros.GitCommitMacro; class CodenameBuildField extends TextField { + // make this empty once you guys are done with the project. + // good luck /gen <3 @crowplexus + public static final releaseCycle:String = " Beta"; + public function new() { super(); defaultTextFormat = Framerate.textFormat; autoSize = LEFT; multiline = wordWrap = false; - text = 'Codename Engine Beta\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; + text = 'Codename Engine${releaseCycle}\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; } -} \ No newline at end of file +} diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 2b73ab10..33ff079d 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -77,8 +77,8 @@ class MainMenuState extends MusicBeatState FlxG.camera.follow(camFollow, null, 0.06); var versionShit:FunkinText = new FunkinText(5, FlxG.height - 2, 0, 'Codename Engine v${Application.current.meta.get('version')}\nAlpha: Commit ${funkin.backend.system.macros.GitCommitMacro.commitNumber} (${funkin.backend.system.macros.GitCommitMacro.commitHash})\n[TAB] Open Mods menu\n'); - versionShit.scrollFactor.set(); versionShit.y -= versionShit.height; + versionShit.scrollFactor.set(); add(versionShit); changeItem(); @@ -165,20 +165,10 @@ class MainMenuState extends MusicBeatState if (event.cancelled) return; switch (daChoice) { - case 'story mode': - FlxG.switchState(new StoryMenuState()); - trace("Story Menu Selected"); - - case 'freeplay': - FlxG.switchState(new FreeplayState()); - trace("Freeplay Menu Selected"); - - case 'donate': - FlxG.switchState(new CreditsMain()); - trace("Credits Menu Selected"); - - case 'options': - FlxG.switchState(new OptionsMenu()); + case 'story mode': FlxG.switchState(new StoryMenuState()); + case 'freeplay': FlxG.switchState(new FreeplayState()); + case 'donate': FlxG.switchState(new CreditsMain()); + case 'options': FlxG.switchState(new OptionsMenu()); } }); } From 8cabf1e31d7dd6b6543c0c386a9e7038d2c05c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:07:09 +0100 Subject: [PATCH 3/3] fixing da pr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #242 and also under @NeeEoo suggestion ive deleted that string part in mainmenustate please tell me if you find another alpha message instead of beta😭 --- source/funkin/backend/system/Main.hx | 4 ++++ .../funkin/backend/system/framerate/CodenameBuildField.hx | 6 +----- source/funkin/import.hx | 3 ++- source/funkin/menus/BetaWarningState.hx | 2 +- source/funkin/menus/MainMenuState.hx | 2 +- source/openfl/utils/Assets.hx | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index 202b5fac..d715103e 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -36,6 +36,10 @@ import funkin.backend.assets.ModsFolder; class Main extends Sprite { + // make this empty once you guys are done with the project. + // good luck /gen <3 @crowplexus + public static final releaseCycle:String = "Beta"; + public static var instance:Main; public static var modToLoad:String = null; diff --git a/source/funkin/backend/system/framerate/CodenameBuildField.hx b/source/funkin/backend/system/framerate/CodenameBuildField.hx index 248adcad..2cef4a26 100644 --- a/source/funkin/backend/system/framerate/CodenameBuildField.hx +++ b/source/funkin/backend/system/framerate/CodenameBuildField.hx @@ -6,15 +6,11 @@ import openfl.text.TextField; import funkin.backend.system.macros.GitCommitMacro; class CodenameBuildField extends TextField { - // make this empty once you guys are done with the project. - // good luck /gen <3 @crowplexus - public static final releaseCycle:String = " Beta"; - public function new() { super(); defaultTextFormat = Framerate.textFormat; autoSize = LEFT; multiline = wordWrap = false; - text = 'Codename Engine${releaseCycle}\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; + text = 'Codename Engine ${Main.releaseCycle}\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; } } diff --git a/source/funkin/import.hx b/source/funkin/import.hx index 4ef601e8..eca238fd 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -1,4 +1,5 @@ #if !macro +import funkin.backend.system.Main; import funkin.backend.assets.Paths; import funkin.backend.MusicBeatState; import funkin.backend.MusicBeatSubstate; @@ -27,4 +28,4 @@ import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; using StringTools; using funkin.backend.utils.CoolUtil; -#end +#end \ No newline at end of file diff --git a/source/funkin/menus/BetaWarningState.hx b/source/funkin/menus/BetaWarningState.hx index 2f234f5a..78813ac0 100644 --- a/source/funkin/menus/BetaWarningState.hx +++ b/source/funkin/menus/BetaWarningState.hx @@ -20,7 +20,7 @@ class BetaWarningState extends MusicBeatState { disclaimer = new FunkinText(16, titleAlphabet.y + titleAlphabet.height + 10, FlxG.width - 32, "", 32); disclaimer.alignment = CENTER; - disclaimer.applyMarkup("This engine is still in a beta state. That means *majority of the features* are either *buggy* or *non finished*. If you find any bugs, please report them to the Codename Engine GitHub.\n\nPress ENTER to continue", + disclaimer.applyMarkup('This engine is still in a *${Main.releaseCycle}* state. That means *majority of the features* are either *buggy* or *non finished*. If you find any bugs, please report them to the Codename Engine GitHub.\n\nPress ENTER to continue', [ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFF4444), "*") ] diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 33ff079d..ea6a71b9 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -76,7 +76,7 @@ class MainMenuState extends MusicBeatState FlxG.camera.follow(camFollow, null, 0.06); - var versionShit:FunkinText = new FunkinText(5, FlxG.height - 2, 0, 'Codename Engine v${Application.current.meta.get('version')}\nAlpha: Commit ${funkin.backend.system.macros.GitCommitMacro.commitNumber} (${funkin.backend.system.macros.GitCommitMacro.commitHash})\n[TAB] Open Mods menu\n'); + var versionShit:FunkinText = new FunkinText(5, FlxG.height - 2, 0, 'Codename Engine v${Application.current.meta.get('version')}\nCommit ${funkin.backend.system.macros.GitCommitMacro.commitNumber} (${funkin.backend.system.macros.GitCommitMacro.commitHash})\n[TAB] Open Mods menu\n'); versionShit.y -= versionShit.height; versionShit.scrollFactor.set(); add(versionShit); diff --git a/source/openfl/utils/Assets.hx b/source/openfl/utils/Assets.hx index f28eea05..528632ca 100644 --- a/source/openfl/utils/Assets.hx +++ b/source/openfl/utils/Assets.hx @@ -1,5 +1,6 @@ package openfl.utils; +import funkin.backend.system.Main; import funkin.options.Options; import funkin.backend.system.OptimizedBitmapData; import openfl.utils._internal.Log;