using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Doozy.Runtime.UIManager.Components;
using Gatekeeper.MainMenuScripts.MainMenu.MainMenuPanel;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ModMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.8")]
[assembly: AssemblyProduct("ModMenu")]
[assembly: AssemblyTitle("ModMenu")]
[assembly: AssemblyVersion("1.0.8.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ModMenu
{
[BepInPlugin("com.naccel.gatemodmenu", "Gatekeeper Mod Menu", "1.0.7")]
public sealed class Plugin : BasePlugin
{
public const string PluginGuid = "com.naccel.gatemodmenu";
public const string PluginName = "Gatekeeper Mod Menu";
public const string PluginVersion = "1.0.7";
internal static ManualLogSource LogSource;
public override void Load()
{
LogSource = ((BasePlugin)this).Log;
ClassInjector.RegisterTypeInIl2Cpp<MenuOverlay>();
((BasePlugin)this).AddComponent<MenuOverlay>();
((BasePlugin)this).Log.LogInfo((object)"Gatekeeper Mod Menu loaded.");
}
}
public sealed class MenuOverlay : MonoBehaviour
{
private bool _open;
private bool _loggedScene;
private Button _menuButton;
private UIButton _doozyMenuButton;
private int _buttonSceneHandle = -1;
private int _buttonSearchFrames;
private bool _warnedMissingButton;
private float _nextButtonSearchTime;
private Rect _window = new Rect(0f, 0f, 760f, 620f);
private Vector2 _scroll;
private MainMenuController _mainMenuController;
private GameObject _hiddenMenuObject;
private bool _menuObjectWasActive;
private ConfigEntryBase _numericEditEntry;
private string _numericBuffer = "";
private bool _numericInputInvalid;
private static Texture2D _panelTexture;
private static Texture2D _backdropTexture;
private static Texture2D _headerTexture;
private static Texture2D _rowTexture;
private static Texture2D _accentTexture;
private static GUIStyle _panelStyle;
private static GUIStyle _rowStyle;
private static GUIStyle _buttonStyle;
private static GUIStyle _toggleStyle;
private static GUIStyle _sectionStyle;
private static GUIStyle _titleStyle;
private static GUIStyle _labelStyle;
private static GUIStyle _inputStyle;
public MenuOverlay(IntPtr ptr)
: base(ptr)
{
}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
private void OnGUI()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_047f: Unknown result type (might be due to invalid IL or missing references)
//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
GUI.depth = -10000;
EnsureStyles();
Scene activeScene = SceneManager.GetActiveScene();
if (!((Scene)(ref activeScene)).name.Contains("MainMenu", StringComparison.OrdinalIgnoreCase))
{
CloseMenu();
_mainMenuController = null;
_buttonSceneHandle = -1;
return;
}
if (!_open || (Object)(object)_mainMenuController == (Object)null)
{
_mainMenuController = Object.FindObjectOfType<MainMenuController>();
}
if ((Object)(object)_mainMenuController == (Object)null || (Object)(object)_mainMenuController.menuObject == (Object)null)
{
CloseMenu();
}
else
{
if (!_open && (!_mainMenuController.menuObject.activeInHierarchy || !_mainMenuController.IsInteractable))
{
return;
}
if (_buttonSceneHandle != ((Scene)(ref activeScene)).handle)
{
_buttonSceneHandle = ((Scene)(ref activeScene)).handle;
_buttonSearchFrames = 0;
_warnedMissingButton = false;
_nextButtonSearchTime = 0f;
}
if (!_loggedScene)
{
ManualLogSource logSource = Plugin.LogSource;
if (logSource != null)
{
logSource.LogInfo((object)"Main menu detected; looking for a vanilla button to clone.");
}
_loggedScene = true;
}
if (!_open && (Object)(object)_doozyMenuButton != (Object)null && !((Component)_doozyMenuButton).gameObject.activeInHierarchy)
{
Object.Destroy((Object)(object)((Component)_doozyMenuButton).gameObject);
_doozyMenuButton = null;
_buttonSearchFrames = 0;
_warnedMissingButton = false;
}
if (!_open && (Object)(object)_menuButton != (Object)null && !((Component)_menuButton).gameObject.activeInHierarchy)
{
Object.Destroy((Object)(object)((Component)_menuButton).gameObject);
_menuButton = null;
_buttonSearchFrames = 0;
_warnedMissingButton = false;
}
if (!_open && (Object)(object)_menuButton == (Object)null && (Object)(object)_doozyMenuButton == (Object)null && _buttonSearchFrames < 120 && Time.unscaledTime >= _nextButtonSearchTime)
{
_buttonSearchFrames++;
AddVanillaStyleButton(((Scene)(ref activeScene)).handle);
_nextButtonSearchTime = Time.unscaledTime + 0.25f;
}
if (!_open && (Object)(object)_menuButton == (Object)null && (Object)(object)_doozyMenuButton == (Object)null && GUI.Button(new Rect((float)(Screen.width - 150), (float)(Screen.height - 72), 130f, 42f), "Mods", _buttonStyle))
{
ToggleMenu();
}
if (_open && Input.GetKeyDown((KeyCode)27) && _numericEditEntry == null)
{
CloseMenu();
}
if (_open)
{
((Rect)(ref _window)).width = Mathf.Min(760f, (float)Screen.width * 0.9f);
((Rect)(ref _window)).height = Mathf.Min(620f, (float)Screen.height * 0.88f);
((Rect)(ref _window)).x = ((float)Screen.width - ((Rect)(ref _window)).width) * 0.5f;
((Rect)(ref _window)).y = ((float)Screen.height - ((Rect)(ref _window)).height) * 0.5f;
if ((Object)(object)_backdropTexture != (Object)null)
{
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_backdropTexture);
}
GUI.Box(_window, GUIContent.none, _panelStyle);
if ((Object)(object)_headerTexture != (Object)null)
{
GUI.DrawTexture(new Rect(((Rect)(ref _window)).x + 2f, ((Rect)(ref _window)).y + 2f, ((Rect)(ref _window)).width - 4f, 52f), (Texture)(object)_headerTexture);
}
if ((Object)(object)_accentTexture != (Object)null)
{
GUI.DrawTexture(new Rect(((Rect)(ref _window)).x + 2f, ((Rect)(ref _window)).y + 2f, ((Rect)(ref _window)).width - 4f, 2f), (Texture)(object)_accentTexture);
GUI.DrawTexture(new Rect(((Rect)(ref _window)).x + 2f, ((Rect)(ref _window)).y + 50f, ((Rect)(ref _window)).width - 4f, 2f), (Texture)(object)_accentTexture);
}
GUI.Label(new Rect(((Rect)(ref _window)).x + 24f, ((Rect)(ref _window)).y + 8f, 420f, 32f), "MOD CONFIGURATION", _titleStyle);
if (GUI.Button(new Rect(((Rect)(ref _window)).xMax - 52f, ((Rect)(ref _window)).y + 10f, 34f, 32f), "X", _buttonStyle))
{
CloseMenu();
}
GUILayout.BeginArea(new Rect(((Rect)(ref _window)).x + 18f, ((Rect)(ref _window)).y + 62f, ((Rect)(ref _window)).width - 36f, ((Rect)(ref _window)).height - 78f));
DrawWindow(72104);
GUILayout.EndArea();
}
}
}
private void AddVanillaStyleButton(int sceneHandle)
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
MainMenuController mainMenuController = _mainMenuController;
UIButton val = ((mainMenuController != null) ? mainMenuController.settingsButton : null);
if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy)
{
MainMenuController mainMenuController2 = _mainMenuController;
val = ((mainMenuController2 != null) ? mainMenuController2.startButton : null);
}
bool flag = default(bool);
ManualLogSource logSource;
if ((Object)(object)val != (Object)null)
{
GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
((Object)val2).name = "GatekeeperModMenuButton";
val2.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1);
UIButton component = val2.GetComponent<UIButton>();
if ((Object)(object)component != (Object)null)
{
((UnityEventBase)((UISelectable)component).onClickEvent).RemoveAllListeners();
((UISelectable)component).onClickEvent.AddListener(UnityAction.op_Implicit((Action)ToggleMenu));
SetButtonLabel(val2);
_doozyMenuButton = component;
logSource = Plugin.LogSource;
if (logSource != null)
{
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(50, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Added Mods button by cloning Doozy menu button '");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val).name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'.");
}
logSource.LogInfo(val3);
}
return;
}
}
if (_warnedMissingButton)
{
return;
}
logSource = Plugin.LogSource;
if (logSource != null)
{
BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(68, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("MainMenuController has no active Settings or Start button in scene ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(sceneHandle);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(".");
}
logSource.LogWarning(val4);
}
_warnedMissingButton = true;
}
private static string GetButtonLabel(UIButton button)
{
TMP_Text componentInChildren = ((Component)button).GetComponentInChildren<TMP_Text>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
return componentInChildren.text;
}
Text componentInChildren2 = ((Component)button).GetComponentInChildren<Text>(true);
if (!((Object)(object)componentInChildren2 != (Object)null))
{
return "";
}
return componentInChildren2.text;
}
private static void SetButtonLabel(GameObject clone)
{
foreach (TMP_Text componentsInChild in clone.GetComponentsInChildren<TMP_Text>(true))
{
componentsInChild.text = "Mods";
}
foreach (Text componentsInChild2 in clone.GetComponentsInChildren<Text>(true))
{
componentsInChild2.text = "Mods";
}
}
private void ToggleMenu()
{
if (_open)
{
CloseMenu();
return;
}
MainMenuController mainMenuController = _mainMenuController;
if (!((Object)(object)((mainMenuController != null) ? mainMenuController.menuObject : null) == (Object)null))
{
_hiddenMenuObject = _mainMenuController.menuObject;
_menuObjectWasActive = _hiddenMenuObject.activeSelf;
_hiddenMenuObject.SetActive(false);
_open = true;
}
}
private void CloseMenu()
{
_open = false;
CancelNumericInput();
if ((Object)(object)_hiddenMenuObject != (Object)null)
{
if (_menuObjectWasActive)
{
_hiddenMenuObject.SetActive(true);
}
_hiddenMenuObject = null;
}
}
private void OnDestroy()
{
CloseMenu();
}
private void DrawWindow(int id)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
foreach (KeyValuePair<string, PluginInfo> item in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Where(delegate(KeyValuePair<string, PluginInfo> pair)
{
PluginInfo value = pair.Value;
return ((value != null) ? value.Instance : null) is BasePlugin;
}).OrderBy<KeyValuePair<string, PluginInfo>, string>((KeyValuePair<string, PluginInfo> pair) => pair.Value.Metadata.Name, StringComparer.OrdinalIgnoreCase))
{
BasePlugin val = (BasePlugin)item.Value.Instance;
ConfigFile config = val.Config;
ConfigDefinition[] array = ((config == null) ? null : config.Keys?.OrderBy((ConfigDefinition k) => k.Section).ThenBy((ConfigDefinition k) => k.Key).ToArray());
if (array != null && array.Length != 0)
{
GUILayout.Space(8f);
GUILayout.Label(item.Value.Metadata.Name.ToUpperInvariant(), _sectionStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
ConfigDefinition[] array2 = array;
foreach (ConfigDefinition val2 in array2)
{
ConfigEntryBase entry = val.Config[val2];
DrawEntry(item.Key, entry);
}
}
}
GUILayout.EndScrollView();
}
private void DrawEntry(string guid, ConfigEntryBase entry)
{
GUILayout.BeginHorizontal(_rowStyle, Array.Empty<GUILayoutOption>());
GUILayout.Label(entry.Definition.Section + " / " + entry.Definition.Key, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) });
Type settingType = entry.SettingType;
string[] choices;
if (settingType == typeof(bool))
{
bool flag = (bool)entry.BoxedValue;
bool flag2 = GUILayout.Toggle(flag, flag ? "ON" : "OFF", _toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
if (flag2 != flag)
{
Save(entry, flag2);
}
}
else if (settingType.IsEnum)
{
string[] names = Enum.GetNames(settingType);
GUILayout.Label(entry.BoxedValue.ToString(), _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) });
int num = Array.IndexOf<string>(names, entry.BoxedValue.ToString());
if (GUILayout.Button("<", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, Enum.Parse(settingType, names[(num + names.Length - 1) % names.Length]));
}
if (GUILayout.Button(">", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, Enum.Parse(settingType, names[(num + 1) % names.Length]));
}
}
else if (IsNumeric(settingType))
{
double num2 = Convert.ToDouble(entry.BoxedValue, CultureInfo.InvariantCulture);
if (_numericEditEntry == entry)
{
ProcessNumericInput(entry);
GUILayout.Label(_numericBuffer + ((Time.unscaledTime % 1f < 0.5f) ? "|" : " "), _inputStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
if (GUILayout.Button("Apply", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) }))
{
CommitNumericInput(entry);
}
if (GUILayout.Button("Cancel", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(68f) }))
{
CancelNumericInput();
}
}
else
{
string text = Convert.ToString(entry.BoxedValue, CultureInfo.InvariantCulture);
if (GUILayout.Button(text, _inputStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }))
{
_numericEditEntry = entry;
_numericBuffer = text;
_numericInputInvalid = false;
}
if (GUILayout.Button("−", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, MakeNumber(settingType, Clamp(entry, num2 - Step(entry, num2))));
}
if (GUILayout.Button("+", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, MakeNumber(settingType, Clamp(entry, num2 + Step(entry, num2))));
}
}
}
else if (settingType == typeof(string) && TryGetStringChoices(entry, out choices))
{
int num3 = Array.IndexOf<string>(choices, entry.BoxedValue?.ToString());
GUILayout.Label(entry.BoxedValue?.ToString() ?? "", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) });
if (GUILayout.Button("<", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, choices[(num3 + choices.Length - 1) % choices.Length]);
}
if (GUILayout.Button(">", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) }))
{
Save(entry, choices[(num3 + 1) % choices.Length]);
}
}
else
{
GUILayout.Label(Convert.ToString(entry.BoxedValue, CultureInfo.InvariantCulture) ?? "", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) });
}
GUILayout.EndHorizontal();
if (_numericEditEntry == entry)
{
GUILayout.Label(_numericInputInvalid ? "Invalid number. Enter applies; Esc cancels." : "Type a value. Enter applies; Esc cancels.", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(700f) });
return;
}
ConfigDescription description = entry.Description;
if (!string.IsNullOrEmpty((description != null) ? description.Description : null))
{
GUILayout.Label(entry.Description.Description, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(700f) });
}
}
private void ProcessNumericInput(ConfigEntryBase entry)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Invalid comparison between Unknown and I4
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Invalid comparison between Unknown and I4
Event current = Event.current;
if (current == null || (int)current.type != 4)
{
return;
}
if ((int)current.keyCode == 13 || (int)current.keyCode == 271)
{
CommitNumericInput(entry);
current.Use();
return;
}
if ((int)current.keyCode == 27)
{
CancelNumericInput();
current.Use();
return;
}
if ((int)current.keyCode == 8)
{
if (_numericBuffer.Length > 0)
{
_numericBuffer = _numericBuffer.Substring(0, _numericBuffer.Length - 1);
}
_numericInputInvalid = false;
current.Use();
return;
}
if ((current.control || current.command) && (int)current.keyCode == 97)
{
_numericBuffer = "";
_numericInputInvalid = false;
current.Use();
return;
}
char character = current.character;
bool flag = IsInteger(entry.SettingType);
bool flag2 = entry.SettingType == typeof(sbyte) || entry.SettingType == typeof(short) || entry.SettingType == typeof(int) || entry.SettingType == typeof(long) || entry.SettingType == typeof(float) || entry.SettingType == typeof(double) || entry.SettingType == typeof(decimal);
if (char.IsDigit(character) || (flag2 && character == '-' && _numericBuffer.Length == 0) || (!flag && (character == '.' || character == ',') && !_numericBuffer.Contains(".") && !_numericBuffer.Contains(",")))
{
_numericBuffer += ((character == ',') ? "." : character.ToString());
_numericInputInvalid = false;
current.Use();
}
}
private void CommitNumericInput(ConfigEntryBase entry)
{
Type settingType = entry.SettingType;
string s = _numericBuffer.Replace(',', '.');
object obj = null;
byte result2;
short result3;
ushort result4;
int result5;
uint result6;
long result7;
ulong result8;
double result9;
decimal result10;
if (settingType == typeof(sbyte) && sbyte.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
obj = Convert.ToSByte(Clamp(entry, result));
}
else if (settingType == typeof(byte) && byte.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result2))
{
obj = Convert.ToByte(Clamp(entry, (int)result2));
}
else if (settingType == typeof(short) && short.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result3))
{
obj = Convert.ToInt16(Clamp(entry, result3));
}
else if (settingType == typeof(ushort) && ushort.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result4))
{
obj = Convert.ToUInt16(Clamp(entry, (int)result4));
}
else if (settingType == typeof(int) && int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result5))
{
obj = Convert.ToInt32(Clamp(entry, result5));
}
else if (settingType == typeof(uint) && uint.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result6))
{
obj = Convert.ToUInt32(Clamp(entry, result6));
}
else if (settingType == typeof(long) && long.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result7))
{
obj = Convert.ToInt64(Clamp(entry, result7));
}
else if (settingType == typeof(ulong) && ulong.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out result8))
{
obj = Convert.ToUInt64(Clamp(entry, result8));
}
else if ((settingType == typeof(float) || settingType == typeof(double)) && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result9) && !double.IsNaN(result9) && !double.IsInfinity(result9))
{
obj = MakeNumber(settingType, Clamp(entry, result9));
}
else if (settingType == typeof(decimal) && decimal.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result10))
{
obj = Convert.ToDecimal(Clamp(entry, (double)result10));
}
if (obj == null)
{
_numericInputInvalid = true;
return;
}
Save(entry, obj);
CancelNumericInput();
}
private void CancelNumericInput()
{
_numericEditEntry = null;
_numericBuffer = "";
_numericInputInvalid = false;
}
private static bool IsNumeric(Type type)
{
if (!IsInteger(type) && !(type == typeof(float)) && !(type == typeof(double)))
{
return type == typeof(decimal);
}
return true;
}
private static bool IsInteger(Type type)
{
if (!(type == typeof(sbyte)) && !(type == typeof(byte)) && !(type == typeof(short)) && !(type == typeof(ushort)) && !(type == typeof(int)) && !(type == typeof(uint)) && !(type == typeof(long)))
{
return type == typeof(ulong);
}
return true;
}
private static bool TryGetStringChoices(ConfigEntryBase entry, out string[] choices)
{
object obj = ((object)entry.Description)?.GetType().GetProperty("AcceptableValues")?.GetValue(entry.Description);
choices = (from object value in (obj?.GetType().GetProperty("AcceptableValues")?.GetValue(obj) as IEnumerable)?
select value?.ToString() into value
where value != null
select value).ToArray() ?? Array.Empty<string>();
return choices.Length != 0;
}
private static double Step(ConfigEntryBase entry, double value)
{
object obj = ((object)entry.Description)?.GetType().GetProperty("AcceptableValues")?.GetValue(entry.Description);
object obj2 = obj?.GetType().GetProperty("MinValue")?.GetValue(obj);
object obj3 = obj?.GetType().GetProperty("MaxValue")?.GetValue(obj);
if (obj2 != null && obj3 != null)
{
double num = Convert.ToDouble(obj3, CultureInfo.InvariantCulture) - Convert.ToDouble(obj2, CultureInfo.InvariantCulture);
return Math.Max(IsInteger(entry.SettingType) ? 1.0 : 0.01, num / 20.0);
}
if (!IsInteger(entry.SettingType))
{
return Math.Max(0.01, Math.Abs(value) * 0.1);
}
return 1.0;
}
private static double Clamp(ConfigEntryBase entry, double value)
{
object obj = ((object)entry.Description)?.GetType().GetProperty("AcceptableValues")?.GetValue(entry.Description);
object obj2 = obj?.GetType().GetProperty("MinValue")?.GetValue(obj);
object obj3 = obj?.GetType().GetProperty("MaxValue")?.GetValue(obj);
if (obj2 != null)
{
value = Math.Max(value, Convert.ToDouble(obj2, CultureInfo.InvariantCulture));
}
if (obj3 != null)
{
value = Math.Min(value, Convert.ToDouble(obj3, CultureInfo.InvariantCulture));
}
return value;
}
private static object MakeNumber(Type type, double value)
{
if (type == typeof(sbyte))
{
return Convert.ToSByte(value);
}
if (type == typeof(byte))
{
return Convert.ToByte(value);
}
if (type == typeof(short))
{
return Convert.ToInt16(value);
}
if (type == typeof(ushort))
{
return Convert.ToUInt16(value);
}
if (type == typeof(int))
{
return Convert.ToInt32(value);
}
if (type == typeof(uint))
{
return Convert.ToUInt32(value);
}
if (type == typeof(long))
{
return Convert.ToInt64(value);
}
if (type == typeof(ulong))
{
return Convert.ToUInt64(value);
}
if (type == typeof(float))
{
return Convert.ToSingle(value);
}
if (type == typeof(decimal))
{
return Convert.ToDecimal(value);
}
return value;
}
private static void Save(ConfigEntryBase entry, object value)
{
try
{
entry.BoxedValue = value;
entry.ConfigFile.Save();
}
catch (Exception)
{
}
}
private static void EnsureStyles()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Expected O, but got Unknown
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01b2: Expected O, but got Unknown
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Expected O, but got Unknown
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Expected O, but got Unknown
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Expected O, but got Unknown
//IL_0203: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Expected O, but got Unknown
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Expected O, but got Unknown
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Expected O, but got Unknown
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Expected O, but got Unknown
//IL_0339: Expected O, but got Unknown
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Expected O, but got Unknown
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Expected O, but got Unknown
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Expected O, but got Unknown
//IL_0417: Expected O, but got Unknown
if ((Object)(object)_backdropTexture == (Object)null)
{
_backdropTexture = MakeTexture(new Color(0.01f, 0.025f, 0.04f, 0.24f));
}
if ((Object)(object)_panelTexture == (Object)null)
{
_panelTexture = MakeTexture(new Color(0.075f, 0.12f, 0.19f, 0.8f));
}
if ((Object)(object)_headerTexture == (Object)null)
{
_headerTexture = MakeTexture(new Color(0.08f, 0.27f, 0.36f, 1f));
}
if ((Object)(object)_rowTexture == (Object)null)
{
_rowTexture = MakeTexture(new Color(0.12f, 0.2f, 0.29f, 0.78f));
}
if ((Object)(object)_accentTexture == (Object)null)
{
_accentTexture = MakeTexture(new Color(0.32f, 0.82f, 0.82f, 1f));
}
if (_panelStyle != null)
{
_panelStyle.normal.background = _panelTexture;
_rowStyle.normal.background = _rowTexture;
_buttonStyle.normal.background = _headerTexture;
_toggleStyle.normal.background = _rowTexture;
_toggleStyle.hover.background = _headerTexture;
_inputStyle.normal.background = _rowTexture;
return;
}
GUIStyle val = new GUIStyle(GUI.skin.box);
val.normal.background = _panelTexture;
val.border = new RectOffset(2, 2, 2, 2);
val.padding = new RectOffset(0, 0, 0, 0);
_panelStyle = val;
GUIStyle val2 = new GUIStyle(GUI.skin.box);
val2.normal.background = _rowTexture;
val2.border = new RectOffset(1, 1, 1, 1);
val2.padding = new RectOffset(8, 8, 5, 5);
val2.margin = new RectOffset(0, 0, 3, 3);
_rowStyle = val2;
GUIStyle val3 = new GUIStyle(GUI.skin.button);
val3.normal.background = _headerTexture;
val3.normal.textColor = Color.white;
val3.hover.background = _accentTexture;
val3.hover.textColor = Color.white;
val3.active.background = _accentTexture;
val3.active.textColor = Color.white;
val3.border = new RectOffset(2, 2, 2, 2);
val3.fontStyle = (FontStyle)1;
_buttonStyle = val3;
GUIStyle val4 = new GUIStyle(_buttonStyle);
val4.normal.background = _rowTexture;
val4.normal.textColor = Color.white;
val4.hover.background = _headerTexture;
val4.hover.textColor = Color.white;
val4.alignment = (TextAnchor)4;
_toggleStyle = val4;
GUIStyle val5 = new GUIStyle(GUI.skin.label);
val5.normal.textColor = new Color(0.48f, 0.9f, 0.91f, 1f);
val5.fontSize = 17;
val5.fontStyle = (FontStyle)1;
val5.padding = new RectOffset(6, 6, 3, 3);
_sectionStyle = val5;
GUIStyle val6 = new GUIStyle(GUI.skin.label);
val6.normal.textColor = Color.white;
val6.fontSize = 20;
val6.fontStyle = (FontStyle)1;
val6.alignment = (TextAnchor)3;
_titleStyle = val6;
GUIStyle val7 = new GUIStyle(GUI.skin.label);
val7.normal.textColor = new Color(0.87f, 0.93f, 0.96f, 1f);
val7.wordWrap = true;
_labelStyle = val7;
GUIStyle val8 = new GUIStyle(_buttonStyle);
val8.normal.background = _rowTexture;
val8.normal.textColor = Color.white;
val8.hover.background = _headerTexture;
val8.hover.textColor = Color.white;
val8.alignment = (TextAnchor)3;
val8.padding = new RectOffset(8, 8, 4, 4);
_inputStyle = val8;
}
private static Texture2D MakeTexture(Color color)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0021: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false)
{
hideFlags = (HideFlags)32
};
val.SetPixel(0, 0, color);
val.Apply();
return val;
}
}
}