Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ConfigurationManager v0.6.2
plugins\ConfigurationManager.dll
Decompiled 5 hours agousing System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ConfigurationManager.Utilities; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.6.2")] [assembly: AssemblyInformationalVersion("0.6.2+15800b8921c0b0a42fdf249a3fdb361ec6a4f358")] [assembly: AssemblyVersion("0.6.2.0")] namespace ConfigurationManager { [BepInPlugin("aedenthorn.ConfigurationManager", "Valheim Configuration Manager", "0.6.2")] public class BepInExPlugin : BaseUnityPlugin { public sealed class PluginSettingsData { public sealed class PluginSettingsGroupData { public string Name; public List<SettingEntryBase> Settings; } public BepInPlugin Info; public List<PluginSettingsGroupData> Categories; public bool _collapsed; public bool Collapsed { get { return _collapsed; } set { _collapsed = value; Height = 0; } } public int Height { get; set; } } public const string GUID = "aedenthorn.ConfigurationManager"; public static bool isDebug = true; public static BepInExPlugin context; public static ManualLogSource Logger; public static SettingFieldDrawer _fieldDrawer; public const int WindowId = -68; public const string SearchBoxName = "searchBox"; public bool _focusSearchBox; public string _searchString = string.Empty; public bool OverrideHotkey; public bool _displayingWindow; public bool _obsoleteCursor; public string _modsWithoutSettings; public List<SettingEntryBase> _allSettings; public List<PluginSettingsData> _filteredSetings = new List<PluginSettingsData>(); public Rect _screenRect; public Rect currentWindowRect; public Vector2 _settingWindowScrollPos; public int _tipsHeight; public bool _showDebug; public PropertyInfo _curLockState; public PropertyInfo _curVisible; public int _previousCursorLockState; public bool _previousCursorVisible; public static ConfigEntry<bool> _showAdvanced; public static ConfigEntry<bool> _showKeybinds; public static ConfigEntry<bool> _showSettings; public static ConfigEntry<bool> _showMenuButton; public static ConfigEntry<KeyboardShortcut> _keybind; public static ConfigEntry<bool> _hideSingleSection; public static ConfigEntry<bool> _pluginConfigCollapsedDefault; public static ConfigEntry<Vector2> _windowPosition; public static ConfigEntry<Vector2> _windowSize; public static ConfigEntry<string> _windowTitle; public static ConfigEntry<string> _normalText; public static ConfigEntry<string> _shortcutsText; public static ConfigEntry<string> _advancedText; public static ConfigEntry<string> _searchText; public static ConfigEntry<string> _reloadText; public static ConfigEntry<string> _resetText; public static ConfigEntry<string> _resetSettingText; public static ConfigEntry<string> _expandText; public static ConfigEntry<string> _collapseText; public static ConfigEntry<string> _tipText; public static ConfigEntry<string> _clearText; public static ConfigEntry<string> _openMenuText; public static ConfigEntry<int> _textSize; public static ConfigEntry<Color> _windowBackgroundColor; public static ConfigEntry<Color> _entryBackgroundColor; public static ConfigEntry<Color> _fontColor; public static ConfigEntry<Color> _widgetBackgroundColor; public static ConfigEntry<int> nexusID; public static GUIStyle windowStyle; public static GUIStyle headerStyle; public static GUIStyle entryStyle; public static GUIStyle labelStyle; public static GUIStyle textStyle; public static GUIStyle toggleStyle; public static GUIStyle buttonStyle; public static GUIStyle boxStyle; public static GUIStyle sliderStyle; public static GUIStyle thumbStyle; public static GUIStyle categoryHeaderSkin; public static GUIStyle pluginHeaderSkin; public static int fontSize = 14; public const float MinWindowWidth = 600f; public const float MinWindowHeight = 480f; public const float PreferredWindowWidth = 650f; public const float PreferredWindowHeight = 800f; public Rect DefaultWindowRect { get; set; } public static Texture2D WindowBackground { get; set; } public static Texture2D EntryBackground { get; set; } public static Texture2D WidgetBackground { get; set; } public int LeftColumnWidth { get; set; } public int RightColumnWidth { get; set; } public bool DisplayingWindow { get { return _displayingWindow; } set { if (_displayingWindow == value) { return; } _displayingWindow = value; SettingFieldDrawer.ClearCache(); if (_displayingWindow) { CalculateDefaultWindowRect(); EnsureUsableWindowRect(); BuildSettingList(); _focusSearchBox = true; if (_curLockState != null) { _previousCursorLockState = (_obsoleteCursor ? Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : ((int)_curLockState.GetValue(null, null))); _previousCursorVisible = (bool)_curVisible.GetValue(null, null); } } else if (!_previousCursorVisible || _previousCursorLockState != 0) { SetUnlockCursor(_previousCursorLockState, _previousCursorVisible); } this.DisplayingWindowChanged?.Invoke(this, new ValueChangedEventArgs<bool>(value)); } } public string SearchString { get { return _searchString; } set { if (value == null) { value = string.Empty; } if (!(_searchString == value)) { _searchString = value; BuildFilteredSettingList(); } } } public event EventHandler<ValueChangedEventArgs<bool>> DisplayingWindowChanged; public static void Dbgl(string str = "", bool pref = true) { if (isDebug) { Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str)); } } public BepInExPlugin() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Expected O, but got Unknown //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) context = this; Logger = ((BaseUnityPlugin)this).Logger; CalculateDefaultWindowRect(); _fieldDrawer = new SettingFieldDrawer(this); _keybind = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Show config manager", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), new ConfigDescription("The shortcut used to toggle the config manager window on and off.\nThe key can be overridden by a game-specific plugin if necessary, in that case this setting is ignored.", (AcceptableValueBase)null, Array.Empty<object>())); nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 740, "Nexus mod ID for updates"); _showAdvanced = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show advanced", true, (ConfigDescription)null); _showKeybinds = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show keybinds", true, (ConfigDescription)null); _showSettings = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "Show settings", true, (ConfigDescription)null); _hideSingleSection = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide single sections", false, new ConfigDescription("Show section title for plugins with only one section", (AcceptableValueBase)null, Array.Empty<object>())); _showMenuButton = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Menu Button", true, new ConfigDescription("Show the menu button on the start menu", (AcceptableValueBase)null, Array.Empty<object>())); _windowTitle = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "WindowTitle", "Configuration Manager", new ConfigDescription("Window title text", (AcceptableValueBase)null, Array.Empty<object>())); _normalText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "NormalText", "Normal", new ConfigDescription("Normal settings toggle text", (AcceptableValueBase)null, Array.Empty<object>())); _shortcutsText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ShortcutsText", "Keybinds", new ConfigDescription("Shortcut key settings toggle text", (AcceptableValueBase)null, Array.Empty<object>())); _advancedText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "AdvancedText", "Advanced", new ConfigDescription("Advanced settings toggle text", (AcceptableValueBase)null, Array.Empty<object>())); _searchText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "SearchText", "Search Settings: ", new ConfigDescription("Search label text", (AcceptableValueBase)null, Array.Empty<object>())); _reloadText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ReloadText", "Reload From File", new ConfigDescription("Reload mod config from file text", (AcceptableValueBase)null, Array.Empty<object>())); _resetText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ResetText", "Reset To Default", new ConfigDescription("Reset mod config to default text", (AcceptableValueBase)null, Array.Empty<object>())); _resetSettingText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ResetSettingText", "Reset", new ConfigDescription("Reset setting text", (AcceptableValueBase)null, Array.Empty<object>())); _expandText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ExpandText", "Expand", new ConfigDescription("Expand button text", (AcceptableValueBase)null, Array.Empty<object>())); _collapseText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "CollapseText", "Collapse", new ConfigDescription("Collapse button text", (AcceptableValueBase)null, Array.Empty<object>())); _tipText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "TipText", "Tip: Click plugin names to expand. Hover over setting names to see their descriptions.", new ConfigDescription("Tip text", (AcceptableValueBase)null, Array.Empty<object>())); _clearText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "ClearText", "Clear", new ConfigDescription("Clear search text", (AcceptableValueBase)null, Array.Empty<object>())); _openMenuText = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "OpenMenuText", "Open Config Menu", new ConfigDescription("Open Menu Button text", (AcceptableValueBase)null, Array.Empty<object>())); _pluginConfigCollapsedDefault = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Plugin collapsed default", true, new ConfigDescription("If set to true plugins will be collapsed when opening the configuration manager window", (AcceptableValueBase)null, Array.Empty<object>())); _windowPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("General", "WindowPosition", new Vector2(55f, 35f), "Window position"); _windowSize = ((BaseUnityPlugin)this).Config.Bind<Vector2>("General", "WindowSize", new Vector2(650f, 800f), "Window size"); _textSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FontSize", 14, "Font Size"); _windowBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "WindowBackgroundColor", new Color(0f, 0f, 0f, 1f), "Window background color"); _entryBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "EntryBackgroundColor", new Color(0.557f, 0.502f, 0.502f, 0.871f), "Entry background color"); _fontColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "FontColor", new Color(1f, 0.714f, 0.361f, 1f), "Font color"); _widgetBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "WidgetColor", new Color(0.882f, 0.463f, 0f, 0.749f), "Widget color"); currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value); EnsureUsableWindowRect(); Patches.ApplyPatches(); } public void OnGUI() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) if (!DisplayingWindow) { return; } if ((int)Event.current.type == 5) { KeyCode keyCode = Event.current.keyCode; KeyboardShortcut value = _keybind.Value; if (keyCode == ((KeyboardShortcut)(ref value)).MainKey) { DisplayingWindow = false; return; } } if (_textSize.Value > 9 && _textSize.Value < 100) { fontSize = Mathf.Clamp(_textSize.Value, 10, 30); } CreateBackgrounds(); CreateStyles(); SetUnlockCursor(0, cursorVisible: true); GUI.Box(currentWindowRect, GUIContent.none, new GUIStyle()); GUI.backgroundColor = _windowBackgroundColor.Value; EnsureUsableWindowRect(); ((Rect)(ref currentWindowRect)).size = _windowSize.Value; RightColumnWidth = Mathf.RoundToInt(((Rect)(ref currentWindowRect)).width / 2.5f * (float)fontSize / 12f); LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref currentWindowRect)).width - (float)RightColumnWidth - 115f); currentWindowRect = GUILayout.Window(-68, currentWindowRect, new WindowFunction(SettingsWindow), _windowTitle.Value, windowStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(((Rect)(ref currentWindowRect)).width), GUILayout.Height(((Rect)(ref currentWindowRect)).height) }); ((Rect)(ref currentWindowRect)).size = _windowSize.Value; if (!SettingFieldDrawer.SettingKeyboardShortcut) { Input.ResetInputAxes(); } if (!Input.GetKey((KeyCode)323)) { bool flag = false; if (((Rect)(ref currentWindowRect)).x != _windowPosition.Value.x || ((Rect)(ref currentWindowRect)).y != _windowPosition.Value.y) { _windowPosition.Value = ((Rect)(ref currentWindowRect)).position; flag = true; } if (flag) { ((BaseUnityPlugin)this).Config.Save(); } } } public void SettingsWindow(int id) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Invalid comparison between Unknown and I4 //IL_008d: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref currentWindowRect)).width, 20f)); DrawWindowHeader(); _settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, Array.Empty<GUILayoutOption>()); float y = _settingWindowScrollPos.y; float height = ((Rect)(ref currentWindowRect)).height; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); Rect lastRect; if (string.IsNullOrEmpty(SearchString)) { DrawTips(); if (_tipsHeight == 0 && (int)Event.current.type == 7) { lastRect = GUILayoutUtility.GetLastRect(); _tipsHeight = (int)((Rect)(ref lastRect)).height; } } int num = _tipsHeight; foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Height == 0 || ((float)(num + filteredSeting.Height) >= y && (float)num <= y + height)) { try { DrawSinglePlugin(filteredSeting); } catch (ArgumentException) { } if (filteredSeting.Height == 0 && (int)Event.current.type == 7) { lastRect = GUILayoutUtility.GetLastRect(); filteredSeting.Height = (int)((Rect)(ref lastRect)).height; } } else { try { GUILayout.Space((float)filteredSeting.Height); } catch (ArgumentException) { } } num += filteredSeting.Height; } if (_showDebug) { GUILayout.Space(10f); GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, labelStyle, Array.Empty<GUILayoutOption>()); } else { GUILayout.Space(70f); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (!SettingFieldDrawer.DrawCurrentDropdown()) { DrawTooltip(currentWindowRect); } } public void DrawTips() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(_tipText.Value, labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; if (GUILayout.Button(_pluginConfigCollapsedDefault.Value ? _expandText.Value : _collapseText.Value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { bool flag = !_pluginConfigCollapsedDefault.Value; _pluginConfigCollapsedDefault.Value = flag; foreach (PluginSettingsData filteredSeting in _filteredSetings) { filteredSeting.Collapsed = flag; } } GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); } public void DrawWindowHeader() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = _entryBackgroundColor.Value; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.enabled = SearchString == string.Empty; bool flag = GUILayout.Toggle(_showSettings.Value, _normalText.Value, toggleStyle, Array.Empty<GUILayoutOption>()); if (_showSettings.Value != flag) { _showSettings.Value = flag; BuildFilteredSettingList(); } flag = GUILayout.Toggle(_showKeybinds.Value, _shortcutsText.Value, toggleStyle, Array.Empty<GUILayoutOption>()); if (_showKeybinds.Value != flag) { _showKeybinds.Value = flag; BuildFilteredSettingList(); } flag = GUILayout.Toggle(_showAdvanced.Value, _advancedText.Value, toggleStyle, Array.Empty<GUILayoutOption>()); if (_showAdvanced.Value != flag) { _showAdvanced.Value = flag; BuildFilteredSettingList(); } GUI.enabled = true; flag = GUILayout.Toggle(_showDebug, "Debug mode", toggleStyle, Array.Empty<GUILayoutOption>()); if (_showDebug != flag) { _showDebug = flag; BuildSettingList(); } if (GUILayout.Button("Log", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { try { Utils.OpenLog(); } catch (SystemException ex) { Logger.Log((LogLevel)10, (object)ex.Message); } } if (GUILayout.Button("Close", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { DisplayingWindow = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(_searchText.Value, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUI.SetNextControlName("searchBox"); SearchString = GUILayout.TextField(SearchString, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (_focusSearchBox) { GUI.FocusWindow(-68); GUI.FocusControl("searchBox"); _focusSearchBox = false; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; if (GUILayout.Button(_clearText.Value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { SearchString = string.Empty; } GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); } public void DrawSinglePlugin(PluginSettingsData plugin) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.textColor = _fontColor.Value; val.normal.background = EntryBackground; val.fontSize = fontSize; GUI.backgroundColor = _entryBackgroundColor.Value; GUILayout.BeginVertical(val, Array.Empty<GUILayoutOption>()); GUIContent val2 = (_showDebug ? new GUIContent(plugin.Info.Name.TrimStart(new char[1] { '!' }) + " " + plugin.Info.Version, "GUID: " + plugin.Info.GUID) : new GUIContent(plugin.Info.Name.TrimStart(new char[1] { '!' }) + " " + plugin.Info.Version)); bool flag = !string.IsNullOrEmpty(SearchString); if (SettingFieldDrawer.DrawPluginHeader(val2, plugin.Collapsed && !flag) && !flag) { plugin.Collapsed = !plugin.Collapsed; } if (flag || !plugin.Collapsed) { foreach (PluginSettingsData.PluginSettingsGroupData category in plugin.Categories) { if (!string.IsNullOrEmpty(category.Name) && (plugin.Categories.Count > 1 || !_hideSingleSection.Value)) { SettingFieldDrawer.DrawCategoryHeader(category.Name); } foreach (SettingEntryBase setting in category.Settings) { DrawSingleSetting(setting); GUILayout.Space(2f); } } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; if (GUILayout.Button(_reloadText.Value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { using (List<PluginSettingsData.PluginSettingsGroupData>.Enumerator enumerator = plugin.Categories.GetEnumerator()) { if (enumerator.MoveNext()) { using List<SettingEntryBase>.Enumerator enumerator2 = enumerator.Current.Settings.GetEnumerator(); if (enumerator2.MoveNext()) { enumerator2.Current.PluginInstance.Config.Reload(); } } } BuildFilteredSettingList(); } if (GUILayout.Button(_resetText.Value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { foreach (PluginSettingsData.PluginSettingsGroupData category2 in plugin.Categories) { foreach (SettingEntryBase setting2 in category2.Settings) { setting2.Set(setting2.DefaultValue); } } BuildFilteredSettingList(); } GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } public void DrawSingleSetting(SettingEntryBase setting) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); try { DrawSettingName(setting); _fieldDrawer.DrawSettingValue(setting); DrawDefaultButton(setting); } catch (Exception arg) { Logger.Log((LogLevel)2, (object)$"Failed to draw setting {setting.DispName} - {arg}"); GUILayout.Label("Failed to draw this field, check log for details.", labelStyle, Array.Empty<GUILayoutOption>()); } GUILayout.EndHorizontal(); } public void DrawSettingName(SettingEntryBase setting) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown if (!setting.HideSettingName) { GUILayout.Label(new GUIContent(setting.DispName.TrimStart(new char[1] { '!' }), setting.Description), labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)LeftColumnWidth), GUILayout.MaxWidth((float)LeftColumnWidth) }); } } public static void DrawDefaultButton(SettingEntryBase setting) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (setting.HideDefaultButton) { return; } GUI.backgroundColor = _widgetBackgroundColor.Value; if (setting.DefaultValue != null) { if (DrawDefaultButton()) { setting.Set(setting.DefaultValue); } } else if (setting.SettingType.IsClass && DrawDefaultButton()) { setting.Set(null); } static bool DrawDefaultButton() { GUILayout.Space(5f); return GUILayout.Button(_resetSettingText.Value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } public static void RegisterCustomSettingDrawer(Type settingType, Action<SettingEntryBase> onGuiDrawer) { if (settingType == null) { throw new ArgumentNullException("settingType"); } if (onGuiDrawer == null) { throw new ArgumentNullException("onGuiDrawer"); } if (SettingFieldDrawer.SettingDrawHandlers.ContainsKey(settingType)) { Logger.LogWarning((object)("Tried to add a setting drawer for type " + settingType.FullName + " while one already exists.")); } else { SettingFieldDrawer.SettingDrawHandlers[settingType] = onGuiDrawer; } } public void BuildSettingList() { SettingSearcher.CollectSettings(out var results, out var modsWithoutSettings, _showDebug); _modsWithoutSettings = string.Join(", ", (from x in modsWithoutSettings select x.TrimStart(new char[1] { '!' }) into x orderby x select x).ToArray()); _allSettings = results.ToList(); BuildFilteredSettingList(); } public void BuildFilteredSettingList() { IEnumerable<SettingEntryBase> source = _allSettings; string[] searchStrings = SearchString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (searchStrings.Length != 0) { source = source.Where((SettingEntryBase x) => ContainsSearchString(x, searchStrings)); } else { if (!_showAdvanced.Value) { source = source.Where((SettingEntryBase x) => x.IsAdvanced != true); } if (!_showKeybinds.Value) { source = source.Where((SettingEntryBase x) => !IsKeyboardShortcut(x)); } if (!_showSettings.Value) { source = source.Where((SettingEntryBase x) => x.IsAdvanced == true || IsKeyboardShortcut(x)); } } bool settingsAreCollapsed = _pluginConfigCollapsedDefault.Value; HashSet<string> nonDefaultCollpasingStateByPluginName = new HashSet<string>(); foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Collapsed != settingsAreCollapsed) { nonDefaultCollpasingStateByPluginName.Add(filteredSeting.Info.Name); } } _filteredSetings = (from x in (from x in source group x by x.PluginInfo).Select(delegate(IGrouping<BepInPlugin, SettingEntryBase> pluginSettings) { IEnumerable<PluginSettingsData.PluginSettingsGroupData> source2 = from x in pluginSettings.GroupBy(GetCategory) orderby string.Equals(x.Key, "Keyboard shortcuts", StringComparison.Ordinal), x.Key select new PluginSettingsData.PluginSettingsGroupData { Name = x.Key, Settings = (from set in x orderby set.Order descending, set.DispName select set).ToList() }; return new PluginSettingsData { Info = pluginSettings.Key, Categories = source2.ToList(), Collapsed = (nonDefaultCollpasingStateByPluginName.Contains(pluginSettings.Key.Name) ? (!settingsAreCollapsed) : settingsAreCollapsed) }; }) orderby x.Info.Name select x).ToList(); static string GetCategory(SettingEntryBase eb) { return eb.Category; } } public static bool IsKeyboardShortcut(SettingEntryBase x) { return x.SettingType == typeof(KeyboardShortcut); } public static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings) { string combinedSearchTarget = setting.PluginInfo.Name + "\n" + setting.PluginInfo.GUID + "\n" + setting.DispName + "\n" + setting.Category + "\n" + setting.Description + "\n" + setting.DefaultValue?.ToString() + "\n" + setting.Get(); return searchStrings.All((string s) => combinedSearchTarget.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0); } public void CalculateDefaultWindowRect() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) float num = ((Screen.width > 100) ? ((float)Screen.width) : 1920f); float num2 = ((Screen.height > 100) ? ((float)Screen.height) : 1080f); float num3 = Mathf.Clamp(650f, 600f, Mathf.Max(600f, num - 40f)); float num4 = Mathf.Clamp(800f, 480f, Mathf.Max(480f, num2 - 40f)); int num5 = Mathf.RoundToInt((num - num3) / 2f); int num6 = Mathf.RoundToInt((num2 - num4) / 2f); DefaultWindowRect = new Rect((float)num5, (float)num6, num3, num4); _screenRect = new Rect(0f, 0f, num, num2); Rect defaultWindowRect = DefaultWindowRect; LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref defaultWindowRect)).width / 2.5f); defaultWindowRect = DefaultWindowRect; RightColumnWidth = (int)((Rect)(ref defaultWindowRect)).width - LeftColumnWidth - 115; } public void EnsureUsableWindowRect() { //IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) CalculateDefaultWindowRect(); Vector2 val = _windowSize.Value; bool flag = false; if (val.x < 600f || val.y < 480f) { Rect defaultWindowRect = DefaultWindowRect; val = ((Rect)(ref defaultWindowRect)).size; flag = true; } float width = ((Rect)(ref _screenRect)).width; float height = ((Rect)(ref _screenRect)).height; float num = Mathf.Max(600f, width - 40f); float num2 = Mathf.Max(480f, height - 40f); float num3 = Mathf.Min(val.x, num); float num4 = Mathf.Min(val.y, num2); if (num3 != val.x || num4 != val.y) { val.x = num3; val.y = num4; flag = true; } if (flag) { _windowSize.Value = val; } Vector2 value = _windowPosition.Value; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(Mathf.Clamp(value.x, 0f, Mathf.Max(0f, width - val.x)), Mathf.Clamp(value.y, 0f, Mathf.Max(0f, height - val.y))); if (val2 != value) { _windowPosition.Value = val2; } currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value); } public static void DrawTooltip(Rect area) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_005f: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(GUI.tooltip)) { Event current = Event.current; GUIStyle val = new GUIStyle(boxStyle) { wordWrap = true, alignment = (TextAnchor)4 }; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _entryBackgroundColor.Value; float num = val.CalcHeight(new GUIContent(GUI.tooltip), 400f) + 10f; float num2 = ((current.mousePosition.x + 400f > ((Rect)(ref area)).width) ? (((Rect)(ref area)).width - 400f) : current.mousePosition.x); float num3 = ((current.mousePosition.y + 25f + num > ((Rect)(ref area)).height) ? (current.mousePosition.y - num) : (current.mousePosition.y + 25f)); GUI.Box(new Rect(num2, num3, 400f, num), GUI.tooltip, val); GUI.backgroundColor = backgroundColor; } } public void Start() { try { Dbgl("Searching for vanilla Config Manager."); ((Behaviour)Chainloader.PluginInfos.First((KeyValuePair<string, PluginInfo> p) => p.Key == "com.bepis.bepinex.configurationmanager").Value.Instance).enabled = false; Dbgl("Disabled Vanilla Config Manager"); } catch { Dbgl("Vanilla Config Manager not found."); } Type typeFromHandle = typeof(Cursor); _curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public); _curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public); if (_curLockState == null && _curVisible == null) { _obsoleteCursor = true; _curLockState = typeof(Screen).GetProperty("lockCursor", BindingFlags.Static | BindingFlags.Public); _curVisible = typeof(Screen).GetProperty("showCursor", BindingFlags.Static | BindingFlags.Public); } try { ((BaseUnityPlugin)this).Config.Save(); } catch (IOException ex) { Logger.Log((LogLevel)12, (object)("WARNING: Failed to write to config directory, expect issues!\nError message:" + ex.Message)); } catch (UnauthorizedAccessException ex2) { Logger.Log((LogLevel)12, (object)("WARNING: Permission denied to write to config directory, expect issues!\nError message:" + ex2.Message)); } } public void Update() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } if (!OverrideHotkey && !DisplayingWindow) { KeyboardShortcut value = _keybind.Value; if (((KeyboardShortcut)(ref value)).IsUp()) { CreateBackgrounds(); DisplayingWindow = true; } } } public void CreateStyles() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown windowStyle = new GUIStyle(GUI.skin.window); windowStyle.normal.textColor = _fontColor.Value; windowStyle.active.textColor = _fontColor.Value; labelStyle = new GUIStyle(GUI.skin.label); labelStyle.normal.textColor = _fontColor.Value; labelStyle.fontSize = fontSize; textStyle = new GUIStyle(GUI.skin.textArea); textStyle.normal.textColor = _fontColor.Value; textStyle.fontSize = fontSize; buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.normal.textColor = _fontColor.Value; buttonStyle.fontSize = fontSize; categoryHeaderSkin = new GUIStyle(labelStyle) { alignment = (TextAnchor)1, wordWrap = true, stretchWidth = true }; pluginHeaderSkin = new GUIStyle(categoryHeaderSkin); toggleStyle = new GUIStyle(GUI.skin.toggle); toggleStyle.normal.textColor = _fontColor.Value; toggleStyle.fontSize = fontSize; boxStyle = new GUIStyle(GUI.skin.box); boxStyle.normal.textColor = _fontColor.Value; boxStyle.fontSize = fontSize; sliderStyle = new GUIStyle(GUI.skin.horizontalSlider); thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb); } public void CreateBackgrounds() { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, _windowBackgroundColor.Value); val.Apply(); WindowBackground = val; Texture2D val2 = new Texture2D(1, 1, (TextureFormat)5, false); val2.SetPixel(0, 0, _entryBackgroundColor.Value); val2.Apply(); EntryBackground = val2; } public void LateUpdate() { if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } } public void SetUnlockCursor(int lockState, bool cursorVisible) { if (_curLockState != null) { if (_obsoleteCursor) { _curLockState.SetValue(null, Convert.ToBoolean(lockState), null); } else { _curLockState.SetValue(null, lockState, null); } _curVisible.SetValue(null, cursorVisible, null); } } } public sealed class ConfigSettingEntry : SettingEntryBase { public ConfigEntryBase Entry { get; } public override Type SettingType => Entry.SettingType; public ConfigSettingEntry(ConfigEntryBase entry, BaseUnityPlugin owner) { Entry = entry; DispName = entry.Definition.Key; base.Category = entry.Definition.Section; ConfigDescription description = entry.Description; base.Description = ((description != null) ? description.Description : null); TypeConverter converter = TomlTypeConverter.GetConverter(entry.SettingType); if (converter != null) { base.ObjToStr = (object o) => converter.ConvertToString(o, entry.SettingType); base.StrToObj = (string s) => converter.ConvertToObject(s, entry.SettingType); } ConfigDescription description2 = entry.Description; AcceptableValueBase val = ((description2 != null) ? description2.AcceptableValues : null); if (val != null) { GetAcceptableValues(val); } base.DefaultValue = entry.DefaultValue; ConfigDescription description3 = entry.Description; SetFromAttributes((description3 != null) ? description3.Tags : null, owner); } public void GetAcceptableValues(AcceptableValueBase values) { Type type = ((object)values).GetType(); PropertyInfo property = type.GetProperty("AcceptableValues", BindingFlags.Instance | BindingFlags.Public); if (property != null) { base.AcceptableValues = ((IEnumerable)property.GetValue(values, null)).Cast<object>().ToArray(); return; } PropertyInfo property2 = type.GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public); if (property2 != null) { PropertyInfo property3 = type.GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public); if (property3 == null) { throw new ArgumentNullException("maxProp"); } base.AcceptableValueRange = new KeyValuePair<object, object>(property2.GetValue(values, null), property3.GetValue(values, null)); base.ShowRangeAsPercent = ((base.AcceptableValueRange.Key.Equals(0) || base.AcceptableValueRange.Key.Equals(1)) && base.AcceptableValueRange.Value.Equals(100)) || (base.AcceptableValueRange.Key.Equals(0f) && base.AcceptableValueRange.Value.Equals(1f)); } } public override object Get() { return Entry.BoxedValue; } protected override void SetValue(object newVal) { Entry.BoxedValue = newVal; } } public class LegacySettingEntry : SettingEntryBase { public Type _settingType; public override string DispName { get { if (!string.IsNullOrEmpty(base.DispName)) { return base.DispName; } return Property.Name; } set { base.DispName = value; } } public object Instance { get; set; } public PropertyInfo Property { get; set; } public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType); public object Wrapper { get; set; } public override object Get() { return Property.GetValue(Instance, null); } protected override void SetValue(object newVal) { Property.SetValue(Instance, newVal, null); } public static LegacySettingEntry FromConfigWrapper(object instance, PropertyInfo settingProp, BepInPlugin pluginInfo, BaseUnityPlugin pluginInstance) { try { object value = settingProp.GetValue(instance, null); if (value == null) { BepInExPlugin.Logger.Log((LogLevel)32, (object)$"Skipping ConfigWrapper entry because it's null : {instance} | {settingProp.Name} | {((pluginInfo != null) ? pluginInfo.Name : null)}"); return null; } PropertyInfo property = value.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public); LegacySettingEntry legacySettingEntry = new LegacySettingEntry(); legacySettingEntry.SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance); if (property == null) { BepInExPlugin.Logger.Log((LogLevel)2, (object)"Failed to find property Value of ConfigWrapper"); return null; } legacySettingEntry.Browsable = property.CanRead && property.CanWrite && legacySettingEntry.Browsable != false; legacySettingEntry.Property = property; legacySettingEntry.Instance = value; legacySettingEntry.Wrapper = value; if (legacySettingEntry.DispName == "Value") { legacySettingEntry.DispName = value.GetType().GetProperty("Key", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value, null) as string; } if (string.IsNullOrEmpty(legacySettingEntry.Category)) { string text = value.GetType().GetProperty("Section", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value, null) as string; if (text != ((pluginInfo != null) ? pluginInfo.GUID : null)) { legacySettingEntry.Category = text; } } object strToObj = value.GetType().GetField("_strToObj", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value); if (strToObj != null) { MethodInfo inv = strToObj.GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public); if (inv != null) { legacySettingEntry.StrToObj = (string s) => inv.Invoke(strToObj, new object[1] { s }); } } object objToStr = value.GetType().GetField("_objToStr", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value); if (objToStr != null) { MethodInfo inv2 = objToStr.GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public); if (inv2 != null) { legacySettingEntry.ObjToStr = (object o) => inv2.Invoke(objToStr, new object[1] { o }) as string; } } else { legacySettingEntry.ObjToStr = (object o) => o.ToString(); } return legacySettingEntry; } catch (SystemException ex) { BepInExPlugin.Logger.Log((LogLevel)2, (object)$"Failed to create ConfigWrapper entry : {instance} | {settingProp?.Name} | {((pluginInfo != null) ? pluginInfo.Name : null)} | Error: {ex.Message}"); return null; } } public static LegacySettingEntry FromNormalProperty(object instance, PropertyInfo settingProp, BepInPlugin pluginInfo, BaseUnityPlugin pluginInstance) { LegacySettingEntry legacySettingEntry = new LegacySettingEntry(); legacySettingEntry.SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance); if (!legacySettingEntry.Browsable.HasValue) { legacySettingEntry.Browsable = settingProp.CanRead && settingProp.CanWrite; } legacySettingEntry.ReadOnly = settingProp.CanWrite; legacySettingEntry.Property = settingProp; legacySettingEntry.Instance = instance; return legacySettingEntry; } } public static class Patches { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__5_0; public static EventHandler <>9__5_1; public static Func<TMP_Text, bool> <>9__6_0; public static UnityAction <>9__6_1; internal void <ApplyPatches>b__5_0(object s, EventArgs e) { SetupMenuButton(); } internal void <ApplyPatches>b__5_1(object s, EventArgs e) { SetupMenuButton(); } internal bool <SetupMenuButton>b__6_0(TMP_Text t) { if (!(t.text == "Show Player.log")) { if (Localization.instance != null) { return t.text == Localization.instance.Localize("Show Player.log"); } return false; } return true; } internal void <SetupMenuButton>b__6_1() { BepInExPlugin.context.DisplayingWindow = true; } } private const string OpenLogString = "Show Player.log"; public static GameObject OpenMenuButton { get; set; } public static void ApplyPatches() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown Harmony val = new Harmony("aedenthorn.ConfigurationManager"); val.Patch((MethodBase)AccessTools.Method(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Patches), "Start", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "InputText", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(Patches), "InputText", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); BepInExPlugin._openMenuText.SettingChanged += delegate { SetupMenuButton(); }; BepInExPlugin._showMenuButton.SettingChanged += delegate { SetupMenuButton(); }; } public static void SetupMenuButton() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown if ((Object)(object)OpenMenuButton == (Object)null && (Object)(object)FejdStartup.instance?.m_mainMenu != (Object)null) { TMP_Text val = ((IEnumerable<TMP_Text>)FejdStartup.instance.m_mainMenu.GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => t.text == "Show Player.log" || (Localization.instance != null && t.text == Localization.instance.Localize("Show Player.log")))); if ((Object)(object)val != (Object)null) { OpenMenuButton = Object.Instantiate<GameObject>(((Component)val.transform.parent).gameObject, val.transform.parent.parent); ((Object)OpenMenuButton).name = "OpenConfigMenu"; Transform transform = OpenMenuButton.transform; transform.localPosition += new Vector3(0f, 25f, 0f); Button component = OpenMenuButton.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { component.onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = component.onClick; object obj = <>c.<>9__6_1; if (obj == null) { UnityAction val2 = delegate { BepInExPlugin.context.DisplayingWindow = true; }; <>c.<>9__6_1 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } } } if (!((Object)(object)OpenMenuButton == (Object)null)) { TMP_Text componentInChildren = OpenMenuButton.GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = BepInExPlugin._openMenuText.Value; } OpenMenuButton.SetActive(BepInExPlugin._showMenuButton.Value); } } public static bool InputText(Terminal __instance) { if ((Object)(object)__instance?.m_input == (Object)null) { return true; } string text = ((TMP_InputField)__instance.m_input).text; if (text != null && text.ToLower().Equals("configurationmanager reset")) { ((BaseUnityPlugin)BepInExPlugin.context).Config.Reload(); ((BaseUnityPlugin)BepInExPlugin.context).Config.Save(); __instance.AddString(text); __instance.AddString(((BaseUnityPlugin)BepInExPlugin.context).Info.Metadata.Name + " config reloaded"); return false; } return true; } public static void Start() { SetupMenuButton(); } } public abstract class SettingEntryBase { public static readonly PropertyInfo[] _myProperties = typeof(SettingEntryBase).GetProperties(BindingFlags.Instance | BindingFlags.Public); public object[] AcceptableValues { get; protected set; } public KeyValuePair<object, object> AcceptableValueRange { get; protected set; } public bool? ShowRangeAsPercent { get; protected set; } public Action<ConfigEntryBase> CustomDrawer { get; set; } public bool? Browsable { get; protected set; } public string Category { get; protected set; } public object DefaultValue { get; protected set; } public bool HideDefaultButton { get; protected set; } public bool HideSettingName { get; protected set; } public string Description { get; set; } public virtual string DispName { get; set; } public BepInPlugin PluginInfo { get; set; } public bool? ReadOnly { get; protected set; } public abstract Type SettingType { get; } public BaseUnityPlugin PluginInstance { get; set; } public bool? IsAdvanced { get; set; } public int Order { get; protected set; } public Func<object, string> ObjToStr { get; set; } public Func<string, object> StrToObj { get; set; } public abstract object Get(); public void Set(object newVal) { if (ReadOnly != true) { SetValue(newVal); } } protected abstract void SetValue(object newVal); public void SetFromAttributes(object[] attribs, BaseUnityPlugin pluginInstance) { PluginInstance = pluginInstance; PluginInfo = ((pluginInstance != null) ? pluginInstance.Info.Metadata : null); if (attribs == null || attribs.Length == 0) { return; } foreach (object obj in attribs) { if (obj == null) { continue; } Action<SettingEntryBase> action = obj as Action<SettingEntryBase>; if (action == null) { if (obj is string text) { switch (text) { case "ReadOnly": ReadOnly = true; break; case "Browsable": Browsable = true; break; case "Unbrowsable": case "Hidden": Browsable = false; break; case "Advanced": IsAdvanced = true; break; } continue; } Type type = obj.GetType(); if (!(type.Name == "ConfigurationManagerAttributes")) { break; } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (var item in from my in _myProperties join other in fields on my.Name equals other.Name select new { my, other }) { try { object value = item.other.GetValue(obj); if (value != null) { item.my.SetValue(this, value, null); } } catch (Exception ex) { BepInExPlugin.Logger.LogWarning((object)("Failed to copy value " + item.my.Name + " from provided tag object " + type.FullName + " - " + ex.Message)); } } } else { CustomDrawer = delegate { action(this); }; } } } } public class SettingFieldDrawer { public sealed class ColorCacheEntry { public Color Last; public Texture2D Tex; } public static readonly IEnumerable<KeyCode> _keysToCheck; public static readonly Dictionary<SettingEntryBase, ComboBox> _comboBoxCache; public static readonly Dictionary<SettingEntryBase, ColorCacheEntry> _colorCache; public readonly BepInExPlugin _instance; public static SettingEntryBase _currentKeyboardShortcutToSet; public readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>(); public static Dictionary<Type, Action<SettingEntryBase>> SettingDrawHandlers { get; } public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null; static SettingFieldDrawer() { _keysToCheck = KeyboardShortcut.AllKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); _comboBoxCache = new Dictionary<SettingEntryBase, ComboBox>(); _colorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>(); SettingDrawHandlers = new Dictionary<Type, Action<SettingEntryBase>> { { typeof(bool), DrawBoolField }, { typeof(KeyboardShortcut), DrawKeyboardShortcut }, { typeof(KeyCode), DrawKeyboardShortcut }, { typeof(Color), DrawColor }, { typeof(Vector2), DrawVector2 }, { typeof(Vector3), DrawVector3 }, { typeof(Vector4), DrawVector4 }, { typeof(Quaternion), DrawQuaternion } }; } public SettingFieldDrawer(BepInExPlugin instance) { _instance = instance; } public void DrawSettingValue(SettingEntryBase setting) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = BepInExPlugin._widgetBackgroundColor.Value; if (setting.CustomDrawer != null) { setting.CustomDrawer((setting is ConfigSettingEntry configSettingEntry) ? configSettingEntry.Entry : null); } else if (setting.ShowRangeAsPercent.HasValue && setting.AcceptableValueRange.Key != null) { DrawRangeField(setting); } else if (setting.AcceptableValues != null) { DrawListField(setting); } else if (setting.SettingType.IsEnum) { if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any()) { DrawFlagsField(setting, Enum.GetValues(setting.SettingType), _instance.RightColumnWidth); return; } Array values = Enum.GetValues(setting.SettingType); Rect defaultWindowRect = _instance.DefaultWindowRect; DrawComboboxField(setting, values, ((Rect)(ref defaultWindowRect)).yMax); } else { DrawFieldBasedOnValueType(setting); } } public static void ClearCache() { _comboBoxCache.Clear(); foreach (KeyValuePair<SettingEntryBase, ColorCacheEntry> item in _colorCache) { Object.Destroy((Object)(object)item.Value.Tex); } _colorCache.Clear(); } public static void DrawCenteredLabel(string text, params GUILayoutOption[] options) { GUILayout.BeginHorizontal(options); GUILayout.FlexibleSpace(); GUILayout.Label(text, BepInExPlugin.labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } public static void DrawCategoryHeader(string text) { GUILayout.Label(text, BepInExPlugin.categoryHeaderSkin, Array.Empty<GUILayoutOption>()); } public static bool DrawPluginHeader(GUIContent content, bool isCollapsed) { return GUILayout.Button(content, BepInExPlugin.pluginHeaderSkin, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } public static bool DrawCurrentDropdown() { if (ComboBox.CurrentDropdownDrawer != null) { ComboBox.CurrentDropdownDrawer(); ComboBox.CurrentDropdownDrawer = null; return true; } return false; } public void DrawListField(SettingEntryBase setting) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) object[] acceptableValues = setting.AcceptableValues; if (acceptableValues.Length == 0) { throw new ArgumentException("AcceptableValueListAttribute returned an empty list of acceptable values. You need to supply at least 1 option."); } if (!setting.SettingType.IsInstanceOfType(acceptableValues.FirstOrDefault((object x) => x != null))) { throw new ArgumentException("AcceptableValueListAttribute returned a list with items of type other than the settng type itself."); } Rect defaultWindowRect = _instance.DefaultWindowRect; DrawComboboxField(setting, acceptableValues, ((Rect)(ref defaultWindowRect)).yMax); } public void DrawFieldBasedOnValueType(SettingEntryBase setting) { if (SettingDrawHandlers.TryGetValue(setting.SettingType, out var value)) { value(setting); } else { DrawUnknownField(setting, _instance.RightColumnWidth); } } public static void DrawBoolField(SettingEntryBase setting) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = BepInExPlugin._widgetBackgroundColor.Value; bool flag = (bool)setting.Get(); bool flag2 = GUILayout.Toggle(flag, flag ? "Enabled" : "Disabled", BepInExPlugin.toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (flag2 != flag) { setting.Set(flag2); } } public static void DrawFlagsField(SettingEntryBase setting, IList enumValues, int maxWidth) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) long num = Convert.ToInt64(setting.Get()); var array = (from Enum x in enumValues select new { name = x.ToString(), val = Convert.ToInt64(x) }).ToArray(); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)maxWidth) }); int num2 = 0; while (num2 < array.Length) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num3 = 0; for (; num2 < array.Length; num2++) { var anon = array[num2]; if (anon.val != 0L) { int num4 = (int)GUI.skin.toggle.CalcSize(new GUIContent(anon.name)).x; num3 += num4; if (num3 > maxWidth) { break; } GUI.changed = false; bool flag = GUILayout.Toggle((num & anon.val) == anon.val, anon.name, BepInExPlugin.toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (GUI.changed) { long value = (flag ? (num | anon.val) : (num & ~anon.val)); setting.Set(Enum.ToObject(setting.SettingType, value)); } } } GUILayout.EndHorizontal(); } GUI.changed = false; GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } public static void DrawComboboxField(SettingEntryBase setting, IList list, float windowYmax) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) GUIContent val = ObjectToGuiContent(setting.Get()); Rect rect = GUILayoutUtility.GetRect(val, GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!_comboBoxCache.TryGetValue(setting, out var value)) { value = new ComboBox(rect, val, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), BepInExPlugin.boxStyle, windowYmax); _comboBoxCache[setting] = value; } else { value.Rect = rect; value.ButtonContent = val; } value.Show(delegate(int id) { if (id >= 0 && id < list.Count) { setting.Set(list[id]); } }); } public static GUIContent ObjectToGuiContent(object x) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (x is Enum) { DescriptionAttribute descriptionAttribute = x.GetType().GetMember(x.ToString()).FirstOrDefault()?.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false).Cast<DescriptionAttribute>().FirstOrDefault(); if (descriptionAttribute == null) { return new GUIContent(x.ToString().ToProperCase()); } return new GUIContent(descriptionAttribute.Description); } return new GUIContent(x.ToString()); } public static void DrawRangeField(SettingEntryBase setting) { object obj = setting.Get(); float num = (float)Convert.ToDouble(obj, CultureInfo.InvariantCulture); float num2 = (float)Convert.ToDouble(setting.AcceptableValueRange.Key, CultureInfo.InvariantCulture); float num3 = (float)Convert.ToDouble(setting.AcceptableValueRange.Value, CultureInfo.InvariantCulture); float num4 = GUILayout.HorizontalSlider(num, num2, num3, BepInExPlugin.sliderStyle, BepInExPlugin.thumbStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (Math.Abs(num4 - num) > Mathf.Abs(num3 - num2) / 1000f) { object newVal = Convert.ChangeType(num4, setting.SettingType, CultureInfo.InvariantCulture); setting.Set(newVal); } if (setting.ShowRangeAsPercent == true) { DrawCenteredLabel(Mathf.Round(100f * Mathf.Abs(num4 - num2) / Mathf.Abs(num3 - num2)) + "%", GUILayout.Width(50f)); return; } string text = obj.ToString().AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (!(text2 != text)) { return; } try { float num5 = Mathf.Clamp((float)Convert.ToDouble(text2, CultureInfo.InvariantCulture), num2, num3); setting.Set(Convert.ChangeType(num5, setting.SettingType, CultureInfo.InvariantCulture)); } catch (FormatException) { } } public void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth) { if (setting.ObjToStr != null && setting.StrToObj != null) { string text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, BepInExPlugin.textStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }); if (text2 != text) { setting.Set(setting.StrToObj(text2)); } } else { object obj = setting.Get(); string text3 = ((obj == null) ? "NULL" : obj.ToString().AppendZeroIfFloat(setting.SettingType)); if (CanCovert(text3, setting.SettingType)) { string text4 = GUILayout.TextField(text3, BepInExPlugin.textStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }); if (text4 != text3) { setting.Set(Convert.ChangeType(text4, setting.SettingType, CultureInfo.InvariantCulture)); } } else { GUILayout.TextArea(text3, BepInExPlugin.textStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }); } } GUILayout.FlexibleSpace(); } public bool CanCovert(string value, Type type) { if (_canCovertCache.ContainsKey(type)) { return _canCovertCache[type]; } try { Convert.ChangeType(value, type); _canCovertCache[type] = true; return true; } catch { _canCovertCache[type] = false; return false; } } public static void DrawKeyboardShortcut(SettingEntryBase setting) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) object obj = setting.Get(); if (obj.GetType() == typeof(KeyCode)) { obj = (object)new KeyboardShortcut((KeyCode)obj, Array.Empty<KeyCode>()); } if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key combination", BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; foreach (KeyCode item in _keysToCheck) { if (Input.GetKeyUp(item)) { setting.Set((object)new KeyboardShortcut(item, _keysToCheck.Where((Func<KeyCode, bool>)Input.GetKey).ToArray())); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", BepInExPlugin.buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { if (GUILayout.Button(obj.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { _currentKeyboardShortcutToSet = setting; } if (GUILayout.Button("Clear", BepInExPlugin.buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { setting.Set(KeyboardShortcut.Empty); _currentKeyboardShortcutToSet = null; } } } public static void DrawVector2(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (Vector2)obj.Get(); Vector2 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); if (val != val2) { obj.Set(val); } } public static void DrawVector3(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)obj.Get(); Vector3 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); if (val != val2) { obj.Set(val); } } public static void DrawVector4(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Vector4 val = (Vector4)obj.Get(); Vector4 val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); val.w = DrawSingleVectorSlider(val.w, "W"); if (val != val2) { obj.Set(val); } } public static void DrawQuaternion(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Quaternion val = (Quaternion)obj.Get(); Quaternion val2 = val; val.x = DrawSingleVectorSlider(val.x, "X"); val.y = DrawSingleVectorSlider(val.y, "Y"); val.z = DrawSingleVectorSlider(val.z, "Z"); val.w = DrawSingleVectorSlider(val.w, "W"); if (val != val2) { obj.Set(val); } } public static float DrawSingleVectorSlider(float setting, string label) { GUILayout.Label(label, BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); float.TryParse(GUILayout.TextField(setting.ToString("F", CultureInfo.InvariantCulture), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), NumberStyles.Any, CultureInfo.InvariantCulture, out var result); return result; } public static void DrawColor(SettingEntryBase obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) Color val = (Color)obj.Get(); if (!_colorCache.TryGetValue(obj, out var value)) { value = new ColorCacheEntry { Tex = new Texture2D(40, 10, (TextureFormat)5, false), Last = val }; value.Tex.FillTexture(val); _colorCache[obj] = value; } GUILayout.Label("R", BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.r = GUILayout.HorizontalSlider(val.r, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("G", BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.g = GUILayout.HorizontalSlider(val.g, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("B", BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.b = GUILayout.HorizontalSlider(val.b, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("A", BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); val.a = GUILayout.HorizontalSlider(val.a, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Space(4f); if (val != value.Last) { obj.Set(val); value.Tex.FillTexture(val); value.Last = val; } GUILayout.Label((Texture)(object)value.Tex, BepInExPlugin.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } public static class SettingSearcher { public static readonly ICollection<string> _updateMethodNames = new string[4] { "Update", "FixedUpdate", "LateUpdate", "OnGUI" }; public static void CollectSettings(out IEnumerable<SettingEntryBase> results, out List<string> modsWithoutSettings, bool showDebug) { modsWithoutSettings = new List<string>(); try { results = GetBepInExCoreConfig(); } catch (Exception ex) { results = Enumerable.Empty<SettingEntryBase>(); BepInExPlugin.Logger.LogError((object)ex); } BaseUnityPlugin[] array = Utils.FindPlugins(); BepInExPlugin.Dbgl($"all plugins: {array.Length}"); BaseUnityPlugin[] array2 = array; foreach (BaseUnityPlugin val in array2) { if ((Object)(object)val == (Object)null) { continue; } if (val.Info.Metadata.GUID == "com.bepis.bepinex.configurationmanager" || !((Behaviour)val).enabled) { BepInExPlugin.Dbgl($"plugin: {val.Info.Metadata.Name} enabled {((Behaviour)val).enabled}"); } Type type = ((object)val).GetType(); BepInPlugin metadata = val.Info.Metadata; if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => !x.Browsable)) { BepInExPlugin.Dbgl(metadata.Name + " has no settings, skipping."); modsWithoutSettings.Add(metadata.Name); continue; } List<SettingEntryBase> list = new List<SettingEntryBase>(); list.AddRange(GetPluginConfig(val).Cast<SettingEntryBase>()); int count = list.FindAll((SettingEntryBase x) => x.Browsable == false).Count; if (count > 0) { BepInExPlugin.Dbgl($"{count} settings are not browseable, removing."); list.RemoveAll((SettingEntryBase x) => x.Browsable == false); } if (!list.Any()) { BepInExPlugin.Dbgl(metadata.Name + " has no showable settings, skipping."); modsWithoutSettings.Add(metadata.Name); } if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo x) => _updateMethodNames.Contains(x.Name))) { LegacySettingEntry legacySettingEntry = LegacySettingEntry.FromNormalProperty(val, type.GetProperty("enabled"), metadata, val); legacySettingEntry.DispName = "!Allow plugin to run on every frame"; legacySettingEntry.Description = "Disabling this will disable some or all of the plugin's functionality.\nHooks and event-based functionality will not be disabled.\nThis setting will be lost after game restart."; legacySettingEntry.IsAdvanced = true; list.Add(legacySettingEntry); } if (list.Any()) { results = results.Concat(list); } } } public static IEnumerable<SettingEntryBase> GetBepInExCoreConfig() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0080: Expected O, but got Unknown PropertyInfo? property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic); if (property == null) { throw new ArgumentNullException("coreConfigProp"); } ConfigFile val = (ConfigFile)property.GetValue(null, null); BepInPlugin bepinMeta = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString()); return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)val).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> x) => new ConfigSettingEntry(x.Value, null) { IsAdvanced = true, PluginInfo = bepinMeta }).Cast<SettingEntryBase>(); } public static IEnumerable<ConfigSettingEntry> GetPluginConfig(BaseUnityPlugin plugin) { return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> x) => new ConfigSettingEntry(x.Value, plugin)); } } public sealed class ValueChangedEventArgs<TValue> : EventArgs { public TValue NewValue { get; } public ValueChangedEventArgs(TValue newValue) { NewValue = newValue; } } } namespace ConfigurationManager.Utilities { public class ComboBox { public static bool forceToUnShow; public static int useControlID = -1; public readonly string boxStyle; public readonly string buttonStyle; public bool isClickedComboButton; public readonly GUIContent[] listContent; public readonly GUIStyle listStyle; public readonly int _windowYmax; public Vector2 _scrollPosition = Vector2.zero; public Rect Rect { get; set; } public GUIContent ButtonContent { get; set; } public static Action CurrentDropdownDrawer { get; set; } public ComboBox(Rect rect, GUIContent buttonContent, GUIContent[] listContent, GUIStyle listStyle, float windowYmax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Rect = rect; ButtonContent = buttonContent; this.listContent = listContent; buttonStyle = "button"; boxStyle = "box"; this.listStyle = listStyle; _windowYmax = (int)windowYmax; } public ComboBox(Rect rect, GUIContent buttonContent, GUIContent[] listContent, string buttonStyle, string boxStyle, GUIStyle listStyle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Rect = rect; ButtonContent = buttonContent; this.listContent = listContent; this.buttonStyle = buttonStyle; this.boxStyle = boxStyle; this.listStyle = listStyle; } public void Show(Action<int> onItemSelected) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_005b: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (forceToUnShow) { forceToUnShow = false; isClickedComboButton = false; } bool flag = false; int controlID = GUIUtility.GetControlID((FocusType)2); Vector2 val = Vector2.zero; if ((int)Event.current.GetTypeForControl(controlID) == 1 && isClickedComboButton) { flag = true; val = Event.current.mousePosition; } if (GUI.Button(Rect, ButtonContent, GUIStyle.op_Implicit(buttonStyle))) { if (useControlID == -1) { useControlID = controlID; isClickedComboButton = false; } if (useControlID != controlID) { forceToUnShow = true; useControlID = controlID; } isClickedComboButton = true; } if (isClickedComboButton) { GUI.enabled = false; GUI.color = new Color(1f, 1f, 1f, 2f); Rect rect = Rect; float x = ((Rect)(ref rect)).x; rect = Rect; Vector2 location = GUIUtility.GUIToScreenPoint(new Vector2(x, ((Rect)(ref rect)).y + listStyle.CalcHeight(listContent[0], 1f))); rect = Rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref rect)).width, listStyle.CalcHeight(listContent[0], 1f) * (float)listContent.Length); Rect innerRect = new Rect(0f, 0f, val2.x, val2.y); Rect outerRectScreen = new Rect(location.x, location.y, val2.x, val2.y); if (((Rect)(ref outerRectScreen)).yMax > (float)_windowYmax) { ((Rect)(ref outerRectScreen)).height = (float)_windowYmax - ((Rect)(ref outerRectScreen)).y; ref Rect reference = ref outerRectScreen; ((Rect)(ref reference)).width = ((Rect)(ref reference)).width + 20f; } if (val != Vector2.zero && ((Rect)(ref outerRectScreen)).Contains(GUIUtility.GUIToScreenPoint(val))) { flag = false; } CurrentDropdownDrawer = delegate { //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_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) GUI.enabled = true; Vector2 val3 = GUIUtility.ScreenToGUIPoint(location); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(val3.x, val3.y, ((Rect)(ref outerRectScreen)).width, ((Rect)(ref outerRectScreen)).height); GUI.Box(val4, GUIContent.none, new GUIStyle { normal = new GUIStyleState { background = BepInExPlugin.WindowBackground } }); _scrollPosition = GUI.BeginScrollView(val4, _scrollPosition, innerRect, false, false); int num = GUI.SelectionGrid(innerRect, -1, listContent, 1, listStyle); if (num != -1) { onItemSelected(num); isClickedComboButton = false; } GUI.EndScrollView(true); }; } if (flag) { isClickedComboButton = false; } } } public static class Utils { public static string ToProperCase(this string str) { if (string.IsNullOrEmpty(str)) { return string.Empty; } if (str.Length < 2) { return str; } string text = str.Substring(0, 1).ToUpper(); for (int i = 1; i < str.Length; i++) { if (char.IsUpper(str[i])) { text += " "; } text += str[i]; } return text; } public static IEnumerable<T> FilterBrowsable<T>(this IEnumerable<T> props, bool expectedBrowsable, bool includeNotSet = false) where T : MemberInfo { if (includeNotSet) { return props.Where((T p) => p.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().All((BrowsableAttribute x) => x.Browsable == expectedBrowsable)); } return props.Where((T p) => p.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => x.Browsable == expectedBrowsable)); } public static bool IsSubclassOfRawGeneric(this Type toCheck, Type generic) { while (toCheck != null && toCheck != typeof(object)) { Type type = (toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck); if (generic == type) { return true; } toCheck = toCheck.BaseType; } return false; } public static BaseUnityPlugin[] FindPlugins() { List<BaseUnityPlugin> list = new List<BaseUnityPlugin>(); foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { list.Add(pluginInfo.Value.Instance); } return list.ToArray(); } public static bool IsNumber(this object value) { if (!(value is sbyte) && !(value is byte) && !(value is short) && !(value is ushort) && !(value is int) && !(value is uint) && !(value is long) && !(value is ulong) && !(value is float) && !(value is double)) { return value is decimal; } return true; } public static string AppendZero(this string s) { if (s.Contains(".")) { return s; } return s + ".0"; } public static string AppendZeroIfFloat(this string s, Type type) { if (!(type == typeof(float)) && !(type == typeof(double)) && !(type == typeof(decimal))) { return s; } return s.AppendZero(); } public static void FillTexture(this Texture2D tex, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ((Texture)tex).width; i++) { for (int j = 0; j < ((Texture)tex).height; j++) { tex.SetPixel(i, j, color); } } tex.Apply(false); } public static void OpenLog() { if (TryOpen(Path.Combine(Path.Combine(Application.dataPath, ".."), "output_log.txt")) || TryOpen(Path.Combine(Application.dataPath, "output_log.txt"))) { return; } PropertyInfo property = typeof(Application).GetProperty("consoleLogPath", BindingFlags.Static | BindingFlags.Public); if ((property != null && TryOpen(property.GetValue(null, null) as string)) || (Directory.Exists(Application.persistentDataPath) && TryOpen(Directory.GetFiles(Application.persistentDataPath, "output_log.txt", SearchOption.AllDirectories).FirstOrDefault()))) { return; } DirectoryInfo parent = Directory.GetParent(Application.dataPath); if (parent.Exists) { FileInfo fileInfo = parent.GetFiles("LogOutput.log", SearchOption.AllDirectories).FirstOrDefault(); if (fileInfo == null) { fileInfo = parent.GetFiles("output_log.txt", SearchOption.AllDirectories).FirstOrDefault(); } if (fileInfo != null && TryOpen(fileInfo.FullName)) { return; } } throw new FileNotFoundException("No log files were found"); static bool TryOpen(string path) { if (!File.Exists(path)) { return false; } try { Process.Start(path); return true; } catch { return false; } } } } }