public FloatElement(string text, Color color, float minValue, float maxValue, float increment, float startValue, int decimalRestriction, Action <float> onValueChanged, string units = "", string subtitleText = "") : base(text, color, subtitleText) { this.minValue = minValue; this.maxValue = maxValue; this.increment = increment; this.units = units; if (decimalRestriction >= 0) { this.decimalRestriction = decimalRestriction; } this.value = startValue; this.onValueChanged = new FloatElement.OnValueChanged(onValueChanged.Invoke); }
public override void OnLeft() { float num = this.value; num -= this.increment; if (num < this.minValue) { num = this.maxValue; } num = (float)Math.Round((double)num, this.decimalRestriction); this.value = num; FloatElement.OnValueChanged onValueChanged = this.onValueChanged; if (onValueChanged != null) { onValueChanged(this.value); } this.Render(base.GetTextObject()); }