diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs index ff422f5..3c6c84c 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs @@ -104,7 +104,7 @@ public class ModdedEnumOption : ModdedOption /// An option for selecting an enum value. /// /// The enum type. -public class ModdedEnumOption : ModdedOption where T : Enum +public class ModdedEnumOption : ModdedOption where T : struct, Enum { /// /// Gets the string values of the enum. @@ -119,17 +119,17 @@ public class ModdedEnumOption : ModdedOption where T : Enum /// An option list of string values to use in place of the enum name. public ModdedEnumOption(string title, T defaultValue, string[]? values = null) : base(title, defaultValue) { - Values = values ?? Enum.GetNames(typeof(T)); + Values = values ?? Enum.GetNames(); Data = ScriptableObject.CreateInstance(); var data = (StringGameSetting)Data; data.Title = StringName; data.Type = global::OptionTypes.String; - data.Values = values is null ? - Enum.GetNames(typeof(T)).Select(CustomStringName.CreateAndRegister).ToArray() - : values.Select(CustomStringName.CreateAndRegister).ToArray(); + data.Values = (values is null + ? Enum.GetNames().Select(CustomStringName.CreateAndRegister) + : values.Select(CustomStringName.CreateAndRegister)).ToArray(); - data.Index = Convert.ToInt32(Value); + data.Index = Convert.ToInt32(Value, NumberFormatInfo.InvariantInfo); } /// @@ -138,9 +138,9 @@ public class ModdedEnumOption : ModdedOption where T : Enum var stringOption = Object.Instantiate(stringOpt, container); stringOption.SetUpFromData(Data, 20); - stringOption.OnValueChanged = (Il2CppSystem.Action)ValueChanged; + stringOption.OnValueChanged = (Action)ValueChanged; - // SetUpFromData method doesnt work correctly so we must set the values manually + // SetUpFromData method doesn't work correctly so we must set the values manually stringOption.Title = StringName; stringOption.Values = (Data as StringGameSetting)?.Values ?? new Il2CppStructArray(0); stringOption.Value = Convert.ToInt32(Value, NumberFormatInfo.InvariantInfo);