From 828c17731de112caeb680555248b5e9e886b90cf Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:36:03 +0700 Subject: [PATCH] Fix custom options crash --- source/funkin/options/OptionsMenu.hx | 7 +++++-- source/funkin/options/type/NumOption.hx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index 10484ce1..0cc170e6 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -171,7 +171,8 @@ class OptionsMenu extends TreeMenu { Logs.warn("A number option requires an \"id\" for option saving."); continue; } - options.push(new NumOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), Std.parseFloat(node.att.step), node.att.id, null, FlxG.save.data)); + var step = node.has.change ? Std.parseFloat(node.att.change) : (node.has.step ? Std.parseFloat(node.att.step) : null); + options.push(new NumOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), step, node.att.id, null, FlxG.save.data)); case "choice": if (!node.has.id) { Logs.warn("A choice option requires an \"id\" for option saving."); @@ -200,7 +201,9 @@ class OptionsMenu extends TreeMenu { Logs.warn("A slider option requires an \"id\" for option saving."); continue; } - options.push(new SliderOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), Std.parseFloat(node.att.step), Std.parseInt(node.att.segments), node.att.id, Std.parseInt(node.att.barWidth), null, FlxG.save.data)); + var step = node.has.change ? Std.parseFloat(node.att.change) : (node.has.step ? Std.parseFloat(node.att.step) : null); + var segments = node.has.segments ? Std.parseInt(node.att.segments) : 5; + options.push(new SliderOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), step, segments, node.att.id, Std.parseInt(node.att.barWidth), null, FlxG.save.data)); case 'separator': options.push(new Separator(Std.parseInt(node.att.height))); diff --git a/source/funkin/options/type/NumOption.hx b/source/funkin/options/type/NumOption.hx index f1d2a33e..27c92966 100644 --- a/source/funkin/options/type/NumOption.hx +++ b/source/funkin/options/type/NumOption.hx @@ -40,7 +40,7 @@ class NumOption extends TextOption { override function changeSelection(change:Int):Void { if (locked) return; - if (currentValue == (currentValue = FlxMath.bound(currentValue + change, min, max))) return; + if (currentValue == (currentValue = FlxMath.bound(currentValue + change * step, min, max))) return; __number.text = ': $currentValue'; Reflect.setField(parent, optionName, currentValue);