using 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.InteropServices; using System.Runtime.Versioning; using System.Text; 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: AssemblyTitle("ConfigManager")] [assembly: AssemblyDescription("Standalone Valheim configuration manager")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("sighsorry")] [assembly: AssemblyMetadata("Author", "sighsorry")] [assembly: AssemblyProduct("ConfigManager")] [assembly: AssemblyCopyright("Copyright © 2018-2026 ConfigManager contributors; modifications © 2026 sighsorry")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0bac4d10-1d45-4b13-861c-48bae48536e9")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public struct HSLColor { public float h; public float s; public float l; public float a; public HSLColor(float h, float s, float l, float a) { this.h = h; this.s = s; this.l = l; this.a = a; } public HSLColor(float h, float s, float l) { this.h = h; this.s = s; this.l = l; a = 1f; } public HSLColor(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) HSLColor hSLColor = FromRGBA(c); h = hSLColor.h; s = hSLColor.s; l = hSLColor.l; a = hSLColor.a; } public static HSLColor FromRGBA(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00e3: 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) float num = c.a; float num2 = Mathf.Min(Mathf.Min(c.r, c.g), c.b); float num3 = Mathf.Max(Mathf.Max(c.r, c.g), c.b); float num4 = (num2 + num3) / 2f; float num5; float num6; if (num2 == num3) { num5 = 0f; num6 = 0f; } else { float num7 = num3 - num2; num5 = ((num4 <= 0.5f) ? (num7 / (num3 + num2)) : (num7 / (2f - (num3 + num2)))); num6 = 0f; if (c.r == num3) { num6 = (c.g - c.b) / num7; } else if (c.g == num3) { num6 = 2f + (c.b - c.r) / num7; } else if (c.b == num3) { num6 = 4f + (c.r - c.g) / num7; } num6 = Mathf.Repeat(num6 * 60f, 360f); } return new HSLColor(num6, num5, num4, num); } public Color ToRGBA() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) float num = a; float num2 = ((l <= 0.5f) ? (l * (1f + s)) : (l + s - l * s)); float n = 2f * l - num2; float num3; float num4; float num5; if (s == 0f) { num3 = (num4 = (num5 = l)); } else { num3 = Value(n, num2, h + 120f); num4 = Value(n, num2, h); num5 = Value(n, num2, h - 120f); } return new Color(num3, num4, num5, num); } private static float Value(float n1, float n2, float hue) { hue = Mathf.Repeat(hue, 360f); if (hue < 60f) { return n1 + (n2 - n1) * hue / 60f; } if (hue < 180f) { return n2; } if (hue < 240f) { return n1 + (n2 - n1) * (240f - hue) / 60f; } return n1; } public static implicit operator HSLColor(Color src) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FromRGBA(src); } public static implicit operator Color(HSLColor src) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return src.ToRGBA(); } } namespace ConfigurationManager { internal sealed class ConfigurationManagerAttributes { public string Category { get; set; } public string DispName { get; set; } public int? CategoryOrder { get; set; } public int? Order { get; set; } public bool? Browsable { get; set; } public bool? IsAdvanced { get; set; } public bool? ReadOnly { get; set; } public bool? HideDefaultButton { get; set; } } internal readonly struct ThemePalette { public Color WindowBackground { get; } public Color EntryBackground { get; } public Color TooltipBackground { get; } public Color HeaderBackground { get; } public Color HeaderHoverBackground { get; } public Color SettingWindowBackground { get; } public Color Widget { get; } public Color Enabled { get; } public Color MainText { get; } public Color DefaultValueText { get; } public Color ChangedValueText { get; } public Color ReadOnlyText { get; } public Color FileEditorText { get; } private ThemePalette(Color windowBackground, Color entryBackground, Color tooltipBackground, Color headerBackground, Color headerHoverBackground, Color settingWindowBackground, Color widget, Color enabled, Color mainText, Color defaultValueText, Color changedValueText, Color readOnlyText, Color fileEditorText) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0030: 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_0038: 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_0040: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) WindowBackground = windowBackground; EntryBackground = entryBackground; TooltipBackground = tooltipBackground; HeaderBackground = headerBackground; HeaderHoverBackground = headerHoverBackground; SettingWindowBackground = settingWindowBackground; Widget = widget; Enabled = enabled; MainText = mainText; DefaultValueText = defaultValueText; ChangedValueText = changedValueText; ReadOnlyText = readOnlyText; FileEditorText = fileEditorText; } public static ThemePalette CreateValheim() { //IL_0014: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) return new ThemePalette(new Color(0f, 0f, 0f, 1f), new Color(0.55f, 0.5f, 0.5f, 0.94f), new Color(0.55f, 0.5f, 0.45f, 0.95f), new Color(0.74f, 0.54f, 0.37f, 0.8f), new Color(0.88f, 0.46f, 0f, 0.8f), new Color(0.55f, 0.5f, 0.5f, 0.65f), new Color(0.88f, 0.46f, 0f, 0.8f), new Color(0.88f, 0.46f, 0f, 1f), new Color(1f, 0.827f, 0.463f, 1f), new Color(1f, 0.827f, 0.463f, 1f), new Color(0.9f, 0.9f, 0.9f, 1f), Color.gray, new Color(0.9f, 0.9f, 0.9f, 1f)); } } public class ConfigFilesEditor : IDisposable { private enum FileEditState { None, CreatingFolder, CreatingFile, RenamingFile } private static readonly string _trashBinDirectory = Path.Combine(Paths.CachePath, "ConfigManagerTrashBin"); private static readonly string[] _directories = new string[3] { Paths.ConfigPath, Paths.PluginPath, _trashBinDirectory }; private static readonly HashSet _editableExtensions = new HashSet(StringComparer.OrdinalIgnoreCase) { ".json", ".yaml", ".yml", ".cfg" }; private readonly Dictionary _folderStates = new Dictionary(); private Vector2 _scrollPosition; private string _fileContent; private string _originalFileContent; private Vector2 _textScrollPosition; private Rect _windowRect = new Rect(ConfigurationManager._windowPositionTextEditor.Value, ConfigurationManager._windowSizeTextEditor.Value); private const int WindowId = -680; private const string SearchBoxName = "searchBoxEditor"; private const int DirectoryOffset = 20; private const string TextEditorControlName = "textEditorTextField"; private bool _focusSearchBox; private bool _focusTextArea; private string _searchString; private string _errorText; private string _activeFile; private string _activeDirectory; private string _newItemName; private string _newItemErrorText; private FileEditState _fileNameState; private bool _isOpen; private bool _clearCache; private int _directoryDepth; private readonly Dictionary _cachedFileTree = new Dictionary(); private readonly Dictionary _cachedDirectories = new Dictionary(); private FileSystemWatcher[] _watchers = Array.Empty(); private string SearchString { get { return _searchString; } set { if (value == null) { value = string.Empty; } _searchString = value; } } public bool IsOpen { get { return _isOpen; } set { if (_isOpen != (_isOpen = value)) { ClearCache(); } } } private void SetFileEditState(FileEditState newState) { _fileNameState = newState; _newItemErrorText = string.Empty; _newItemName = string.Empty; } public void OnGUI() { //IL_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { ((Rect)(ref _windowRect)).size = ConfigurationManager._windowSizeTextEditor.Value; ((Rect)(ref _windowRect)).position = ConfigurationManager._windowPositionTextEditor.Value; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.WindowBackground; _windowRect = GUI.Window(-680, _windowRect, new WindowFunction(DrawWindow), Utility.IsNullOrWhiteSpace(_activeFile) ? "Configuration Files Editor" : ("..." + _activeFile.Replace(Path.GetDirectoryName(Paths.BepInExRootPath) ?? string.Empty, "")), ConfigurationManagerStyles.GetWindowStyle()); if (!UnityInput.Current.GetKeyDown((KeyCode)323) && ((Rect)(ref _windowRect)).position != ConfigurationManager._windowPositionTextEditor.Value) { SaveCurrentSizeAndPosition(); } GUI.backgroundColor = backgroundColor; } } internal void SaveCurrentSizeAndPosition() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) ConfigurationManager._windowSizeTextEditor.Value = new Vector2(Mathf.Clamp(((Rect)(ref _windowRect)).size.x, 1000f / ConfigurationManager.instance.ScaleFactor, ConfigurationManager.instance.ScreenWidth), Mathf.Clamp(((Rect)(ref _windowRect)).size.y, 600f / ConfigurationManager.instance.ScaleFactor, ConfigurationManager.instance.ScreenHeight)); ConfigurationManager._windowPositionTextEditor.Value = new Vector2(Mathf.Clamp(((Rect)(ref _windowRect)).position.x, 0f, ConfigurationManager.instance.ScreenWidth - ConfigurationManager._windowSize.Value.x / 4f), Mathf.Clamp(((Rect)(ref _windowRect)).position.y, 0f, ConfigurationManager.instance.ScreenHeight - 40f)); ((BaseUnityPlugin)ConfigurationManager.instance).Config.Save(); } private void DrawSearchBox() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00dc: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(ConfigurationManagerStyles.GetLabelStyle().CalcSize(new GUIContent("Search:")).x + 4f) }); GUI.SetNextControlName("searchBoxEditor"); SearchString = GUILayout.TextField(SearchString, ConfigurationManagerStyles.GetTextStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (_focusSearchBox) { GUI.FocusWindow(-680); GUI.FocusControl("searchBoxEditor"); _focusSearchBox = false; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.Widget; if (GUILayout.Button("Clear", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { SearchString = string.Empty; } GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); } private void DrawContentButtons() { GUILayout.BeginHorizontal(Array.Empty()); GUI.enabled = !Utility.IsNullOrWhiteSpace(_activeFile) && _fileContent != _originalFileContent; if (GUILayout.Button("Save", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { SaveActiveFile(); } GUI.enabled = true; GUILayout.Label(_errorText, ConfigurationManagerStyles.GetLabelStyle(isDefaultValue: false), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("Font size: ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (int.TryParse(GUILayout.TextField(StringExtensionMethods.ToFastString(ConfigurationManager._textEditorFontSize.Value), ConfigurationManagerStyles.GetTextStyle((float)ConfigurationManager._textEditorFontSize.Value, (float)(int)((ConfigEntryBase)ConfigurationManager._textEditorFontSize).DefaultValue), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }), out var result)) { ConfigurationManager._textEditorFontSize.Value = Mathf.Clamp(result, 8, 36); } ConfigurationManager._textEditorWordWrap.Value = GUILayout.Toggle(ConfigurationManager._textEditorWordWrap.Value, "Word wrap", ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (GUILayout.Button("Close", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { IsOpen = false; } GUILayout.EndHorizontal(); } private void DrawWindow(int windowID) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.EntryBackground; GUILayout.BeginVertical(ConfigurationManagerStyles.GetBackgroundStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(GetFileListWidth()) }); DrawSearchBox(); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(((Rect)(ref _windowRect)).width * 0.3f) }); _directoryDepth = 0; DrawDirectories(_directories); GUILayout.EndScrollView(); DrawDirectoriesMenu(); GUILayout.EndVertical(); GUILayout.BeginVertical(ConfigurationManagerStyles.GetBackgroundStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(((Rect)(ref _windowRect)).width * 0.7f) }); DrawContentButtons(); _textScrollPosition = GUILayout.BeginScrollView(_textScrollPosition, Array.Empty()); GUI.enabled = File.Exists(_activeFile); GUI.SetNextControlName("textEditorTextField"); _fileContent = GUILayout.TextArea(_fileContent, ConfigurationManagerStyles.GetFileEditorTextArea(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) }); if (_focusTextArea || GUI.GetNameOfFocusedControl() == "textEditorTextField") { GUI.FocusWindow(-680); GUI.FocusControl("textEditorTextField"); _focusTextArea = false; } GUI.enabled = true; GUILayout.EndScrollView(); if (ConfigurationManager._showFullName.Value) { GUILayout.TextField(_activeFile, ConfigurationManagerStyles.GetTextStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } GUILayout.EndVertical(); GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 20f)); if (!SettingFieldDrawer.DrawCurrentDropdown()) { ConfigurationManager.DrawTooltip(_windowRect); } _windowRect = Utils.ResizeWindow(windowID, _windowRect, out var sizeChanged); if (sizeChanged) { SaveCurrentSizeAndPosition(); } } private float GetFileListWidth() { return ((Rect)(ref _windowRect)).width * 0.3f; } private void DrawDirectory(string path) { _directoryDepth++; DrawDirectories(GetDirectories(path)); if (path == _activeDirectory && _fileNameState == FileEditState.CreatingFolder) { DrawFileNameField(); } DrawFiles(path); _directoryDepth--; } private void DrawDirectories(IEnumerable directories) { foreach (string directory in directories) { if ((ConfigurationManager._showTrashBin.Value || !(directory == _trashBinDirectory)) && (ConfigurationManager._showEmptyFolders.Value || DirectoryContainsValidFiles(directory))) { if (!_folderStates.ContainsKey(directory)) { _folderStates[directory] = false; } bool num = _folderStates[directory]; bool flag = (_folderStates[directory] = GUILayout.Toggle(_folderStates[directory], Path.GetFileName(directory), ConfigurationManagerStyles.GetDirectoryStyle(directory == _activeDirectory), Array.Empty())); if (num != flag && _folderStates[directory]) { _activeDirectory = directory; SetFileEditState(FileEditState.None); } if (_folderStates[directory]) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Space(20f); GUILayout.BeginVertical(Array.Empty()); DrawDirectory(directory); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } } } private void DrawFileNameField() { GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(GetFileListWidth() - (float)(20 * (_directoryDepth + 1)) - 5f) }); if (_fileNameState == FileEditState.CreatingFolder || _fileNameState == FileEditState.CreatingFile) { GUILayout.Label((_fileNameState == FileEditState.CreatingFolder) ? "Folder:" : "File:", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } _newItemName = GUILayout.TextField(_newItemName, ConfigurationManagerStyles.GetFileNameFieldStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("OK", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { if (_fileNameState == FileEditState.CreatingFolder || _fileNameState == FileEditState.CreatingFile) { CreateNewItem(_newItemName, _fileNameState == FileEditState.CreatingFolder); } else if (_fileNameState == FileEditState.RenamingFile) { RenameActiveFile(); } } GUILayout.EndHorizontal(); if (!Utility.IsNullOrWhiteSpace(_newItemErrorText)) { GUILayout.Label(_newItemErrorText, ConfigurationManagerStyles.GetFileNameErrorStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } GUILayout.EndVertical(); } private void RenameActiveFile() { if (_newItemName == Path.GetFileName(_activeFile)) { SetFileEditState(FileEditState.None); return; } string directoryName = Path.GetDirectoryName(_activeFile); if (directoryName == null) { return; } if (!TryGetSafeChildPath(directoryName, _newItemName, out var path)) { _newItemErrorText = "Invalid file name"; return; } if (File.Exists(path) || Directory.Exists(path)) { _newItemErrorText = "File already exists"; return; } try { File.Move(_activeFile, path); _activeFile = path; SetFileEditState(FileEditState.None); } catch (Exception ex) { _newItemErrorText = ex.Message; } } private void MoveActiveFileToTrash() { if (Utility.IsNullOrWhiteSpace(_activeFile)) { return; } Directory.CreateDirectory(_trashBinDirectory); string text = Path.Combine(_trashBinDirectory, Path.GetFileName(_activeFile)); if (File.Exists(text)) { text = Path.Combine(_trashBinDirectory, $"{Path.GetFileNameWithoutExtension(text)}_{DateTime.UtcNow:yyyyMMdd_HHmmss}_{Guid.NewGuid():N}{Path.GetExtension(text)}"); } try { if (_activeFile != null) { File.Move(_activeFile, text); } _activeFile = string.Empty; _fileContent = string.Empty; _originalFileContent = string.Empty; SetFileEditState(FileEditState.None); } catch (Exception ex) { _newItemErrorText = ex.Message; } } public ConfigFilesEditor() { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) InitializeFileWatcher(); } private void InitializeFileWatcher() { _watchers = new FileSystemWatcher[2] { new FileSystemWatcher(Paths.ConfigPath), new FileSystemWatcher(Paths.PluginPath) }; FileSystemWatcher[] watchers = _watchers; foreach (FileSystemWatcher obj in watchers) { obj.IncludeSubdirectories = true; obj.SynchronizingObject = ThreadingHelper.SynchronizingObject; obj.Changed += delegate { ClearCache(); }; obj.Created += delegate { ClearCache(); }; obj.Deleted += delegate { ClearCache(); }; obj.Renamed += delegate { ClearCache(); }; } } private void ClearCache() { _clearCache = true; FileSystemWatcher[] watchers = _watchers; for (int i = 0; i < watchers.Length; i++) { watchers[i].EnableRaisingEvents = IsOpen; } } internal void SetWatching(bool enabled) { FileSystemWatcher[] watchers = _watchers; for (int i = 0; i < watchers.Length; i++) { watchers[i].EnableRaisingEvents = enabled && IsOpen; } } private string[] GetFiles(string path) { if (_clearCache) { _cachedFileTree.Clear(); _cachedDirectories.Clear(); } _clearCache = false; if (_cachedFileTree.TryGetValue(path, out var value)) { return value; } string[] array; try { array = (Directory.Exists(path) ? Directory.GetFiles(path) : Array.Empty()); } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { ConfigurationManager.LogWarning("Could not read files from " + path + ": " + ex.Message); array = Array.Empty(); } _cachedFileTree[path] = array; return array; } private string[] GetDirectories(string path) { if (_clearCache) { _cachedFileTree.Clear(); _cachedDirectories.Clear(); } _clearCache = false; if (_cachedDirectories.TryGetValue(path, out var value)) { return value; } string[] array; try { array = (Directory.Exists(path) ? (from directory in Directory.GetDirectories(path) where (File.GetAttributes(directory) & FileAttributes.ReparsePoint) == 0 select directory).ToArray() : Array.Empty()); } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { ConfigurationManager.LogWarning("Could not read directories from " + path + ": " + ex.Message); array = Array.Empty(); } _cachedDirectories[path] = array; return array; } private void DrawFiles(string path) { bool flag = false; string[] files = GetFiles(path); foreach (string text in files) { if (IsValidFile(text)) { if (text == _activeFile && _fileNameState == FileEditState.RenamingFile) { DrawFileNameField(); } else if (GUILayout.Button(Path.GetFileName(text), ConfigurationManagerStyles.GetFileStyle(text == _activeFile), Array.Empty())) { LoadFileToEditor(text); } if (path == _activeDirectory && text == _activeFile && _fileNameState == FileEditState.CreatingFile) { DrawFileNameField(); flag = true; } } } if (!flag && path == _activeDirectory && _fileNameState == FileEditState.CreatingFile) { DrawFileNameField(); } } private bool IsValidFile(string file) { string fileName = Path.GetFileName(file); if (fileName == "manifest.json") { return false; } try { if ((File.GetAttributes(file) & FileAttributes.ReparsePoint) != FileAttributes.None) { return false; } } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { return false; } if (string.Equals(fileName, "ConfigManager.hiddensettings.txt", StringComparison.OrdinalIgnoreCase)) { if (!Utility.IsNullOrWhiteSpace(SearchString)) { return fileName.IndexOf(SearchString, StringComparison.OrdinalIgnoreCase) > -1; } return true; } if (Chainloader.PluginInfos.Values.Any((PluginInfo plugin) => plugin.Instance.Config.ConfigFilePath == file)) { return false; } string extension = Path.GetExtension(file); if (_editableExtensions.Contains(extension)) { if (!Utility.IsNullOrWhiteSpace(SearchString)) { return fileName.IndexOf(SearchString, StringComparison.OrdinalIgnoreCase) > -1; } return true; } return false; } private bool DirectoryContainsValidFiles(string path) { if (!GetFiles(path).Any(IsValidFile)) { return GetDirectories(path).Any(DirectoryContainsValidFiles); } return true; } private void LoadFileToEditor(string filePath) { try { _fileContent = File.ReadAllText(filePath); _originalFileContent = _fileContent; _activeFile = filePath; _activeDirectory = Path.GetDirectoryName(filePath); _errorText = string.Empty; SetFileEditState(FileEditState.None); _focusTextArea = true; } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { ConfigurationManager.LogError("Failed to load file " + filePath + ": " + ex.Message); _errorText = "Failed to load file"; _fileContent = ex.Message; _originalFileContent = string.Empty; _activeFile = string.Empty; } } private void DrawDirectoriesMenu() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("New folder", ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.CreatingFolder); } if (GUILayout.Button("New file", ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.CreatingFile); } if (GUILayout.Button("Rename", ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.RenamingFile); _newItemName = Path.GetFileName(_activeFile); } if (GUILayout.Button(new GUIContent("Delete", "File will be moved into Trash Bin"), ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { MoveActiveFileToTrash(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); ConfigurationManager._showEmptyFolders.Value = GUILayout.Toggle(ConfigurationManager._showEmptyFolders.Value, "Show empty folders", ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.FlexibleSpace(); ConfigurationManager._showFullName.Value = GUILayout.Toggle(ConfigurationManager._showFullName.Value, new GUIContent("Show file name", "Show full name of active file"), ConfigurationManagerStyles.GetToggleStyle(), Array.Empty()); ConfigurationManager._showTrashBin.Value = GUILayout.Toggle(ConfigurationManager._showTrashBin.Value, "Show Trash Bin", ConfigurationManagerStyles.GetToggleStyle(), Array.Empty()); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void CreateNewItem(string itemName, bool isFolder) { if (string.IsNullOrWhiteSpace(itemName) || string.IsNullOrEmpty(_activeDirectory)) { return; } if (!TryGetSafeChildPath(_activeDirectory, itemName, out var path)) { _newItemErrorText = "Invalid file or folder name"; return; } if (File.Exists(path) || Directory.Exists(path)) { _newItemErrorText = "File already exists"; return; } try { if (isFolder) { Directory.CreateDirectory(path); ConfigurationManager._showEmptyFolders.Value = true; _activeDirectory = path; _activeFile = string.Empty; } else { File.Create(path).Close(); LoadFileToEditor(path); } SetFileEditState(FileEditState.None); } catch (Exception ex) { _newItemErrorText = ex.Message; } } private void SaveActiveFile() { try { if (Utility.IsNullOrWhiteSpace(_activeFile) || !File.Exists(_activeFile)) { _errorText = "The active file no longer exists"; return; } using (FileStream fileStream = new FileStream(_activeFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { string a; using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, 1024, leaveOpen: true)) { a = streamReader.ReadToEnd(); } if (!string.Equals(a, _originalFileContent, StringComparison.Ordinal)) { _errorText = "The file changed outside ConfigManager. Reload it before saving."; return; } fileStream.Position = 0L; fileStream.SetLength(0L); using (StreamWriter streamWriter = new StreamWriter(fileStream, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), 1024, leaveOpen: true)) { streamWriter.Write(_fileContent); streamWriter.Flush(); } fileStream.Flush(); } _originalFileContent = _fileContent; _errorText = string.Empty; } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { _errorText = ex.Message; } } private static bool TryGetSafeChildPath(string directory, string itemName, out string path) { path = null; if (Utility.IsNullOrWhiteSpace(directory) || Utility.IsNullOrWhiteSpace(itemName) || Path.IsPathRooted(itemName)) { return false; } string text = itemName.Trim(); if (text.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || text.IndexOf(Path.DirectorySeparatorChar) >= 0 || text.IndexOf(Path.AltDirectorySeparatorChar) >= 0 || text.IndexOf('/') >= 0 || text.IndexOf('\\') >= 0) { return false; } try { string text2 = Path.GetFullPath(directory).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); if (!IsPathInsideEditorRoots(text2)) { return false; } string fullPath = Path.GetFullPath(Path.Combine(text2, text)); string b = Path.GetDirectoryName(fullPath)?.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); if (!string.Equals(text2, b, GetPathComparison())) { return false; } path = fullPath; return true; } catch (Exception ex) when (ex is ArgumentException || ex is NotSupportedException || ex is PathTooLongException) { return false; } } private static bool IsPathInsideEditorRoots(string path) { string[] directories = _directories; for (int i = 0; i < directories.Length; i++) { string text = Path.GetFullPath(directories[i]).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); if (string.Equals(path, text, GetPathComparison()) || path.StartsWith(text + Path.DirectorySeparatorChar, GetPathComparison())) { return true; } } return false; } private static StringComparison GetPathComparison() { if (Path.DirectorySeparatorChar != '\\') { return StringComparison.Ordinal; } return StringComparison.OrdinalIgnoreCase; } public void Dispose() { FileSystemWatcher[] watchers = _watchers; for (int i = 0; i < watchers.Length; i++) { watchers[i].Dispose(); } _watchers = Array.Empty(); } } internal 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); } private 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().ToArray(); return; } PropertyInfo property2 = type.GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public); PropertyInfo property3 = type.GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public); if (property2 != null && property3 != null) { base.AcceptableValueRange = new KeyValuePair(property2.GetValue(values, null), property3.GetValue(values, null)); } } public override object Get() { return Entry.BoxedValue; } protected override void SetValue(object newVal) { Entry.BoxedValue = newVal; } internal bool ShouldBeHidden() { return ConfigurationManager.IsSettingHidden(base.PluginInfo.GUID + "=" + Entry.Definition.Section + "=" + Entry.Definition.Key); } } internal static class HiddenSettingsParser { internal static bool TryParseLine(string rawLine, out string setting) { setting = null; if (rawLine == null) { return false; } string text = rawLine.Trim(); if (text.Length == 0 || text.StartsWith("#", StringComparison.Ordinal)) { return false; } int num = text.IndexOf('='); int num2 = ((num < 0) ? (-1) : text.IndexOf('=', num + 1)); if (num <= 0 || num2 <= num + 1 || num2 == text.Length - 1) { return false; } string text2 = text.Substring(0, num).Trim(); string text3 = text.Substring(num + 1, num2 - num - 1).Trim(); string text4 = text.Substring(num2 + 1).Trim(); if (text2.Length == 0 || text3.Length == 0 || text4.Length == 0) { return false; } setting = text2 + "=" + text3 + "=" + text4; return true; } } internal class SettingEditWindow { private sealed class ColorCacheEntry { public Color Last; public Texture2D Tex; } private Rect _windowRect = new Rect(ConfigurationManager._windowPositionEditSetting.Value, ConfigurationManager._windowSizeEditSetting.Value); private const int WindowId = -6800; private const string NewItemFieldControlName = "StringListNewItemField"; private SettingEntryBase setting; private static SettingEntryBase _currentKeyboardShortcutToSet; private static IEnumerable _keysToCheck; private static readonly Dictionary ColorCache = new Dictionary(); private Vector2 _scrollPosition = Vector2.zero; private Vector2 _scrollPositionEnum = Vector2.zero; private int listIndex = -1; private IList listEnum; private Action drawerFunction; private string errorText; private object valueToSet; private string errorOnSetting; private readonly List vectorParts = new List(); private readonly List vectorFloats = new List(); private readonly List vectorDefault = new List(); private string colorAsHEX; private List separatedStringDefault = new List(); private List separatedString = new List(); private string separator; private int editStringView; private string newItem; private ConfigEntryBase dummyCustomDrawerConfigEntry; private static readonly Dictionary typeMappings = new Dictionary { { typeof(int), "Integer" }, { typeof(float), "Float" }, { typeof(double), "Double" }, { typeof(decimal), "Decimal" }, { typeof(bool), "Boolean" }, { typeof(string), "String" }, { typeof(long), "Long" }, { typeof(short), "Short" }, { typeof(byte), "Byte" }, { typeof(sbyte), "Signed Byte" }, { typeof(uint), "Unsigned Integer" }, { typeof(ulong), "Unsigned Long" }, { typeof(ushort), "Unsigned Short" }, { typeof(char), "Character" }, { typeof(DateTime), "DateTime" }, { typeof(TimeSpan), "TimeSpan" }, { typeof(Guid), "GUID" }, { typeof(KeyValuePair<, >), "Map" }, { typeof(object), "Object" } }; private readonly Dictionary _canCovertCache = new Dictionary(); public Dictionary SettingDrawHandlers { get; } private bool IsStringList { get { if (setting != null && setting.SettingType != null) { return typeof(IList).IsAssignableFrom(setting.SettingType); } return false; } } public bool IsOpen { get; set; } public SettingEditWindow() { //IL_0006: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) SettingDrawHandlers = new Dictionary { { typeof(bool), DrawBoolField }, { typeof(KeyboardShortcut), DrawKeyboardShortcut }, { typeof(KeyCode), DrawKeyCode }, { typeof(Color), DrawColor }, { typeof(Vector2), DrawVector }, { typeof(Vector3), DrawVector }, { typeof(Vector4), DrawVector }, { typeof(Quaternion), DrawVector } }; } public void EditSetting(SettingEntryBase setting) { if (this.setting == setting && IsOpen) { IsOpen = false; return; } this.setting = setting; InitializeWindow(); IsOpen = true; } public void OnGUI() { //IL_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (IsOpen) { ((Rect)(ref _windowRect)).size = ConfigurationManager._windowSizeEditSetting.Value; ((Rect)(ref _windowRect)).position = ConfigurationManager._windowPositionEditSetting.Value; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.WindowBackground; _windowRect = GUI.Window(-6800, _windowRect, new WindowFunction(DrawWindow), $"{setting.PluginInfo.Name} {setting.PluginInfo.Version}", ConfigurationManagerStyles.GetWindowStyle()); if (!UnityInput.Current.GetKeyDown((KeyCode)323) && ((Rect)(ref _windowRect)).position != ConfigurationManager._windowPositionEditSetting.Value) { SaveCurrentSizeAndPosition(); } GUI.backgroundColor = backgroundColor; } } private void UpdateStringList() { if (Utility.IsNullOrWhiteSpace(separator)) { separator = ","; } if (setting.SettingType != typeof(string) && !IsStringList) { return; } separatedString.Clear(); if (IsStringList) { try { separatedString.AddRange(valueToSet as IList); } catch { separatedString.AddRange(valueToSet.ToString().Split(new string[1] { separator }, StringSplitOptions.None)); } } else { separatedString.AddRange(valueToSet.ToString().Split(new string[1] { separator }, StringSplitOptions.None)); } separatedStringDefault.Clear(); if (setting.DefaultValue == null) { return; } if (IsStringList) { try { separatedStringDefault.AddRange((setting.DefaultValue as IList).Select((string s) => s.Trim())); return; } catch { separatedStringDefault.AddRange(from s in setting.DefaultValue.ToString().Split(new string[1] { separator }, StringSplitOptions.None) select s.Trim()); return; } } separatedStringDefault.AddRange(from s in setting.DefaultValue.ToString().Split(new string[1] { separator }, StringSplitOptions.None) select s.Trim()); } private void InitializeWindow() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown listEnum = null; listIndex = -1; drawerFunction = null; valueToSet = ((setting.SettingType == typeof(Color)) ? ((object)Utils.RoundColorToHEX((Color)setting.Get())) : setting.Get()); errorText = string.Empty; errorOnSetting = string.Empty; colorAsHEX = ((setting.SettingType == typeof(Color)) ? ("#" + ColorUtility.ToHtmlStringRGBA((Color)valueToSet)) : string.Empty); separator = ","; separatedString.Clear(); newItem = string.Empty; editStringView = 0; _scrollPosition = Vector2.zero; _scrollPositionEnum = Vector2.zero; dummyCustomDrawerConfigEntry = null; if (setting is ConfigSettingEntry configSettingEntry && (setting.CustomDrawer != null || setting.CustomHotkeyDrawer != null)) { ConstructorInfo constructorInfo = AccessTools.Constructor(typeof(ConfigEntry<>).MakeGenericType(configSettingEntry.Entry.SettingType), new Type[4] { typeof(ConfigFile), typeof(ConfigDefinition), configSettingEntry.Entry.SettingType, typeof(ConfigDescription) }, false); dummyCustomDrawerConfigEntry = (ConfigEntryBase)constructorInfo.Invoke(new object[4] { configSettingEntry.Entry.ConfigFile, configSettingEntry.Entry.Definition, configSettingEntry.Entry.DefaultValue, configSettingEntry.Entry.Description }); dummyCustomDrawerConfigEntry.BoxedValue = configSettingEntry.Entry.BoxedValue; } if (setting.AcceptableValueRange.Key != null) { drawerFunction = DrawRangeField; } else if (setting.AcceptableValues != null && setting.AcceptableValues.Length != 0 && setting.SettingType.IsInstanceOfType(setting.AcceptableValues.FirstOrDefault((object x) => x != null))) { SetAcceptableValuesDrawer(); } else if (setting.SettingType.IsEnum && setting.SettingType != typeof(KeyCode)) { listEnum = Enum.GetValues(setting.SettingType); if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any()) { drawerFunction = DrawFlagsField; } else { drawerFunction = DrawEnumListField; } } else { SettingDrawHandlers.TryGetValue(setting.SettingType, out drawerFunction); } InitListIndex(); InitVectorParts(); UpdateStringList(); } private void InitListIndex() { listIndex = ((listEnum == null) ? (-1) : listEnum.IndexOf(valueToSet)); } private void InitVectorParts() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) vectorParts.Clear(); vectorFloats.Clear(); vectorDefault.Clear(); if (setting.SettingType == typeof(Vector2)) { FillVectorList(vectorFloats, (Vector2)valueToSet); FillVectorList(vectorDefault, (Vector2)setting.DefaultValue); } else if (setting.SettingType == typeof(Vector3)) { FillVectorList(vectorFloats, (Vector3)valueToSet); FillVectorList(vectorDefault, (Vector3)setting.DefaultValue); } else if (setting.SettingType == typeof(Vector4)) { FillVectorList(vectorFloats, (Vector4)valueToSet); FillVectorList(vectorDefault, (Vector4)setting.DefaultValue); } else if (setting.SettingType == typeof(Quaternion)) { FillVectorList(vectorFloats, (Quaternion)valueToSet); FillVectorList(vectorDefault, (Quaternion)setting.DefaultValue); } vectorParts.AddRange(vectorFloats.Select((float f) => f.ToString())); } private void SetAcceptableValuesDrawer() { if (setting.SettingType == typeof(KeyCode)) { listEnum = ((setting.AcceptableValues.Length > 1) ? setting.AcceptableValues : Enum.GetValues(setting.SettingType)); drawerFunction = DrawKeyCode; } else { listEnum = setting.AcceptableValues; drawerFunction = DrawEnumListField; } } internal void SaveCurrentSizeAndPosition() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_006e: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) ConfigurationManager._windowSizeEditSetting.Value = new Vector2(Mathf.Clamp(((Rect)(ref _windowRect)).size.x, 200f, ConfigurationManager.instance.ScreenWidth / 2f), Mathf.Clamp(((Rect)(ref _windowRect)).size.y, 200f, ConfigurationManager.instance.ScreenHeight * 0.9f)); ConfigurationManager._windowPositionEditSetting.Value = new Vector2(Mathf.Clamp(((Rect)(ref _windowRect)).position.x, 0f, ConfigurationManager.instance.ScreenWidth - ConfigurationManager._windowSize.Value.x / 4f), Mathf.Clamp(((Rect)(ref _windowRect)).position.y, 0f, ConfigurationManager.instance.ScreenHeight - 40f)); ((BaseUnityPlugin)ConfigurationManager.instance).Config.Save(); } private void DrawWindow(int windowID) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.EntryBackground; GUILayout.BeginVertical(ConfigurationManagerStyles.GetSettingWindowBackgroundStyle(), Array.Empty()); GUILayout.Space(1f); GUILayout.Label("" + setting.Category + "", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); DrawDelimiterLine(); GUILayout.Space(1f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(false) }); GUILayout.Label(setting.DispName + " ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Label("(" + GetTypeRepresentation(setting.SettingType) + ")", ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); GUILayout.Label(setting.Description, ConfigurationManagerStyles.GetLabelStyle(isDefaultValue: false), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (setting.DefaultValue != null) { GUIStyle labelStyle = ConfigurationManagerStyles.GetLabelStyle(); GUIContent val = new GUIContent("Default: "); float num = labelStyle.CalcSize(val).x + 3f; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(false) }); GUILayout.Label("Default: ", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) }); GUILayout.Label(GetValueRepresentation(setting.DefaultValue, setting.SettingType) ?? "", ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); } DrawDelimiterLine(); GUILayout.Space(5f); DrawSettingValue(); if (!Utility.IsNullOrWhiteSpace(errorOnSetting)) { GUILayout.Label(errorOnSetting, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); } DrawDelimiterLine(); GUILayout.Space(1f); DrawMenuButtons(); GUILayout.EndVertical(); GUI.backgroundColor = backgroundColor; GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 20f)); if (!SettingFieldDrawer.DrawCurrentDropdown()) { ConfigurationManager.DrawTooltip(_windowRect); } _windowRect = Utils.ResizeWindow(windowID, _windowRect, out var sizeChanged); if (sizeChanged) { SaveCurrentSizeAndPosition(); } } private void DrawLabel(string label, string value) { bool flag = !Utility.IsNullOrWhiteSpace(label) && !Utility.IsNullOrWhiteSpace(value); if (flag) { GUILayout.BeginHorizontal(Array.Empty()); } if (!Utility.IsNullOrWhiteSpace(label)) { GUILayout.Label(Utility.IsNullOrWhiteSpace(value) ? label : (label + ":"), ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } if (!Utility.IsNullOrWhiteSpace(value)) { GUILayout.Label(value, ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } if (flag) { GUILayout.EndHorizontal(); } } private void DrawInfo(string info) { DrawLabel(null, info); } private string GetTypeRepresentation(Type type) { if (!type.IsGenericType) { if (!typeMappings.TryGetValue(type, out var value)) { return type.Name; } return value; } Type[] genericArguments = type.GetGenericArguments(); string value2; string text = string.Join(", ", genericArguments.Select((Type t) => (!typeMappings.TryGetValue(t, out value2)) ? t.Name : value2)); return ZDOHelper.GetValueOrDefaultPiktiv((IDictionary)typeMappings, type, type.Name) + "<" + text + ">"; } private string GetValueRepresentation(object value, Type type) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (type == typeof(Color)) { return "#" + ColorUtility.ToHtmlStringRGBA((Color)value); } if (type == typeof(bool)) { if (!(bool)value) { return "Disabled"; } return "Enabled"; } return value.ToString(); } private void DrawMenuButtons() { GUILayout.BeginHorizontal(Array.Empty()); bool enabled = GUI.enabled; GUI.enabled = enabled && !IsValueToSetDefaultValue(); DrawDefaultButton(); GUI.enabled = enabled; GUILayout.Label("Press Escape to close window", ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); enabled = GUI.enabled; GUI.enabled = enabled && !ConfigurationManagerStyles.IsEqualConfigValues(setting.SettingType, valueToSet, setting.Get()); if (GUILayout.Button("Apply", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { ApplySettingValue(); } GUI.enabled = enabled; if (GUILayout.Button("Close", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { IsOpen = false; } GUILayout.EndHorizontal(); } private void ApplySettingValue() { if (valueToSet != null) { try { setting.Set(valueToSet); InitializeWindow(); } catch (Exception ex) { errorOnSetting = ex.ToString(); } } } private void DrawSettingValue() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.Widget; bool drawStringMenu = false; _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty()); if (!DrawCustomField() && !DrawKnownDrawer()) { if (errorText.Length > 0) { GUILayout.Label("Error:\n" + errorText, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); } DrawUnknownField(out drawStringMenu); } GUILayout.EndScrollView(); if (drawStringMenu) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Edit as: ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); _ = editStringView; int num = (editStringView = GUILayout.SelectionGrid(editStringView, new string[2] { "Text", "List" }, 2, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })); if (editStringView > 0) { GUILayout.Label("Separator: ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (separator != (separator = GUILayout.TextField(separator, Array.Empty()))) { UpdateStringList(); } if (GUILayout.Button("Trim whitespace", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { separatedString = separatedString.Select((string s) => s.Trim()).ToList(); valueToSet = setting.StrToObj(string.Join(separator, separatedString)); } } GUILayout.EndHorizontal(); } GUI.backgroundColor = backgroundColor; } private static void DrawDelimiterLine() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.Widget; GUILayout.Label("", ConfigurationManagerStyles.GetDelimiterLine(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(2f) }); GUI.backgroundColor = backgroundColor; } private bool DrawKnownDrawer() { if (drawerFunction == null) { return false; } try { drawerFunction(); return true; } catch (Exception ex) { ConfigurationManager.LogWarning(ex); errorText = ex.GetType().Name + " - " + ex.Message; } return false; } public bool DrawCustomField() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_00ff: Unknown result type (might be due to invalid IL or missing references) if (SettingFieldDrawer.IsSettingFailedToCustomDraw(setting)) { GUILayout.Label("Error when calling custom drawer function.", Array.Empty()); return false; } Color contentColor = GUI.contentColor; bool flag = true; int fontSize = GUI.skin.textField.fontSize; int fontSize2 = GUI.skin.textArea.fontSize; int fontSize3 = GUI.skin.label.fontSize; int fontSize4 = GUI.skin.button.fontSize; GUI.skin.textArea.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.textField.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.label.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.button.fontSize = ConfigurationManagerStyles.fontSize; GUILayout.BeginHorizontal(Array.Empty()); int rightColumnWidth = ConfigurationManager.instance.RightColumnWidth; ConfigurationManager.instance.SetRightColumnWidth(Mathf.RoundToInt(((Rect)(ref _windowRect)).width * 0.9f)); try { GUI.contentColor = (IsValueToSetDefaultValue() ? ConfigurationManager.Palette.DefaultValueText : ConfigurationManager.Palette.ChangedValueText); if (setting.CustomDrawer != null) { setting.CustomDrawer(dummyCustomDrawerConfigEntry); } else if (setting.CustomHotkeyDrawer != null) { bool isCurrentlyAcceptingInput = _currentKeyboardShortcutToSet == setting; bool flag2 = isCurrentlyAcceptingInput; setting.CustomHotkeyDrawer(dummyCustomDrawerConfigEntry, ref isCurrentlyAcceptingInput); if (isCurrentlyAcceptingInput != flag2) { _currentKeyboardShortcutToSet = (isCurrentlyAcceptingInput ? setting : null); } } else { flag = false; } } catch (Exception e) { SettingFieldDrawer.SetSettingFailedToCustomDraw(setting, e); flag = false; } finally { ConfigurationManager.instance.SetRightColumnWidth(rightColumnWidth); } GUILayout.EndHorizontal(); GUI.contentColor = contentColor; GUI.skin.textField.fontSize = fontSize; GUI.skin.textArea.fontSize = fontSize2; GUI.skin.label.fontSize = fontSize3; GUI.skin.button.fontSize = fontSize4; if (flag && dummyCustomDrawerConfigEntry != null) { valueToSet = dummyCustomDrawerConfigEntry.BoxedValue; } return flag; } private void DrawRangeField() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown object obj = valueToSet; 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 = ConfigurationManagerStyles.GetTextStyle(setting).CalcHeight(new GUIContent(obj.ToString()), 100f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Range: ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Label($"{num2} - {num3}", ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4) }); try { float num5 = DrawCenteredHorizontalSlider(num, num2, num3, num4); if ((double)Math.Abs(num5 - num) >= (double)Mathf.Abs(num3 - num2) / Math.Pow(10.0, 5.0)) { valueToSet = Convert.ChangeType(Utils.RoundWithPrecision(num5, 3), setting.SettingType, CultureInfo.InvariantCulture); } if (setting.ShowRangeAsPercent == true) { SettingFieldDrawer.DrawCenteredLabel($"{Mathf.Abs(num5 - num2) / Mathf.Abs(num3 - num2):P0}", ConfigurationManagerStyles.GetLabelStyle(setting)); return; } string text = obj.ToString().AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text2 != text && Utils.TryParseFloat(text2, out var result)) { float value = Mathf.Clamp(result, num2, num3); valueToSet = Convert.ChangeType(Utils.RoundWithPrecision(value, 3), setting.SettingType); } } finally { GUILayout.EndHorizontal(); } } private static float DrawCenteredHorizontalSlider(float converted, float leftValue, float rightValue, float height) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(height) }); GUILayout.Space(height * 0.35f); float result = GUILayout.HorizontalSlider(converted, leftValue, rightValue, ConfigurationManagerStyles.GetSliderStyle(), ConfigurationManagerStyles.GetThumbStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(height) }); GUILayout.EndVertical(); return result; } private void DrawUnknownField(out bool drawStringMenu) { drawStringMenu = false; if (setting.ObjToStr != null && setting.StrToObj != null) { string text = setting.ObjToStr(valueToSet).AppendZeroIfFloat(setting.SettingType); if (setting.SettingType == typeof(string) || IsStringList) { if (editStringView > 0) { DrawEditableList(); valueToSet = setting.StrToObj(string.Join(separator, separatedString)); GUILayout.FlexibleSpace(); } else { string text2 = GUILayout.TextArea(text, ConfigurationManagerStyles.GetTextStyle(IsValueToSetDefaultValue()), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }).AppendZeroIfFloat(setting.SettingType); if (text2 != text) { valueToSet = setting.StrToObj(text2); } } drawStringMenu = true; } else { string text3 = GUILayout.TextArea(text, ConfigurationManagerStyles.GetTextStyle(IsValueToSetDefaultValue()), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }).AppendZeroIfFloat(setting.SettingType); if (text3 != text) { valueToSet = setting.StrToObj(text3); } } return; } string text4 = ((valueToSet == null) ? "NULL" : Convert.ToString(valueToSet, CultureInfo.InvariantCulture).AppendZeroIfFloat(setting.SettingType)); if (CanCovert(text4, setting.SettingType)) { string text5 = GUILayout.TextArea(text4, ConfigurationManagerStyles.GetTextStyle(IsValueToSetDefaultValue()), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }).AppendZeroIfFloat(setting.SettingType); if (text5 != text4) { try { valueToSet = Convert.ChangeType(text5, setting.SettingType, CultureInfo.InvariantCulture); } catch { } } } else { valueToSet = GUILayout.TextArea(text4, ConfigurationManagerStyles.GetTextStyle(IsValueToSetDefaultValue()), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }).AppendZeroIfFloat(setting.SettingType); } } private void DrawEditableList() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Invalid comparison between Unknown and I4 //IL_01a2: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Round(ConfigurationManagerStyles.GetButtonStyle().CalcSize(new GUIContent("▲")).x); for (int i = 0; i < separatedString.Count; i++) { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("✕", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) })) { GUILayout.EndHorizontal(); separatedString.RemoveAt(i); break; } separatedString[i] = GUILayout.TextArea(separatedString[i], ConfigurationManagerStyles.GetTextStyle(separatedStringDefault.IndexOf(separatedString[i].Trim()) == i), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); bool enabled = GUI.enabled; GUI.enabled = i > 0; if (GUILayout.Button("▲", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) })) { SwapElements(i, i - 1); } GUI.enabled = i < separatedString.Count - 1; if (GUILayout.Button("▼", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) })) { SwapElements(i, i + 1); } GUI.enabled = enabled; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(Array.Empty()); GUI.SetNextControlName("StringListNewItemField"); newItem = GUILayout.TextField(newItem, ConfigurationManagerStyles.GetTextStyle(isDefaultValue: false), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (string.IsNullOrEmpty(newItem) && (int)Event.current.type == 7) { GUI.Label(GUILayoutUtility.GetLastRect(), "Enter new value", ConfigurationManagerStyles.GetPlaceholderTextStyle()); } if (GUILayout.Button("Add", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }) && !string.IsNullOrWhiteSpace(newItem)) { separatedString.Add(newItem); newItem = ""; GUI.FocusControl("StringListNewItemField"); } GUILayout.EndHorizontal(); void SwapElements(int indexA, int indexB) { List list = separatedString; List list2 = separatedString; string value = separatedString[indexB]; string value2 = separatedString[indexA]; list[indexA] = value; list2[indexB] = value2; } } private bool IsValueToSetDefaultValue() { return ConfigurationManagerStyles.IsEqualConfigValues(setting.SettingType, valueToSet, setting.DefaultValue); } private 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 ClearCache() { foreach (KeyValuePair item in ColorCache) { Object.Destroy((Object)(object)item.Value.Tex); } ColorCache.Clear(); } internal void DrawDefaultButton() { //IL_000e: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) if (setting.HideDefaultButton) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.Widget; if (setting.DefaultValue != null) { if (DrawResetButton()) { if (setting.SettingType == typeof(Color)) { valueToSet = Utils.RoundColorToHEX((Color)setting.DefaultValue); colorAsHEX = "#" + ColorUtility.ToHtmlStringRGBA((Color)valueToSet); } else { valueToSet = setting.DefaultValue; } if (dummyCustomDrawerConfigEntry != null) { dummyCustomDrawerConfigEntry.BoxedValue = setting.DefaultValue; } InitListIndex(); InitVectorParts(); UpdateStringList(); ClearCache(); } } else if (setting.SettingType.IsClass && DrawResetButton()) { valueToSet = null; if (dummyCustomDrawerConfigEntry != null) { dummyCustomDrawerConfigEntry.BoxedValue = null; } InitListIndex(); InitVectorParts(); UpdateStringList(); ClearCache(); } GUI.backgroundColor = backgroundColor; static bool DrawResetButton() { GUILayout.Space(5f); return GUILayout.Button("Reset", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } private void DrawBoolField() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0084: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = ConfigurationManager.Palette.Widget; bool flag = (bool)valueToSet; Color backgroundColor = GUI.backgroundColor; if (flag) { GUI.backgroundColor = ConfigurationManager.Palette.Enabled; } bool flag2 = GUILayout.SelectionGrid((!flag) ? 1 : 0, new string[2] { "Enabled", "Disabled" }, 2, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }) == 0; if (flag2 != flag) { valueToSet = flag2; } if (flag) { GUI.backgroundColor = backgroundColor; } } private void DrawFlagsField() { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) long num = Convert.ToInt64(valueToSet); long num2 = Convert.ToInt64(setting.DefaultValue); var array = (from Enum x in Enum.GetValues(setting.SettingType) select new { name = x.ToString(), val = Convert.ToInt64(x) }).ToArray(); float num3 = ((Rect)(ref _windowRect)).width * 0.8f; GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(num3) }); int num4 = 0; while (num4 < array.Length) { GUILayout.BeginHorizontal(Array.Empty()); int num5 = 0; bool flag = false; for (; num4 < array.Length; num4++) { var anon = array[num4]; if (anon.val != 0L) { bool flag2 = (num & anon.val) == anon.val; bool flag3 = (num2 & anon.val) == anon.val; GUIStyle buttonStyle = ConfigurationManagerStyles.GetButtonStyle(flag2 == flag3); int num6 = (int)buttonStyle.CalcSize(new GUIContent(anon.name)).x; if ((float)(num5 + num6) > num3 && flag) { break; } flag = true; num5 += num6; GUI.changed = false; if (GUILayout.Button(anon.name, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { flag2 = !flag2; } if (GUI.changed) { long value = (flag2 ? (num | anon.val) : (num & ~anon.val)); valueToSet = Enum.ToObject(setting.SettingType, value); } } } if (!flag) { num4++; } GUILayout.EndHorizontal(); } GUI.changed = false; GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } private void DrawEnumListField() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) GUIContent[] array = listEnum.Cast().Select(SettingFieldDrawer.ObjectToGuiContent).ToArray(); _scrollPositionEnum = GUILayout.BeginScrollView(_scrollPositionEnum, false, false, Array.Empty()); try { listIndex = GUILayout.SelectionGrid(listIndex, array, 1, ConfigurationManagerStyles.GetComboBoxStyle(), Array.Empty()); if (listEnum != null && listIndex >= 0 && listIndex < listEnum.Count) { valueToSet = listEnum[listIndex]; } } finally { GUILayout.EndScrollView(); } GUILayout.FlexibleSpace(); } private void DrawKeyCode() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0084: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; if (_keysToCheck == null) { _keysToCheck = UnityInput.Current.SupportedKeyCodes.Except((IEnumerable)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (UnityInput.Current.GetKeyUp(item)) { valueToSet = item; _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { if (listEnum == null) { listEnum = Enum.GetValues(setting.SettingType); } DrawEnumListField(); if (GUILayout.Button(new GUIContent("Set"), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = setting; } } } private void DrawKeyboardShortcut() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; IInputSystem current = UnityInput.Current; if (_keysToCheck == null) { _keysToCheck = current.SupportedKeyCodes.Except((IEnumerable)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (current.GetKeyUp(item)) { valueToSet = (object)new KeyboardShortcut(item, _keysToCheck.Where((Func)current.GetKey).ToArray()); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { if (GUILayout.Button(valueToSet.ToString(), ConfigurationManagerStyles.GetButtonStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { _currentKeyboardShortcutToSet = setting; } if (GUILayout.Button("Clear", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { valueToSet = KeyboardShortcut.Empty; _currentKeyboardShortcutToSet = null; } } } private void DrawVectorPart(int position) { object obj = position switch { 0 => "X", 1 => "Y", 2 => "Z", 3 => "W", _ => "", }; float result; bool isDefaultValue = Utils.TryParseFloat(vectorParts[position], out result) && vectorDefault[position] == result; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label((string?)obj + " ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); vectorParts[position] = GUILayout.TextField(vectorParts[position], ConfigurationManagerStyles.GetTextStyle(isDefaultValue), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }).KeepDigitsAndFirstDot(); GUILayout.EndHorizontal(); } private void DrawVector() { //IL_008a: 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_0140: 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) for (int i = 0; i < vectorParts.Count; i++) { DrawVectorPart(i); } for (int j = 0; j < vectorParts.Count; j++) { if (Utils.TryParseFloat(vectorParts[j], out var result)) { vectorFloats[j] = result; } } if (setting.SettingType == typeof(Vector2)) { valueToSet = (object)new Vector2(vectorFloats[0], vectorFloats[1]); } else if (setting.SettingType == typeof(Vector3)) { valueToSet = (object)new Vector3(vectorFloats[0], vectorFloats[1], vectorFloats[2]); } else if (setting.SettingType == typeof(Vector4)) { valueToSet = (object)new Vector4(vectorFloats[0], vectorFloats[1], vectorFloats[2], vectorFloats[3]); } else if (setting.SettingType == typeof(Quaternion)) { valueToSet = (object)new Quaternion(vectorFloats[0], vectorFloats[1], vectorFloats[2], vectorFloats[3]); } GUILayout.FlexibleSpace(); } private void DrawColor() { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) Color value = (Color)valueToSet; Color val = Utils.RoundColorToHEX((Color)setting.DefaultValue); GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); DrawHexField(ref value, val); GUILayout.Space(3f); GUIHelper.BeginColor(value); GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!ColorCache.TryGetValue(setting, out var value2)) { value2 = new ColorCacheEntry { Tex = new Texture2D(40, 10, (TextureFormat)5, false), Last = value }; value2.Tex.FillTexture(value); ColorCache[setting] = value2; } if ((int)Event.current.type == 7) { GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)value2.Tex); } GUIHelper.EndColor(); GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(2f); DrawColorField("Red", ref value, ref value.r, Utils.RoundColor(value.r) == Utils.RoundColor(val.r)); DrawColorField("Green", ref value, ref value.g, Utils.RoundColor(value.g) == Utils.RoundColor(val.g)); DrawColorField("Blue", ref value, ref value.b, Utils.RoundColor(value.b) == Utils.RoundColor(val.b)); DrawColorField("Alpha", ref value, ref value.a, Utils.RoundColor(value.a) == Utils.RoundColor(val.a)); HSLColor hSLColor = val; HSLColor settingColor = value; DrawHSLField("Hue", ref settingColor, ref settingColor.h, Utils.RoundWithPrecision(settingColor.h, 1) == Utils.RoundWithPrecision(hSLColor.h, 1)); DrawHSLField("Saturation", ref settingColor, ref settingColor.s, Utils.RoundColor(settingColor.s) == Utils.RoundColor(hSLColor.s)); DrawHSLField("Lightness", ref settingColor, ref settingColor.l, Utils.RoundColor(settingColor.l) == Utils.RoundColor(hSLColor.l)); value = settingColor; if (value != value2.Last) { valueToSet = value; value2.Tex.FillTexture(value); value2.Last = value; colorAsHEX = "#" + ColorUtility.ToHtmlStringRGBA(value); } GUILayout.EndVertical(); } private bool DrawHexField(ref Color value, Color defaultValue) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) GUIStyle textStyle = ConfigurationManagerStyles.GetTextStyle(value, defaultValue); Utils.UpdateHexString(ref colorAsHEX, GUILayout.TextField(colorAsHEX, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(textStyle.CalcSize(new GUIContent("#CCCCCCCC.")).x), GUILayout.ExpandWidth(false) })); bool enabled = GUI.enabled; GUI.enabled = !colorAsHEX.Replace("#", "").Equals(ColorUtility.ToHtmlStringRGBA(value), StringComparison.OrdinalIgnoreCase); Color val = default(Color); if (GUILayout.Button("Set", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }) && ColorUtility.TryParseHtmlString(colorAsHEX, ref val)) { value = val; } GUI.enabled = enabled; return ConfigurationManagerStyles.IsEqualColorConfig(value, defaultValue); } private void DrawColorField(string fieldLabel, ref Color settingColor, ref float settingValue, bool isDefaultValue) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0034: 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) //IL_006a: Expected O, but got Unknown //IL_0065: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(fieldLabel, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(ConfigurationManagerStyles.GetLabelStyle().CalcSize(new GUIContent("Green.")).x), GUILayout.ExpandWidth(false) }); GUIStyle textStyle = ConfigurationManagerStyles.GetTextStyle(isDefaultValue); Vector2 val = textStyle.CalcSize(new GUIContent("0,000.")); string text = GUILayout.TextField(Utils.RoundWithPrecision(settingValue, 3).ToString("0.000"), textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(val.x), GUILayout.ExpandWidth(false) }); float result; if (text.StartsWith('1')) { SetColorValue(ref settingColor, 1f); } else if (text.StartsWith('0') && settingValue == 1f) { SetColorValue(ref settingColor, 0f); } else if (Utils.TryParseFloat(text, out result)) { SetColorValue(ref settingColor, result); } if (byte.TryParse(GUILayout.TextField((Utils.RoundWithPrecision(settingValue, 3) * 255f).ToString("F0"), textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(textStyle.CalcSize(new GUIContent("000.")).x), GUILayout.ExpandWidth(false) }), out var result2)) { SetColorValue(ref settingColor, (float)(int)result2 / 255f); } SetColorValue(ref settingColor, DrawCenteredHorizontalSlider(settingValue, 0f, 1f, val.y)); GUILayout.EndHorizontal(); void SetColorValue(ref Color color, float value) { float num = Utils.RoundWithPrecision(value, 3); switch (fieldLabel) { case "Red": color.r = Mathf.Clamp01(num); break; case "Green": color.g = Mathf.Clamp01(num); break; case "Blue": color.b = Mathf.Clamp01(num); break; case "Alpha": color.a = Mathf.Clamp01(num); break; } } } private void DrawHSLField(string fieldLabel, ref HSLColor settingColor, ref float settingValue, bool isDefaultValue) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0034: 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) //IL_006a: Expected O, but got Unknown //IL_0065: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(fieldLabel, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(ConfigurationManagerStyles.GetLabelStyle().CalcSize(new GUIContent("Saturation..")).x), GUILayout.ExpandWidth(false) }); GUIStyle textStyle = ConfigurationManagerStyles.GetTextStyle(isDefaultValue); Vector2 val = textStyle.CalcSize(new GUIContent("000,00.")); if (Utils.TryParseFloat(GUILayout.TextField(Utils.RoundWithPrecision(settingValue, (fieldLabel == "Hue") ? 2 : 4).ToString((fieldLabel == "Hue") ? "000.00" : "0.0000"), textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(val.x), GUILayout.ExpandWidth(false) }), out var result)) { SetColorValue(ref settingColor, result); } SetColorValue(ref settingColor, DrawCenteredHorizontalSlider(settingValue, 0f, (fieldLabel == "Hue") ? 360f : 1f, val.y)); GUILayout.EndHorizontal(); void SetColorValue(ref HSLColor color, float value) { float num = Utils.RoundWithPrecision(value, (fieldLabel == "Hue") ? 2 : 4); switch (fieldLabel) { case "Hue": color.h = Mathf.Clamp(num, 0f, 360f); break; case "Saturation": color.s = Mathf.Clamp01((num > 1f) ? (num / 100f) : num); break; case "Lightness": color.l = Mathf.Clamp01((num > 1f) ? (num / 100f) : num); break; } } } private static void FillVectorList(List list, T value) { //IL_0021: 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_0028: 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_0058: 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) //IL_005f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (value != null) { if (value is Vector2 val) { list.Add(val.x); list.Add(val.y); } else if (value is Vector3 val2) { list.Add(val2.x); list.Add(val2.y); list.Add(val2.z); } else if (value is Vector4 val3) { list.Add(val3.x); list.Add(val3.y); list.Add(val3.z); list.Add(val3.w); } else if (value is Quaternion val4) { list.Add(val4.x); list.Add(val4.y); list.Add(val4.z); list.Add(val4.w); } } } } internal class LegacySettingEntry : SettingEntryBase { private Type _settingType; public override string DispName { get { if (!string.IsNullOrEmpty(base.DispName)) { return base.DispName; } return Property.Name; } protected internal set { base.DispName = value; } } public object Instance { get; internal set; } public PropertyInfo Property { get; internal set; } public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType); public object Wrapper { get; internal set; } private LegacySettingEntry() { } 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) { ConfigurationManager.LogInfo($"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) { ConfigurationManager.LogInfo("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) { ConfigurationManager.LogInfo($"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; } } internal class PropertySettingEntry : SettingEntryBase { private Type _settingType; public object Instance { get; internal set; } public PropertyInfo Property { get; internal set; } public override string DispName { get { if (!string.IsNullOrEmpty(base.DispName)) { return base.DispName; } return Property.Name; } protected internal set { base.DispName = value; } } public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType); public PropertySettingEntry(object instance, PropertyInfo settingProp, BaseUnityPlugin pluginInstance) { SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance); if (!base.Browsable.HasValue) { base.Browsable = settingProp.CanRead && settingProp.CanWrite; } base.ReadOnly = settingProp.CanWrite; Property = settingProp; Instance = instance; } public override object Get() { return Property.GetValue(Instance, null); } protected override void SetValue(object newVal) { Property.SetValue(Instance, newVal, null); } } public abstract class SettingEntryBase { public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); private static readonly PropertyInfo[] MyProperties = typeof(SettingEntryBase).GetProperties(BindingFlags.Instance | BindingFlags.Public); private static readonly FieldInfo[] MyFields = typeof(SettingEntryBase).GetFields(BindingFlags.Instance | BindingFlags.Public); public object[] AcceptableValues { get; protected set; } public KeyValuePair AcceptableValueRange { get; protected set; } public bool? ShowRangeAsPercent { get; protected set; } public Action CustomDrawer { get; private set; } public CustomHotkeyDrawerFunc CustomHotkeyDrawer { get; private 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; protected internal set; } public virtual string DispName { get; protected internal set; } public BepInPlugin PluginInfo { get; protected internal set; } public bool? ReadOnly { get; protected set; } public abstract Type SettingType { get; } public BaseUnityPlugin PluginInstance { get; private set; } public bool? IsAdvanced { get; internal set; } public int Order { get; protected set; } public int CategoryOrder { get; protected set; } public Func ObjToStr { get; internal set; } public Func StrToObj { get; internal set; } internal string SettingID { get { if (PluginInfo != null) { return PluginInfo.GUID + "-" + Category + "-" + DispName; } return ""; } } public abstract object Get(); public void Set(object newVal) { if (ReadOnly != true) { SetValue(newVal); } } protected abstract void SetValue(object newVal); internal 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; } if (!(obj is DisplayNameAttribute displayNameAttribute)) { if (!(obj is CategoryAttribute categoryAttribute)) { if (!(obj is DescriptionAttribute descriptionAttribute)) { if (!(obj is DefaultValueAttribute defaultValueAttribute)) { if (!(obj is ReadOnlyAttribute readOnlyAttribute)) { if (!(obj is BrowsableAttribute browsableAttribute)) { Action action = obj as Action; 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; } PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (var item in from my in MyProperties join other in properties 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); } } catch (Exception ex) { ConfigurationManager.LogInfo("Failed to copy value " + item.my.Name + " from provided tag object " + type.FullName + " - " + ex.Message); } } foreach (var item2 in from my in MyFields join other in properties on my.Name equals other.Name select new { my, other }) { try { object value2 = item2.other.GetValue(obj); if (value2 != null) { item2.my.SetValue(this, value2); } } catch (Exception ex2) { ConfigurationManager.LogInfo("Failed to copy value " + item2.my.Name + " from provided tag object " + type.FullName + " - " + ex2.Message); } } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (var item3 in from my in MyFields join other in fields on my.Name equals other.Name select new { my, other }) { try { object value3 = item3.other.GetValue(obj); if (value3 != null) { item3.my.SetValue(this, value3); } } catch (Exception ex3) { ConfigurationManager.LogInfo("Failed to copy value " + item3.my.Name + " from provided tag object " + type.FullName + " - " + ex3.Message); } } foreach (var item4 in from my in MyProperties join other in fields on my.Name equals other.Name select new { my, other }) { try { object value4 = item4.other.GetValue(obj); if (value4 != null) { item4.my.SetValue(this, value4); } } catch (Exception ex4) { ConfigurationManager.LogInfo("Failed to copy value " + item4.my.Name + " from provided tag object " + type.FullName + " - " + ex4.Message); } } } else { CustomDrawer = delegate { action(this); }; } } else { Browsable = browsableAttribute.Browsable; } } else { ReadOnly = readOnlyAttribute.IsReadOnly; } } else { DefaultValue = defaultValueAttribute.Value; } } else { Description = descriptionAttribute.Description; } } else { Category = categoryAttribute.Category; } } else { DispName = displayNameAttribute.DisplayName; } } } public override string ToString() { return SettingID; } } internal class SettingFieldDrawer { private sealed class ColorCacheEntry { public Color Last; public Texture2D Tex; } private static IEnumerable _keysToCheck; private static readonly Dictionary ComboBoxCache; private static readonly Dictionary ColorCache; private static ConfigurationManager _instance; private static SettingEntryBase _currentKeyboardShortcutToSet; public static readonly HashSet CustomFieldDrawerFailed; private readonly Dictionary _canCovertCache = new Dictionary(); public static Dictionary> SettingDrawHandlers { get; } public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null; static SettingFieldDrawer() { ComboBoxCache = new Dictionary(); ColorCache = new Dictionary(); CustomFieldDrawerFailed = new HashSet(); SettingDrawHandlers = new Dictionary> { { typeof(bool), DrawBoolField }, { typeof(KeyboardShortcut), DrawKeyboardShortcut }, { typeof(KeyCode), DrawKeyCode }, { typeof(Color), DrawColor }, { typeof(Vector2), DrawVector2 }, { typeof(Vector3), DrawVector3 }, { typeof(Vector4), DrawVector4 }, { typeof(Quaternion), DrawQuaternion } }; } public SettingFieldDrawer(ConfigurationManager instance) { _instance = instance; } public void DrawSettingValue(SettingEntryBase setting) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager.Palette.Widget; if (DrawCustomField(setting)) { return; } if (setting.AcceptableValueRange.Key != null) { DrawRangeField(setting); } else if (setting.AcceptableValues != null) { DrawListField(setting); } else { if (DrawFieldBasedOnValueType(setting)) { return; } if (setting.SettingType.IsEnum) { DrawEnumField(setting); } else { DrawUnknownField(setting, _instance.RightColumnWidth); } } GUI.backgroundColor = backgroundColor; } public bool DrawCustomField(SettingEntryBase setting) { //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_015a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) if (IsSettingFailedToCustomDraw(setting)) { return false; } Color contentColor = GUI.contentColor; bool result = true; int fontSize = GUI.skin.textField.fontSize; int fontSize2 = GUI.skin.textArea.fontSize; int fontSize3 = GUI.skin.label.fontSize; int fontSize4 = GUI.skin.button.fontSize; GUI.skin.textArea.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.textField.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.label.fontSize = ConfigurationManagerStyles.fontSize; GUI.skin.button.fontSize = ConfigurationManagerStyles.fontSize; try { GUI.contentColor = (ConfigurationManagerStyles.IsDefaultValue(setting) ? ConfigurationManager.Palette.DefaultValueText : ConfigurationManager.Palette.ChangedValueText); if (setting.CustomDrawer != null) { setting.CustomDrawer((setting is ConfigSettingEntry configSettingEntry) ? configSettingEntry.Entry : null); } else if (setting.CustomHotkeyDrawer != null) { bool isCurrentlyAcceptingInput = _currentKeyboardShortcutToSet == setting; bool flag = isCurrentlyAcceptingInput; setting.CustomHotkeyDrawer((setting is ConfigSettingEntry configSettingEntry2) ? configSettingEntry2.Entry : null, ref isCurrentlyAcceptingInput); if (isCurrentlyAcceptingInput != flag) { _currentKeyboardShortcutToSet = (isCurrentlyAcceptingInput ? setting : null); } } else { result = false; } } catch (Exception e) { SetSettingFailedToCustomDraw(setting, e); result = false; } GUI.contentColor = contentColor; GUI.skin.textField.fontSize = fontSize; GUI.skin.textArea.fontSize = fontSize2; GUI.skin.label.fontSize = fontSize3; GUI.skin.button.fontSize = fontSize4; return result; } public static bool IsSettingFailedToCustomDraw(SettingEntryBase setting) { if (setting == null) { return false; } return CustomFieldDrawerFailed.Contains(setting.SettingID); } public static void SetSettingFailedToCustomDraw(SettingEntryBase setting, Exception e = null) { CustomFieldDrawerFailed.Add(setting.SettingID); if (e != null) { ConfigurationManager.LogWarning(setting.SettingID + "\n" + e); } } public static void ClearCache() { ClearComboboxCache(); foreach (KeyValuePair item in ColorCache) { Object.Destroy((Object)(object)item.Value.Tex); } ColorCache.Clear(); } public static void ClearComboboxCache() { ComboBoxCache.Clear(); } public static void DrawCenteredLabel(string text, GUIStyle labelStyle) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); GUILayout.FlexibleSpace(); GUILayout.Label(text, labelStyle, Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } public static bool DrawCategoryHeader(string text) { return GUILayout.Button(text, ConfigurationManagerStyles.GetCategoryStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } public static bool DrawCollapsedCategoryHeader(string text, bool isDefaultStyle) { return GUILayout.Button("> " + text + " <", ConfigurationManagerStyles.GetCategoryStyle(isDefaultStyle), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } public static bool DrawPluginHeader(GUIContent content, bool isCollapsed, bool hasCollapsedCategories, bool withHover, out bool toggleCollapseAll) { GUILayout.BeginHorizontal(ConfigurationManagerStyles.GetBackgroundStyle(withHover), Array.Empty()); toggleCollapseAll = false; bool result = GUILayout.Button(content, ConfigurationManagerStyles.GetHeaderStyle(withHover && !isCollapsed), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); toggleCollapseAll = !isCollapsed && GUILayout.Button(hasCollapsedCategories ? "v" : "<", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.EndHorizontal(); return result; } public static bool DrawPluginHeaderSplitViewList(GUIContent content, bool isActivePlugin) { return GUILayout.Button(content, ConfigurationManagerStyles.GetHeaderSplitViewStyle(isActivePlugin), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } public static bool DrawPluginCategorySplitViewList(GUIContent content, bool isActiveCategory) { return GUILayout.Button(content, ConfigurationManagerStyles.GetCategorySplitViewStyle(isActiveCategory), (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; } private static void DrawListField(SettingEntryBase setting) { 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."); } if (setting.SettingType == typeof(KeyCode)) { DrawKeyCode(setting); } else { DrawComboboxField(setting, acceptableValues, ((Rect)(ref _instance.currentWindowRect)).yMax); } } private static bool DrawFieldBasedOnValueType(SettingEntryBase setting) { if (SettingDrawHandlers.TryGetValue(setting.SettingType, out var value)) { value(setting); return true; } return false; } private static void DrawBoolField(SettingEntryBase setting) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0077: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = ConfigurationManager.Palette.Widget; bool flag = (bool)setting.Get(); Color backgroundColor = GUI.backgroundColor; if (flag) { GUI.backgroundColor = ConfigurationManager.Palette.Enabled; } bool flag2 = GUILayout.Toggle(flag, flag ? "Enabled" : "Disabled", ConfigurationManagerStyles.GetToggleStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (flag2 != flag) { setting.Set(flag2); } if (flag) { GUI.backgroundColor = backgroundColor; } } private static void DrawEnumField(SettingEntryBase setting) { if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any()) { DrawFlagsField(setting, Enum.GetValues(setting.SettingType), (int)((float)_instance.RightColumnWidth * 0.8f)); } else { DrawComboboxField(setting, Enum.GetValues(setting.SettingType), ((Rect)(ref _instance.currentWindowRect)).yMax); } } private static void DrawFlagsField(SettingEntryBase setting, IList enumValues, int maxWidth) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) long num = Convert.ToInt64(setting.Get()); long num2 = Convert.ToInt64(setting.DefaultValue); 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 num3 = 0; while (num3 < array.Length) { GUILayout.BeginHorizontal(Array.Empty()); int num4 = 0; bool flag = false; for (; num3 < array.Length; num3++) { var anon = array[num3]; if (anon.val != 0L) { bool flag2 = (num & anon.val) == anon.val; bool flag3 = (num2 & anon.val) == anon.val; GUIStyle toggleStyle = ConfigurationManagerStyles.GetToggleStyle(flag2 == flag3); int num5 = (int)toggleStyle.CalcSize(new GUIContent(anon.name)).x; if (num4 + num5 > maxWidth && flag) { break; } flag = true; num4 += num5; GUI.changed = false; bool flag4 = GUILayout.Toggle(flag2, anon.name, toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (GUI.changed) { long value = (flag4 ? (num | anon.val) : (num & ~anon.val)); setting.Set(Enum.ToObject(setting.SettingType, value)); } } } if (!flag) { num3++; } GUILayout.EndHorizontal(); } GUI.changed = false; GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } private static void DrawComboboxField(SettingEntryBase setting, IList list, float windowYmax) { //IL_003a: 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_00b7: 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) GUIContent val = ObjectToGuiContent(setting.Get()); Rect rect = GUILayoutUtility.GetRect(val, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!ComboBoxCache.TryGetValue(setting, out var value)) { value = new ComboBox(rect, val, list.Cast().Select(ObjectToGuiContent).ToArray(), ObjectToGuiContent(setting.DefaultValue), ConfigurationManagerStyles.GetButtonStyle(), ConfigurationManagerStyles.GetButtonStyle(isDefaultValue: false), ConfigurationManagerStyles.GetBoxStyle(), ConfigurationManagerStyles.GetComboBoxStyle(), 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]); } }); } internal 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().FirstOrDefault(); if (descriptionAttribute == null) { return new GUIContent(x.ToString().ToProperCase()); } return new GUIContent(descriptionAttribute.Description); } return new GUIContent(x.ToString()); } private static void DrawRangeField(SettingEntryBase setting) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown 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 = ConfigurationManagerStyles.GetTextStyle(setting).CalcHeight(new GUIContent(obj.ToString()), 100f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4) }); try { float num5 = DrawCenteredHorizontalSlider(num, num2, num3, num4); if ((double)Math.Abs(num5 - num) >= (double)Mathf.Abs(num3 - num2) / Math.Pow(10.0, 5.0)) { object newVal = Convert.ChangeType(Utils.RoundWithPrecision(num5, 3), setting.SettingType, CultureInfo.InvariantCulture); setting.Set(newVal); } if (setting.ShowRangeAsPercent == true) { DrawCenteredLabel($"{Mathf.Abs(num5 - num2) / Mathf.Abs(num3 - num2):P0}", ConfigurationManagerStyles.GetLabelStyle(setting)); return; } string text = Convert.ToString(obj, CultureInfo.InvariantCulture).AppendZeroIfFloat(setting.SettingType); string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text2 != text && Utils.TryParseFloat(text2, out var result)) { float value = Mathf.Clamp(result, num2, num3); setting.Set(Convert.ChangeType(Utils.RoundWithPrecision(value, 3), setting.SettingType)); } } finally { GUILayout.EndHorizontal(); } } private static float DrawCenteredHorizontalSlider(float converted, float leftValue, float rightValue, float height) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(height) }); GUILayout.Space(height * 0.45f); float result = GUILayout.HorizontalSlider(converted, leftValue, rightValue, ConfigurationManagerStyles.GetSliderStyle(), ConfigurationManagerStyles.GetThumbStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndVertical(); return result; } private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth) { //IL_006e: 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) GUILayout.BeginVertical(Array.Empty()); GUILayout.Space(4f); if (setting.ObjToStr != null && setting.StrToObj != null) { string text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType); if (Utility.IsNullOrWhiteSpace(text) && setting.DefaultValue.ToString() != "") { GUI.backgroundColor = ConfigurationManager.Palette.ChangedValueText; } string text2 = GUILayout.TextArea(text, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }).AppendZeroIfFloat(setting.SettingType); if (text2 != text) { setting.Set(setting.StrToObj(text2)); } } else { object obj = setting.Get(); string text3 = ((obj == null) ? "NULL" : Convert.ToString(obj, CultureInfo.InvariantCulture).AppendZeroIfFloat(setting.SettingType)); if (Utility.IsNullOrWhiteSpace(text3) && setting.DefaultValue.ToString() != "") { GUI.backgroundColor = ConfigurationManager.Palette.ChangedValueText; } if (CanCovert(text3, setting.SettingType)) { string text4 = GUILayout.TextField(text3, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }).AppendZeroIfFloat(setting.SettingType); if (text4 != text3) { try { setting.Set(Convert.ChangeType(text4, setting.SettingType, CultureInfo.InvariantCulture)); } catch { } } } else { GUILayout.TextArea(text3, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) }); } } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } private 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; } } private static void DrawKeyCode(SettingEntryBase setting) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007d: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; IInputSystem current = UnityInput.Current; if (_keysToCheck == null) { _keysToCheck = current.SupportedKeyCodes.Except((IEnumerable)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (current.GetKeyUp(item)) { setting.Set(item); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { object[] acceptableValues = setting.AcceptableValues; Array list = ((acceptableValues != null && acceptableValues.Length > 1) ? setting.AcceptableValues : Enum.GetValues(setting.SettingType)); DrawComboboxField(setting, list, ((Rect)(ref _instance.currentWindowRect)).yMax); if (GUILayout.Button(new GUIContent("Set"), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = setting; } } } private static void DrawKeyboardShortcut(SettingEntryBase setting) { //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label("Press any key", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIUtility.keyboardControl = -1; IInputSystem current = UnityInput.Current; if (_keysToCheck == null) { _keysToCheck = current.SupportedKeyCodes.Except((IEnumerable)(object)new KeyCode[2] { (KeyCode)323, default(KeyCode) }).ToArray(); } foreach (KeyCode item in _keysToCheck) { if (current.GetKeyUp(item)) { setting.Set((object)new KeyboardShortcut(item, _keysToCheck.Where((Func)current.GetKey).ToArray())); _currentKeyboardShortcutToSet = null; break; } } if (GUILayout.Button("Cancel", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = null; } } else { if (GUILayout.Button(setting.Get().ToString(), ConfigurationManagerStyles.GetButtonStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { _currentKeyboardShortcutToSet = setting; } if (GUILayout.Button("Clear", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { setting.Set(KeyboardShortcut.Empty); _currentKeyboardShortcutToSet = null; } } } private 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0066: 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", ((Vector2)obj.DefaultValue).x); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector2)obj.DefaultValue).y); if (val != val2) { obj.Set(val); } } private 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008d: 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", ((Vector3)obj.DefaultValue).x); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector3)obj.DefaultValue).y); val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector3)obj.DefaultValue).z); if (val != val2) { obj.Set(val); } } private 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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", ((Vector4)obj.DefaultValue).x); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector4)obj.DefaultValue).y); val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector4)obj.DefaultValue).z); val.w = DrawSingleVectorSlider(val.w, "W", ((Vector4)obj.DefaultValue).w); if (val != val2) { obj.Set(val); } } private 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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", ((Quaternion)obj.DefaultValue).x); val.y = DrawSingleVectorSlider(val.y, "Y", ((Quaternion)obj.DefaultValue).y); val.z = DrawSingleVectorSlider(val.z, "Z", ((Quaternion)obj.DefaultValue).z); val.w = DrawSingleVectorSlider(val.w, "W", ((Quaternion)obj.DefaultValue).w); if (val != val2) { obj.Set(val); } } private static float DrawSingleVectorSlider(float setting, string label, float defaultValue) { GUILayout.Label(label, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); string text = "0." + new string('#', 3); string text2 = GUILayout.TextField(setting.ToString(text, CultureInfo.InvariantCulture), ConfigurationManagerStyles.GetTextStyle(setting, defaultValue), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text2.EndsWith(".") || text2.EndsWith(",")) { text2 = text2 + string.Empty.PadRight(Math.Max(2, 0), '0') + 1; } Utils.TryParseFloat(text2, out var result); return result; } private 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_00c7: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f3: Unknown result type (might be due to invalid IL or missing references) Color value = Utils.RoundColorToHEX((Color)obj.Get()); Color val = Utils.RoundColorToHEX((Color)obj.DefaultValue); GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginVertical(ConfigurationManagerStyles.GetBoxStyle(), Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); DrawHexField(ref value, val); GUILayout.Space(3f); GUIHelper.BeginColor(value); GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!ColorCache.TryGetValue(obj, out var value2)) { value2 = new ColorCacheEntry { Tex = new Texture2D(40, 10, (TextureFormat)5, false), Last = value }; value2.Tex.FillTexture(value); ColorCache[obj] = value2; } if ((int)Event.current.type == 7) { GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)value2.Tex); } GUIHelper.EndColor(); GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(2f); GUILayout.BeginHorizontal(Array.Empty()); DrawColorField("R", ref value, ref value.r, Utils.RoundColor(value.r) == Utils.RoundColor(val.r)); GUILayout.Space(3f); DrawColorField("G", ref value, ref value.g, Utils.RoundColor(value.g) == Utils.RoundColor(val.g)); GUILayout.Space(3f); DrawColorField("B", ref value, ref value.b, Utils.RoundColor(value.b) == Utils.RoundColor(val.b)); GUILayout.Space(3f); DrawColorField("A", ref value, ref value.a, Utils.RoundColor(value.a) == Utils.RoundColor(val.a)); if (value != value2.Last) { obj.Set(value); value2.Tex.FillTexture(value); value2.Last = value; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(2f); GUILayout.EndVertical(); } private static bool DrawHexField(ref Color value, Color defaultValue) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) GUIStyle textStyle = ConfigurationManagerStyles.GetTextStyle(value, defaultValue); string originalHEX = "#" + ColorUtility.ToHtmlStringRGBA(value); Utils.UpdateHexString(ref originalHEX, GUILayout.TextField(originalHEX, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(textStyle.CalcSize(new GUIContent("#CCCCCCCC.")).x), GUILayout.ExpandWidth(false) })); Color val = default(Color); if (ColorUtility.TryParseHtmlString(originalHEX, ref val)) { value = val; } return ConfigurationManagerStyles.IsEqualColorConfig(value, defaultValue); } private static void DrawColorField(string fieldLabel, ref Color settingColor, ref float settingValue, bool isDefaultValue) { GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(fieldLabel, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); string text = GUILayout.TextField(Utils.RoundWithPrecision(settingValue, 3).ToString("0.000"), ConfigurationManagerStyles.GetTextStyle(isDefaultValue), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MaxWidth(45f), GUILayout.ExpandWidth(true) }); float result; if (text.StartsWith('1')) { SetColorValue(ref settingColor, 1f); } else if (text.StartsWith('0') && settingValue == 1f) { SetColorValue(ref settingColor, 0f); } else if (Utils.TryParseFloat(text, out result)) { SetColorValue(ref settingColor, result); } GUILayout.EndHorizontal(); GUILayout.Space(1f); SetColorValue(ref settingColor, GUILayout.HorizontalSlider(settingValue, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })); GUILayout.EndVertical(); void SetColorValue(ref Color color, float value) { float num = Utils.RoundWithPrecision(value, 3); switch (fieldLabel) { case "R": color.r = num; break; case "G": color.g = num; break; case "B": color.b = num; break; case "A": color.a = num; break; } } } } internal static class SettingSearcher { public static BaseUnityPlugin[] FindPlugins() { return (from x in Chainloader.PluginInfos.Values select x.Instance into plugin where (Object)(object)plugin != (Object)null select plugin).Union(Object.FindObjectsByType(typeof(BaseUnityPlugin), (FindObjectsInactive)0, (FindObjectsSortMode)0).Cast()).ToArray(); } public static void CollectSettings(out IEnumerable results, out List modsWithoutSettings) { modsWithoutSettings = new List(); try { results = GetBepInExCoreConfig(); } catch (Exception data) { results = Enumerable.Empty(); ConfigurationManager.LogError(data); } BaseUnityPlugin[] array = FindPlugins(); foreach (BaseUnityPlugin val in array) { Type type = ((object)val).GetType(); BepInPlugin metadata = val.Info.Metadata; string item = ((metadata != null) ? metadata.Name : null) ?? ((object)val).GetType().FullName; if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast().Any((BrowsableAttribute x) => !x.Browsable)) { modsWithoutSettings.Add(item); continue; } List list = new List(); list.AddRange(GetPluginConfig(val)); list.RemoveAll((SettingEntryBase x) => x.Browsable == false); if (list.Count == 0) { modsWithoutSettings.Add(item); } if (list.Count > 0) { results = results.Concat(list); } } } private static IEnumerable 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>)val).Select((Func, SettingEntryBase>)((KeyValuePair kvp) => new ConfigSettingEntry(kvp.Value, null) { IsAdvanced = true, PluginInfo = bepinMeta })); } private static IEnumerable GetPluginConfig(BaseUnityPlugin plugin) { return ((IEnumerable>)plugin.Config).Select((KeyValuePair kvp) => new ConfigSettingEntry(kvp.Value, plugin)); } } public class ConfigurationManagerStyles { private static GUIStyle windowStyle; private static GUIStyle labelStyle; private static GUIStyle labelStyleSettingName; private static GUIStyle labelStyleInfo; private static GUIStyle labelStyleValueDefault; private static GUIStyle labelStyleValueChanged; private static GUIStyle textStyle; private static GUIStyle textStyleValueDefault; private static GUIStyle textStyleValueChanged; private static GUIStyle toggleStyle; private static GUIStyle toggleStyleValueDefault; private static GUIStyle toggleStyleValueChanged; private static GUIStyle buttonStyle; private static GUIStyle buttonStyleValueDefault; private static GUIStyle buttonStyleValueChanged; private static GUIStyle comboBoxStyle; private static GUIStyle boxStyle; private static GUIStyle sliderStyle; private static GUIStyle thumbStyle; private static GUIStyle categoryHeaderStyleDefault; private static GUIStyle categoryHeaderStyleChanged; private static GUIStyle pluginHeaderStyle; private static GUIStyle pluginHeaderStyleActive; private static GUIStyle pluginHeaderStyleSplitView; private static GUIStyle pluginHeaderStyleSplitViewActive; private static GUIStyle pluginCategoryStyleSplitView; private static GUIStyle pluginCategoryStyleSplitViewActive; private static GUIStyle backgroundStyle; private static GUIStyle backgroundStyleWithHover; private static GUIStyle categoryBackgroundStyle; private static GUIStyle categoryHeaderBackgroundStyle; private static GUIStyle categoryHeaderBackgroundStyleWithHover; private static GUIStyle settingWindowBackgroundStyle; private static GUIStyle categorySplitViewBackgroundStyle; private static GUIStyle tooltipStyle; private static GUIStyle fileEditorFileStyle; private static GUIStyle fileEditorFileStyleActive; private static GUIStyle fileEditorDirectoryStyle; private static GUIStyle fileEditorDirectoryStyleActive; private static GUIStyle fileEditorRenameFileField; private static GUIStyle fileEditorErrorText; private static GUIStyle fileEditorTextArea; private static GUIStyle delimiterLine; private static GUIStyle placeholderText; public static int fontSize = 14; public static void CreateStyles() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0068: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0122: 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_013b: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01e2: 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_01fb: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Expected O, but got Unknown //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Expected O, but got Unknown //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Expected O, but got Unknown //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_045a: 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_047e: Expected O, but got Unknown //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Expected O, but got Unknown //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Expected O, but got Unknown //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Expected O, but got Unknown //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Expected O, but got Unknown //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Expected O, but got Unknown //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Expected O, but got Unknown //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Expected O, but got Unknown //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_07fb: Expected O, but got Unknown //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_081e: Expected O, but got Unknown //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Expected O, but got Unknown //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Expected O, but got Unknown //IL_08b9: Unknown result type (might be due to invalid IL or missing references) //IL_08c3: Expected O, but got Unknown //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Expected O, but got Unknown //IL_08eb: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: Expected O, but got Unknown //IL_08ff: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Expected O, but got Unknown //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Expected O, but got Unknown //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_09a9: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Expected O, but got Unknown //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09c7: Expected O, but got Unknown //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Expected O, but got Unknown //IL_09ea: Unknown result type (might be due to invalid IL or missing references) //IL_09f4: Expected O, but got Unknown //IL_0a04: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Expected O, but got Unknown //IL_0a20: Unknown result type (might be due to invalid IL or missing references) //IL_0a3c: Unknown result type (might be due to invalid IL or missing references) //IL_0a4b: Unknown result type (might be due to invalid IL or missing references) //IL_0a55: Expected O, but got Unknown //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0a9f: Expected O, but got Unknown //IL_0ab1: Unknown result type (might be due to invalid IL or missing references) //IL_0acd: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0ae6: Expected O, but got Unknown //IL_0af6: Unknown result type (might be due to invalid IL or missing references) //IL_0b00: Expected O, but got Unknown //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) //IL_0b1e: Unknown result type (might be due to invalid IL or missing references) //IL_0b28: Expected O, but got Unknown //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Expected O, but got Unknown //IL_0b44: Unknown result type (might be due to invalid IL or missing references) //IL_0b4e: Expected O, but got Unknown //IL_0b9e: Unknown result type (might be due to invalid IL or missing references) //IL_0ba8: Unknown result type (might be due to invalid IL or missing references) //IL_0bb2: Expected O, but got Unknown //IL_0bda: Unknown result type (might be due to invalid IL or missing references) //IL_0be4: Expected O, but got Unknown //IL_0bee: Unknown result type (might be due to invalid IL or missing references) ConfigurationManager._textSize.Value = Mathf.Clamp(ConfigurationManager._textSize.Value, 10, 30); if (fontSize != ConfigurationManager._textSize.Value) { fontSize = ConfigurationManager._textSize.Value; SettingFieldDrawer.ClearCache(); } windowStyle = new GUIStyle(GUI.skin.window); windowStyle.normal.textColor = ConfigurationManager.Palette.MainText; windowStyle.fontSize = fontSize; windowStyle.onNormal.textColor = ConfigurationManager.Palette.MainText; labelStyle = new GUIStyle(GUI.skin.label); labelStyle.normal.textColor = ConfigurationManager.Palette.MainText; labelStyle.fontSize = fontSize; labelStyleSettingName = new GUIStyle(labelStyle); labelStyleSettingName.wordWrap = true; labelStyleSettingName.clipping = (TextClipping)1; labelStyleInfo = new GUIStyle(labelStyleSettingName); labelStyleInfo.normal.textColor = ConfigurationManager.Palette.ReadOnlyText; labelStyleValueDefault = new GUIStyle(labelStyle); labelStyleValueDefault.normal.textColor = ConfigurationManager.Palette.DefaultValueText; labelStyleValueChanged = new GUIStyle(labelStyle); labelStyleValueChanged.normal.textColor = ConfigurationManager.Palette.ChangedValueText; textStyle = new GUIStyle(GUI.skin.textArea); textStyle.normal.textColor = ConfigurationManager.Palette.MainText; textStyle.fontSize = fontSize; textStyleValueDefault = new GUIStyle(textStyle); textStyleValueDefault.normal.textColor = ConfigurationManager.Palette.DefaultValueText; textStyleValueChanged = new GUIStyle(textStyle); textStyleValueChanged.normal.textColor = ConfigurationManager.Palette.ChangedValueText; buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.normal.textColor = ConfigurationManager.Palette.MainText; buttonStyle.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; buttonStyle.fontSize = fontSize; buttonStyleValueDefault = new GUIStyle(buttonStyle); buttonStyleValueDefault.normal.textColor = ConfigurationManager.Palette.DefaultValueText; buttonStyleValueDefault.onNormal.textColor = ConfigurationManager.Palette.DefaultValueText; buttonStyleValueChanged = new GUIStyle(buttonStyle); buttonStyleValueChanged.normal.textColor = ConfigurationManager.Palette.ChangedValueText; buttonStyleValueChanged.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; categoryHeaderStyleDefault = new GUIStyle(labelStyle) { alignment = (TextAnchor)4, wordWrap = false, stretchWidth = true }; RectOffset padding = categoryHeaderStyleDefault.padding; int top = (categoryHeaderStyleDefault.padding.bottom = 1); padding.top = top; categoryHeaderStyleChanged = new GUIStyle(categoryHeaderStyleDefault); categoryHeaderStyleChanged.normal.textColor = ConfigurationManager.Palette.ChangedValueText; categoryHeaderStyleChanged.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginHeaderStyle = new GUIStyle(categoryHeaderStyleDefault); pluginHeaderStyleActive = new GUIStyle(pluginHeaderStyle); pluginHeaderStyleActive.normal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginHeaderStyleSplitView = new GUIStyle(labelStyle); RectOffset margin = pluginHeaderStyleSplitView.margin; top = (pluginHeaderStyleSplitView.margin.bottom = 2); margin.top = top; pluginHeaderStyleSplitView.padding = new RectOffset(); pluginHeaderStyleSplitView.alignment = (TextAnchor)3; pluginHeaderStyleSplitView.wordWrap = false; pluginHeaderStyleSplitViewActive = new GUIStyle(pluginHeaderStyleSplitView); pluginHeaderStyleSplitViewActive.normal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginHeaderStyleSplitViewActive.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginHeaderStyleSplitViewActive.fontStyle = (FontStyle)1; pluginCategoryStyleSplitView = new GUIStyle(pluginHeaderStyleSplitView); RectOffset margin2 = pluginCategoryStyleSplitView.margin; top = (pluginCategoryStyleSplitView.margin.bottom = 2); margin2.top = top; pluginCategoryStyleSplitView.clipping = (TextClipping)1; pluginCategoryStyleSplitView.hover.textColor = ConfigurationManager.Palette.ChangedValueText; pluginCategoryStyleSplitView.hover.background = ConfigurationManager.HeaderBackground; pluginCategoryStyleSplitViewActive = new GUIStyle(pluginCategoryStyleSplitView); pluginCategoryStyleSplitViewActive.normal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginCategoryStyleSplitViewActive.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; pluginCategoryStyleSplitViewActive.fontStyle = (FontStyle)1; toggleStyle = new GUIStyle(GUI.skin.toggle); toggleStyle.normal.textColor = ConfigurationManager.Palette.MainText; toggleStyle.onNormal.textColor = ConfigurationManager.Palette.MainText; toggleStyle.fontSize = fontSize; toggleStyle.imagePosition = (ImagePosition)0; toggleStyle.padding.top = 2; toggleStyle.padding.left = 16; toggleStyle.margin.top = 5; toggleStyleValueDefault = new GUIStyle(toggleStyle); toggleStyleValueDefault.normal.textColor = ConfigurationManager.Palette.DefaultValueText; toggleStyleValueDefault.onNormal.textColor = ConfigurationManager.Palette.DefaultValueText; toggleStyleValueChanged = new GUIStyle(toggleStyle); toggleStyleValueChanged.normal.textColor = ConfigurationManager.Palette.ChangedValueText; toggleStyleValueChanged.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; boxStyle = new GUIStyle(GUI.skin.box); boxStyle.normal.textColor = ConfigurationManager.Palette.MainText; boxStyle.onNormal.textColor = ConfigurationManager.Palette.MainText; boxStyle.fontSize = fontSize; comboBoxStyle = new GUIStyle(GUI.skin.button); comboBoxStyle.normal = boxStyle.normal; comboBoxStyle.normal.textColor = ConfigurationManager.Palette.DefaultValueText; comboBoxStyle.hover.background = comboBoxStyle.normal.background; comboBoxStyle.hover.textColor = ConfigurationManager.Palette.ChangedValueText; comboBoxStyle.fontSize = fontSize; comboBoxStyle.border = boxStyle.border; comboBoxStyle.stretchHeight = true; comboBoxStyle.padding.top = 1; comboBoxStyle.padding.bottom = 1; comboBoxStyle.margin.top = 0; comboBoxStyle.margin.bottom = 0; backgroundStyle = new GUIStyle(GUI.skin.box); backgroundStyle.normal.textColor = ConfigurationManager.Palette.MainText; backgroundStyle.fontSize = fontSize; backgroundStyle.normal.background = ConfigurationManager.EntryBackground; backgroundStyleWithHover = new GUIStyle(backgroundStyle); backgroundStyleWithHover.hover.background = ConfigurationManager.TooltipBackground; categoryBackgroundStyle = new GUIStyle(backgroundStyle); categoryBackgroundStyle.margin.bottom = 6; categoryBackgroundStyle.margin.top = 0; categoryHeaderBackgroundStyle = new GUIStyle(backgroundStyle); categoryHeaderBackgroundStyle.normal.background = ConfigurationManager.HeaderBackground; categoryHeaderBackgroundStyle.margin.bottom = 0; categoryHeaderBackgroundStyle.padding.bottom = 0; categoryHeaderBackgroundStyle.padding.top = 0; categoryHeaderBackgroundStyleWithHover = new GUIStyle(categoryHeaderBackgroundStyle); categoryHeaderBackgroundStyleWithHover.hover.background = ConfigurationManager.HeaderBackgroundHover; settingWindowBackgroundStyle = new GUIStyle(backgroundStyle); settingWindowBackgroundStyle.normal.background = ConfigurationManager.SettingWindowBackground; categorySplitViewBackgroundStyle = new GUIStyle(backgroundStyleWithHover); categorySplitViewBackgroundStyle.padding = new RectOffset(); categorySplitViewBackgroundStyle.margin = new RectOffset(20, 4, 2, 2); tooltipStyle = new GUIStyle(GUI.skin.box); tooltipStyle.normal.textColor = ConfigurationManager.Palette.MainText; tooltipStyle.fontSize = fontSize; tooltipStyle.wordWrap = true; tooltipStyle.alignment = (TextAnchor)3; tooltipStyle.normal.background = ConfigurationManager.TooltipBackground; tooltipStyle.padding.left = 10; tooltipStyle.padding.right = 10; tooltipStyle.richText = false; sliderStyle = new GUIStyle(GUI.skin.horizontalSlider); thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb); fileEditorDirectoryStyle = new GUIStyle(toggleStyle); fileEditorDirectoryStyle.wordWrap = false; fileEditorDirectoryStyle.margin = new RectOffset(4, 4, 4, 4); fileEditorDirectoryStyle.fontStyle = (FontStyle)1; fileEditorDirectoryStyleActive = new GUIStyle(fileEditorDirectoryStyle); fileEditorDirectoryStyleActive.normal.textColor = ConfigurationManager.Palette.ChangedValueText; fileEditorDirectoryStyleActive.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; fileEditorFileStyle = new GUIStyle(labelStyle); fileEditorFileStyle.padding.left = 6; fileEditorFileStyle.wordWrap = false; fileEditorFileStyle.margin.bottom = 2; fileEditorFileStyle.margin.top = 2; fileEditorFileStyleActive = new GUIStyle(fileEditorFileStyle); fileEditorFileStyleActive.normal.textColor = ConfigurationManager.Palette.ChangedValueText; fileEditorFileStyleActive.onNormal.textColor = ConfigurationManager.Palette.ChangedValueText; fileEditorRenameFileField = new GUIStyle(textStyleValueChanged); fileEditorRenameFileField.wordWrap = true; fileEditorErrorText = new GUIStyle(labelStyle); fileEditorErrorText.normal.textColor = Color.red; fileEditorTextArea = new GUIStyle(GUI.skin.textArea); fileEditorTextArea.padding = new RectOffset(5, 5, 5, 5); fileEditorTextArea.margin = new RectOffset(1, 1, 3, 3); fileEditorTextArea.wordWrap = ConfigurationManager._textEditorWordWrap.Value; fileEditorTextArea.richText = false; fileEditorTextArea.alignment = (TextAnchor)0; fileEditorTextArea.fontSize = ConfigurationManager._textEditorFontSize.Value; fileEditorTextArea.normal.textColor = ConfigurationManager.Palette.FileEditorText; delimiterLine = new GUIStyle(); delimiterLine.normal.background = ConfigurationManager.EntryBackground; delimiterLine.fixedHeight = 2f; placeholderText = new GUIStyle(textStyleValueDefault); placeholderText.normal.textColor = Color.gray; } public static GUIStyle GetWindowStyle() { return windowStyle; } public static GUIStyle GetCategoryStyle(bool isDefaultStyle = true) { if (!isDefaultStyle) { return categoryHeaderStyleChanged; } return categoryHeaderStyleDefault; } public static GUIStyle GetHeaderStyle(bool isActive) { if (!isActive) { return pluginHeaderStyle; } return pluginHeaderStyleActive; } public static GUIStyle GetHeaderSplitViewStyle(bool isActivePlugin = false) { if (!isActivePlugin) { return pluginHeaderStyleSplitView; } return pluginHeaderStyleSplitViewActive; } public static GUIStyle GetCategorySplitViewStyle(bool isActiveCategory = false) { if (!isActiveCategory) { return pluginCategoryStyleSplitView; } return pluginCategoryStyleSplitViewActive; } public static GUIStyle GetCategorySplitViewBackgroundStyle() { return categorySplitViewBackgroundStyle; } public static GUIStyle GetSliderStyle() { return sliderStyle; } public static GUIStyle GetThumbStyle() { return thumbStyle; } public static GUIStyle GetBoxStyle() { return boxStyle; } public static GUIStyle GetTooltipStyle() { return tooltipStyle; } public static GUIStyle GetBackgroundStyle(bool withHover = false) { if (!withHover) { return backgroundStyle; } return backgroundStyleWithHover; } public static GUIStyle GetCategoryBackgroundStyle() { return categoryBackgroundStyle; } public static GUIStyle GetCategoryHeaderBackgroundStyle(bool withHover = false) { if (!withHover) { return categoryHeaderBackgroundStyle; } return categoryHeaderBackgroundStyleWithHover; } public static GUIStyle GetSettingWindowBackgroundStyle() { return settingWindowBackgroundStyle; } public static GUIStyle GetComboBoxStyle() { return comboBoxStyle; } public static GUIStyle GetToggleStyle() { return toggleStyle; } public static GUIStyle GetToggleStyle(bool isDefaultValue = true) { if (!isDefaultValue) { return toggleStyleValueChanged; } return toggleStyleValueDefault; } public static GUIStyle GetToggleStyle(SettingEntryBase setting) { return GetToggleStyle(IsDefaultValue(setting)); } public static GUIStyle GetLabelStyle() { return labelStyle; } public static GUIStyle GetLabelStyle(bool isDefaultValue = true) { if (!isDefaultValue) { return labelStyleValueChanged; } return labelStyleValueDefault; } public static GUIStyle GetLabelStyle(SettingEntryBase setting) { return GetLabelStyle(IsDefaultValue(setting)); } public static GUIStyle GetLabelStyleInfo() { return labelStyleInfo; } public static GUIStyle GetLabelStyleSettingName() { return labelStyleSettingName; } public static GUIStyle GetButtonStyle() { return buttonStyle; } public static GUIStyle GetButtonStyle(bool isDefaultValue = true) { if (!isDefaultValue) { return buttonStyleValueChanged; } return buttonStyleValueDefault; } public static GUIStyle GetButtonStyle(SettingEntryBase setting) { return GetButtonStyle(IsDefaultValue(setting)); } public static GUIStyle GetTextStyle(bool isDefaultValue = true) { if (!isDefaultValue) { return textStyleValueChanged; } return textStyleValueDefault; } public static GUIStyle GetTextStyle(SettingEntryBase setting) { return GetTextStyle(IsDefaultValue(setting)); } public static GUIStyle GetTextStyle(float setting, float defaultValue) { return GetTextStyle(setting == defaultValue); } public static GUIStyle GetTextStyle(Color setting, Color defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetTextStyle(IsEqualColorConfig(setting, defaultValue)); } public static GUIStyle GetFileStyle(bool isActive) { if (!isActive) { return fileEditorFileStyle; } return fileEditorFileStyleActive; } public static GUIStyle GetDirectoryStyle(bool isActive) { if (!isActive) { return fileEditorDirectoryStyle; } return fileEditorDirectoryStyleActive; } public static GUIStyle GetFileNameFieldStyle() { return fileEditorRenameFileField; } public static GUIStyle GetFileNameErrorStyle() { return fileEditorErrorText; } public static GUIStyle GetFileEditorTextArea() { return fileEditorTextArea; } public static GUIStyle GetDelimiterLine() { return delimiterLine; } public static GUIStyle GetPlaceholderTextStyle() { return placeholderText; } public static bool IsEqualColorConfig(Color setting, Color defaultValue) { //IL_0000: 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) return ColorUtility.ToHtmlStringRGBA(setting) == ColorUtility.ToHtmlStringRGBA(defaultValue); } internal static bool IsDefaultValue(SettingEntryBase setting) { if (setting == null || setting.DefaultValue == null || setting.Get() == null) { return true; } try { return IsEqualConfigValues(setting.SettingType, setting.Get(), setting.DefaultValue); } catch { return true; } } internal static bool IsEqualConfigValues(Type type, object value1, object value2) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((object)type != null) { if (type == typeof(Color)) { return IsEqualColorConfig((Color)value1, (Color)value2); } if (type == typeof(Vector2)) { return (Vector2)value1 == (Vector2)value2; } if (type == typeof(Vector3)) { return (Vector3)value1 == (Vector3)value2; } if (type == typeof(Vector4)) { return (Vector4)value1 == (Vector4)value2; } if (type == typeof(Quaternion)) { return (Quaternion)value1 == (Quaternion)value2; } } return value1.ToString().Equals(value2.ToString(), StringComparison.OrdinalIgnoreCase); } } [BepInPlugin("sighsorry.ConfigManager", "ConfigManager", "1.0.0")] [BepInIncompatibility("com.bepis.bepinex.configurationmanager")] [BepInIncompatibility("_shudnal.ConfigurationManager")] [BepInIncompatibility("blizz.ConfigManager")] public class ConfigurationManager : BaseUnityPlugin { private sealed class PluginSettingsData { public sealed class PluginSettingsGroupData { public string ID; public string Name; public List Settings; public bool Collapsed; public bool Selected { get { if ((Object)(object)instance != (Object)null) { return instance._selectedCategory == ID; } return false; } set { if ((Object)(object)instance != (Object)null) { instance._selectedCategory = (value ? ID : string.Empty); } } } public override string ToString() { return Name; } } public BepInPlugin Info; public List Categories; private bool _collapsed; public bool Collapsed { get { return _collapsed; } set { _collapsed = value; Height = 0; } } public bool Selected { get { if ((Object)(object)instance != (Object)null) { return instance._selectedPlugin == Info.GUID; } return false; } set { if ((Object)(object)instance != (Object)null) { instance._selectedPlugin = (value ? Info.GUID : string.Empty); } } } public bool ShowCategories { get { if ((Object)(object)instance != (Object)null) { if (!(instance._showPluginCategories == Info.GUID)) { return instance.IsSearching; } return true; } return false; } set { if ((Object)(object)instance != (Object)null) { instance._showPluginCategories = (value ? Info.GUID : string.Empty); } } } public int Height { get; set; } public override string ToString() { if (Info != null) { return $"{Info.Name} {Info.Version}"; } return ""; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] [HarmonyPriority(0)] public static class PlayerController_TakeInput_PreventInput { public static void Postfix(ref bool __result) { __result = __result && !instance.DisplayingWindow; } } [HarmonyPatch(typeof(TextInput), "IsVisible")] [HarmonyPriority(0)] public static class TextInput_IsVisible_PreventInput { public static void Postfix(ref bool __result) { __result = __result || instance.DisplayingWindow; } } [HarmonyPatch] public static class Inventory_PreventInput { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(InventoryGrid), "OnLeftClick", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(InventoryGrid), "OnRightClick", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(InventoryGui), "OnSelectedItem", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(InventoryGui), "OnRightClickItem", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Toggle), "OnSubmit", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Toggle), "OnPointerClick", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Player), "UseHotbarItem", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ScrollRect), "OnScroll", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static bool Prefix() { return !instance.DisplayingWindow; } } [HarmonyPatch] public static class Button_PreventInput { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(Button), "OnPointerClick", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Button), "OnSubmit", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Button), "Press", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static bool Prefix(Button __instance) { if (instance.DisplayingWindow) { return ((Object)__instance).name == "ConfigManager"; } return true; } } [HarmonyPatch] public static class ZInput_PreventPlayerInput { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "GetMouseButton", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetMouseButtonDown", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetMouseButtonUp", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetRadialTap", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetRadialMultiTap", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static bool Prefix(ref bool __result) { if (instance.DisplayingWindow) { return __result = false; } return true; } } [HarmonyPatch] public static class ZInput_Float_PreventMouseInput { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickX", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickY", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyRTrigger", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyLTrigger", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickX", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickY", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null); } [HarmonyPriority(0)] private static void Postfix(ref float __result) { if (instance.DisplayingWindow) { __result = 0f; } } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] public static class ZInput_GetMouseDelta_PreventMouseInput { [HarmonyPriority(0)] public static void Postfix(ref Vector2 __result) { //IL_000d: 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) if (instance.DisplayingWindow) { __result = Vector2.zero; } } } [HarmonyPatch(typeof(FejdStartup), "Start")] public static class FejdStartup_Start_MenuButton { public static void Postfix() { instance.SetupMenuButton(); } } [HarmonyPatch(typeof(Menu), "Start")] public static class Menu_Start_MenuButton { public static void Postfix() { instance.SetupMenuButton(); } } [HarmonyPatch(typeof(Menu), "UpdateNavigation")] public static class Menu_UpdateNavigation_MenuButton { public static void Postfix() { instance.SetupMenuButton(); } } internal const int HeaderSize = 20; internal const int DefaultWidth = 750; internal const int DefaultHeight = 900; internal float scaleFactor; internal Matrix4x4 guiMatrix; private float lastClickTime; private Vector2 lastClickPosition; private const float DoubleClickThreshold = 0.3f; private ConfigFilesEditor _configFilesEditor; private SettingEditWindow _configSettingWindow; internal string _selectedCategory; internal string _selectedPlugin; internal string _showPluginCategories; public const string GUID = "sighsorry.ConfigManager"; public const string pluginName = "ConfigManager"; public const string ModVersion = "1.0.0"; public const string Version = "1.0.0"; internal static ConfigurationManager instance; private static SettingFieldDrawer _fieldDrawer; private const int WindowId = -68; private const string SearchBoxName = "searchBox"; private bool _focusSearchBox; private string _searchString = string.Empty; public bool OverrideHotkey; private bool _displayingWindow; private bool _obsoleteCursor; private string _modsWithoutSettings; private List _allSettings; private List _filteredSetings = new List(); public Rect currentWindowRect; private Vector2 _settingWindowScrollPos; private readonly Dictionary _settingWindowCategoriesScrollPos = new Dictionary(); public static bool isTempWindowUnity6000 = true; private PropertyInfo _curLockState; private PropertyInfo _curVisible; private int _previousCursorLockState; private bool _previousCursorVisible; internal const string GeneralSection = "General"; internal const string InternalSection = "Internal"; internal const int GeneralSectionOrder = 500; private const bool PluginsInitiallyCollapsed = true; private const float SettingLabelWidth = 0.4f; private const float SplitViewPluginListWidth = 0.33f; internal const int NumericPrecision = 3; private static readonly KeyboardShortcut ResetWindowLayoutShortcut = new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }); public static ConfigEntry _showAdvanced; public static ConfigEntry _showKeybinds; public static ConfigEntry _loggingEnabled; public static ConfigEntry _keybind; public static ConfigEntry _textSize; public static ConfigEntry _splitView; public static ConfigEntry _windowPosition; public static ConfigEntry _windowSize; public static ConfigEntry _windowPositionTextEditor; public static ConfigEntry _windowSizeTextEditor; public static ConfigEntry _showEmptyFolders; public static ConfigEntry _showTrashBin; public static ConfigEntry _showFullName; public static ConfigEntry _textEditorFontSize; public static ConfigEntry _textEditorWordWrap; public static ConfigEntry _windowPositionEditSetting; public static ConfigEntry _windowSizeEditSetting; internal const string menuButtonName = "ConfigManager"; internal const string hiddenSettingsFileName = "ConfigManager.hiddensettings.txt"; public static ConfigEntry _showMainMenuButton; private const string MainMenuButtonCaption = "Mods settings"; private static readonly Harmony harmony = new Harmony("sighsorry.ConfigManager"); private static readonly FieldInfo fejdStartupMenuButtonsField = AccessTools.Field(typeof(FejdStartup), "m_menuButtons"); private static readonly FieldInfo menuCloseMenuStateField = AccessTools.Field(typeof(Menu), "m_closeMenuState"); private static readonly FieldInfo menuRebuildLayoutField = AccessTools.Field(typeof(Menu), "m_rebuildLayout"); private static readonly FieldInfo guiScalerMinWidthField = AccessTools.Field(typeof(GuiScaler), "m_minWidth"); private static readonly FieldInfo guiScalerMinHeightField = AccessTools.Field(typeof(GuiScaler), "m_minHeight"); private static readonly FieldInfo guiScalerLargeScaleField = AccessTools.Field(typeof(GuiScaler), "m_largeGuiScale"); private static HashSet hiddenSettings = new HashSet(StringComparer.Ordinal); private static DirectoryInfo pluginDirectory; private static DirectoryInfo configDirectory; private readonly List hiddenSettingsWatchers = new List(); private Coroutine hiddenSettingsReloadCoroutine; public bool SplitView { get { if (_splitView != null) { return _splitView.Value; } return true; } set { if (_splitView != null) { _splitView.Value = value; } } } public bool IsSearching => SearchString.Length > 1; public Rect DefaultWindowRect { get; private set; } internal Rect SettingWindowRect { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return currentWindowRect; } private set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) currentWindowRect = value; } } public bool IsWindowFullscreen => false; public float ScaleFactor => GetScreenSizeFactor(); public float ScreenWidth => (float)ScreenSystemWidth / ScaleFactor; public float ScreenHeight => (float)ScreenSystemHeight / ScaleFactor; public int ScreenSystemWidth { get { if (!isTempWindowUnity6000) { return Screen.width; } return Display.main.systemWidth; } } public int ScreenSystemHeight { get { if (!isTempWindowUnity6000) { return Screen.height; } return Display.main.systemHeight; } } internal static Texture2D WindowBackground { get; private set; } internal static Texture2D EntryBackground { get; private set; } internal static Texture2D TooltipBackground { get; private set; } internal static Texture2D HeaderBackground { get; private set; } internal static Texture2D HeaderBackgroundHover { get; private set; } internal static Texture2D SettingWindowBackground { get; private set; } internal int LeftColumnWidth { get; private set; } internal int RightColumnWidth { get; private set; } internal int PluginListColumnWidth { get; private set; } internal int SettingsListColumnWidth { get; private set; } internal static ThemePalette Palette { get; } = ThemePalette.CreateValheim(); public bool DisplayingWindow { get { return _displayingWindow; } set { if (_displayingWindow == value) { return; } _displayingWindow = value; SettingFieldDrawer.ClearCache(); CreateBackgrounds(); if (_displayingWindow) { BuildSettingList(); _focusSearchBox = false; 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(value)); } } public string SearchString { get { return _searchString; } private set { if (value == null) { value = string.Empty; } if (!(_searchString == value)) { _searchString = value; BuildFilteredSettingList(); } } } public event EventHandler> DisplayingWindowChanged; private void OnGUI() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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) if (DisplayingWindow) { ConfigurationManagerStyles.CreateStyles(); SetUnlockCursor(0, cursorVisible: true); if (scaleFactor != (scaleFactor = ScaleFactor)) { guiMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(scaleFactor, scaleFactor, 1f)); } ((Rect)(ref currentWindowRect)).size = _windowSize.Value; ((Rect)(ref currentWindowRect)).position = _windowPosition.Value; GUI.tooltip = ""; Matrix4x4 matrix = GUI.matrix; GUI.matrix = guiMatrix; GUI.Box(currentWindowRect, GUIContent.none, new GUIStyle()); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.WindowBackground; CalculateSettingsColumnsWidth(((Rect)(ref currentWindowRect)).width); currentWindowRect = GUILayout.Window(-68, currentWindowRect, new WindowFunction(SettingsWindow), "Configuration Manager", ConfigurationManagerStyles.GetWindowStyle(), Array.Empty()); if (!UnityInput.Current.GetKeyDown((KeyCode)323) && ((Rect)(ref currentWindowRect)).position != _windowPosition.Value) { SaveCurrentSizeAndPosition(); } GUI.backgroundColor = backgroundColor; _configFilesEditor.OnGUI(); _configSettingWindow.OnGUI(); GUI.matrix = matrix; } } private void CalculateSettingsColumnsWidth(float width) { PluginListColumnWidth = Mathf.RoundToInt(width * 0.33f); SettingsListColumnWidth = Mathf.RoundToInt(SplitView ? (width - (float)PluginListColumnWidth) : width); LeftColumnWidth = Mathf.Max(200, Mathf.RoundToInt(Mathf.Clamp((float)SettingsListColumnWidth * 0.4f, width * 0.1f, width * 0.6f)) - ConfigurationManagerStyles.fontSize / 2); RightColumnWidth = Mathf.Max(200, Mathf.RoundToInt(Mathf.Clamp((float)(SettingsListColumnWidth - LeftColumnWidth - ConfigurationManagerStyles.fontSize - 90 - ConfigurationManagerStyles.fontSize), width * 0.3f, width * 0.8f))); } internal void SaveCurrentSizeAndPosition() { //IL_000b: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0090: 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) _windowSize.Value = new Vector2(Mathf.Clamp(((Rect)(ref currentWindowRect)).size.x, 500f, ScreenWidth), Mathf.Clamp(((Rect)(ref currentWindowRect)).size.y, 200f, ScreenHeight)); _windowPosition.Value = new Vector2(Mathf.Clamp(((Rect)(ref currentWindowRect)).position.x, 0f, ScreenWidth - _windowSize.Value.x / 4f), Mathf.Clamp(((Rect)(ref currentWindowRect)).position.y, 0f, ScreenHeight - 40f)); ((BaseUnityPlugin)this).Config.Save(); SettingFieldDrawer.ClearComboboxCache(); } internal void ResetWindowSizeAndPosition() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003c: 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: Unknown result type (might be due to invalid IL or missing references) CalculateDefaultWindowRect(); _windowSize.Value = GetDefaultManagerWindowSize(); _windowPosition.Value = GetDefaultManagerWindowPosition(); _windowSizeTextEditor.Value = GetDefaultTextEditorWindowSize(); _windowPositionTextEditor.Value = GetDefaultTextEditorWindowPosition(); _windowPositionEditSetting.Value = GetDefaultEditSettingWindowPosition(); _windowSizeEditSetting.Value = GetDefaultEditSettingWindowSize(); ((BaseUnityPlugin)this).Config.Save(); SettingFieldDrawer.ClearComboboxCache(); } private void HandleHeaderDblClick(Rect titleBarRect) { //IL_0014: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (UnityInput.Current.GetMouseButtonDown(0) && ((Rect)(ref titleBarRect)).Contains(Event.current.mousePosition)) { float num = (float)Math.Round(Time.realtimeSinceStartup, 1); if (lastClickPosition == Event.current.mousePosition && num != lastClickTime && num - lastClickTime < 0.3f) { ResetWindowSizeAndPosition(); } lastClickTime = num; lastClickPosition = Event.current.mousePosition; } } private void SettingsWindow(int id) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0041: 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_0082: 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_006e: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref currentWindowRect)).width, 20f); HandleHeaderDblClick(val); GUI.DragWindow(val); DrawWindowHeader(); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.EntryBackground; if (SplitView) { DrawSplitView(); } else { DrawListView(); } GUI.backgroundColor = backgroundColor; if (!SettingFieldDrawer.DrawCurrentDropdown()) { DrawTooltip(currentWindowRect); } currentWindowRect = Utils.ResizeWindow(id, currentWindowRect, out var sizeChanged); if (sizeChanged) { SaveCurrentSizeAndPosition(); } } private void DrawSplitView() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)PluginListColumnWidth) }); _settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, Array.Empty()); try { CollectionExtensions.Do((IEnumerable)_filteredSetings, (Action)DrawPluginInSplitViewList); GUILayout.Space(5f); GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); GUILayout.Space(5f); } finally { GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.Space(5f); PluginSettingsData pluginSettingsData = _filteredSetings.FirstOrDefault((PluginSettingsData plg) => plg.Selected) ?? _filteredSetings.FirstOrDefault(); if (pluginSettingsData != null) { pluginSettingsData.Collapsed = false; bool selected = pluginSettingsData.Selected; bool flag = (pluginSettingsData.Selected = true); if (selected != flag) { pluginSettingsData.ShowCategories = true; } GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)SettingsListColumnWidth) }); bool hasCollapsedCategories = pluginSettingsData.Categories.Any((PluginSettingsData.PluginSettingsGroupData cat) => cat.Collapsed); SettingFieldDrawer.DrawPluginHeader(GetPluginHeaderName(pluginSettingsData, showGuid: true), pluginSettingsData.Collapsed, hasCollapsedCategories, withHover: false, out var toggleCollapseAll); _settingWindowCategoriesScrollPos[pluginSettingsData.Info.GUID] = GUILayout.BeginScrollView(_settingWindowCategoriesScrollPos.TryGetValue(pluginSettingsData.Info.GUID, out var value) ? value : Vector2.zero, false, true, Array.Empty()); try { DrawPluginCategories(pluginSettingsData, hasCollapsedCategories, toggleCollapseAll); } finally { GUILayout.EndScrollView(); } GUILayout.EndVertical(); } else { GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } private void DrawListView() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) _settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, Array.Empty()); float y = _settingWindowScrollPos.y; float height = ((Rect)(ref currentWindowRect)).height; GUILayout.BeginVertical(Array.Empty()); try { float num = 0f; foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Height == 0 || (num + (float)filteredSeting.Height >= y && num <= y + height)) { try { DrawSinglePlugin(filteredSeting); } catch (ArgumentException) { } if ((int)Event.current.type == 7) { Rect lastRect = GUILayoutUtility.GetLastRect(); filteredSeting.Height = (int)((Rect)(ref lastRect)).height; } } else { try { if (filteredSeting.Height > 0) { GUILayout.Space((float)filteredSeting.Height); } } catch (ArgumentException) { } } num += (float)(filteredSeting.Height + 1); } GUILayout.Space(20f); GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); GUILayout.Space(10f); } finally { GUILayout.EndVertical(); GUILayout.EndScrollView(); } } private void DrawWindowHeader() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0077: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.EntryBackground; GUILayout.BeginHorizontal(Array.Empty()); bool enabled = GUI.enabled; GUI.enabled = !IsSearching; bool value = _showAdvanced.Value; bool flag = (_showAdvanced.Value = GUILayout.Toggle(_showAdvanced.Value, new GUIContent("Advanced", "Show plugins and settings marked by author as advanced.\nFor example BepInEx settings are marked as advanced."), ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })); if (value != flag) { BuildFilteredSettingList(); } bool value2 = _showKeybinds.Value; flag = (_showKeybinds.Value = GUILayout.Toggle(_showKeybinds.Value, new GUIContent("Keybinds only", "Show only plugins and settings with keybind shortcuts"), ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })); if (value2 != flag) { BuildFilteredSettingList(); } GUI.enabled = enabled; GUILayout.Space(15f); DrawSearchBox(); GUILayout.Space(15f); if (GUILayout.Button("Show File Editor", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _configFilesEditor.IsOpen = !_configFilesEditor.IsOpen; } GUILayout.Space(15f); string text = (("List View".Length > "Split View".Length) ? "List View" : "Split View"); if (GUILayout.Button(SplitView ? "List View" : "Split View", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(false), GUILayout.Width(ConfigurationManagerStyles.GetButtonStyle().CalcSize(new GUIContent(text)).x) })) { SplitView = !SplitView; } if (GUILayout.Button("Close", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { DisplayingWindow = false; } GUILayout.EndHorizontal(); GUI.backgroundColor = backgroundColor; } private void DrawSearchBox() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.EntryBackground; GUI.SetNextControlName("searchBox"); SearchString = GUILayout.TextField(SearchString, ConfigurationManagerStyles.GetTextStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (string.IsNullOrEmpty(SearchString) && (int)Event.current.type == 7) { GUI.Label(GUILayoutUtility.GetLastRect(), "Search settings", ConfigurationManagerStyles.GetPlaceholderTextStyle()); } if (_focusSearchBox) { GUI.FocusWindow(-68); GUI.FocusControl("searchBox"); _focusSearchBox = false; } GUI.backgroundColor = Palette.Widget; if (GUILayout.Button("Clear", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { SearchString = string.Empty; } GUI.backgroundColor = backgroundColor; } private void DrawSinglePlugin(PluginSettingsData plugin) { GUILayout.BeginVertical(Array.Empty()); try { bool hasCollapsedCategories = plugin.Categories.Any((PluginSettingsData.PluginSettingsGroupData cat) => cat.Collapsed); if (SettingFieldDrawer.DrawPluginHeader(GetPluginHeaderName(plugin), plugin.Collapsed, hasCollapsedCategories, withHover: true, out var toggleCollapseAll) && !IsSearching) { plugin.Collapsed = !plugin.Collapsed; } if (IsSearching || !plugin.Collapsed) { DrawPluginCategories(plugin, hasCollapsedCategories, toggleCollapseAll); } } finally { GUILayout.EndVertical(); } } private GUIContent GetPluginHeaderName(PluginSettingsData plugin, bool showGuid = false) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown return new GUIContent(string.Format("{0} {1}{2}", plugin.Info.Name.TrimStart('!'), plugin.Info.Version, showGuid ? (" (" + plugin.Info.GUID + ")") : "")); } private void DrawPluginInSplitViewList(PluginSettingsData plugin) { //IL_000d: 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) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.EntryBackground; GUILayout.BeginHorizontal(ConfigurationManagerStyles.GetBackgroundStyle(withHover: true), Array.Empty()); if (SettingFieldDrawer.DrawPluginHeaderSplitViewList(GetPluginHeaderName(plugin), plugin.Selected)) { plugin.Selected = true; plugin.ShowCategories = !plugin.ShowCategories; } GUILayout.EndHorizontal(); if (IsSearching || (plugin.Selected && plugin.ShowCategories && plugin.Categories.Count > 1)) { GUILayout.BeginVertical(ConfigurationManagerStyles.GetCategorySplitViewBackgroundStyle(), Array.Empty()); CollectionExtensions.Do((IEnumerable)plugin.Categories, (Action)DrawPluginCategorySplitViewCollapsableList); GUILayout.EndVertical(); } GUI.backgroundColor = backgroundColor; void DrawPluginCategorySplitViewCollapsableList(PluginSettingsData.PluginSettingsGroupData category) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown GUILayout.BeginHorizontal(Array.Empty()); if (SettingFieldDrawer.DrawPluginCategorySplitViewList(new GUIContent(category.Name), category.Selected)) { plugin.Selected = true; category.Selected = !category.Selected; if (category.Selected) { category.Collapsed = false; } } GUILayout.EndHorizontal(); } } private void DrawPluginCategories(PluginSettingsData plugin, bool hasCollapsedCategories, bool toggleCollapseAll = false) { bool hasSelectedCategory = SplitView && plugin.Categories.Any((PluginSettingsData.PluginSettingsGroupData cat) => cat.Selected); CollectionExtensions.Do((IEnumerable)plugin.Categories, (Action)delegate(PluginSettingsData.PluginSettingsGroupData category) { DrawSingleCategory(plugin, hasCollapsedCategories, hasSelectedCategory, toggleCollapseAll, category); }); } private void DrawSingleCategory(PluginSettingsData plugin, bool hasCollapsedCategories, bool hasSelectedCategory, bool toggleCollapseAll, PluginSettingsData.PluginSettingsGroupData category) { //IL_000d: 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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (hasSelectedCategory && !category.Selected) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.EntryBackground; if (!string.IsNullOrEmpty(category.Name)) { if (toggleCollapseAll && !IsSearching) { category.Collapsed = !hasCollapsedCategories; } GUILayout.BeginVertical(ConfigurationManagerStyles.GetCategoryHeaderBackgroundStyle(withHover: true), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(false) }); bool num; if (!category.Collapsed || IsSearching) { if (!SettingFieldDrawer.DrawCategoryHeader(category.Name)) { goto IL_00cb; } num = !IsSearching; } else { num = SettingFieldDrawer.DrawCollapsedCategoryHeader(category.Name, category.Settings.All(ConfigurationManagerStyles.IsDefaultValue)); } if (num) { category.Collapsed = !category.Collapsed; } goto IL_00cb; } goto IL_00d0; IL_00cb: GUILayout.EndVertical(); goto IL_00d0; IL_00d0: if (category.Settings.Any() && (!category.Collapsed || IsSearching)) { GUILayout.BeginVertical(ConfigurationManagerStyles.GetCategoryBackgroundStyle(), Array.Empty()); try { CollectionExtensions.Do((IEnumerable)category.Settings, (Action)DrawSingleSetting); } finally { GUILayout.EndVertical(); } } GUI.backgroundColor = backgroundColor; } private void DrawSingleSetting(SettingEntryBase setting) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) Color contentColor = GUI.contentColor; bool enabled = GUI.enabled; if (setting.ReadOnly == true) { GUI.contentColor = Palette.ReadOnlyText; } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)SettingsListColumnWidth) }); try { DrawSettingName(setting); _fieldDrawer.DrawSettingValue(setting); DrawDefaultButton(setting); } catch (FormatException) { LogInfo("Incorrect input: " + setting.PluginInfo.Name + " - " + setting.Category + " - " + setting.DispName); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.Log((LogLevel)2, (object)$"Failed to draw setting {setting.PluginInfo.Name} - {setting.Category} - {setting.DispName}:\n{ex2}"); GUILayout.Label("Failed to draw this field, check log for details.", ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); } GUILayout.EndHorizontal(); if (!ComboBox.IsShown()) { GUI.enabled = enabled; } GUI.contentColor = contentColor; } private void DrawSettingName(SettingEntryBase setting) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_007b: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (!setting.HideSettingName) { Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.Widget; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)LeftColumnWidth), GUILayout.MaxWidth((float)LeftColumnWidth) }); GUILayout.Label(new GUIContent(setting.DispName.TrimStart('!'), setting.Description), ConfigurationManagerStyles.GetLabelStyleSettingName(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button(new GUIContent("Edit", setting.Description), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _configSettingWindow.EditSetting(setting); } GUILayout.EndHorizontal(); GUI.backgroundColor = backgroundColor; } } internal static void DrawDefaultButton(SettingEntryBase setting) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (setting.HideDefaultButton) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.Widget; if (setting.DefaultValue != null) { if (DrawResetButton()) { setting.Set(setting.DefaultValue); } } else if (setting.SettingType.IsClass && DrawResetButton()) { setting.Set(null); } GUI.backgroundColor = backgroundColor; static bool DrawResetButton() { GUILayout.Space(5f); return GUILayout.Button("Reset", ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } public void BuildSettingList() { SettingSearcher.CollectSettings(out var results, out var modsWithoutSettings); _modsWithoutSettings = string.Join(", ", (from x in modsWithoutSettings select x.TrimStart('!') into x orderby x select x).ToArray()); _allSettings = results.ToList(); BuildFilteredSettingList(); } public void BuildFilteredSettingList() { IEnumerable source = _allSettings; Dictionary, int> categoryOrders = (from setting in _allSettings where setting.PluginInfo != null group setting by Tuple.Create(setting.PluginInfo.GUID, setting.Category)).ToDictionary((IGrouping, SettingEntryBase> group) => group.Key, (IGrouping, SettingEntryBase> group) => (from setting in @group select setting.CategoryOrder into order where order != 0 select order).DefaultIfEmpty(0).Max()); if (HideSettings()) { source = source.Where((SettingEntryBase x) => !(x is ConfigSettingEntry configSettingEntry) || !configSettingEntry.ShouldBeHidden()); } if (IsSearching) { source = source.Where((SettingEntryBase x) => ContainsSearchString(x, SearchString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries))); } else { if (!_showAdvanced.Value) { source = source.Where((SettingEntryBase x) => x.IsAdvanced != true); } if (_showKeybinds.Value) { source = source.Where((SettingEntryBase x) => IsKeyboardShortcut(x)); } } HashSet nonDefaultCollapsedPluginState = new HashSet(); Dictionary, bool> collapsedCategoryState = new Dictionary, bool>(); foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (!filteredSeting.Collapsed) { nonDefaultCollapsedPluginState.Add(filteredSeting.Info.Name); } foreach (PluginSettingsData.PluginSettingsGroupData category in filteredSeting.Categories) { collapsedCategoryState[Tuple.Create(filteredSeting.Info.Name, category.Name)] = category.Collapsed; } } _filteredSetings = (from x in (from x in source group x by x.PluginInfo).Select(delegate(IGrouping pluginSettings) { List originalCategoryOrder = pluginSettings.Select((SettingEntryBase x) => x.Category).Distinct().ToList(); bool value; IEnumerable source2 = from x in pluginSettings group x by x.Category into x select new { Group = x, OriginalOrder = originalCategoryOrder.IndexOf(x.Key), ExplicitOrder = (categoryOrders.TryGetValue(Tuple.Create(pluginSettings.Key.GUID, x.Key), out value) ? value : 0) } into x orderby x.ExplicitOrder descending, x.OriginalOrder select new PluginSettingsData.PluginSettingsGroupData { ID = pluginSettings.Key.GUID + "-" + x.Group.Key, Name = x.Group.Key, Settings = (from set in x.Group orderby set.Order descending, set.DispName select set).ToList(), Collapsed = (collapsedCategoryState.TryGetValue(Tuple.Create(pluginSettings.Key.Name, x.Group.Key), out value) ? value : (originalCategoryOrder.Count > 20 && x.Group.All(ConfigurationManagerStyles.IsDefaultValue))) }; return new PluginSettingsData { Info = pluginSettings.Key, Categories = source2.ToList(), Collapsed = !nonDefaultCollapsedPluginState.Contains(pluginSettings.Key.Name) }; }) orderby x.Info.Name, x.Info.GUID select x).ToList(); } private static bool IsKeyboardShortcut(SettingEntryBase x) { return x.SettingType == typeof(KeyboardShortcut); } private 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.SettingType.Name + "\n" + setting.Get(); return searchStrings.All((string s) => combinedSearchTarget.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0); } private void CalculateDefaultWindowRect() { //IL_0062: 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_0073: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min((float)ScreenSystemWidth, 750f * (SplitView ? 1.33f : 1f)); int num2 = Mathf.Min(ScreenSystemHeight, 900); float num3 = (float)Mathf.RoundToInt(Mathf.Min((float)ScreenSystemWidth - num, (float)(ScreenSystemHeight - num2))) / 16f; DefaultWindowRect = new Rect(num3, num3, num, (float)num2); Rect defaultWindowRect = DefaultWindowRect; CalculateSettingsColumnsWidth(((Rect)(ref defaultWindowRect)).width); } internal static void DrawTooltip(Rect area) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00d3: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(GUI.tooltip)) { return; } Event current = Event.current; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Palette.TooltipBackground; float num = 0f; GUIStyle tooltipStyle = ConfigurationManagerStyles.GetTooltipStyle(); string text = GUI.tooltip.Replace("\r\n", "\n").Replace("\r", "\n"); string[] array = text.Split('\n'); float num2 = default(float); float num3 = default(float); foreach (string text2 in array) { tooltipStyle.CalcMinMaxWidth(new GUIContent(text2), ref num2, ref num3); if (num3 > num) { num = num3; } } num = Mathf.Min(num + 2f, ((Rect)(ref area)).width * 0.8f); float num4 = ConfigurationManagerStyles.GetTooltipStyle().CalcHeight(new GUIContent(text), num) + 10f; float num5 = ((current.mousePosition.x + num > ((Rect)(ref area)).width) ? (((Rect)(ref area)).width - num) : current.mousePosition.x); float num6 = ((current.mousePosition.y + 25f + num4 > ((Rect)(ref area)).height) ? (current.mousePosition.y - num4) : (current.mousePosition.y + 25f)); GUI.Box(new Rect(num5, num6, num, num4), text, ConfigurationManagerStyles.GetTooltipStyle()); GUI.backgroundColor = backgroundColor; } private void CreateBackgrounds() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0066: 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_0076: 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_008b: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown if ((Object)(object)WindowBackground == (Object)null) { Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, Palette.WindowBackground); val.Apply(); WindowBackground = val; Texture2D val2 = new Texture2D(1, 1, (TextureFormat)5, false); val2.SetPixel(0, 0, Palette.EntryBackground); val2.Apply(); EntryBackground = val2; Texture2D val3 = new Texture2D(1, 1, (TextureFormat)5, false); val3.SetPixel(0, 0, Palette.TooltipBackground); val3.Apply(); TooltipBackground = val3; Texture2D val4 = new Texture2D(1, 1, (TextureFormat)5, false); val4.SetPixel(0, 0, Palette.HeaderBackground); val4.Apply(); HeaderBackground = val4; Texture2D val5 = new Texture2D(1, 1, (TextureFormat)5, false); val5.SetPixel(0, 0, Palette.HeaderHoverBackground); val5.Apply(); HeaderBackgroundHover = val5; Texture2D val6 = new Texture2D(1, 1, (TextureFormat)5, false); val6.SetPixel(0, 0, Palette.SettingWindowBackground); val6.Apply(); SettingWindowBackground = val6; } } private 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); } } internal void SetRightColumnWidth(int value) { RightColumnWidth = value; } internal static void LogInfo(object data) { ConfigEntry loggingEnabled = _loggingEnabled; if (loggingEnabled != null && loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } } internal static void LogWarning(object data) { ConfigurationManager configurationManager = instance; if (configurationManager != null) { ((BaseUnityPlugin)configurationManager).Logger.LogWarning(data); } } internal static void LogError(object data) { ConfigurationManager configurationManager = instance; if (configurationManager != null) { ((BaseUnityPlugin)configurationManager).Logger.LogError(data); } } private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) instance = this; _fieldDrawer = new SettingFieldDrawer(this); _keybind = ((BaseUnityPlugin)this).Config.Bind("General", "Open manager shortcut", new KeyboardShortcut((KeyCode)282, Array.Empty()), Describe("Toggle the ConfigManager window.", 500, 1000)); _textSize = ((BaseUnityPlugin)this).Config.Bind("General", "Font size", 14, Describe("Font size used throughout ConfigManager.", 500, 900, (AcceptableValueBase)(object)new AcceptableValueRange(10, 30))); _loggingEnabled = ((BaseUnityPlugin)this).Config.Bind("Internal", "Verbose logging", false, HiddenDescription("Write diagnostic ConfigManager messages.")); _splitView = ((BaseUnityPlugin)this).Config.Bind("Internal", "Split view", true, HiddenDescription("Current layout selected from the window toolbar.")); _showAdvanced = ((BaseUnityPlugin)this).Config.Bind("Internal", "Show advanced entries", false, HiddenDescription("Current Advanced filter state.")); _showKeybinds = ((BaseUnityPlugin)this).Config.Bind("Internal", "Keybind-only filter", false, HiddenDescription("Current keybind filter state.")); _showEmptyFolders = ((BaseUnityPlugin)this).Config.Bind("Internal", "Show empty folders", false, HiddenDescription("Current file editor folder filter.")); _showTrashBin = ((BaseUnityPlugin)this).Config.Bind("Internal", "Show trash bin", true, HiddenDescription("Current file editor trash-bin filter.")); _showFullName = ((BaseUnityPlugin)this).Config.Bind("Internal", "Show active file path", true, HiddenDescription("Show the complete path of the active file.")); _textEditorFontSize = ((BaseUnityPlugin)this).Config.Bind("Internal", "File editor font size", 14, HiddenDescription("Font size selected in the file editor.", (AcceptableValueBase)(object)new AcceptableValueRange(8, 36))); _textEditorWordWrap = ((BaseUnityPlugin)this).Config.Bind("Internal", "File editor word wrap", true, HiddenDescription("Word-wrap state selected in the file editor.")); CalculateDefaultWindowRect(); _windowPosition = ((BaseUnityPlugin)this).Config.Bind("Internal", "Manager window position", GetDefaultManagerWindowPosition(), HiddenDescription("Main window position.")); _windowSize = ((BaseUnityPlugin)this).Config.Bind("Internal", "Manager window size", GetDefaultManagerWindowSize(), HiddenDescription("Main window size.")); _windowPositionTextEditor = ((BaseUnityPlugin)this).Config.Bind("Internal", "File editor window position", GetDefaultTextEditorWindowPosition(), HiddenDescription("File editor position.")); _windowSizeTextEditor = ((BaseUnityPlugin)this).Config.Bind("Internal", "File editor window size", GetDefaultTextEditorWindowSize(), HiddenDescription("File editor size.")); _windowPositionEditSetting = ((BaseUnityPlugin)this).Config.Bind("Internal", "Setting editor window position", GetDefaultEditSettingWindowPosition(), HiddenDescription("Setting editor position.")); _windowSizeEditSetting = ((BaseUnityPlugin)this).Config.Bind("Internal", "Setting editor window size", GetDefaultEditSettingWindowSize(), HiddenDescription("Setting editor size.")); currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value); _configFilesEditor = new ConfigFilesEditor(); _configSettingWindow = new SettingEditWindow(); } private static ConfigDescription Describe(string description, int categoryOrder, int order, AcceptableValueBase acceptableValues = null, bool advanced = false, bool browsable = true) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown return new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { CategoryOrder = categoryOrder, Order = order, IsAdvanced = advanced, Browsable = browsable } }); } private static ConfigDescription HiddenDescription(string description, AcceptableValueBase acceptableValues = null) { return Describe(description, 0, 0, acceptableValues, advanced: false, browsable: false); } private Vector2 GetDefaultManagerWindowPosition() { //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_0009: Unknown result type (might be due to invalid IL or missing references) Rect defaultWindowRect = DefaultWindowRect; return ((Rect)(ref defaultWindowRect)).position; } private Vector2 GetDefaultManagerWindowSize() { //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_0009: Unknown result type (might be due to invalid IL or missing references) Rect defaultWindowRect = DefaultWindowRect; return ((Rect)(ref defaultWindowRect)).size; } private Vector2 GetDefaultTextEditorWindowPosition() { //IL_0001: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) return new Vector2(GetDefaultManagerWindowPosition().x + GetDefaultManagerWindowSize().x + 20f, GetDefaultManagerWindowPosition().y); } private Vector2 GetDefaultTextEditorWindowSize() { //IL_0008: 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_0020: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) return new Vector2((float)ScreenSystemWidth - GetDefaultTextEditorWindowPosition().x - GetDefaultManagerWindowPosition().x, GetDefaultManagerWindowSize().y + GetDefaultManagerWindowPosition().y); } private Vector2 GetDefaultEditSettingWindowSize() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return new Vector2(500f, 500f); } private Vector2 GetDefaultEditSettingWindowPosition() { //IL_0001: 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_001e: 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_0034: 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) return new Vector2(GetDefaultManagerWindowPosition().x + GetDefaultManagerWindowSize().x + 10f, GetDefaultManagerWindowPosition().y + (GetDefaultManagerWindowSize().y - GetDefaultEditSettingWindowSize().y) / 2f); } private void OnDestroy() { _configFilesEditor?.Dispose(); instance = null; } private void Start() { 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) { ((BaseUnityPlugin)this).Logger.Log((LogLevel)12, (object)("WARNING: Failed to write to config directory, expect issues!\nError message:" + ex.Message)); } catch (UnauthorizedAccessException ex2) { ((BaseUnityPlugin)this).Logger.Log((LogLevel)12, (object)("WARNING: Permission denied to write to config directory, expect issues!\nError message:" + ex2.Message)); } isTempWindowUnity6000 = false; } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } if (OverrideHotkey) { return; } KeyboardShortcut val = ResetWindowLayoutShortcut; if (((KeyboardShortcut)(ref val)).IsDown()) { ResetWindowSizeAndPosition(); } if (!DisplayingWindow) { val = _keybind.Value; if (((KeyboardShortcut)(ref val)).IsDown()) { DisplayingWindow = true; return; } } if (!DisplayingWindow) { return; } if (!UnityInput.Current.GetKeyDown((KeyCode)27)) { val = _keybind.Value; if (!((KeyboardShortcut)(ref val)).IsDown()) { return; } } if (_configSettingWindow.IsOpen) { _configSettingWindow.IsOpen = false; } else { DisplayingWindow = false; } } private void LateUpdate() { if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } } public static void RegisterCustomSettingDrawer(Type settingType, Action onGuiDrawer) { if (settingType == null) { throw new ArgumentNullException("settingType"); } if (onGuiDrawer == null) { throw new ArgumentNullException("onGuiDrawer"); } if (SettingFieldDrawer.SettingDrawHandlers.ContainsKey(settingType)) { LogInfo("Tried to add a setting drawer for type " + settingType.FullName + " while one already exists."); } else { SettingFieldDrawer.SettingDrawHandlers[settingType] = onGuiDrawer; } } private void OnEnable() { _showMainMenuButton = ((BaseUnityPlugin)this).Config.Bind("General", "Show main-menu button", true, Describe("Add a main-menu button that opens ConfigManager.", 500, 800)); _showMainMenuButton.SettingChanged += MainMenuSettingChanged; harmony.PatchAll(); DisplayingWindowChanged += ConfigurationManager_DisplayingWindowChanged; pluginDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent; configDirectory = new DirectoryInfo(Paths.ConfigPath); _configFilesEditor?.SetWatching(enabled: true); SetupHiddenSettingsWatcher(); } private void OnDisable() { if (hiddenSettingsReloadCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(hiddenSettingsReloadCoroutine); hiddenSettingsReloadCoroutine = null; } DisposeHiddenSettingsWatchers(); _configFilesEditor?.SetWatching(enabled: false); if (_showMainMenuButton != null) { _showMainMenuButton.SettingChanged -= MainMenuSettingChanged; } Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } DisplayingWindowChanged -= ConfigurationManager_DisplayingWindowChanged; } private void MainMenuSettingChanged(object sender, EventArgs args) { SetupMenuButton(); } public void ToggleWindow() { DisplayingWindow = !DisplayingWindow; } private void SetupHiddenSettingsWatcher() { DisposeHiddenSettingsWatchers(); AddHiddenSettingsWatcher(pluginDirectory); if (!string.Equals(pluginDirectory.FullName, configDirectory.FullName, StringComparison.OrdinalIgnoreCase)) { AddHiddenSettingsWatcher(configDirectory); } ReadConfigs(); } private void AddHiddenSettingsWatcher(DirectoryInfo directory) { if (directory != null && directory.Exists) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(directory.FullName, "ConfigManager.hiddensettings.txt") { IncludeSubdirectories = false, NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite), SynchronizingObject = ThreadingHelper.SynchronizingObject }; fileSystemWatcher.Changed += QueueHiddenSettingsReload; fileSystemWatcher.Created += QueueHiddenSettingsReload; fileSystemWatcher.Renamed += QueueHiddenSettingsReload; fileSystemWatcher.Deleted += QueueHiddenSettingsReload; fileSystemWatcher.EnableRaisingEvents = true; hiddenSettingsWatchers.Add(fileSystemWatcher); } } private void DisposeHiddenSettingsWatchers() { foreach (FileSystemWatcher hiddenSettingsWatcher in hiddenSettingsWatchers) { hiddenSettingsWatcher.Dispose(); } hiddenSettingsWatchers.Clear(); } private void QueueHiddenSettingsReload(object sender, FileSystemEventArgs args) { if (((Behaviour)this).isActiveAndEnabled) { if (hiddenSettingsReloadCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(hiddenSettingsReloadCoroutine); } hiddenSettingsReloadCoroutine = ((MonoBehaviour)this).StartCoroutine(ReloadHiddenSettingsAfterDelay()); } } private IEnumerator ReloadHiddenSettingsAfterDelay() { yield return (object)new WaitForSecondsRealtime(0.2f); hiddenSettingsReloadCoroutine = null; ReadConfigs(); } private static void ReadConfigs(object sender = null, FileSystemEventArgs eargs = null) { HashSet hashSet = new HashSet(StringComparer.Ordinal); bool flag = false; foreach (string hiddenSettingsPath in GetHiddenSettingsPaths()) { if (!File.Exists(hiddenSettingsPath)) { continue; } LogInfo("Loading " + hiddenSettingsPath); try { using FileStream stream = new FileStream(hiddenSettingsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using StreamReader streamReader = new StreamReader(stream); int num = 0; string text; while ((text = streamReader.ReadLine()) != null) { num++; if (HiddenSettingsParser.TryParseLine(text, out var setting)) { hashSet.Add(setting); } else if (!Utility.IsNullOrWhiteSpace(text) && !text.TrimStart().StartsWith("#", StringComparison.Ordinal)) { flag = true; LogWarning($"Invalid hidden setting at {hiddenSettingsPath}:{num}; keeping the previous list"); } } } catch (Exception ex) { flag = true; LogWarning("Could not read hidden settings file (" + hiddenSettingsPath + "): " + ex.Message); } } if (!flag) { hiddenSettings = hashSet; LogInfo($"Loaded {hiddenSettings.Count} local hidden setting(s)"); if ((Object)(object)instance != (Object)null && instance._allSettings != null) { instance.BuildFilteredSettingList(); } } } private static IEnumerable GetHiddenSettingsPaths() { string pluginPath = Path.Combine(pluginDirectory.FullName, "ConfigManager.hiddensettings.txt"); yield return pluginPath; string text = Path.Combine(configDirectory.FullName, "ConfigManager.hiddensettings.txt"); if (!string.Equals(pluginPath, text, StringComparison.OrdinalIgnoreCase)) { yield return text; } } internal static bool IsSettingHidden(string setting) { return hiddenSettings.Contains(setting); } private void ConfigurationManager_DisplayingWindowChanged(object sender, ValueChangedEventArgs e) { if (Object.op_Implicit((Object)(object)FejdStartup.instance) && Object.op_Implicit((Object)(object)FejdStartup.instance.m_mainMenu) && FejdStartup.instance.m_mainMenu.activeSelf) { FejdStartup.instance.m_mainMenu.SetActive(false); FejdStartup.instance.m_mainMenu.SetActive(true); } if (Object.op_Implicit((Object)(object)Menu.instance)) { SetMenuCloseState(Menu.instance, DisplayingWindow ? "SettingsOpen" : "CanBeClosed"); menuRebuildLayoutField?.SetValue(Menu.instance, true); } } private bool HideSettings() { return hiddenSettings.Count > 0; } private void SetupMenuButton() { if (Object.op_Implicit((Object)(object)FejdStartup.instance) && Object.op_Implicit((Object)(object)FejdStartup.instance.m_menuList)) { SetupMainMenuButton(FejdStartup.instance.m_menuList.transform.Find("MenuEntries")); fejdStartupMenuButtonsField?.SetValue(FejdStartup.instance, FejdStartup.instance.m_menuList.GetComponentsInChildren