mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
35 lines
994 B
C#
35 lines
994 B
C#
using System.Globalization;
|
|
|
|
namespace EHR;
|
|
|
|
public class FloatOptionItem(int id, string name, FloatValueRule rule, float defaultValue, TabGroup tab, bool isSingleValue = false) : OptionItem(id, name, rule.GetNearestIndex(defaultValue), tab, isSingleValue)
|
|
{
|
|
public readonly FloatValueRule Rule = rule;
|
|
|
|
// Getter
|
|
public override int GetInt()
|
|
{
|
|
return (int)Rule.GetValueByIndex(CurrentValue);
|
|
}
|
|
|
|
public override float GetFloat()
|
|
{
|
|
return Rule.GetValueByIndex(CurrentValue);
|
|
}
|
|
|
|
public override string GetString()
|
|
{
|
|
return ApplyFormat(((float)((int)(Rule.GetValueByIndex(CurrentValue) * 100) * 1.0) / 100).ToString(CultureInfo.CurrentCulture));
|
|
}
|
|
|
|
public override int GetValue()
|
|
{
|
|
return Rule.RepeatIndex(base.GetValue());
|
|
}
|
|
|
|
// Setter
|
|
public override void SetValue(int value, bool doSync = true)
|
|
{
|
|
base.SetValue(Rule.RepeatIndex(value), doSync);
|
|
}
|
|
} |