diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs index 04cfd09..ec9e24f 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs @@ -32,16 +32,83 @@ public class ModdedNumberOption : ModdedOption /// public MiraNumberSuffixes SuffixType { get; } + /// + /// Gets a value indicating what zero appears as. + /// + public string ZeroWordValue { get; } + + /// + /// Gets a value indicating what negative one appears as. + /// + public string NegativeWordValue { get; } + /// /// Gets a value indicating whether zero is infinity. /// - public bool ZeroInfinity { get; } + public bool ZeroInfinity => ZeroWordValue == "∞"; /// /// Gets a value indicating whether holding shift will divide the increment. /// public bool ShiftIncrement { get; } + /// + /// Initializes a new instance of the class. + /// + /// The title of the option. + /// The default value as a float. + /// The minimum value. + /// The maximum value. + /// The increment. + /// The suffix type. + /// Optional format string for the option screen. + /// Determines what is shown for zero. Options: ∞, #, or a word value (such as Off). + /// Determines what is shown for negative 1. Options: ∞, #, or a word value (such as Off). + /// Whether increments can be split in half. + /// Whether to include this option in the preset or not. + public ModdedNumberOption( + string title, + float defaultValue, + float min, + float max, + float increment, + string zeroBehavior, + string negativeBehavior, + MiraNumberSuffixes suffixType, + string? formatString = null, + bool halfIncrements = false, + bool includeInPreset = true) : base(title, defaultValue, includeInPreset) + { + Min = min; + Max = max; + Increment = increment; + SuffixType = suffixType; + ZeroWordValue = zeroBehavior; + NegativeWordValue = negativeBehavior; + ShiftIncrement = halfIncrements; + + Value = Mathf.Clamp(defaultValue, min, max); + + Data = ScriptableObject.CreateInstance(); + + var data = (FloatGameSetting)Data; + data.Type = global::OptionTypes.Float; + data.Title = StringName; + data.Value = Value; + data.Increment = Increment; + data.ValidRange = new FloatRange(Min, Max); + data.FormatString = formatString ?? + (defaultValue.IsInteger() && + Increment.IsInteger() && + Value.IsInteger() && + Min.IsInteger() && + Max.IsInteger() ? "0" : "0.0"); + + data.ZeroIsInfinity = ZeroInfinity; + data.SuffixType = (NumberSuffixes)SuffixType; + data.OptionName = FloatOptionNames.Invalid; + } + /// /// Initializes a new instance of the class. /// @@ -69,7 +136,8 @@ public class ModdedNumberOption : ModdedOption Max = max; Increment = increment; SuffixType = suffixType; - ZeroInfinity = zeroInfinity; + ZeroWordValue = zeroInfinity ? "∞" : "#"; + NegativeWordValue = "#"; ShiftIncrement = increment != 1f; Value = Mathf.Clamp(defaultValue, min, max);