using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RiskOfOptions;
using RiskOfOptions.Components.Options;
using RiskOfOptions.Components.Panel;
using RiskOfOptions.Containers;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using SimpleJSON;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Local.Option.Generator
{
internal abstract class Option<T> : BaseOption, ITypedValueHolder<T> where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
{
protected abstract class Field : ModSettingsNumericField<T>
{
public override bool TryParse(string text, NumberStyles style, IFormatProvider provider, out T result)
{
try
{
result = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(text);
return true;
}
catch
{
result = default(T);
return false;
}
}
public override T Clamp(T value)
{
if (value.CompareTo(base.min) >= 0)
{
if (value.CompareTo(base.max) <= 0)
{
return value;
}
return base.max;
}
return base.min;
}
}
protected abstract class Slider : Field
{
internal Slider slider;
public override void Awake()
{
((ModSettingsNumericField<T>)this).Awake();
slider.minValue = Convert.ToSingle(((ModSettingsNumericField<T>)this).min);
slider.maxValue = Convert.ToSingle(((ModSettingsNumericField<T>)this).max);
((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)OnSliderValueChanged);
((UnityEvent<string>)(object)((ModSettingsNumericField<T>)this).valueText.onEndEdit).AddListener((UnityAction<string>)((ModSettingsNumericField<T>)this).OnTextEdited);
((UnityEvent<string>)(object)((ModSettingsNumericField<T>)this).valueText.onSubmit).AddListener((UnityAction<string>)((ModSettingsNumericField<T>)this).OnTextEdited);
}
public override void Enable()
{
OnStateChanged(enabled: true);
}
private void OnStateChanged(bool enabled)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)slider).transform;
ColorBlock colors;
Color val;
if (!enabled)
{
colors = ((Selectable)slider).colors;
val = ((ColorBlock)(ref colors)).disabledColor;
}
else
{
colors = ((Selectable)slider).colors;
val = ((ColorBlock)(ref colors)).normalColor;
}
Color color = val;
((Selectable)slider).interactable = enabled;
((Graphic)((Component)transform.Find("Fill Area/Fill")).GetComponent<Image>()).color = color;
HGButton[] componentsInChildren = ((Component)this).GetComponentsInChildren<HGButton>();
foreach (HGButton val2 in componentsInChildren)
{
((Selectable)val2).interactable = enabled;
Color val3;
if (!enabled)
{
colors = ((Selectable)val2).colors;
val3 = ((ColorBlock)(ref colors)).disabledColor;
}
else
{
colors = ((Selectable)val2).colors;
val3 = ((ColorBlock)(ref colors)).normalColor;
}
color = val3;
}
((Graphic)((Component)transform.parent.Find("TextArea")).GetComponent<Image>()).color = color;
}
public override void Disable()
{
OnStateChanged(enabled: false);
}
protected virtual void OnSliderValueChanged(float value)
{
if (!((ModSettingsControl<T>)(object)this).InUpdateControls)
{
((ModSettingsControl<T>)(object)this).SubmitValue((T)Convert.ChangeType(value, typeof(T)));
}
}
public override void OnUpdateControls()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
((ModSettingsNumericField<T>)this).OnUpdateControls();
float num = Convert.ToSingle(((ModSettingsNumericField<T>)this).Clamp(((ModSettingsControl<T>)(object)this).GetCurrentValue()));
slider.value = num;
((ModSettingsNumericField<T>)this).valueText.text = string.Format(DecimalSeparatorExtensions.GetCultureInfo(ModSetting.Separator), ((ModSettingsNumericField<T>)this).formatString, num);
}
protected void MoveSlider(float delta)
{
Slider obj = slider;
obj.normalizedValue += delta;
}
}
private class FieldConfig : NumericFieldConfig<T>
{
public override T Min { get; set; }
public override T Max { get; set; }
}
[CompilerGenerated]
private ConfigEntry<T> <entry>P;
private readonly T original;
private readonly FieldConfig configuration;
public override ConfigEntryBase ConfigEntry => (ConfigEntryBase)(object)<entry>P;
public T Value
{
get
{
return <entry>P.Value;
}
set
{
<entry>P.Value = value;
}
}
public override string OptionTypeName { get; set; }
protected Option(ConfigEntry<T> entry)
{
<entry>P = entry;
original = <entry>P.Value;
OptionTypeName = typeof(T).Name.ToLowerInvariant() + "_field";
configuration = new FieldConfig();
((BaseOption)this)..ctor();
}
protected GameObject CreateOptionGameObject<X>(GameObject prefab, Transform parent, out X field) where X : Field
{
GameObject val = Object.Instantiate<GameObject>(prefab, parent);
Object.DestroyImmediate((Object)(object)val.GetComponent<ModSetting>());
field = val.AddComponent<X>();
X val2 = field;
((Object)val2).name = "Mod " + ((object)this).GetType().Name + " Field, " + ((BaseOption)this).Name;
((ModSetting)field).nameToken = ((BaseOption)this).GetNameToken();
((ModSetting)field).settingToken = ((BaseOption)this).Identifier;
if (field is Slider slider)
{
slider.slider = val.GetComponentInChildren<Slider>();
}
((ModSettingsNumericField<T>)field).valueText = val.GetComponentInChildren<TMP_InputField>();
((ModSetting)field).nameLabel = val.GetComponent<LanguageTextMeshController>();
if (((ConfigEntryBase)<entry>P).Description.AcceptableValues is AcceptableValueRange<T> val3)
{
((ModSettingsNumericField<T>)field).min = val3.MinValue;
((ModSettingsNumericField<T>)field).max = val3.MaxValue;
}
ModSettingsNumericField<T> val4 = field;
if (val4.formatString == null)
{
val4.formatString = "{0}";
}
return val;
}
public T GetOriginalValue()
{
return original;
}
public bool ValueChanged()
{
return !<entry>P.Value.Equals(original);
}
public override BaseOptionConfig GetConfig()
{
return (BaseOptionConfig)(object)configuration;
}
}
internal class ListOption : BaseOption, ITypedValueHolder<object>
{
private class Controller : ModSettingsControl<object>
{
internal object[] choices;
internal int index;
private RooDropdown dropdown;
public override void Awake()
{
dropdown = ((Component)this).GetComponentInChildren<RooDropdown>();
base.Awake();
((UnityEvent<int>)(object)dropdown.OnValueChanged).AddListener((UnityAction<int>)OnChoiceChanged);
}
public override void Enable()
{
OnStateChanged(enabled: true);
}
private void OnStateChanged(bool enabled)
{
((Selectable)dropdown).interactable = enabled;
HGButton[] componentsInChildren = ((Component)this).GetComponentsInChildren<HGButton>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Selectable)componentsInChildren[i]).interactable = enabled;
}
}
public override void Disable()
{
OnStateChanged(enabled: false);
}
protected void OnEnable()
{
base.OnEnable();
dropdown.choices = choices.Select((object element) => element.ToString()).ToArray();
base.UpdateControls();
}
private void OnChoiceChanged(int index)
{
base.SubmitValue(choices[this.index = index]);
}
public override void OnUpdateControls()
{
base.OnUpdateControls();
dropdown.SetChoice(index);
}
}
[CompilerGenerated]
private ConfigEntryBase <entry>P;
[CompilerGenerated]
private object[] <list>P;
private readonly object original;
private readonly BaseOptionConfig configuration;
public override ConfigEntryBase ConfigEntry => <entry>P;
public object Value
{
get
{
return <entry>P.BoxedValue;
}
set
{
<entry>P.BoxedValue = value;
}
}
public override string OptionTypeName { get; set; }
public ListOption(ConfigEntryBase entry, object[] list)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
<entry>P = entry;
<list>P = list;
original = <entry>P.BoxedValue;
OptionTypeName = <entry>P.SettingType.Name.ToLowerInvariant() + "_list";
configuration = new BaseOptionConfig();
((BaseOption)this)..ctor();
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
GameObject val = Object.Instantiate<GameObject>(prefab, parent);
Object.DestroyImmediate((Object)(object)val.GetComponent<DropDownController>());
Controller controller = val.AddComponent<Controller>();
((Object)controller).name = "Mod Option " + <entry>P.SettingType.Name + " List, " + ((BaseOption)this).Name;
controller.choices = <list>P;
controller.index = Array.IndexOf(<list>P, <entry>P.BoxedValue);
((ModSetting)controller).nameLabel = val.GetComponentInChildren<LanguageTextMeshController>();
((ModSetting)controller).nameLabel.token = (((ModSetting)controller).nameToken = ((BaseOption)this).GetNameToken());
((ModSetting)controller).settingToken = ((BaseOption)this).Identifier;
return val;
}
public object GetOriginalValue()
{
return original;
}
public bool ValueChanged()
{
return !<entry>P.BoxedValue.Equals(original);
}
public override BaseOptionConfig GetConfig()
{
return configuration;
}
}
[BepInPlugin("local.option.generator", "OptionGenerator", "0.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string version = "0.2.0";
public const string identifier = "local.option.generator";
private static ConfigFile configuration;
private const string section = "Enabled";
protected void Awake()
{
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
configuration = ((BaseUnityPlugin)this).Config;
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
configuration.Bind<bool>("Enabled", value.Metadata.GUID, true, "If option menu should be generated for \"" + value.Metadata.Name + "\".");
}
});
}
[HarmonyPatch(typeof(ModOptionPanelController), "Start")]
[HarmonyPrefix]
private static void Generate()
{
ConfigEntry<bool> val = default(ConfigEntry<bool>);
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
string gUID = value.Metadata.GUID;
string name = value.Metadata.Name;
configuration.TryGetEntry<bool>("Enabled", gUID, ref val);
if ((!(val?.Value)) ?? false)
{
RemoveOption(gUID);
continue;
}
if (Object.op_Implicit((Object)(object)value.Instance) && CheckDependency(value))
{
foreach (ConfigFile item in ScanForConfig(value.Instance))
{
foreach (ConfigDefinition key in item.Keys)
{
ConfigEntryBase entry = item[key];
if (!HasEntry(gUID, entry))
{
BaseOption val2 = CreateOption(entry);
if (val2 != null)
{
ModSettingsManager.EnsureContainerExists(gUID, name);
ModSettingsManager.AddOption(val2, gUID, name);
}
}
}
}
}
LoadIcon(value);
SetDescription(value);
}
}
private static bool CheckDependency(PluginInfo info)
{
if (info.Metadata.GUID == "local.option.generator")
{
return true;
}
foreach (BepInDependency dependency in info.Dependencies)
{
if (dependency.DependencyGUID == "com.rune580.riskofoptions")
{
return false;
}
}
return true;
}
private static IEnumerable<ConfigFile> ScanForConfig(BaseUnityPlugin instance)
{
HashSet<ConfigFile> hashSet = new HashSet<ConfigFile> { instance.Config };
Type type = ((object)instance).GetType();
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
FieldInfo[] fields = type.GetFields(bindingAttr);
foreach (FieldInfo fieldInfo in fields)
{
if (typeof(ConfigEntryBase).IsAssignableFrom(fieldInfo.FieldType))
{
object? value = fieldInfo.GetValue(instance);
object? obj = ((value is ConfigEntryBase) ? value : null);
hashSet.Add((obj != null) ? ((ConfigEntryBase)obj).ConfigFile : null);
}
else if (typeof(ConfigFile).IsAssignableFrom(fieldInfo.FieldType))
{
object? value2 = fieldInfo.GetValue(instance);
hashSet.Add((ConfigFile)((value2 is ConfigFile) ? value2 : null));
}
}
PropertyInfo[] properties = type.GetProperties(bindingAttr);
foreach (PropertyInfo propertyInfo in properties)
{
if (typeof(ConfigEntryBase).IsAssignableFrom(propertyInfo.PropertyType))
{
object? value3 = propertyInfo.GetValue(instance);
object? obj2 = ((value3 is ConfigEntryBase) ? value3 : null);
hashSet.Add((obj2 != null) ? ((ConfigEntryBase)obj2).ConfigFile : null);
}
else if (typeof(ConfigFile).IsAssignableFrom(propertyInfo.PropertyType))
{
object? value4 = propertyInfo.GetValue(instance);
hashSet.Add((ConfigFile)((value4 is ConfigFile) ? value4 : null));
}
}
hashSet.Remove(null);
return hashSet;
}
private static bool HasEntry(string identifier, ConfigEntryBase entry)
{
try
{
Category val = ModSettingsManager.OptionCollection[identifier][entry.Definition.Section];
for (int i = 0; i < val.OptionCount; i++)
{
if (entry == val[i].ConfigEntry)
{
return true;
}
}
}
catch (KeyNotFoundException)
{
}
return false;
}
private static BaseOption CreateOption(ConfigEntryBase entry)
{
AcceptableValueBase acceptableValues = entry.Description.AcceptableValues;
Type type = ((object)acceptableValues)?.GetType();
Type typeFromHandle = typeof(AcceptableValueList<>);
bool? flag = type?.IsGenericType;
if (flag.HasValue && flag.GetValueOrDefault() && type.GetGenericTypeDefinition() == typeFromHandle)
{
Array source = typeFromHandle.MakeGenericType(acceptableValues.ValueType).GetProperty("AcceptableValues").GetMethod.Invoke(acceptableValues, null) as Array;
return (BaseOption)(object)new ListOption(entry, source.Cast<object>().ToArray());
}
Type type2;
if (!(acceptableValues is AcceptableValueRange<sbyte>))
{
if (!(acceptableValues is AcceptableValueRange<byte>))
{
if (!(acceptableValues is AcceptableValueRange<short>))
{
if (!(acceptableValues is AcceptableValueRange<ushort>))
{
if (!(acceptableValues is AcceptableValueRange<int>))
{
if (!(acceptableValues is AcceptableValueRange<uint>))
{
if (!(acceptableValues is AcceptableValueRange<long>))
{
if (!(acceptableValues is AcceptableValueRange<ulong>))
{
if (!(acceptableValues is AcceptableValueRange<float>))
{
if (!(acceptableValues is AcceptableValueRange<double>))
{
if (acceptableValues is AcceptableValueRange<decimal>)
{
type2 = typeof(DecimalSliderOption);
}
else
{
Type type3 = ((entry is ConfigEntry<sbyte>) ? typeof(SByteOption) : ((entry is ConfigEntry<byte>) ? typeof(ByteOption) : ((entry is ConfigEntry<short>) ? typeof(Int16Option) : ((entry is ConfigEntry<ushort>) ? typeof(UInt16Option) : ((entry is ConfigEntry<int>) ? typeof(Int32Option) : ((entry is ConfigEntry<uint>) ? typeof(UInt32Option) : ((entry is ConfigEntry<long>) ? typeof(Int64Option) : ((entry is ConfigEntry<ulong>) ? typeof(UInt64Option) : ((entry is ConfigEntry<float>) ? typeof(SingleOption) : ((entry is ConfigEntry<double>) ? typeof(DoubleOption) : ((entry is ConfigEntry<decimal>) ? typeof(DecimalOption) : ((entry is ConfigEntry<bool>) ? typeof(BooleanOption) : ((entry is ConfigEntry<string>) ? typeof(StringOption) : ((entry is ConfigEntry<Color>) ? typeof(ColorOption) : ((!(entry is ConfigEntry<KeyboardShortcut>)) ? (entry.SettingType.IsEnum ? typeof(ChoiceOption) : null) : typeof(KeyBindOption))))))))))))))));
type2 = type3;
}
}
else
{
type2 = typeof(DoubleSliderOption);
}
}
else
{
type2 = typeof(SingleSliderOption);
}
}
else
{
type2 = typeof(UInt64SliderOption);
}
}
else
{
type2 = typeof(Int64SliderOption);
}
}
else
{
type2 = typeof(UInt32SliderOption);
}
}
else
{
type2 = typeof(Int32SliderOption);
}
}
else
{
type2 = typeof(UInt16SliderOption);
}
}
else
{
type2 = typeof(Int16SliderOption);
}
}
else
{
type2 = typeof(ByteSliderOption);
}
}
else
{
type2 = typeof(SByteSliderOption);
}
type = type2;
if ((object)type == null)
{
Console.WriteLine("No option for type " + ((object)entry).GetType());
return null;
}
object? obj = Activator.CreateInstance(type, entry);
return (BaseOption)((obj is BaseOption) ? obj : null);
}
private static void LoadIcon(PluginInfo info)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (!TryGetOption(info.Metadata.GUID, out var option) || (Object)(object)option.icon != (Object)null || (Object)(object)option.iconPrefab != (Object)null || !FindPath(info, "icon.png", out var path))
{
return;
}
Texture2D val = new Texture2D(256, 256, (TextureFormat)5, 3, false);
try
{
if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
{
throw new Exception();
}
}
catch
{
Console.WriteLine("Unable to load '" + path + "'\n");
return;
}
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero), option.ModGuid, option.ModName);
}
private static void SetDescription(PluginInfo info)
{
if (TryGetOption(info.Metadata.GUID, out var option) && Language.IsTokenInvalid(option.DescriptionToken) && FindPath(info, "manifest.json", out var path))
{
string text = "description";
try
{
text = JSONNode.op_Implicit(JSON.Parse(File.ReadAllText(path))[text]);
}
catch
{
Console.WriteLine("Unable to load '" + path + "'\n");
return;
}
ModSettingsManager.SetModDescription(text, option.ModGuid, option.ModName);
}
}
private static bool TryGetOption(string identifier, out OptionCollection option)
{
if (ModSettingsManager.OptionCollection.ContainsModGuid(identifier))
{
option = ModSettingsManager.OptionCollection[identifier];
return true;
}
option = null;
return false;
}
private static void RemoveOption(string identifier)
{
if (!ModSettingsManager.OptionCollection.ContainsModGuid(identifier))
{
return;
}
KeyValuePair<string, string>[] array = ModSettingsManager.OptionCollection._identifierModGuidMap.ToArray();
ModSettingsManager.OptionCollection._optionCollections.Remove(identifier);
KeyValuePair<string, string>[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
KeyValuePair<string, string> keyValuePair = array2[i];
if (identifier == keyValuePair.Value)
{
ModSettingsManager.OptionCollection._identifierModGuidMap.Remove(keyValuePair.Key);
}
}
}
private static bool FindPath(PluginInfo info, string filename, out string path)
{
string directoryName = Path.GetDirectoryName(info.Location);
path = Path.Combine(directoryName, filename);
if (!File.Exists(path))
{
path = Path.Combine(Directory.GetParent(directoryName).FullName, filename);
}
return File.Exists(path);
}
[HarmonyPatch(typeof(ModOptionPanelController), "LoadOptionListFromCategory")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> IL)
{
foreach (CodeInstruction instruction in IL)
{
if (instruction.opcode == OpCodes.Isinst)
{
yield return new CodeInstruction(OpCodes.Dup, (object)null);
yield return instruction;
yield return Transpilers.EmitDelegate<Func<object, object, object>>((Func<object, object, object>)delegate(object obj, object result)
{
if (result != null)
{
return result;
}
return CheckType(obj, instruction.operand as Type) ? obj : null;
});
}
else
{
yield return instruction;
}
}
}
private static bool CheckType(object obj, Type type)
{
if (type == typeof(IntFieldOption))
{
return obj is SByteOption || obj is ByteOption || obj is Int16Option || obj is UInt16Option || obj is Int32Option || obj is UInt32Option || obj is Int64Option || obj is UInt64Option;
}
if (type == typeof(IntSliderOption))
{
return obj is SByteSliderOption || obj is ByteSliderOption || obj is Int16SliderOption || obj is UInt16SliderOption || obj is Int32SliderOption || obj is UInt32SliderOption || obj is Int64SliderOption || obj is UInt64SliderOption;
}
if (type == typeof(FloatFieldOption))
{
return obj is SingleOption || obj is DoubleOption || obj is DecimalOption;
}
if (type == typeof(SliderOption))
{
return obj is SingleSliderOption || obj is DoubleSliderOption || obj is DecimalSliderOption;
}
if (type == typeof(ChoiceOption))
{
return obj is ListOption;
}
return false;
}
}
internal class SByteOption : Option<sbyte>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<sbyte>)this).min = sbyte.MinValue;
((ModSettingsNumericField<sbyte>)this).max = sbyte.MaxValue;
}
}
public SByteOption(ConfigEntry<sbyte> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class SByteSliderOption : Option<sbyte>
{
private class Control : Slider
{
}
public SByteSliderOption(ConfigEntry<sbyte> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class ByteOption : Option<byte>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<byte>)this).min = 0;
((ModSettingsNumericField<byte>)this).max = byte.MaxValue;
}
}
public ByteOption(ConfigEntry<byte> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class ByteSliderOption : Option<byte>
{
private class Control : Slider
{
}
public ByteSliderOption(ConfigEntry<byte> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class Int16Option : Option<short>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<short>)this).min = short.MinValue;
((ModSettingsNumericField<short>)this).max = short.MaxValue;
}
}
public Int16Option(ConfigEntry<short> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class Int16SliderOption : Option<short>
{
private class Control : Slider
{
}
public Int16SliderOption(ConfigEntry<short> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class UInt16Option : Option<ushort>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<ushort>)this).min = 0;
((ModSettingsNumericField<ushort>)this).max = ushort.MaxValue;
}
}
public UInt16Option(ConfigEntry<ushort> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class UInt16SliderOption : Option<ushort>
{
private class Control : Slider
{
}
public UInt16SliderOption(ConfigEntry<ushort> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class Int32Option : IntFieldOption
{
public Int32Option(ConfigEntry<int> entry)
: base(entry)
{
}
}
internal class Int32SliderOption : IntSliderOption
{
public Int32SliderOption(ConfigEntry<int> entry)
: base(entry, Initialize(entry))
{
}
private static IntSliderConfig Initialize(ConfigEntry<int> entry)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
IntSliderConfig val = new IntSliderConfig
{
min = int.MinValue,
max = int.MaxValue
};
if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<int> val2)
{
val.min = val2.MinValue;
val.max = val2.MaxValue;
}
return val;
}
}
internal class UInt32Option : Option<uint>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<uint>)this).min = 0u;
((ModSettingsNumericField<uint>)this).max = uint.MaxValue;
}
}
public UInt32Option(ConfigEntry<uint> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class UInt32SliderOption : Option<uint>
{
private class Control : Slider
{
}
public UInt32SliderOption(ConfigEntry<uint> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class Int64Option : Option<long>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<long>)this).min = long.MinValue;
((ModSettingsNumericField<long>)this).max = long.MaxValue;
}
}
public Int64Option(ConfigEntry<long> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class Int64SliderOption : Option<long>
{
private class Control : Slider
{
}
public Int64SliderOption(ConfigEntry<long> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class UInt64Option : Option<ulong>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<ulong>)this).min = 0uL;
((ModSettingsNumericField<ulong>)this).max = ulong.MaxValue;
}
}
public UInt64Option(ConfigEntry<ulong> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class UInt64SliderOption : Option<ulong>
{
private class Control : Slider
{
}
public UInt64SliderOption(ConfigEntry<ulong> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class SingleOption : FloatFieldOption
{
public SingleOption(ConfigEntry<float> entry)
: base(entry)
{
}
}
internal class SingleSliderOption : SliderOption
{
public SingleSliderOption(ConfigEntry<float> entry)
: base(entry, Initialize(entry))
{
}
public static SliderConfig Initialize(ConfigEntry<float> entry)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
SliderConfig val = new SliderConfig
{
min = float.MinValue,
max = float.MaxValue
};
if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<float> val2)
{
val.min = val2.MinValue;
val.max = val2.MaxValue;
}
float min = val.min;
bool flag = ((min == -50f || min == 0f || min == 50f) ? true : false);
bool flag2 = flag;
if (flag2)
{
float max = val.max;
bool flag3 = ((max == 50f || max == 100f || max == 150f || max == 200f) ? true : false);
flag2 = flag3;
}
if (flag2)
{
val.formatString = "{0:0.0}%";
}
else
{
val.formatString = "{0:0.00}";
}
return val;
}
}
internal class DoubleOption : Option<double>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<double>)this).formatString = "{0:0.00}";
((ModSettingsNumericField<double>)this).min = -3.4028234663852886E+38;
((ModSettingsNumericField<double>)this).max = 3.4028234663852886E+38;
}
}
public DoubleOption(ConfigEntry<double> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class DoubleSliderOption : Option<double>
{
private class Control : Slider
{
}
public DoubleSliderOption(ConfigEntry<double> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
GameObject result = CreateOptionGameObject<Control>(prefab, parent, out field);
double min = ((ModSettingsNumericField<double>)field).min;
bool flag = ((min == -50.0 || min == 0.0 || min == 50.0) ? true : false);
bool flag2 = flag;
if (flag2)
{
double max = ((ModSettingsNumericField<double>)field).max;
bool flag3 = ((max == 50.0 || max == 100.0 || max == 150.0 || max == 200.0) ? true : false);
flag2 = flag3;
}
if (flag2)
{
((ModSettingsNumericField<double>)field).formatString = "{0:0.0}%";
return result;
}
((ModSettingsNumericField<double>)field).formatString = "{0:0.00}";
return result;
}
}
internal class DecimalOption : Option<decimal>
{
private class Control : Field
{
protected Control()
{
((ModSettingsNumericField<decimal>)this).formatString = "{0:0.00}";
((ModSettingsNumericField<decimal>)this).min = decimal.MinValue;
((ModSettingsNumericField<decimal>)this).max = decimal.MaxValue;
}
}
public DecimalOption(ConfigEntry<decimal> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
return CreateOptionGameObject<Control>(prefab, parent, out field);
}
}
internal class DecimalSliderOption : Option<decimal>
{
private class Control : Slider
{
}
public DecimalSliderOption(ConfigEntry<decimal> entry)
: base(entry)
{
}
public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
{
Control field;
GameObject result = CreateOptionGameObject<Control>(prefab, parent, out field);
decimal min = ((ModSettingsNumericField<decimal>)field).min;
bool flag = ((min == -50m || min == 0m || min == 50m) ? true : false);
bool flag2 = flag;
bool flag3;
if (flag2)
{
decimal max = ((ModSettingsNumericField<decimal>)field).max;
if (max <= 100m)
{
if (max == 50m || max == 100m)
{
goto IL_00a7;
}
}
else if (max == 150m || max == 200m)
{
goto IL_00a7;
}
flag3 = false;
goto IL_00af;
}
goto IL_00b2;
IL_00a7:
flag3 = true;
goto IL_00af;
IL_00b2:
if (flag2)
{
((ModSettingsNumericField<decimal>)field).formatString = "{0:0.0}%";
return result;
}
((ModSettingsNumericField<decimal>)field).formatString = "{0:0.00}";
return result;
IL_00af:
flag2 = flag3;
goto IL_00b2;
}
}
internal class BooleanOption : CheckBoxOption
{
public BooleanOption(ConfigEntry<bool> entry)
: base(entry)
{
}
}
internal class StringOption : StringInputFieldOption
{
public StringOption(ConfigEntry<string> entry)
: base(entry, Initialize())
{
}
private static InputFieldConfig Initialize()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
return new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0,
richText = false
};
}
}
}