Fix custom options crash

This commit is contained in:
Ralty
2025-08-02 03:36:03 +07:00
parent 0aa30ef781
commit 828c17731d
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -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)));
+1 -1
View File
@@ -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);