Fix repeating number option (#243)

* round number option

* optimized

---------

Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
This commit is contained in:
bctix
2024-02-15 15:36:10 +01:00
committed by GitHub
co-authored by ⍚~Nex
parent 8cabf1e31d
commit b02839dfa4
+3 -7
View File
@@ -36,19 +36,15 @@ class NumOption extends OptionType {
this.currentSelection = Reflect.field(parent, optionName);
this.changeVal = changeVal;
this.optionName = optionName;
add(__text = new Alphabet(100, 20, text, true));
add(__number = new Alphabet(__text.width + 120, -30, ': $currentSelection', false));
}
public override function draw() {
super.draw();
}
public override function onChangeSelection(change:Float):Void
{
if(currentSelection <= min && change == -1 || currentSelection >= max && change == 1 ) return;
currentSelection += change*changeVal;
if(currentSelection <= min && change == -1 || currentSelection >= max && change == 1) return;
currentSelection = FlxMath.roundDecimal(currentSelection + (change * changeVal), FlxMath.getDecimals(changeVal));
__number.text = ': $currentSelection';
Reflect.setField(parent, optionName, currentSelection);