Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion source/funkin/ui/options/items/NumberPreferenceItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class NumberPreferenceItem extends TextMenuItem
public var min:Float;
public var max:Float;
public var step:Float;
public var baseStep:Float;
public var precision:Int;
public var onChangeCallback:Null<Float->Void>;
public var valueFormatter:Null<Float->String>;
public var dragStepMultiplier:Float;
public var keyMultiplier:Float;

// Variables
var holdDelayTimer:Float = HOLD_DELAY; // seconds
Expand All @@ -45,9 +47,10 @@ class NumberPreferenceItem extends TextMenuItem
* @param callback Will get called every time the user changes the setting; use this to apply/save the setting.
* @param valueFormatter Will get called every time the game needs to display the float value; use this to change how the displayed string looks
* @param dragStepMultiplier The multiplier for step value in case player does touch drag.
* @param keyMultiplier The multiplier for pressing Left or Right on a Number Preference Item while holding Shift.
*/
public function new(x:Float, y:Float, name:String, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int, ?callback:Float->Void,
?valueFormatter:Float->String, dragStepMultiplier:Float = 1):Void
?valueFormatter:Float->String, dragStepMultiplier:Float = 1, keyMultiplier:Float = 5):Void
{
super(x, y, name, function() {
callback(this.currentValue);
Expand All @@ -60,10 +63,12 @@ class NumberPreferenceItem extends TextMenuItem
this.min = min;
this.max = max;
this.step = step;
this.baseStep = step;
this.precision = precision;
this.onChangeCallback = callback;
this.valueFormatter = valueFormatter;
this.dragStepMultiplier = dragStepMultiplier;
this.keyMultiplier = keyMultiplier;

this.fireInstantly = true;
}
Expand All @@ -90,6 +95,16 @@ class NumberPreferenceItem extends TextMenuItem
changeRateTimer = 0.0;
}

step = baseStep;

if (selected)
{
if (FlxG.keys.pressed.SHIFT)
{
step = baseStep * keyMultiplier;
}
}

var shouldDecrease:Bool = jpLeft;
var shouldIncrease:Bool = jpRight;
var valueChangeMultiplier:Float = 1;
Expand Down