mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
order code
This commit is contained in:
5 files changed
+47
-58
No files matched your search
@@ -61,10 +61,10 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
/// <param name="max">The maximum value.</param>
|
||||
/// <param name="increment">The increment.</param>
|
||||
/// <param name="suffixType">The suffix type.</param>
|
||||
/// <param name="formatString">Optional format string for the option screen.</param>
|
||||
/// <param name="zeroBehavior">Determines what is shown for zero. Options: ∞, #, or a word value (such as Off).</param>
|
||||
/// <param name="negativeBehavior">Determines what is shown for negative 1. Options: ∞, #, or a word value (such as Off).</param>
|
||||
/// <param name="zeroBehavior">Determines what is shown for zero.</param>
|
||||
/// <param name="negativeBehavior">Determines what is shown for negative 1.</param>
|
||||
/// <param name="halfIncrements">Whether increments can be split in half.</param>
|
||||
/// <param name="formatString">Optional format string for the option screen.</param>
|
||||
/// <param name="includeInPreset">Whether to include this option in the preset or not.</param>
|
||||
public ModdedNumberOption(
|
||||
string title,
|
||||
@@ -78,36 +78,8 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
string? formatString = null,
|
||||
bool halfIncrements = false,
|
||||
bool includeInPreset = true)
|
||||
: base(title, defaultValue, includeInPreset)
|
||||
: this(title, defaultValue, min, max, increment, suffixType, zeroBehavior, negativeBehavior, halfIncrements, formatString, includeInPreset)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
Increment = increment;
|
||||
SuffixType = suffixType;
|
||||
ZeroWordValue = zeroBehavior;
|
||||
NegativeWordValue = negativeBehavior;
|
||||
ShiftIncrement = halfIncrements;
|
||||
|
||||
Value = Mathf.Clamp(defaultValue, min, max);
|
||||
|
||||
Data = ScriptableObject.CreateInstance<FloatGameSetting>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,8 +91,8 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
/// <param name="max">The maximum value.</param>
|
||||
/// <param name="increment">The increment.</param>
|
||||
/// <param name="suffixType">The suffix type.</param>
|
||||
/// <param name="formatString">Optional format string for the option screen.</param>
|
||||
/// <param name="zeroInfinity">Whether zero is infinity or not.</param>
|
||||
/// <param name="formatString">Optional format string for the option screen.</param>
|
||||
/// <param name="includeInPreset">Whether to include this option in the preset or not.</param>
|
||||
public ModdedNumberOption(
|
||||
string title,
|
||||
@@ -132,21 +104,35 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
string? formatString = null,
|
||||
bool zeroInfinity = false,
|
||||
bool includeInPreset = true)
|
||||
: this(title, defaultValue, min, max, increment, suffixType, zeroInfinity ? "∞" : "#", "#", increment == 1f, formatString, includeInPreset)
|
||||
{
|
||||
}
|
||||
|
||||
private ModdedNumberOption(
|
||||
string title,
|
||||
float defaultValue,
|
||||
float min,
|
||||
float max,
|
||||
float increment,
|
||||
MiraNumberSuffixes suffixType,
|
||||
string zeroBehavior,
|
||||
string negativeBehavior,
|
||||
bool shiftIncrement,
|
||||
string? formatString,
|
||||
bool includeInPreset)
|
||||
: base(title, defaultValue, includeInPreset)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
Increment = increment;
|
||||
SuffixType = suffixType;
|
||||
ZeroWordValue = zeroInfinity ? "∞" : "#";
|
||||
NegativeWordValue = "#";
|
||||
ShiftIncrement = Mathf.Approximately(increment, 1f);
|
||||
ZeroWordValue = zeroBehavior;
|
||||
ShiftIncrement = shiftIncrement;
|
||||
NegativeWordValue = negativeBehavior;
|
||||
|
||||
Value = Mathf.Clamp(defaultValue, min, max);
|
||||
|
||||
Data = ScriptableObject.CreateInstance<FloatGameSetting>();
|
||||
|
||||
var data = (FloatGameSetting)Data;
|
||||
var data = ScriptableObject.CreateInstance<FloatGameSetting>();
|
||||
data.Type = global::OptionTypes.Float;
|
||||
data.Title = StringName;
|
||||
data.Value = Value;
|
||||
@@ -162,6 +148,8 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
data.ZeroIsInfinity = ZeroInfinity;
|
||||
data.SuffixType = (NumberSuffixes)SuffixType;
|
||||
data.OptionName = FloatOptionNames.Invalid;
|
||||
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -44,6 +44,13 @@ public class ModdedOptionList<T> : IModdedOptionList<T>
|
||||
Options = [.. options];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexes the option of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <param name="idx">The option's index.</param>
|
||||
/// <returns>option of type <typeparamref name="T"/>.</returns>
|
||||
public T this[int idx] => Options[idx];
|
||||
|
||||
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
@@ -62,13 +69,6 @@ public class ModdedOptionList<T> : IModdedOptionList<T>
|
||||
return ((IEnumerable<IModdedOption>)Options).GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexes the option of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <param name="idx">The option's index.</param>
|
||||
/// <returns>option of type <typeparamref name="T"/>.</returns>
|
||||
public T this[int idx] => Options[idx];
|
||||
|
||||
/// <inheritdoc cref="IReadOnlyList{T}.this"/>
|
||||
IModdedOption IReadOnlyList<IModdedOption>.this[int index] => this[index];
|
||||
}
|
||||
@@ -37,15 +37,16 @@ public class ModdedPlayerOption : ModdedOption<int>
|
||||
public ModdedPlayerOption(string title, bool allowNone = true)
|
||||
: base(title, allowNone ? -1 : 0, false)
|
||||
{
|
||||
Data = ScriptableObject.CreateInstance<PlayerSelectionGameSetting>();
|
||||
var data = (PlayerSelectionGameSetting)Data;
|
||||
Values = [];
|
||||
AllowNone = allowNone;
|
||||
|
||||
Value = DefaultValue;
|
||||
|
||||
var data = ScriptableObject.CreateInstance<PlayerSelectionGameSetting>();
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.Player;
|
||||
|
||||
Values = [];
|
||||
AllowNone = allowNone;
|
||||
Value = DefaultValue;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -36,15 +36,15 @@ public class ModdedStringOption : ModdedOption<string>
|
||||
: base(title, defaultValue, includeInPreset)
|
||||
{
|
||||
Values = values;
|
||||
Data = ScriptableObject.CreateInstance<StringGameSetting>();
|
||||
var data = (StringGameSetting)Data;
|
||||
StringNameValues = [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
|
||||
var data = ScriptableObject.CreateInstance<StringGameSetting>();
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
StringNameValues = [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
data.Values = StringNameValues;
|
||||
|
||||
data.Index = GetIndex(Value);
|
||||
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -20,11 +20,11 @@ public class ModdedToggleOption : ModdedOption<bool>
|
||||
public ModdedToggleOption(string title, bool defaultValue, bool includeInPreset = true)
|
||||
: base(title, defaultValue, includeInPreset)
|
||||
{
|
||||
Data = ScriptableObject.CreateInstance<CheckboxGameSetting>();
|
||||
|
||||
var data = (CheckboxGameSetting)Data;
|
||||
var data = ScriptableObject.CreateInstance<CheckboxGameSetting>();
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.Checkbox;
|
||||
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in new issue
Block a user