Skip to content

Commit

Permalink
Fix repeating number option (#243)
Browse files Browse the repository at this point in the history
* round number option

* optimized

---------

Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
  • Loading branch information
bctix and NexIsDumb authored Feb 15, 2024
1 parent 8cabf1e commit b02839d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions source/funkin/options/type/NumOption.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b02839d

Please sign in to comment.