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.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ConditionalConfigSync; using ConfigurationManager.Utilities; using HarmonyLib; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Valheim Configuration Manager")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Valheim Configuration Manager")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0bac4d10-1d45-4b13-861c-48bae48536e9")] [assembly: AssemblyFileVersion("1.1.16")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.16.0")] [module: UnverifiableCode] 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_0001: 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_0001: 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_000e: 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_0026: 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_0037: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_010a: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_0001: Unknown result type (might be due to invalid IL or missing references) return FromRGBA(src); } public static implicit operator Color(HSLColor src) { //IL_0003: 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_000b: Unknown result type (might be due to invalid IL or missing references) return src.ToRGBA(); } } namespace ConfigurationManager { public class ConfigFilesEditor { private enum FileEditState { None, CreatingFolder, CreatingFile, RenamingFile } private static readonly string _trashBinDirectory = Path.Combine(Paths.CachePath, "ConfigurationManagerTrashBin"); private static readonly string[] _directories = new string[3] { Paths.ConfigPath, Paths.PluginPath, _trashBinDirectory }; private readonly Dictionary _folderStates = new Dictionary(); private Vector2 _scrollPosition; private string _fileContent; 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; 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_001e: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00d9: 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_00fb: 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._windowBackgroundColor.Value; _windowRect = GUI.Window(-680, _windowRect, new WindowFunction(DrawWindow), Utility.IsNullOrWhiteSpace(_activeFile) ? ConfigurationManager._windowTitleTextEditor.Value : ("..." + _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_000c: 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_0064: 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_0098: 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_00d8: 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 DrawFilters() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00f1: 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) GUILayout.BeginHorizontal(Array.Empty()); string value = ConfigurationManager._extensionsTitleTextEditor.Value; GUILayout.Label(value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(ConfigurationManagerStyles.GetLabelStyle().CalcSize(new GUIContent(value)).x + 2f) }); ConfigurationManager._editableExtensions.Value = GUILayout.TextField(ConfigurationManager._editableExtensions.Value, ConfigurationManagerStyles.GetTextStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); Color backgroundColor = GUI.backgroundColor; if (ConfigurationManager._hideModConfigs.Value) { GUI.backgroundColor = ConfigurationManager._enabledBackgroundColor.Value; } ConfigurationManager._hideModConfigs.Value = GUILayout.Toggle(ConfigurationManager._hideModConfigs.Value, new GUIContent(((ConfigEntryBase)ConfigurationManager._hideModConfigs).Definition.Key, ((ConfigEntryBase)ConfigurationManager._hideModConfigs).Description.Description), ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUI.backgroundColor = backgroundColor; GUILayout.EndHorizontal(); } private void DrawSearchBox() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00f8: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(ConfigurationManager._searchTextEditor.Value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(ConfigurationManagerStyles.GetLabelStyle().CalcSize(new GUIContent(ConfigurationManager._searchTextEditor.Value)).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._widgetBackgroundColor.Value; if (GUILayout.Button(ConfigurationManager._clearText.Value, 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()); bool flag = !Utility.IsNullOrWhiteSpace(_activeFile); try { GUI.enabled = flag && _fileContent != File.ReadAllText(_activeFile); if (GUILayout.Button(ConfigurationManager._saveFileTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { File.WriteAllText(_activeFile, _fileContent); } } catch (Exception ex) { _errorText = ex.Message; } finally { GUI.enabled = true; } GUI.enabled = flag; if (GUILayout.Button(ConfigurationManager._validateJsonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _errorText = IsValidJSON(_fileContent); } if (GUILayout.Button(ConfigurationManager._validateYamlTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _errorText = IsValidYAML(_fileContent); } GUI.enabled = true; GUILayout.Label(_errorText, ConfigurationManagerStyles.GetLabelStyle(isDefaultValue: false), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(ConfigurationManager._richTextFontSize.Value, 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 = result; } ConfigurationManager._textEditorWordWrap.Value = GUILayout.Toggle(ConfigurationManager._textEditorWordWrap.Value, ConfigurationManager._wordWrapTextEditor.Value, ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); ConfigurationManager._textEditorRichText.Value = GUILayout.Toggle(ConfigurationManager._textEditorRichText.Value, ConfigurationManager._richTextTextEditor.Value, ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (GUILayout.Button(ConfigurationManager._closeText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { IsOpen = false; } GUILayout.EndHorizontal(); } private void DrawWindow(int windowID) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._entryBackgroundColor.Value; GUILayout.BeginVertical(ConfigurationManagerStyles.GetBackgroundStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(GetFileListWidth()) }); DrawFilters(); 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) ? ConfigurationManager._newFolderLabelTextEditor.Value : ConfigurationManager._newFileLabelTextEditor.Value, 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(ConfigurationManager._newEntryOKButtonTextEditor.Value, 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; } string text = Path.Combine(directoryName, _newItemName); if (File.Exists(text)) { _newItemErrorText = ConfigurationManager._fileExistsTextEditor.Value; return; } try { File.Move(_activeFile, text); _activeFile = text; 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.Now:yyyyMMdd_HHmmss}{Path.GetExtension(text)}"); } try { if (_activeFile != null) { File.Move(_activeFile, text); } _activeFile = string.Empty; _fileContent = 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 fileSystemWatcher in watchers) { fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.Changed += delegate { ClearCache(); }; fileSystemWatcher.Created += delegate { ClearCache(); }; fileSystemWatcher.Deleted += delegate { ClearCache(); }; fileSystemWatcher.Renamed += delegate { ClearCache(); }; } } private void ClearCache() { _clearCache = true; FileSystemWatcher[] watchers = _watchers; foreach (FileSystemWatcher fileSystemWatcher in watchers) { fileSystemWatcher.EnableRaisingEvents = 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 = (Directory.Exists(path) ? Directory.GetFiles(path) : 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 = (Directory.Exists(path) ? Directory.GetDirectories(path) : 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; } if (ConfigurationManager._hideModConfigs.Value && Chainloader.PluginInfos.Values.Any((PluginInfo plugin) => plugin.Instance.Config.ConfigFilePath == file)) { return false; } string extension = Path.GetExtension(file).ToLower(); if (ConfigurationManager._editableExtensions.Value.Split(',').Select(GetNormalizedExtension).Any((string validExtension) => extension == validExtension)) { return Utility.IsNullOrWhiteSpace(SearchString) || fileName.IndexOf(SearchString, StringComparison.OrdinalIgnoreCase) > -1; } return false; } private static string GetNormalizedExtension(string extension) { if (Utility.IsNullOrWhiteSpace(extension)) { return string.Empty; } string text = extension.Trim().ToLower(); return text.StartsWith(".") ? text : ("." + text); } private bool DirectoryContainsValidFiles(string path) { return GetFiles(path).Any(IsValidFile) || GetDirectories(path).Any(DirectoryContainsValidFiles); } private void LoadFileToEditor(string filePath) { try { _fileContent = File.ReadAllText(filePath); _activeFile = filePath; _activeDirectory = Path.GetDirectoryName(filePath); _errorText = string.Empty; SetFileEditState(FileEditState.None); _focusTextArea = true; } catch (IOException ex) { ConfigurationManager.LogError("Failed to load file " + filePath + ": " + ex.Message); _errorText = "Failed to load file"; _fileContent = ex.Message; } } private void DrawDirectoriesMenu() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button(ConfigurationManager._newFolderButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.CreatingFolder); } if (GUILayout.Button(ConfigurationManager._newFileButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.CreatingFile); } if (GUILayout.Button(ConfigurationManager._renameFileButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { SetFileEditState(FileEditState.RenamingFile); _newItemName = Path.GetFileName(_activeFile); } if (GUILayout.Button(new GUIContent(ConfigurationManager._deleteFileButtonTextEditor.Value, ConfigurationManager._deleteFileTooltipTextEditor.Value), ConfigurationManagerStyles.GetButtonStyle(), Array.Empty())) { MoveActiveFileToTrash(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); ConfigurationManager._showEmptyFolders.Value = GUILayout.Toggle(ConfigurationManager._showEmptyFolders.Value, ConfigurationManager._showEmptyTextEditor.Value, ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.FlexibleSpace(); ConfigurationManager._showFullName.Value = GUILayout.Toggle(ConfigurationManager._showFullName.Value, new GUIContent(ConfigurationManager._showFullNameTextEditor.Value, ConfigurationManager._showFullNameTooltipTextEditor.Value), ConfigurationManagerStyles.GetToggleStyle(), Array.Empty()); ConfigurationManager._showTrashBin.Value = GUILayout.Toggle(ConfigurationManager._showTrashBin.Value, ConfigurationManager._showTrashBinTextEditor.Value, ConfigurationManagerStyles.GetToggleStyle(), Array.Empty()); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void CreateNewItem(string itemName, bool isFolder) { if (string.IsNullOrWhiteSpace(itemName) || string.IsNullOrEmpty(_activeDirectory)) { return; } string text = Path.Combine(_activeDirectory, itemName); try { if (isFolder) { Directory.CreateDirectory(text); ConfigurationManager._showEmptyFolders.Value = true; _activeDirectory = text; _activeFile = string.Empty; } else { File.Create(text).Close(); LoadFileToEditor(text); } SetFileEditState(FileEditState.None); } catch (Exception ex) { _newItemErrorText = ex.Message; } } public string IsValidJSON(string text) { if (Utility.IsNullOrWhiteSpace(text)) { return string.Empty; } try { JToken.Parse(text); return ConfigurationManager._fileIsValidJsonTextEditor.Value; } catch { return ConfigurationManager._fileIsNotValidJsonTextEditor.Value; } } public string IsValidYAML(string text) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (Utility.IsNullOrWhiteSpace(text)) { return string.Empty; } try { IDeserializer val = ((BuilderSkeleton)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); val.Deserialize(text); return ConfigurationManager._fileIsValidYamlTextEditor.Value; } catch { return ConfigurationManager._fileIsNotValidYamlTextEditor.Value; } } } internal sealed class ConfigSettingEntry : SettingEntryBase { private sealed class DynamicAttributeSource { private readonly object source; private readonly PropertyInfo readOnlyProperty; private readonly FieldInfo readOnlyField; private readonly PropertyInfo browsableProperty; private readonly FieldInfo browsableField; internal Type SourceType { get; } internal DynamicAttributeSource(object source, Type sourceType, PropertyInfo readOnlyProperty, FieldInfo readOnlyField, PropertyInfo browsableProperty, FieldInfo browsableField) { this.source = source; SourceType = sourceType; this.readOnlyProperty = readOnlyProperty; this.readOnlyField = readOnlyField; this.browsableProperty = browsableProperty; this.browsableField = browsableField; } internal bool TryGetReadOnly(out bool value) { return TryGetBoolean(readOnlyProperty, readOnlyField, out value); } internal bool TryGetBrowsable(out bool value) { return TryGetBoolean(browsableProperty, browsableField, out value); } private bool TryGetBoolean(PropertyInfo property, FieldInfo field, out bool value) { if (((property != null) ? property.GetValue(source, null) : field?.GetValue(source)) is bool flag) { value = flag; return true; } value = false; return false; } } private readonly ConfigSynchronizationInfo synchronizationInfo; private readonly List dynamicAttributeSources = new List(); 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); ConfigDescription description4 = entry.Description; InitializeDynamicAttributeSources((description4 != null) ? description4.Tags : null); synchronizationInfo = ConfigSynchronizationInfo.Create(entry); } 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)); } } private void InitializeDynamicAttributeSources(object[] tags) { if (tags == null) { return; } foreach (object obj in tags) { if (obj == null) { continue; } Type type = obj.GetType(); if (!(type.Name != "ConfigurationManagerAttributes")) { PropertyInfo property = type.GetProperty("ReadOnly", BindingFlags.Instance | BindingFlags.Public); FieldInfo field = type.GetField("ReadOnly", BindingFlags.Instance | BindingFlags.Public); PropertyInfo property2 = type.GetProperty("Browsable", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = type.GetField("Browsable", BindingFlags.Instance | BindingFlags.Public); if (property != null || field != null || property2 != null || field2 != null) { dynamicAttributeSources.Add(new DynamicAttributeSource(obj, type, property, field, property2, field2)); } } } } internal override bool RefreshDynamicAttributes() { bool? readOnly = base.ReadOnly; bool? browsable = base.Browsable; foreach (DynamicAttributeSource dynamicAttributeSource in dynamicAttributeSources) { try { if (dynamicAttributeSource.TryGetReadOnly(out var value)) { base.ReadOnly = value; } if (dynamicAttributeSource.TryGetBrowsable(out var value2)) { base.Browsable = value2; } } catch (Exception ex) { ConfigurationManager.LogInfo("Failed to refresh dynamic attributes from " + dynamicAttributeSource.SourceType.FullName + " - " + ex.Message); } } return readOnly != base.ReadOnly || browsable != base.Browsable; } public override object Get() { return Entry.BoxedValue; } protected override void SetValue(object newVal) { Entry.BoxedValue = newVal; } internal ConfigSynchronizationState GetSynchronizationState() { return synchronizationInfo.GetState(); } internal bool ToggleSynchronizationPolicy() { return synchronizationInfo.TogglePolicy(); } internal bool ShouldBeHidden() { return ConfigurationManager.hiddenSettings.Value.Contains(base.PluginInfo.GUID + "=" + Entry.Definition.Section + "=" + Entry.Definition.Key); } } internal enum ConfigSynchronizationProvider { None, Jotunn, ServerSync, ConditionalConfigSync } internal readonly struct ConfigSynchronizationState { internal static readonly ConfigSynchronizationState None = new ConfigSynchronizationState(ConfigSynchronizationProvider.None, isServerControlled: false, isConditional: false, isOverridden: false, canChangePolicy: false, string.Empty); internal ConfigSynchronizationProvider Provider { get; } internal bool IsServerControlled { get; } internal bool IsConditional { get; } internal bool IsOverridden { get; } internal bool CanChangePolicy { get; } internal string Tooltip { get; } internal bool IsVisible => IsConditional || IsServerControlled || IsOverridden; internal ConfigSynchronizationState(ConfigSynchronizationProvider provider, bool isServerControlled, bool isConditional, bool isOverridden, bool canChangePolicy, string tooltip) { Provider = provider; IsServerControlled = isServerControlled; IsConditional = isConditional; IsOverridden = isOverridden; CanChangePolicy = canChangePolicy; Tooltip = tooltip; } } internal abstract class ConfigSynchronizationInfo { private sealed class NoSynchronizationInfo : ConfigSynchronizationInfo { internal override ConfigSynchronizationState GetState() { return ConfigSynchronizationState.None; } } private sealed class ConditionalConfigSynchronizationInfo : ConfigSynchronizationInfo { private readonly OwnConfigEntryBase entry; private ConfigSyncMode lastMode; private bool lastDefaultServerControlled; private bool lastServerControlled; private bool lastOverridden; private ConfigSyncPolicyControlState lastPolicyControlState; private bool hasCachedState; private ConfigSynchronizationState cachedState; internal ConditionalConfigSynchronizationInfo(OwnConfigEntryBase entry) { this.entry = entry; } internal override ConfigSynchronizationState GetState() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0051: 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_00b5: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected I4, but got Unknown bool flag = (int)entry.SyncMode == 1; bool isSynchronizationOverridden = entry.IsSynchronizationOverridden; bool isServerControlled = entry.IsServerControlled; bool serverControlledByDefault = entry.ServerControlledByDefault; ConfigSyncPolicyControlState synchronizationPolicyControlState = entry.SynchronizationPolicyControlState; bool canChangePolicy = (int)synchronizationPolicyControlState == 1; if (hasCachedState && lastMode == entry.SyncMode && lastDefaultServerControlled == serverControlledByDefault && lastServerControlled == isServerControlled && lastOverridden == isSynchronizationOverridden && lastPolicyControlState == synchronizationPolicyControlState) { return cachedState; } string text = FormatOwnership(isServerControlled) + " setting\nSynchronization provider: Conditional Config Sync\n" + $"Mode: {entry.SyncMode}"; if (flag) { text = text + "\nMod default: " + FormatOwnership(serverControlledByDefault); text = ((!isSynchronizationOverridden) ? (text + "\nServer policy: No override; using mod default") : (text + $"\nServer policy override: {entry.EffectiveOverride}")); ConfigSyncPolicyControlState val = synchronizationPolicyControlState; ConfigSyncPolicyControlState val2 = val; text = (val2 - 1) switch { 0 => text + "\nClick to switch policy to " + FormatOwnership(!isServerControlled), 2 => text + "\nPolicy control: Requires administrator access", 1 => text + "\nPolicy control: Requires a compatible active server session", _ => text + "\nPolicy control: Fixed by the mod", }; } else { text += "\nPolicy control: Fixed by the mod"; } cachedState = new ConfigSynchronizationState(ConfigSynchronizationProvider.ConditionalConfigSync, isServerControlled, flag, isSynchronizationOverridden, canChangePolicy, text); lastMode = entry.SyncMode; lastDefaultServerControlled = serverControlledByDefault; lastServerControlled = isServerControlled; lastOverridden = isSynchronizationOverridden; lastPolicyControlState = synchronizationPolicyControlState; hasCachedState = true; return cachedState; } internal override bool TogglePolicy() { return entry.ToggleSynchronizationPolicy(); } } private sealed class ReflectedBooleanSynchronizationInfo : ConfigSynchronizationInfo { private readonly object source; private readonly FieldInfo field; private readonly PropertyInfo property; private readonly ConfigSynchronizationState serverControlledState; internal ReflectedBooleanSynchronizationInfo(ConfigSynchronizationProvider provider, object source, FieldInfo field, string providerName) { this.source = source; this.field = field; serverControlledState = CreateServerControlledState(provider, providerName); } internal ReflectedBooleanSynchronizationInfo(ConfigSynchronizationProvider provider, object source, PropertyInfo property, string providerName) { this.source = source; this.property = property; serverControlledState = CreateServerControlledState(provider, providerName); } internal override ConfigSynchronizationState GetState() { bool flag; try { flag = ((field != null) ? ((bool)field.GetValue(source)) : ((bool)property.GetValue(source))); } catch { return ConfigSynchronizationState.None; } if (!flag) { return ConfigSynchronizationState.None; } return serverControlledState; } private static ConfigSynchronizationState CreateServerControlledState(ConfigSynchronizationProvider provider, string providerName) { return new ConfigSynchronizationState(provider, isServerControlled: true, isConditional: false, isOverridden: false, canChangePolicy: false, "Server-controlled setting\nSynchronization provider: " + providerName + "\nPolicy control: Fixed by the synchronization provider"); } } private const BindingFlags InstanceMembers = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal static readonly ConfigSynchronizationInfo None = new NoSynchronizationInfo(); internal abstract ConfigSynchronizationState GetState(); internal virtual bool TogglePolicy() { return false; } internal static ConfigSynchronizationInfo Create(ConfigEntryBase entry) { ConfigDescription description = entry.Description; object[] array = ((description != null) ? description.Tags : null); if (array == null || array.Length == 0) { return None; } OwnConfigEntryBase val = array.OfType().FirstOrDefault((Func)((OwnConfigEntryBase tag) => tag.BaseConfig == entry)); if (val != null) { return new ConditionalConfigSynchronizationInfo(val); } object[] array2 = array; foreach (object obj in array2) { if (obj != null && TryCreateServerSyncInfo(entry, obj, out var info)) { return info; } } object[] array3 = array; foreach (object obj2 in array3) { if (obj2 != null && TryCreateJotunnInfo(obj2, out var info2)) { return info2; } } return None; } private static bool TryCreateServerSyncInfo(ConfigEntryBase entry, object tag, out ConfigSynchronizationInfo info) { info = null; Type type = tag.GetType(); if (!HasBaseType(type, "ServerSync.OwnConfigEntryBase")) { return false; } PropertyInfo property = type.GetProperty("BaseConfig", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field = type.GetField("SynchronizedConfig", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property == null || field?.FieldType != typeof(bool)) { return false; } try { if (property.GetValue(tag) != entry) { return false; } } catch { return false; } info = new ReflectedBooleanSynchronizationInfo(ConfigSynchronizationProvider.ServerSync, tag, field, "ServerSync"); return true; } private static bool TryCreateJotunnInfo(object tag, out ConfigSynchronizationInfo info) { info = null; Type type = tag.GetType(); if (!string.Equals(type.Assembly.GetName().Name, "Jotunn", StringComparison.Ordinal) || !string.Equals(type.Name, "ConfigurationManagerAttributes", StringComparison.Ordinal)) { return false; } PropertyInfo property = type.GetProperty("IsAdminOnly", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property?.PropertyType != typeof(bool)) { return false; } info = new ReflectedBooleanSynchronizationInfo(ConfigSynchronizationProvider.Jotunn, tag, property, "Jotunn"); return true; } private static bool HasBaseType(Type type, string fullName) { Type type2 = type; while (type2 != null) { if (string.Equals(type2.FullName, fullName, StringComparison.Ordinal)) { return true; } type2 = type2.BaseType; } return false; } private static string FormatOwnership(bool isServerControlled) { return isServerControlled ? "Server-controlled" : "Client-controlled"; } } 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 = null; 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 => setting != null && setting.SettingType != null && typeof(IList).IsAssignableFrom(setting.SettingType); 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_0095: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } setting.RefreshDynamicAttributes(); if (setting.Browsable == false) { IsOpen = false; return; } if (setting.ReadOnly == true) { valueToSet = setting.Get(); errorOnSetting = string.Empty; } ((Rect)(ref _windowRect)).size = ConfigurationManager._windowSizeEditSetting.Value; ((Rect)(ref _windowRect)).position = ConfigurationManager._windowPositionEditSetting.Value; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._windowBackgroundColor.Value; _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_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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)) { Type type = typeof(ConfigEntry<>).MakeGenericType(configSettingEntry.Entry.SettingType); ConstructorInfo constructorInfo = AccessTools.Constructor(type, 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_0050: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_000c: 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_005a: 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_008e: 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_00ce: 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_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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._entryBackgroundColor.Value; 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(ConfigurationManager._defaultValueDescriptionEditWindow.Value); float num = labelStyle.CalcSize(val).x + 3f; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(false) }); GUILayout.Label(ConfigurationManager._defaultValueDescriptionEditWindow.Value, 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); bool enabled = GUI.enabled; GUI.enabled = enabled && setting.ReadOnly != true; DrawSettingValue(); GUI.enabled = enabled; 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) { string value; if (!type.IsGenericType) { return typeMappings.TryGetValue(type, out value) ? value : type.Name; } Type[] genericArguments = type.GetGenericArguments(); string value2; string text = string.Join(", ", genericArguments.Select((Type t) => typeMappings.TryGetValue(t, out value2) ? value2 : t.Name)); return ZDOHelper.GetValueOrDefaultPiktiv((IDictionary)typeMappings, type, type.Name) + "<" + text + ">"; } private string GetValueRepresentation(object value, Type type) { //IL_001b: 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)) { return ((bool)value) ? ConfigurationManager._enabledText.Value : ConfigurationManager._disabledText.Value; } return value.ToString(); } private void DrawMenuButtons() { setting.RefreshDynamicAttributes(); bool valueOrDefault = setting.ReadOnly == true; GUILayout.BeginHorizontal(Array.Empty()); bool enabled = GUI.enabled; GUI.enabled = enabled && !valueOrDefault && !IsValueToSetDefaultValue(); DrawDefaultButton(); GUI.enabled = enabled; GUILayout.Label(ConfigurationManager._pressEscapeHintEditWindow.Value, ConfigurationManagerStyles.GetLabelStyleInfo(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); enabled = GUI.enabled; GUI.enabled = enabled && !valueOrDefault && !ConfigurationManagerStyles.IsEqualConfigValues(setting.SettingType, valueToSet, setting.Get()); if (GUILayout.Button(ConfigurationManager._applyButtonEditWindow.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { ApplySettingValue(); } GUI.enabled = enabled; if (GUILayout.Button(ConfigurationManager._closeText.Value, 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_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_000c: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value; 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(ConfigurationManager._editAsLabelEditWindow.Value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (editStringView != (editStringView = GUILayout.SelectionGrid(editStringView, new string[2] { ConfigurationManager._editAsTextEditWindow.Value, ConfigurationManager._editAsListEditWindow.Value }, 2, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))) { } if (editStringView > 0) { GUILayout.Label(ConfigurationManager._separatorLabelEditWindow.Value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (separator != (separator = GUILayout.TextField(separator, Array.Empty()))) { UpdateStringList(); } if (GUILayout.Button(ConfigurationManager._trimWhitespaceButtonEditWindow.Value, 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_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_000c: 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._widgetBackgroundColor.Value; 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_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) //IL_01eb: 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) //IL_010f: 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._fontColorValueDefault.Value : ConfigurationManager._fontColorValueChanged.Value); 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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(ConfigurationManager._rangeLabelEditWindow.Value, 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, ConfigurationManager._rangePrecision.Value + 2)) { valueToSet = Convert.ChangeType(Utils.RoundWithPrecision(num5, ConfigurationManager._rangePrecision.Value), 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, ConfigurationManager._rangePrecision.Value), 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Invalid comparison between Unknown and I4 //IL_01cb: 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(), ConfigurationManager._newValuePlaceholderEditWindow.Value, ConfigurationManagerStyles.GetPlaceholderTextStyle()); } if (GUILayout.Button(ConfigurationManager._addButtonEditWindow.Value, 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 { object obj = 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_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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (setting.HideDefaultButton) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value; 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(ConfigurationManager._resetSettingText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } } private void DrawBoolField() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_009d: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value; bool flag = (bool)valueToSet; Color backgroundColor = GUI.backgroundColor; if (flag) { GUI.backgroundColor = ConfigurationManager._enabledBackgroundColor.Value; } bool flag2 = GUILayout.SelectionGrid((!flag) ? 1 : 0, new string[2] { ConfigurationManager._enabledText.Value, ConfigurationManager._disabledText.Value }, 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0101: 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; for (; num4 < array.Length; num4++) { var anon = array[num4]; if (anon.val != 0) { bool flag = (num & anon.val) == anon.val; bool flag2 = (num2 & anon.val) == anon.val; GUIStyle buttonStyle = ConfigurationManagerStyles.GetButtonStyle(flag == flag2); int num6 = (int)buttonStyle.CalcSize(new GUIContent(anon.name)).x; num5 += num6; if ((float)num5 > num3) { break; } GUI.changed = false; if (GUILayout.Button(anon.name, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { flag = !flag; } if (GUI.changed) { long value = (flag ? (num | anon.val) : (num & ~anon.val)); valueToSet = Enum.ToObject(setting.SettingType, value); } } } GUILayout.EndHorizontal(); } GUI.changed = false; GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } private void DrawEnumListField() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_007e: 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_008a: 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) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, 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(ConfigurationManager._cancelText.Value, 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(ConfigurationManager._shortcutKeyText.Value), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = setting; } } } private void DrawKeyboardShortcut() { //IL_0179: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00b3: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, 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(ConfigurationManager._cancelText.Value, 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(ConfigurationManager._clearText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { valueToSet = KeyboardShortcut.Empty; _currentKeyboardShortcutToSet = null; } } } private void DrawVectorPart(int position) { if (1 == 0) { } string text = position switch { 0 => "X", 1 => "Y", 2 => "Z", 3 => "W", _ => "", }; if (1 == 0) { } string text2 = text; float result; bool isDefaultValue = Utils.TryParseFloat(vectorParts[position], out result) && vectorDefault[position] == result; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(text2 + " ", 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label($"{ConfigurationManager._precisionLabelEditWindow.Value}: {ConfigurationManager._vectorPrecision.Value} ", ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); float height = ConfigurationManagerStyles.GetTextStyle(setting).CalcHeight(new GUIContent(ConfigurationManager._vectorPrecision.Value.ToString()), 100f); ConfigurationManager._vectorPrecision.Value = Mathf.RoundToInt(DrawCenteredHorizontalSlider(ConfigurationManager._vectorPrecision.Value, 0f, 5f, height)); GUILayout.EndHorizontal(); } private void DrawColor() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00a2: 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_00af: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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; Color val2 = Utils.RoundColorToHEX(value); if (!ConfigurationManagerStyles.IsEqualColorConfig(val2, value2.Last)) { valueToSet = val2; value2.Tex.FillTexture(val2); value2.Last = val2; colorAsHEX = "#" + ColorUtility.ToHtmlStringRGBA(val2); } GUILayout.EndVertical(); } private bool DrawHexField(ref Color value, Color defaultValue) { //IL_0002: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_002e: 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_00cf: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) 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(ConfigurationManager._shortcutKeyText.Value, 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0036: 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_006d: Expected O, but got Unknown //IL_0068: 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_008f: 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_0146: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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 = Utils.RoundWithPrecision(settingValue, 3).ToString("0.000"); string text2 = GUILayout.TextField(text, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(val.x), GUILayout.ExpandWidth(false) }); float result; if (text2.StartsWith('1')) { SetColorValue(ref settingColor, 1f); } else if (text2.StartsWith('0') && settingValue == 1f) { SetColorValue(ref settingColor, 0f); } else if (Utils.TryParseFloat(text2, 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0036: 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_006d: Expected O, but got Unknown //IL_0068: 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_00bd: 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) 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.")); string text = Utils.RoundWithPrecision(settingValue, (fieldLabel == "Hue") ? 2 : 4).ToString((fieldLabel == "Hue") ? "000.00" : "0.0000"); if (Utils.TryParseFloat(GUILayout.TextField(text, 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_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) //IL_003b: 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_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_0084: 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_009e: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_014e: 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_016a: 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 { return string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName; } 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 { return string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName; } 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 Func ObjToStr { get; internal set; } public Func StrToObj { get; internal set; } internal string SettingID => (PluginInfo == null) ? "" : (PluginInfo.GUID + "-" + Category + "-" + DispName); public abstract object Get(); public void Set(object newVal) { RefreshDynamicAttributes(); if (ReadOnly != true) { SetValue(newVal); } } internal virtual bool RefreshDynamicAttributes() { return false; } 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) { object obj2 = obj; object obj3 = obj2; if (obj3 == null) { continue; } if (!(obj3 is DisplayNameAttribute displayNameAttribute)) { if (!(obj3 is CategoryAttribute categoryAttribute)) { if (!(obj3 is DescriptionAttribute descriptionAttribute)) { if (!(obj3 is DefaultValueAttribute defaultValueAttribute)) { if (!(obj3 is ReadOnlyAttribute readOnlyAttribute)) { if (!(obj3 is BrowsableAttribute browsableAttribute)) { Action action = obj3 as Action; if (action == null) { if (obj3 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_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_000c: 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) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value; 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_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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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._fontColorValueDefault.Value : ConfigurationManager._fontColorValueChanged.Value); 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) { if (ConfigurationManager._categoriesCollapseable.Value) { return GUILayout.Button(text, ConfigurationManagerStyles.GetCategoryStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } GUILayout.Label(text, ConfigurationManagerStyles.GetCategoryStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); return false; } 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) }); if (ConfigurationManager._categoriesCollapseable.Value) { 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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_008e: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value; bool flag = (bool)setting.Get(); Color backgroundColor = GUI.backgroundColor; if (flag) { GUI.backgroundColor = ConfigurationManager._enabledBackgroundColor.Value; } bool flag2 = GUILayout.Toggle(flag, flag ? ConfigurationManager._enabledText.Value : ConfigurationManager._disabledText.Value, 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00dd: 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 != 0) { 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_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_00c3: 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) 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if (x is Enum) { Type type = x.GetType(); DescriptionAttribute descriptionAttribute = type.GetMember(x.ToString()).FirstOrDefault()?.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false).Cast().FirstOrDefault(); if (descriptionAttribute != null) { return new GUIContent(descriptionAttribute.Description); } return new GUIContent(x.ToString().ToProperCase()); } return new GUIContent(x.ToString()); } private static void DrawRangeField(SettingEntryBase setting) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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, ConfigurationManager._rangePrecision.Value + 2)) { object newVal = Convert.ChangeType(Utils.RoundWithPrecision(num5, ConfigurationManager._rangePrecision.Value), 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, ConfigurationManager._rangePrecision.Value), 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 * (ConfigurationManager._compactConfigList.Value ? 0.3f : 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty()); if (!ConfigurationManager._compactConfigList.Value) { 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._fontColorValueChanged.Value; } 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._fontColorValueChanged.Value; } 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 { object obj = Convert.ChangeType(value, type); _canCovertCache[type] = true; return true; } catch { _canCovertCache[type] = false; return false; } } private static void DrawKeyCode(SettingEntryBase setting) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0080: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, 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(ConfigurationManager._cancelText.Value, 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(ConfigurationManager._shortcutKeyText.Value), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _currentKeyboardShortcutToSet = setting; } } } private static void DrawKeyboardShortcut(SettingEntryBase setting) { //IL_0173: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) if (_currentKeyboardShortcutToSet == setting) { GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, 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(ConfigurationManager._cancelText.Value, 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(ConfigurationManager._clearText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { setting.Set(KeyboardShortcut.Empty); _currentKeyboardShortcutToSet = null; } } } private static void DrawVector2(SettingEntryBase obj) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (Vector2)obj.Get(); Vector2 val2 = val; bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f; val.x = DrawSingleVectorSlider(val.x, "X", ((Vector2)obj.DefaultValue).x, integerValuesOnly); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector2)obj.DefaultValue).y, integerValuesOnly); if (val != val2) { obj.Set(val); } } private static void DrawVector3(SettingEntryBase obj) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0076: 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_00c4: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)obj.Get(); Vector3 val2 = val; bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f; val.x = DrawSingleVectorSlider(val.x, "X", ((Vector3)obj.DefaultValue).x, integerValuesOnly); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector3)obj.DefaultValue).y, integerValuesOnly); val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector3)obj.DefaultValue).z, integerValuesOnly); if (val != val2) { obj.Set(val); } } private static void DrawVector4(SettingEntryBase obj) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00d9: 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_0100: 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_010b: 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) Vector4 val = (Vector4)obj.Get(); Vector4 val2 = val; bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f && val.w % 1f == 0f; val.x = DrawSingleVectorSlider(val.x, "X", ((Vector4)obj.DefaultValue).x, integerValuesOnly); val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector4)obj.DefaultValue).y, integerValuesOnly); val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector4)obj.DefaultValue).z, integerValuesOnly); val.w = DrawSingleVectorSlider(val.w, "W", ((Vector4)obj.DefaultValue).w, integerValuesOnly); if (val != val2) { obj.Set(val); } } private static void DrawQuaternion(SettingEntryBase obj) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00d9: 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_0100: 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_010b: 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) Quaternion val = (Quaternion)obj.Get(); Quaternion val2 = val; bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f && val.w % 1f == 0f; val.x = DrawSingleVectorSlider(val.x, "X", ((Quaternion)obj.DefaultValue).x, integerValuesOnly); val.y = DrawSingleVectorSlider(val.y, "Y", ((Quaternion)obj.DefaultValue).y, integerValuesOnly); val.z = DrawSingleVectorSlider(val.z, "Z", ((Quaternion)obj.DefaultValue).z, integerValuesOnly); val.w = DrawSingleVectorSlider(val.w, "W", ((Quaternion)obj.DefaultValue).w, integerValuesOnly); if (val != val2) { obj.Set(val); } } private static float DrawSingleVectorSlider(float setting, string label, float defaultValue, bool integerValuesOnly) { GUILayout.Label(label, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); int num = ((!(ConfigurationManager._vectorDynamicPrecision.Value && integerValuesOnly)) ? Math.Abs(ConfigurationManager._vectorPrecision.Value) : 0); string text = GUILayout.TextField(setting.ToString("F" + num, CultureInfo.InvariantCulture), ConfigurationManagerStyles.GetTextStyle(setting, defaultValue), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (num == 0 && (text.EndsWith(".") || text.EndsWith(","))) { text = text + string.Empty.PadRight(Math.Abs(ConfigurationManager._vectorPrecision.Value - 1), '0') + 1; } Utils.TryParseFloat(text, out var result); return result; } private static void DrawColor(SettingEntryBase obj) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Invalid comparison between Unknown and I4 //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //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) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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) Color val = (Color)obj.Get(); Color value = Utils.RoundColorToHEX(val); Color val2 = Utils.RoundColorToHEX((Color)obj.DefaultValue); GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginVertical(ConfigurationManagerStyles.GetBoxStyle(), Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); bool isDefaultValue = DrawHexField(ref value, val2); GUILayout.Space(3f); GUIHelper.BeginColor(value); GUILayout.Label(string.Empty, ConfigurationManagerStyles.GetTextStyle(isDefaultValue), (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(val2.r)); GUILayout.Space(3f); DrawColorField("G", ref value, ref value.g, Utils.RoundColor(value.g) == Utils.RoundColor(val2.g)); GUILayout.Space(3f); DrawColorField("B", ref value, ref value.b, Utils.RoundColor(value.b) == Utils.RoundColor(val2.b)); GUILayout.Space(3f); DrawColorField("A", ref value, ref value.a, Utils.RoundColor(value.a) == Utils.RoundColor(val2.a)); Color val3 = Utils.RoundColorToHEX(value); if (!ConfigurationManagerStyles.IsEqualColorConfig(val3, val)) { obj.Set(val3); } if (!ConfigurationManagerStyles.IsEqualColorConfig(val3, value2.Last)) { value2.Tex.FillTexture(val3); value2.Last = val3; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(2f); GUILayout.EndVertical(); } private static bool DrawHexField(ref Color value, Color defaultValue) { //IL_0002: 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_0014: 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_0040: Expected O, but got Unknown //IL_003b: 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_0078: 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_006d: 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 = Utils.RoundWithPrecision(settingValue, 3).ToString("0.000"); string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(isDefaultValue), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MaxWidth(45f), GUILayout.ExpandWidth(true) }); float result; if (text2.StartsWith('1')) { SetColorValue(ref settingColor, 1f); } else if (text2.StartsWith('0') && settingValue == 1f) { SetColorValue(ref settingColor, 0f); } else if (Utils.TryParseFloat(text2, 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown PropertyInfo property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic); if (property == null) { throw new ArgumentNullException("coreConfigProp"); } ConfigFile source = (ConfigFile)property.GetValue(null, null); BepInPlugin bepinMeta = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString()); return ((IEnumerable>)source).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 pluginSplitViewContainerStyle; private static GUIStyle pluginHeaderStyleSplitView; private static GUIStyle pluginHeaderStyleSplitViewActive; private static GUIStyle pluginHeaderSplitViewBackgroundStyle; 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; private static GUIStyle synchronizationIndicatorStyle; private static GUIStyle settingRowStyle; public static int fontSize = 14; public static void CreateStyles() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0186: 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) //IL_01a0: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0241: 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_025b: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0373: 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_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Expected O, but got Unknown //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Expected O, but got Unknown //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Expected O, but got Unknown //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Expected O, but got Unknown //IL_0477: Expected O, but got Unknown //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Expected O, but got Unknown //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Expected O, but got Unknown //IL_04ce: Expected O, but got Unknown //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Expected O, but got Unknown //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Expected O, but got Unknown //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Expected O, but got Unknown //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Expected O, but got Unknown //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0766: Expected O, but got Unknown //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Expected O, but got Unknown //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Expected O, but got Unknown //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_0849: Expected O, but got Unknown //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Expected O, but got Unknown //IL_0949: Unknown result type (might be due to invalid IL or missing references) //IL_097e: Unknown result type (might be due to invalid IL or missing references) //IL_0988: Expected O, but got Unknown //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09a7: Unknown result type (might be due to invalid IL or missing references) //IL_09a8: Unknown result type (might be due to invalid IL or missing references) //IL_09b2: Expected O, but got Unknown //IL_09b3: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_09be: Expected O, but got Unknown //IL_09c4: Expected O, but got Unknown //IL_09c9: Unknown result type (might be due to invalid IL or missing references) //IL_09d3: Expected O, but got Unknown //IL_09fa: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Expected O, but got Unknown //IL_0a51: Unknown result type (might be due to invalid IL or missing references) //IL_0a5b: Expected O, but got Unknown //IL_0a75: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Expected O, but got Unknown //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0a9e: Unknown result type (might be due to invalid IL or missing references) //IL_0a9f: Unknown result type (might be due to invalid IL or missing references) //IL_0aa9: Expected O, but got Unknown //IL_0aaa: Unknown result type (might be due to invalid IL or missing references) //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0ab3: Unknown result type (might be due to invalid IL or missing references) //IL_0ac9: Expected O, but got Unknown //IL_0acf: Expected O, but got Unknown //IL_0ad9: Unknown result type (might be due to invalid IL or missing references) //IL_0ae3: Expected O, but got Unknown //IL_0af2: Unknown result type (might be due to invalid IL or missing references) //IL_0b74: Unknown result type (might be due to invalid IL or missing references) //IL_0b7e: Expected O, but got Unknown //IL_0b88: Unknown result type (might be due to invalid IL or missing references) //IL_0b92: Expected O, but got Unknown //IL_0b97: Unknown result type (might be due to invalid IL or missing references) //IL_0ba1: Expected O, but got Unknown //IL_0bb6: Unknown result type (might be due to invalid IL or missing references) //IL_0bc0: Expected O, but got Unknown //IL_0bd2: Unknown result type (might be due to invalid IL or missing references) //IL_0bdc: Expected O, but got Unknown //IL_0beb: Unknown result type (might be due to invalid IL or missing references) //IL_0c05: Unknown result type (might be due to invalid IL or missing references) //IL_0c15: Unknown result type (might be due to invalid IL or missing references) //IL_0c1f: Expected O, but got Unknown //IL_0c63: Unknown result type (might be due to invalid IL or missing references) //IL_0c6d: Expected O, but got Unknown //IL_0c7c: Unknown result type (might be due to invalid IL or missing references) //IL_0c96: Unknown result type (might be due to invalid IL or missing references) //IL_0ca6: Unknown result type (might be due to invalid IL or missing references) //IL_0cb0: Expected O, but got Unknown //IL_0cc1: Unknown result type (might be due to invalid IL or missing references) //IL_0ccb: Expected O, but got Unknown //IL_0cd5: Unknown result type (might be due to invalid IL or missing references) //IL_0cea: Unknown result type (might be due to invalid IL or missing references) //IL_0cf4: Expected O, but got Unknown //IL_0cfd: Unknown result type (might be due to invalid IL or missing references) //IL_0d07: Expected O, but got Unknown //IL_0d11: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Expected O, but got Unknown //IL_0d50: Unknown result type (might be due to invalid IL or missing references) //IL_0d7f: Unknown result type (might be due to invalid IL or missing references) //IL_0d8a: Unknown result type (might be due to invalid IL or missing references) //IL_0d94: Expected O, but got Unknown //IL_0dbe: Unknown result type (might be due to invalid IL or missing references) //IL_0dc8: Expected O, but got Unknown //IL_0dd2: Unknown result type (might be due to invalid IL or missing references) //IL_0de2: Unknown result type (might be due to invalid IL or missing references) //IL_0dec: Expected O, but got Unknown //IL_0e4f: Unknown result type (might be due to invalid IL or missing references) //IL_0e54: Unknown result type (might be due to invalid IL or missing references) //IL_0e5c: Unknown result type (might be due to invalid IL or missing references) //IL_0e64: Unknown result type (might be due to invalid IL or missing references) //IL_0e65: Unknown result type (might be due to invalid IL or missing references) //IL_0e6f: Expected O, but got Unknown //IL_0e70: Unknown result type (might be due to invalid IL or missing references) //IL_0e84: Unknown result type (might be due to invalid IL or missing references) //IL_0e8e: Expected O, but got Unknown //IL_0e94: Expected O, but got Unknown bool value = ConfigurationManager._compactConfigList.Value; 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._fontColor.Value; windowStyle.fontSize = fontSize; windowStyle.onNormal.textColor = ConfigurationManager._fontColor.Value; labelStyle = new GUIStyle(GUI.skin.label); labelStyle.normal.textColor = ConfigurationManager._fontColor.Value; labelStyle.fontSize = fontSize; int top; if (value) { RectOffset margin = labelStyle.margin; top = (labelStyle.margin.bottom = 1); margin.top = top; } labelStyleSettingName = new GUIStyle(labelStyle); labelStyleSettingName.wordWrap = true; labelStyleSettingName.clipping = (TextClipping)1; labelStyleInfo = new GUIStyle(labelStyleSettingName); labelStyleInfo.normal.textColor = ConfigurationManager._readOnlyColor.Value; labelStyleValueDefault = new GUIStyle(labelStyle); labelStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value; labelStyleValueChanged = new GUIStyle(labelStyle); labelStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; textStyle = new GUIStyle(GUI.skin.textArea); textStyle.normal.textColor = ConfigurationManager._fontColor.Value; textStyle.fontSize = fontSize; if (value) { RectOffset margin2 = textStyle.margin; top = (textStyle.margin.bottom = 1); margin2.top = top; } textStyleValueDefault = new GUIStyle(textStyle); textStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value; textStyleValueChanged = new GUIStyle(textStyle); textStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.normal.textColor = ConfigurationManager._fontColor.Value; buttonStyle.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; buttonStyle.fontSize = fontSize; if (value) { RectOffset margin3 = buttonStyle.margin; top = (buttonStyle.margin.bottom = 1); margin3.top = top; } buttonStyleValueDefault = new GUIStyle(buttonStyle); buttonStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value; buttonStyleValueDefault.onNormal.textColor = ConfigurationManager._fontColorValueDefault.Value; buttonStyleValueChanged = new GUIStyle(buttonStyle); buttonStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; buttonStyleValueChanged.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; categoryHeaderStyleDefault = new GUIStyle(labelStyle) { alignment = (TextAnchor)4, wordWrap = false, stretchWidth = true }; RectOffset padding = categoryHeaderStyleDefault.padding; top = (categoryHeaderStyleDefault.padding.bottom = 1); padding.top = top; categoryHeaderStyleChanged = new GUIStyle(categoryHeaderStyleDefault); categoryHeaderStyleChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; categoryHeaderStyleChanged.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginHeaderStyle = new GUIStyle(categoryHeaderStyleDefault); pluginHeaderStyleActive = new GUIStyle(pluginHeaderStyle); pluginHeaderStyleActive.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginSplitViewContainerStyle = new GUIStyle(GUIStyle.none) { stretchWidth = true, padding = new RectOffset(), margin = new RectOffset(0, 0, 0, 2) }; pluginHeaderStyleSplitView = new GUIStyle(labelStyle) { alignment = (TextAnchor)3, clipping = (TextClipping)1, wordWrap = false, stretchWidth = true, padding = new RectOffset(4, 2, value ? 1 : 2, value ? 1 : 2), margin = new RectOffset() }; if (value) { pluginHeaderStyleSplitView.normal.background = ConfigurationManager.EntryBackground; } pluginHeaderStyleSplitView.hover.background = ConfigurationManager.TooltipBackground; pluginHeaderStyleSplitView.active.background = ConfigurationManager.TooltipBackground; pluginHeaderStyleSplitView.hover.textColor = ConfigurationManager._fontColor.Value; pluginHeaderStyleSplitView.active.textColor = ConfigurationManager._fontColor.Value; pluginHeaderStyleSplitViewActive = new GUIStyle(pluginHeaderStyleSplitView); pluginHeaderStyleSplitViewActive.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginHeaderStyleSplitViewActive.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginHeaderStyleSplitViewActive.hover.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginHeaderStyleSplitViewActive.active.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginHeaderStyleSplitViewActive.fontStyle = (FontStyle)1; pluginCategoryStyleSplitView = new GUIStyle(labelStyle); RectOffset margin4 = pluginCategoryStyleSplitView.margin; top = (pluginCategoryStyleSplitView.margin.bottom = 2); margin4.top = top; pluginCategoryStyleSplitView.padding = new RectOffset(); pluginCategoryStyleSplitView.alignment = (TextAnchor)3; pluginCategoryStyleSplitView.wordWrap = false; pluginCategoryStyleSplitView.clipping = (TextClipping)1; pluginCategoryStyleSplitView.hover.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginCategoryStyleSplitView.hover.background = ConfigurationManager.HeaderBackground; pluginCategoryStyleSplitViewActive = new GUIStyle(pluginCategoryStyleSplitView); pluginCategoryStyleSplitViewActive.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginCategoryStyleSplitViewActive.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; pluginCategoryStyleSplitViewActive.fontStyle = (FontStyle)1; toggleStyle = new GUIStyle(GUI.skin.toggle); toggleStyle.normal.textColor = ConfigurationManager._fontColor.Value; toggleStyle.onNormal.textColor = ConfigurationManager._fontColor.Value; toggleStyle.fontSize = fontSize; toggleStyle.imagePosition = (ImagePosition)0; toggleStyle.padding.top = 2; toggleStyle.padding.left = 16; toggleStyle.margin.top = (ConfigurationManager._compactConfigList.Value ? 2 : 5); toggleStyleValueDefault = new GUIStyle(toggleStyle); toggleStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value; toggleStyleValueDefault.onNormal.textColor = ConfigurationManager._fontColorValueDefault.Value; toggleStyleValueChanged = new GUIStyle(toggleStyle); toggleStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value; toggleStyleValueChanged.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; boxStyle = new GUIStyle(GUI.skin.box); boxStyle.normal.textColor = ConfigurationManager._fontColor.Value; boxStyle.onNormal.textColor = ConfigurationManager._fontColor.Value; boxStyle.fontSize = fontSize; comboBoxStyle = new GUIStyle(GUI.skin.button); comboBoxStyle.normal = boxStyle.normal; comboBoxStyle.normal.textColor = ConfigurationManager._fontColorValueDefault.Value; comboBoxStyle.hover.background = comboBoxStyle.normal.background; comboBoxStyle.hover.textColor = ConfigurationManager._fontColorValueChanged.Value; 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._fontColor.Value; backgroundStyle.fontSize = fontSize; backgroundStyle.normal.background = ConfigurationManager.EntryBackground; backgroundStyleWithHover = new GUIStyle(backgroundStyle); backgroundStyleWithHover.hover.background = ConfigurationManager.TooltipBackground; pluginHeaderSplitViewBackgroundStyle = new GUIStyle(backgroundStyleWithHover) { margin = new RectOffset(), padding = new RectOffset() }; 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) { padding = new RectOffset(), margin = (value ? new RectOffset(20, 4, 2, 0) : new RectOffset(20, 4, 2, 2)) }; tooltipStyle = new GUIStyle(GUI.skin.box); tooltipStyle.normal.textColor = ConfigurationManager._fontColor.Value; 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._fontColorValueChanged.Value; fileEditorDirectoryStyleActive.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; 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._fontColorValueChanged.Value; fileEditorFileStyleActive.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value; 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 = ConfigurationManager._textEditorRichText.Value; fileEditorTextArea.alignment = ConfigurationManager._textEditorAlignment.Value; fileEditorTextArea.fontSize = ConfigurationManager._textEditorFontSize.Value; fileEditorTextArea.normal.textColor = ConfigurationManager._textEditorFontColor.Value; delimiterLine = new GUIStyle(); delimiterLine.normal.background = ConfigurationManager.EntryBackground; delimiterLine.fixedHeight = 2f; placeholderText = new GUIStyle(textStyleValueDefault); placeholderText.normal.textColor = Color.gray; synchronizationIndicatorStyle = new GUIStyle(buttonStyle); synchronizationIndicatorStyle.alignment = (TextAnchor)4; synchronizationIndicatorStyle.richText = true; synchronizationIndicatorStyle.wordWrap = false; synchronizationIndicatorStyle.stretchWidth = false; synchronizationIndicatorStyle.stretchHeight = false; synchronizationIndicatorStyle.padding.left = 3; synchronizationIndicatorStyle.padding.right = 3; settingRowStyle = new GUIStyle(GUIStyle.none) { stretchWidth = true, stretchHeight = false, padding = new RectOffset(), margin = new RectOffset(0, 0, (!ConfigurationManager._compactConfigList.Value) ? 1 : 0, 1) }; } public static GUIStyle GetWindowStyle() { return windowStyle; } public static GUIStyle GetCategoryStyle(bool isDefaultStyle = true) { return isDefaultStyle ? categoryHeaderStyleDefault : categoryHeaderStyleChanged; } public static GUIStyle GetHeaderStyle(bool isActive) { return isActive ? pluginHeaderStyleActive : pluginHeaderStyle; } public static GUIStyle GetPluginSplitViewContainerStyle() { return pluginSplitViewContainerStyle; } public static GUIStyle GetHeaderSplitViewStyle(bool isActivePlugin = false) { return isActivePlugin ? pluginHeaderStyleSplitViewActive : pluginHeaderStyleSplitView; } public static GUIStyle GetPluginHeaderSplitViewBackgroundStyle() { return pluginHeaderSplitViewBackgroundStyle; } public static GUIStyle GetCategorySplitViewStyle(bool isActiveCategory = false) { return isActiveCategory ? pluginCategoryStyleSplitViewActive : pluginCategoryStyleSplitView; } 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) { return withHover ? backgroundStyleWithHover : backgroundStyle; } public static GUIStyle GetCategoryBackgroundStyle() { return categoryBackgroundStyle; } public static GUIStyle GetCategoryHeaderBackgroundStyle(bool withHover = false) { return withHover ? categoryHeaderBackgroundStyleWithHover : categoryHeaderBackgroundStyle; } 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) { return isDefaultValue ? toggleStyleValueDefault : toggleStyleValueChanged; } public static GUIStyle GetToggleStyle(SettingEntryBase setting) { return GetToggleStyle(IsDefaultValue(setting)); } public static GUIStyle GetLabelStyle() { return labelStyle; } public static GUIStyle GetLabelStyle(bool isDefaultValue = true) { return isDefaultValue ? labelStyleValueDefault : labelStyleValueChanged; } 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) { return isDefaultValue ? buttonStyleValueDefault : buttonStyleValueChanged; } public static GUIStyle GetButtonStyle(SettingEntryBase setting) { return GetButtonStyle(IsDefaultValue(setting)); } public static GUIStyle GetTextStyle(bool isDefaultValue = true) { return isDefaultValue ? textStyleValueDefault : textStyleValueChanged; } 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) { return isActive ? fileEditorFileStyleActive : fileEditorFileStyle; } public static GUIStyle GetDirectoryStyle(bool isActive) { return isActive ? fileEditorDirectoryStyleActive : fileEditorDirectoryStyle; } 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 GUIStyle GetSynchronizationIndicatorStyle() { return synchronizationIndicatorStyle; } public static GUIStyle GetSettingRowStyle() { return settingRowStyle; } public static bool IsEqualColorConfig(Color setting, Color defaultValue) { //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_0007: 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_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(setting); Color32 val2 = Color32.op_Implicit(defaultValue); return val.r == val2.r && val.g == val2.g && val.b == val2.b && val.a == val2.a; } 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } if ((object)type == null) { goto IL_00ec; } bool result; if (type == typeof(Color)) { result = IsEqualColorConfig((Color)value1, (Color)value2); } else { Type type2 = type; if (type2 == typeof(Vector2)) { result = (Vector2)value1 == (Vector2)value2; } else { Type type3 = type; if (type3 == typeof(Vector3)) { result = (Vector3)value1 == (Vector3)value2; } else { Type type4 = type; if (type4 == typeof(Vector4)) { result = (Vector4)value1 == (Vector4)value2; } else { Type type5 = type; if (!(type5 == typeof(Quaternion))) { goto IL_00ec; } result = (Quaternion)value1 == (Quaternion)value2; } } } } goto IL_0102; IL_0102: if (1 == 0) { } return result; IL_00ec: result = value1.ToString().Equals(value2.ToString(), StringComparison.OrdinalIgnoreCase); goto IL_0102; } } [BepInPlugin("_shudnal.ConfigurationManager", "Valheim Configuration Manager", "1.1.16")] [BepInDependency("_shudnal.ConditionalConfigSync", "1.0.2")] [BepInIncompatibility("com.bepis.bepinex.configurationmanager")] public class ConfigurationManager : BaseUnityPlugin { public enum ReadOnlyStyle { Ignored, Colored, Disabled, Hidden } private sealed class PluginSettingsData { public sealed class PluginSettingsGroupData { public string ID; public string Name; public List Settings; public bool Collapsed; public bool Selected { get { return (Object)(object)instance != (Object)null && instance._selectedCategory == ID; } 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 { return (Object)(object)instance != (Object)null && instance._selectedPlugin == Info.GUID; } set { if ((Object)(object)instance != (Object)null) { instance._selectedPlugin = (value ? Info.GUID : string.Empty); } } } public bool ShowCategories { get { return (Object)(object)instance != (Object)null && (instance._showPluginCategories == Info.GUID || instance.IsSearching); } set { if ((Object)(object)instance != (Object)null) { instance._showPluginCategories = (value ? Info.GUID : string.Empty); } } } public int Height { get; set; } public override string ToString() { return (Info == null) ? "" : $"{Info.Name} {Info.Version}"; } } public enum PreventInput { Off, Player, All } [HarmonyPatch(typeof(PlayerController), "TakeInput")] [HarmonyPriority(0)] public static class PlayerController_TakeInput_PreventInput { public static void Postfix(ref bool __result) { if (PreventPlayerInput()) { __result = __result && !instance.DisplayingWindow; } } } [HarmonyPatch(typeof(TextInput), "IsVisible")] [HarmonyPriority(0)] public static class TextInput_IsVisible_PreventInput { public static void Postfix(ref bool __result) { if (PreventPlayerInput()) { __result = __result || instance.DisplayingWindow; } } } [HarmonyPatch] public static class Inventory_PreventAllInput { 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 !PreventPlayerInput() || !instance.DisplayingWindow; } } [HarmonyPatch] public static class Button_PreventAllInput { 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) { return !PreventPlayerInput() || !instance.DisplayingWindow || ((Object)__instance).name == "Configuration Manager"; } } [HarmonyPatch] public static class ZInput_PreventAllInput { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "ShouldAcceptInputFromSource", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKey", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKeyUp", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKeyDown", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButton", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButtonDown", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButtonUp", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static bool Prefix(ref bool __result) { return !PreventAllInput() || !instance.DisplayingWindow || (__result = false); } } [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) { return !PreventPlayerInput() || !instance.DisplayingWindow || (__result = false); } } [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 (PreventPlayerInput() && instance.DisplayingWindow) { __result = 0f; } } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] public static class ZInput_GetMouseDelta_PreventMouseInput { [HarmonyPriority(0)] public static void Postfix(ref Vector2 __result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (PreventPlayerInput() && 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 float lastDoubleClickTime; private Vector2 lastClickPosition; private const float DoubleClickThreshold = 0.3f; private ConfigFilesEditor _configFilesEditor; private SettingEditWindow _configSettingWindow; private int _dynamicAttributesRefreshFrame = -1; internal string _selectedCategory; internal string _selectedPlugin; internal string _showPluginCategories; public const string GUID = "_shudnal.ConfigurationManager"; public const string pluginName = "Valheim Configuration Manager"; public const string Version = "1.1.16"; 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(); private bool _windowWasMoved; private bool _showDebug; public static bool isTempWindowUnity6000 = true; private PropertyInfo _curLockState; private PropertyInfo _curVisible; private int _previousCursorLockState; private bool _previousCursorVisible; public static ConfigEntry _showAdvanced; public static ConfigEntry _showKeybinds; public static ConfigEntry _loggingEnabled; public static ConfigEntry _readOnlyStyle; public static ConfigEntry _keybind; public static ConfigEntry _keybindResetPosition; public static ConfigEntry _keybindResetScale; public static ConfigEntry _hideSingleSection; public static ConfigEntry _pluginConfigCollapsedDefault; public static ConfigEntry _textSize; public static ConfigEntry _orderPluginByGuid; public static ConfigEntry _rangePrecision; public static ConfigEntry _vectorPrecision; public static ConfigEntry _vectorDynamicPrecision; public static ConfigEntry _splitView; public static ConfigEntry _scaleFactor; public static ConfigEntry _splitViewListSize; public static ConfigEntry _columnSeparatorPosition; public static ConfigEntry _windowPosition; public static ConfigEntry _windowSize; public static ConfigEntry _showEditButton; public static ConfigEntry _compactConfigList; public static ConfigEntry _sortCategoriesByName; public static ConfigEntry _categoriesCollapseable; public static ConfigEntry _categoriesCollapsedDefault; public static ConfigEntry _windowTitle; public static ConfigEntry _normalText; public static ConfigEntry _shortcutsText; public static ConfigEntry _shortcutsTextTooltip; public static ConfigEntry _advancedText; public static ConfigEntry _advancedTextTooltip; public static ConfigEntry _compactListText; public static ConfigEntry _compactListTextTooltip; public static ConfigEntry _closeText; public static ConfigEntry _windowPositionTextEditor; public static ConfigEntry _windowSizeTextEditor; public static ConfigEntry _showEmptyFolders; public static ConfigEntry _hideModConfigs; public static ConfigEntry _showTrashBin; public static ConfigEntry _showFullName; public static ConfigEntry _textEditorFontSize; public static ConfigEntry _textEditorFontColor; public static ConfigEntry _textEditorWordWrap; public static ConfigEntry _textEditorAlignment; public static ConfigEntry _textEditorRichText; public static ConfigEntry _searchTextEditor; public static ConfigEntry _saveFileTextEditor; public static ConfigEntry _windowTitleTextEditor; public static ConfigEntry _editableExtensions; public static ConfigEntry _extensionsTitleTextEditor; public static ConfigEntry _validateJsonTextEditor; public static ConfigEntry _validateYamlTextEditor; public static ConfigEntry _newFileLabelTextEditor; public static ConfigEntry _newFolderLabelTextEditor; public static ConfigEntry _newEntryOKButtonTextEditor; public static ConfigEntry _fileExistsTextEditor; public static ConfigEntry _newFolderButtonTextEditor; public static ConfigEntry _newFileButtonTextEditor; public static ConfigEntry _renameFileButtonTextEditor; public static ConfigEntry _deleteFileButtonTextEditor; public static ConfigEntry _deleteFileTooltipTextEditor; public static ConfigEntry _showEmptyTextEditor; public static ConfigEntry _showTrashBinTextEditor; public static ConfigEntry _showFullNameTextEditor; public static ConfigEntry _showFullNameTooltipTextEditor; public static ConfigEntry _fileIsValidJsonTextEditor; public static ConfigEntry _fileIsNotValidJsonTextEditor; public static ConfigEntry _fileIsValidYamlTextEditor; public static ConfigEntry _fileIsNotValidYamlTextEditor; public static ConfigEntry _wordWrapTextEditor; public static ConfigEntry _richTextTextEditor; public static ConfigEntry _richTextFontSize; public static ConfigEntry _windowPositionEditSetting; public static ConfigEntry _windowSizeEditSetting; public static ConfigEntry _defaultValueDescriptionEditWindow; public static ConfigEntry _pressEscapeHintEditWindow; public static ConfigEntry _applyButtonEditWindow; public static ConfigEntry _editAsLabelEditWindow; public static ConfigEntry _editAsTextEditWindow; public static ConfigEntry _editAsListEditWindow; public static ConfigEntry _separatorLabelEditWindow; public static ConfigEntry _trimWhitespaceButtonEditWindow; public static ConfigEntry _rangeLabelEditWindow; public static ConfigEntry _addButtonEditWindow; public static ConfigEntry _newValuePlaceholderEditWindow; public static ConfigEntry _precisionLabelEditWindow; public static ConfigEntry _searchText; public static ConfigEntry _resetSettingText; public static ConfigEntry _clearText; public static ConfigEntry _cancelText; public static ConfigEntry _enabledText; public static ConfigEntry _disabledText; public static ConfigEntry _shortcutKeyText; public static ConfigEntry _shortcutKeysText; public static ConfigEntry _noOptionsPluginsText; public static ConfigEntry _toggleTextEditorText; public static ConfigEntry _viewModeListViewText; public static ConfigEntry _viewModeSplitViewText; public static ConfigEntry _editText; public static ConfigEntry _windowBackgroundColor; public static ConfigEntry _tooltipBackgroundColor; public static ConfigEntry _headerBackgroundColor; public static ConfigEntry _headerBackgroundHoverColor; public static ConfigEntry _entryBackgroundColor; public static ConfigEntry _editWindowBackgroundColor; public static ConfigEntry _fontColor; public static ConfigEntry _fontColorValueChanged; public static ConfigEntry _fontColorValueDefault; public static ConfigEntry _changedSynchronizationPolicyColor; public static ConfigEntry _widgetBackgroundColor; public static ConfigEntry _enabledBackgroundColor; public static ConfigEntry _readOnlyColor; internal const string menuButtonName = "Configuration Manager"; internal static string[] hiddenSettingsFileNames = new string[2] { "_shudnal.ConfigurationManager.hiddensettings.json", "shudnal.ConfigurationManager.hiddensettings.json" }; public static ConfigEntry _configLocked; public static ConfigEntry _pauseGame; public static ConfigEntry _preventInput; public static ConfigEntry _showMainMenuButton; public static ConfigEntry _mainMenuButtonCaption; public static ConfigEntry _useValheimGuiScaleFactor; private static readonly Harmony harmony = new Harmony("_shudnal.ConfigurationManager"); internal static readonly ConfigSync configSync = new ConfigSync("_shudnal.ConfigurationManager") { DisplayName = "Valheim Configuration Manager", CurrentVersion = "1.1.16", MinimumRequiredVersion = "1.1.16", ModRequired = false }; internal static readonly CustomSyncedValue> hiddenSettings = new CustomSyncedValue>((ConditionalConfigSync)(object)configSync, "Hidden settings", new List(), 0, (IEqualityComparer>)null); private static DirectoryInfo pluginDirectory; private static DirectoryInfo configDirectory; public bool SplitView { get { return _splitView == null || _splitView.Value; } 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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) currentWindowRect = value; } } public bool IsWindowFullscreen => false; public float ScaleFactor => _scaleFactor.Value * (_useValheimGuiScaleFactor.Value ? GetScreenSizeFactor() : 1f); public float ScreenWidth => (float)ScreenSystemWidth / ScaleFactor; public float ScreenHeight => (float)ScreenSystemHeight / ScaleFactor; public int ScreenSystemWidth => isTempWindowUnity6000 ? Display.main.systemWidth : Screen.width; public int ScreenSystemHeight => isTempWindowUnity6000 ? Display.main.systemHeight : Screen.height; 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; } 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_0074: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b3: 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_00c7: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0119: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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 = _windowBackgroundColor.Value; CalculateSettingsColumnsWidth(((Rect)(ref currentWindowRect)).width); currentWindowRect = GUILayout.Window(-68, currentWindowRect, new WindowFunction(SettingsWindow), _windowTitle.Value, 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 * _splitViewListSize.Value); SettingsListColumnWidth = Mathf.RoundToInt(SplitView ? (width - (float)PluginListColumnWidth) : width); LeftColumnWidth = Mathf.Max(200, Mathf.RoundToInt(Mathf.Clamp((float)SettingsListColumnWidth * _columnSeparatorPosition.Value, 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_000c: 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_0046: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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 ResetWindowScale() { _scaleFactor.Value = (float)((ConfigEntryBase)_scaleFactor).DefaultValue; } internal void ResetWindowSizeAndPosition() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) _splitViewListSize.Value = (float)((ConfigEntryBase)_splitViewListSize).DefaultValue; _columnSeparatorPosition.Value = (float)((ConfigEntryBase)_columnSeparatorPosition).DefaultValue; 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_0015: 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_0043: 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_00b6: Unknown result type (might be due to invalid IL or missing references) if (!UnityInput.Current.GetMouseButtonDown(0) || !((Rect)(ref titleBarRect)).Contains(Event.current.mousePosition)) { return; } float num = (float)Math.Round(Time.realtimeSinceStartup, 1); if (lastClickPosition == Event.current.mousePosition && num != lastClickTime && num - lastClickTime < 0.3f) { ResetWindowSizeAndPosition(); if (num != lastDoubleClickTime && num - lastDoubleClickTime < 0.3f) { ResetWindowScale(); } lastDoubleClickTime = num; } lastClickTime = num; lastClickPosition = Event.current.mousePosition; } private void SettingsWindow(int id) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_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_006f: 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_009a: 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_0085: Unknown result type (might be due to invalid IL or missing references) RefreshDynamicSettingAttributes(); 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 = _entryBackgroundColor.Value; 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 RefreshDynamicSettingAttributes() { if (_allSettings == null || _dynamicAttributesRefreshFrame == Time.frameCount) { return; } _dynamicAttributesRefreshFrame = Time.frameCount; bool flag = false; for (int i = 0; i < _allSettings.Count; i++) { if (_allSettings[i] is ConfigSettingEntry configSettingEntry && configSettingEntry.RefreshDynamicAttributes()) { flag = true; } } if (flag) { BuildFilteredSettingList(); } } private void DrawSplitView() { //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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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) PluginSettingsData pluginSettingsData = _filteredSetings.FirstOrDefault((PluginSettingsData plg) => plg.Selected) ?? _filteredSetings.FirstOrDefault(); if (pluginSettingsData != null) { pluginSettingsData.Collapsed = false; if (!pluginSettingsData.Selected) { pluginSettingsData.Selected = true; pluginSettingsData.ShowCategories = true; } } 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(_noOptionsPluginsText.Value + ": " + _modsWithoutSettings, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); GUILayout.Space(5f); } finally { GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.Space(5f); if (pluginSettingsData != null) { 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_0003: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) _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(_noOptionsPluginsText.Value + ": " + _modsWithoutSettings, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty()); GUILayout.Space(10f); } finally { GUILayout.EndVertical(); GUILayout.EndScrollView(); } } private void DrawWindowHeader() { //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_000c: 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_0083: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _entryBackgroundColor.Value; 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(_advancedText.Value, _advancedTextTooltip.Value), 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(_shortcutsText.Value, _shortcutsTextTooltip.Value), ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })); if (value2 != flag) { BuildFilteredSettingList(); } GUI.enabled = enabled; bool flag4 = GUILayout.Toggle(_compactConfigList.Value, new GUIContent(_compactListText.Value, _compactListTextTooltip.Value), ConfigurationManagerStyles.GetToggleStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (_compactConfigList.Value != flag4) { _compactConfigList.Value = flag4; } GUILayout.Space(15f); DrawSearchBox(); GUILayout.Space(15f); if (GUILayout.Button(_toggleTextEditorText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _configFilesEditor.IsOpen = !_configFilesEditor.IsOpen; } GUILayout.Space(15f); string text = ((_viewModeListViewText.Value.Length > _viewModeSplitViewText.Value.Length) ? _viewModeListViewText.Value : _viewModeSplitViewText.Value); if (GUILayout.Button(SplitView ? _viewModeListViewText.Value : _viewModeSplitViewText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(false), GUILayout.Width(ConfigurationManagerStyles.GetButtonStyle().CalcSize(new GUIContent(text)).x) })) { SplitView = !SplitView; } if (GUILayout.Button(_closeText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { DisplayingWindow = false; } GUILayout.EndHorizontal(); GUI.backgroundColor = backgroundColor; } private void DrawSearchBox() { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _entryBackgroundColor.Value; 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(), _searchText.Value, ConfigurationManagerStyles.GetPlaceholderTextStyle()); } if (_focusSearchBox) { GUI.FocusWindow(-68); GUI.FocusControl("searchBox"); _focusSearchBox = false; } GUI.backgroundColor = _widgetBackgroundColor.Value; if (GUILayout.Button(_clearText.Value, 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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _entryBackgroundColor.Value; GUILayout.BeginVertical(ConfigurationManagerStyles.GetPluginSplitViewContainerStyle(), Array.Empty()); try { GUILayout.BeginHorizontal(_compactConfigList.Value ? GUIStyle.none : ConfigurationManagerStyles.GetPluginHeaderSplitViewBackgroundStyle(), Array.Empty()); try { if (SettingFieldDrawer.DrawPluginHeaderSplitViewList(GetPluginHeaderName(plugin), plugin.Selected)) { plugin.Selected = true; plugin.ShowCategories = !plugin.ShowCategories; } } finally { 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(); } } finally { GUILayout.EndVertical(); GUI.backgroundColor = backgroundColor; } void DrawPluginCategorySplitViewCollapsableList(PluginSettingsData.PluginSettingsGroupData category) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) if (hasSelectedCategory && !category.Selected) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _entryBackgroundColor.Value; if (!string.IsNullOrEmpty(category.Name)) { if (!_categoriesCollapseable.Value) { category.Collapsed = false; } else if (toggleCollapseAll && !IsSearching) { category.Collapsed = !hasCollapsedCategories; } if (plugin.Categories.Count > 1 || !_hideSingleSection.Value) { GUILayout.BeginVertical(ConfigurationManagerStyles.GetCategoryHeaderBackgroundStyle(_categoriesCollapseable.Value), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(false) }); bool num; if (!category.Collapsed || IsSearching) { if (!SettingFieldDrawer.DrawCategoryHeader(category.Name)) { goto IL_0137; } num = !IsSearching; } else { num = SettingFieldDrawer.DrawCollapsedCategoryHeader(category.Name, category.Settings.All(ConfigurationManagerStyles.IsDefaultValue)); } if (num) { category.Collapsed = !category.Collapsed; } goto IL_0137; } } goto IL_013f; IL_0137: GUILayout.EndVertical(); goto IL_013f; IL_013f: 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_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_017c: 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) Color contentColor = GUI.contentColor; bool enabled = GUI.enabled; if (setting.ReadOnly == true && _readOnlyStyle.Value != ReadOnlyStyle.Ignored) { if (enabled) { GUI.enabled = _readOnlyStyle.Value != ReadOnlyStyle.Disabled; } if (_readOnlyStyle.Value == ReadOnlyStyle.Colored) { GUI.contentColor = _readOnlyColor.Value; } } GUILayout.BeginHorizontal(ConfigurationManagerStyles.GetSettingRowStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)SettingsListColumnWidth) }); try { DrawSettingName(setting, enabled); _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, bool interactionEnabled) { //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_001b: 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_0081: Expected O, but got Unknown //IL_00dd: 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_00c6: Expected O, but got Unknown if (!setting.HideSettingName) { Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; 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) }); DrawSynchronizationIndicator(setting, interactionEnabled); if (_showEditButton.Value && GUILayout.Button(new GUIContent(_editText.Value, setting.Description), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { _configSettingWindow.EditSetting(setting); } GUILayout.EndHorizontal(); GUI.backgroundColor = backgroundColor; } } private static void DrawSynchronizationIndicator(SettingEntryBase setting, bool interactionEnabled) { //IL_00e3: 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_0074: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009f: 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_00d0: Expected O, but got Unknown if (!(setting is ConfigSettingEntry configSettingEntry)) { return; } ConfigSynchronizationState synchronizationState = configSettingEntry.GetSynchronizationState(); if (!synchronizationState.IsVisible) { return; } string symbol = (synchronizationState.IsServerControlled ? "S" : "C"); Color color = ((synchronizationState.IsConditional && synchronizationState.IsOverridden) ? _changedSynchronizationPolicyColor.Value : _fontColor.Value); symbol = ColorizeSynchronizationSymbol(symbol, color); bool enabled = GUI.enabled; Color contentColor = GUI.contentColor; try { GUI.enabled = interactionEnabled && synchronizationState.CanChangePolicy; GUI.contentColor = Color.white; if (GUILayout.Button(new GUIContent(symbol, synchronizationState.Tooltip), ConfigurationManagerStyles.GetSynchronizationIndicatorStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { configSettingEntry.ToggleSynchronizationPolicy(); } } finally { GUI.contentColor = contentColor; GUI.enabled = enabled; } } private static string ColorizeSynchronizationSymbol(string symbol, Color color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return "" + symbol + ""; } internal static void DrawDefaultButton(SettingEntryBase setting) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (setting.HideDefaultButton) { return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; 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(_resetSettingText.Value, 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.Where((SettingEntryBase x) => x.Browsable != false); if (_readOnlyStyle.Value == ReadOnlyStyle.Hidden) { source = source.Where((SettingEntryBase x) => x.ReadOnly != true); } if (HideSettings()) { source = source.Where((SettingEntryBase x) => !((ConfigSettingEntry)x).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)); } } bool settingsAreCollapsed = _pluginConfigCollapsedDefault.Value; HashSet nonDefaultCollapsedPluginState = new HashSet(); Dictionary, bool> collapsedCategoryState = new Dictionary, bool>(); foreach (PluginSettingsData filteredSeting in _filteredSetings) { if (filteredSeting.Collapsed != settingsAreCollapsed) { 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 orderby _sortCategoriesByName.Value ? (-1) : originalCategoryOrder.IndexOf(x.Key), x.Key select new PluginSettingsData.PluginSettingsGroupData { ID = pluginSettings.Key.GUID + "-" + x.Key, Name = x.Key, Settings = (from set in x orderby set.Order descending, set.DispName select set).ToList(), Collapsed = (_categoriesCollapseable.Value && (collapsedCategoryState.TryGetValue(Tuple.Create(pluginSettings.Key.Name, x.Key), out value) ? value : (_categoriesCollapsedDefault.Value && originalCategoryOrder.Count > 20 && x.All(ConfigurationManagerStyles.IsDefaultValue)))) }; return new PluginSettingsData { Info = pluginSettings.Key, Categories = source2.ToList(), Collapsed = (nonDefaultCollapsedPluginState.Contains(pluginSettings.Key.Name) ? (!settingsAreCollapsed) : settingsAreCollapsed) }; }) orderby _orderPluginByGuid.Value ? x.Info.GUID : x.Info.Name 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min((float)ScreenSystemWidth, 750f * (SplitView ? (1f + _splitViewListSize.Value) : 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_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_0027: 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_0090: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0157: 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) if (string.IsNullOrEmpty(GUI.tooltip)) { return; } Event current = Event.current; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = _tooltipBackgroundColor.Value; 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0026: 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) //IL_0049: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_007c: 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_00a0: Expected O, but got Unknown //IL_00a9: 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_00cf: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)WindowBackground == (Object)null) { Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, _windowBackgroundColor.Value); val.Apply(); WindowBackground = val; Texture2D val2 = new Texture2D(1, 1, (TextureFormat)5, false); val2.SetPixel(0, 0, _entryBackgroundColor.Value); val2.Apply(); EntryBackground = val2; Texture2D val3 = new Texture2D(1, 1, (TextureFormat)5, false); val3.SetPixel(0, 0, _tooltipBackgroundColor.Value); val3.Apply(); TooltipBackground = val3; Texture2D val4 = new Texture2D(1, 1, (TextureFormat)5, false); val4.SetPixel(0, 0, _headerBackgroundColor.Value); val4.Apply(); HeaderBackground = val4; Texture2D val5 = new Texture2D(1, 1, (TextureFormat)5, false); val5.SetPixel(0, 0, _headerBackgroundHoverColor.Value); val5.Apply(); HeaderBackgroundHover = val5; Texture2D val6 = new Texture2D(1, 1, (TextureFormat)5, false); val6.SetPixel(0, 0, _editWindowBackgroundColor.Value); val6.Apply(); SettingWindowBackground = val6; } } private void UpdateBackgrounds() { Object.Destroy((Object)(object)WindowBackground); Object.Destroy((Object)(object)EntryBackground); Object.Destroy((Object)(object)TooltipBackground); Object.Destroy((Object)(object)HeaderBackground); Object.Destroy((Object)(object)HeaderBackgroundHover); Object.Destroy((Object)(object)SettingWindowBackground); WindowBackground = null; EntryBackground = null; TooltipBackground = null; HeaderBackground = null; HeaderBackgroundHover = null; SettingWindowBackground = null; CreateBackgrounds(); } 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) { if (_loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } } internal static void LogWarning(object data) { if (_loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogWarning(data); } } internal static void LogError(object data) { if (_loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogError(data); } } private void Awake() { //IL_0027: 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: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0d60: Unknown result type (might be due to invalid IL or missing references) //IL_0d94: Unknown result type (might be due to invalid IL or missing references) //IL_0dc8: Unknown result type (might be due to invalid IL or missing references) //IL_0dfc: Unknown result type (might be due to invalid IL or missing references) //IL_0e30: Unknown result type (might be due to invalid IL or missing references) //IL_0e64: Unknown result type (might be due to invalid IL or missing references) //IL_0e98: Unknown result type (might be due to invalid IL or missing references) //IL_0ecc: Unknown result type (might be due to invalid IL or missing references) //IL_0f00: Unknown result type (might be due to invalid IL or missing references) //IL_0fbe: Unknown result type (might be due to invalid IL or missing references) //IL_0ff2: Unknown result type (might be due to invalid IL or missing references) //IL_1026: Unknown result type (might be due to invalid IL or missing references) //IL_105a: Unknown result type (might be due to invalid IL or missing references) //IL_1075: Unknown result type (might be due to invalid IL or missing references) //IL_107f: Unknown result type (might be due to invalid IL or missing references) //IL_1084: Unknown result type (might be due to invalid IL or missing references) //IL_1089: Unknown result type (might be due to invalid IL or missing references) instance = this; _fieldDrawer = new SettingFieldDrawer(this); _keybind = config("General", "Show config manager", new KeyboardShortcut((KeyCode)282, Array.Empty()), "The shortcut used to toggle the config manager window on and off.\nThe key can be overridden by a game-specific plugin if necessary, in that case this setting is ignored."); _hideSingleSection = config("General", "Hide single sections", defaultValue: false, "Show section title for plugins with only one section"); _loggingEnabled = config("General", "Logging enabled", defaultValue: false, "Enable logging"); _pluginConfigCollapsedDefault = config("General", "Plugin collapsed default", defaultValue: true, "If set to true plugins will be collapsed when opening the configuration manager window"); _textSize = config("General", "Font size", 14, "Font size"); _orderPluginByGuid = config("General", "Order plugins by GUID", defaultValue: false, "Default order is by plugin name"); _rangePrecision = config("General", "Range field precision", 3, new ConfigDescription("Number of symbols after comma in floating-point numbers", (AcceptableValueBase)(object)new AcceptableValueRange(2, 5), Array.Empty())); _vectorPrecision = config("General", "Vector field precision", 2, new ConfigDescription("Number of symbols after comma in vectors", (AcceptableValueBase)(object)new AcceptableValueRange(2, 5), Array.Empty())); _vectorDynamicPrecision = config("General", "Vector field dynamic precision", defaultValue: true, "If every value in vector is integer .0 part will be omitted. Type \",\" or \".\" in vector field to enable precision back."); _keybindResetPosition = config("General", "Reset position and size", new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Set configuration manager window size and position to default values."); _keybindResetScale = config("General", "Reset scale", new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Set configuration manager window scale to default value."); _orderPluginByGuid.SettingChanged += delegate { BuildSettingList(); }; _splitView = config("General - Window", "Split View", defaultValue: true, "If enabled - plugins will be shown in the left column and plugin settings will be shown in the right column."); _scaleFactor = config("General - Window", "Scale factor", 1f, new ConfigDescription("Scale factor of configuration manager window. Triple click on configuration manager window title to reset scale.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 2.5f), Array.Empty())); _splitViewListSize = config("General - Window", "Split View list relative size", 0.33f, new ConfigDescription("Relative size (percentage of window width) of split view plugin names list", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 0.5f), Array.Empty())); _columnSeparatorPosition = config("General - Window", "Setting name relative size", 0.4f, new ConfigDescription("Relative position of virtual line separating setting name from value", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 0.6f), Array.Empty())); CalculateDefaultWindowRect(); _windowPosition = config("General - Window", "Window position", GetDefaultManagerWindowPosition(), "Window position. Double click on window title to reset position."); _windowSize = config("General - Window", "Window size", GetDefaultManagerWindowSize(), "Window size. Double click on window title to reset size."); _showEditButton = config("General - Window", "Show Edit button next to config values", defaultValue: true, "Show hoverable block to get tooltip."); _compactConfigList = config("General - Window", "Compact config list", defaultValue: true, "Reduce vertical spacing between configuration rows."); _editableExtensions = config("General - File Editor", "Editable files", "json,yaml,yml,cfg", "Comma separated list of extensions"); _hideModConfigs = config("General - File Editor", "Hide mod configs", defaultValue: true, "Hide .cfg files with mod configurations generated by BepInEx\nIt is meant to be edited in configuration manager main window.\nConfigurations from inactive mod will be loaded anyway"); _showEmptyFolders = config("General - File Editor", "Show empty folders", defaultValue: false, "Hide or show directories with no files"); _windowPositionTextEditor = config("General - File Editor", "Window position", GetDefaultTextEditorWindowPosition(), "Window position. Double click on window title to reset position."); _windowSizeTextEditor = config("General - File Editor", "Window size", GetDefaultTextEditorWindowSize(), "Window size. Double click on window title to reset size."); _showTrashBin = config("General - File Editor", "Show Trash Bin in file editor", defaultValue: true, "Show configuration manager trash bin folder in list."); _showFullName = config("General - File Editor", "Show full name of active file", defaultValue: true, "Show full name of active file."); _windowPositionEditSetting = config("General - Setting Edit Window", "Window position", GetDefaultEditSettingWindowPosition(), "Window position. Double click on window title to reset position."); _windowSizeEditSetting = config("General - Setting Edit Window", "Window size", GetDefaultEditSettingWindowSize(), "Window size. Double click on window title to reset size."); _sortCategoriesByName = config("General - Categories", "Sort by name", defaultValue: false, "If disabled, categories will be sorted in the order in which they were declared by the mod author."); _categoriesCollapseable = config("General - Categories", "Collapsable categories", defaultValue: true, "Categories can be collapsed to reduce lagging and to ease scrolling."); _categoriesCollapsedDefault = config("General - Categories", "Collapsed by default", defaultValue: true, "If set to true plugin categories will be collapsed by default if plugin has more than 20 categories.\nCategories with non default values will not be collapsed."); _sortCategoriesByName.SettingChanged += delegate { BuildSettingList(); }; _categoriesCollapseable.SettingChanged += delegate { BuildSettingList(); }; _categoriesCollapsedDefault.SettingChanged += delegate { BuildSettingList(); }; _showAdvanced = config("Filtering", "Show advanced", defaultValue: false, "Show only configs with Advanced tag"); _showKeybinds = config("Filtering", "Show only keybinds", defaultValue: false, "Show only KeyboardShortcut configs"); _readOnlyStyle = config("Filtering", "Style readonly entries", ReadOnlyStyle.Colored, "Entries marked as readonly are not available for change."); _readOnlyStyle.SettingChanged += delegate { BuildSettingList(); }; _textEditorFontSize = config("File editor - Text style", "Font size", 14, "Font size of text editor"); _textEditorFontColor = config("File editor - Text style", "Font color", new Color(0.9f, 0.9f, 0.9f, 1f), "Font color of text editor"); _textEditorWordWrap = config("File editor - Text style", "Word wrap", defaultValue: true, "Word wrap of text editor"); _textEditorAlignment = config("File editor - Text style", "Text alignment", (TextAnchor)0, "Text alignment of text editor"); _textEditorRichText = config("File editor - Text style", "Rich text", defaultValue: true, "Rich text of text editor"); _windowTitle = config("Text - Menu", "Window Title", "Configuration Manager", "Window title text"); _normalText = config("Text - Menu", "Normal", "Normal", "Normal settings toggle text"); _shortcutsText = config("Text - Menu", "Keybinds", "Keybinds only", "Keybinds key settings toggle text"); _shortcutsTextTooltip = config("Text - Menu", "Keybinds tooltip", "Show only plugins and settings with keybind shortcuts", "Keybinds toolip toggle text"); _advancedText = config("Text - Menu", "Advanced", "Advanced", "Advanced settings toggle text"); _advancedTextTooltip = config("Text - Menu", "Advanced tooltip", "Show plugins and settings marked by author as advanced.\nFor example BepInEx settings are marked as advanced.", "Advanced settings toggle tooltip"); _compactListText = config("Text - Menu", "Compact list", "Compact", "Compact config list toggle text"); _compactListTextTooltip = config("Text - Menu", "Compact list tooltip", "Reduce vertical spacing between configuration rows.", "Compact config list toggle tooltip"); _closeText = config("Text - Menu", "Close", "Close", "Close button text"); _searchText = config("Text - Menu", "Search placeholder", "Search settings", "Search placeholder text"); _noOptionsPluginsText = config("Text - Menu", "Plugins without options", "Plugins with no options available", "Text in footer"); _viewModeListViewText = config("Text - Menu", "List View", "List View", "Text for button to change to single column legacy view mode"); _viewModeSplitViewText = config("Text - Menu", "Split View", "Split View", "Text for button to change to split view mode"); _editText = config("Text - Menu", "Edit", "Edit", "Text for button to open edit setting window"); _toggleTextEditorText = config("Text - File Editor", "Open button", "Show File Editor", "Open file editor label text"); _searchTextEditor = config("Text - File Editor", "Search", "Search:", "Search label text"); _saveFileTextEditor = config("Text - File Editor", "Save", "Save", "Save changes in file"); _windowTitleTextEditor = config("Text - File Editor", "Title", "Configuration Files Editor", "Window title"); _extensionsTitleTextEditor = config("Text - File Editor", "Extensions label", "Files:", "Label for extension list"); _validateJsonTextEditor = config("Text - File Editor", "JSON validation button", "Validate JSON", "Button for JSON validation"); _validateYamlTextEditor = config("Text - File Editor", "YAML validation button", "Validate YAML", "Button for YAML validation"); _newFileLabelTextEditor = config("Text - File Editor", "New file label", "File:", "Label for new file name"); _newFolderLabelTextEditor = config("Text - File Editor", "New folder label", "Folder:", "Label for new folder name"); _newEntryOKButtonTextEditor = config("Text - File Editor", "New object confirmation button", "OK", "Label for confirmation button"); _fileExistsTextEditor = config("Text - File Editor", "Error text file exists", "File already exists", "Error text if file already exists"); _newFolderButtonTextEditor = config("Text - File Editor", "New folder", "New folder", "Text for new folder button"); _newFileButtonTextEditor = config("Text - File Editor", "New file", "New file", "Text for new file button"); _renameFileButtonTextEditor = config("Text - File Editor", "Rename", "Rename", "Text for Rename button"); _deleteFileButtonTextEditor = config("Text - File Editor", "Delete", "Delete", "Text for Delete button"); _deleteFileTooltipTextEditor = config("Text - File Editor", "Delete tooltip", "File will be moved into Trash Bin", "Tooltip for Delete button"); _showEmptyTextEditor = config("Text - File Editor", "Show empty folders", "Show empty folders", "Text for show empty folders toggle"); _showTrashBinTextEditor = config("Text - File Editor", "Show Trash Bin", "Show Trash Bin", "Text for show trash bin toggle"); _showFullNameTextEditor = config("Text - File Editor", "Show file name", "Show file name", "Text for show file name toggle"); _showFullNameTooltipTextEditor = config("Text - File Editor", "Show file name tooltip", "Show full name of active file", "Text for show file name toggle tooltip"); _fileIsValidJsonTextEditor = config("Text - File Editor", "File is valid JSON", "File is valid JSON", "Text for JSON validation result"); _fileIsNotValidJsonTextEditor = config("Text - File Editor", "File is not valid JSON", "File is not valid JSON", "Text for JSON validation result"); _fileIsValidYamlTextEditor = config("Text - File Editor", "File is valid YAML", "File is valid YAML", "Text for YAML validation result"); _fileIsNotValidYamlTextEditor = config("Text - File Editor", "File is not valid YAML", "File is not valid YAML", "Text for YAML validation result"); _wordWrapTextEditor = config("Text - File Editor", "Word wrap", "Word wrap", "Text for word wrap toggle"); _richTextTextEditor = config("Text - File Editor", "Rich text", "Rich text", "Text for rich text toggle"); _richTextFontSize = config("Text - File Editor", "Font size", "Font size: ", "Text for font size field"); _defaultValueDescriptionEditWindow = config("Text - Edit Window", "Default value description", "Default: ", "Label for default value"); _pressEscapeHintEditWindow = config("Text - Edit Window", "Press Escape hint", "Press Escape to close window", "Hint in window bottom"); _applyButtonEditWindow = config("Text - Edit Window", "Apply button", "Apply", "Apply button label"); _editAsLabelEditWindow = config("Text - Edit Window", "Edit as label", "Edit as: ", "Label for edit as element"); _editAsTextEditWindow = config("Text - Edit Window", "Edit as text", "Text", "Label for edit as Text button"); _editAsListEditWindow = config("Text - Edit Window", "Edit as list", "List", "Label for edit as List button"); _separatorLabelEditWindow = config("Text - Edit Window", "Separator lable", "Separator: ", "Label for separator field"); _trimWhitespaceButtonEditWindow = config("Text - Edit Window", "Trim whitespace button", "Trim whitespace", "Text for trim whitespace button"); _rangeLabelEditWindow = config("Text - Edit Window", "Range label", "Range: ", "Label for Range field"); _addButtonEditWindow = config("Text - Edit Window", "Add button", "Add", "Label for add button"); _newValuePlaceholderEditWindow = config("Text - Edit Window", "New value placeholder", "Enter new value", "Label for new value placeholder in list view"); _precisionLabelEditWindow = config("Text - Edit Window", "Precision label", "Precision", "Label for vector precision field"); _resetSettingText = config("Text - Config", "Setting Reset", "Reset", "Reset setting text"); _clearText = config("Text - Config", "Setting Clear", "Clear", "Clear search text"); _cancelText = config("Text - Config", "Setting Cancel", "Cancel", "Cancel button text"); _enabledText = config("Text - Config", "Toggle True", "Enabled", "Text on enabled toggle"); _disabledText = config("Text - Config", "Toggle False", "Disabled", "Text on disabled toggle"); _shortcutKeyText = config("Text - Config", "Shortcut key single", "Set", "Text when waiting for key press"); _shortcutKeysText = config("Text - Config", "Shortcut keys combination", "Press any key", "Text when waiting for key combination"); _windowBackgroundColor = config("Colors", "Window background color", new Color(0f, 0f, 0f, 1f), "Window background color"); _entryBackgroundColor = config("Colors", "Entry background color", new Color(0.55f, 0.5f, 0.5f, 0.94f), "Entry background color"); _tooltipBackgroundColor = config("Colors", "Tooltip background color", new Color(0.55f, 0.5f, 0.45f, 0.95f), "Tooltip background color"); _headerBackgroundColor = config("Colors", "Header background color", new Color(0.74f, 0.54f, 0.37f, 0.8f), "Header background color"); _headerBackgroundHoverColor = config("Colors", "Header hover background color", new Color(0.88f, 0.46f, 0f, 0.8f), "Header hover background color"); _widgetBackgroundColor = config("Colors", "Widget color", new Color(0.88f, 0.46f, 0f, 0.8f), "Widget color"); _enabledBackgroundColor = config("Colors", "Enabled toggle color", new Color(0.88f, 0.46f, 0f, 1f), "Color of enabled toggle"); _readOnlyColor = config("Colors", "Readonly color", new Color(0.851f, 0.851f, 0.851f, 1f), "Color of readonly setting"); _editWindowBackgroundColor = config("Colors", "Setting window background color", new Color(0.55f, 0.5f, 0.5f, 0.65f), "Setting window background color"); _windowBackgroundColor.SettingChanged += delegate { UpdateBackgrounds(); }; _entryBackgroundColor.SettingChanged += delegate { UpdateBackgrounds(); }; _tooltipBackgroundColor.SettingChanged += delegate { UpdateBackgrounds(); }; _headerBackgroundColor.SettingChanged += delegate { UpdateBackgrounds(); }; _headerBackgroundHoverColor.SettingChanged += delegate { UpdateBackgrounds(); }; _editWindowBackgroundColor.SettingChanged += delegate { UpdateBackgrounds(); }; _fontColor = config("Colors - Font", "Main font", new Color(1f, 0.827f, 0.463f, 1f), "Font color"); _fontColorValueDefault = config("Colors - Font", "Default value", new Color(1f, 0.827f, 0.463f, 1f), "Font color"); _fontColorValueChanged = config("Colors - Font", "Changed value", new Color(0.9f, 0.9f, 0.9f, 1f), "Font color when value is not default"); _changedSynchronizationPolicyColor = config("Colors - Font", "Changed synchronization policy", new Color(0.45f, 0.82f, 1f, 1f), "Color of the synchronization state button when server policy changed the mod-defined behavior"); currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value); _configFilesEditor = new ConfigFilesEditor(); _configSettingWindow = new SettingEditWindow(); } private ConfigEntry config(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = false) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)1, synchronizedSetting).SourceConfig; } private ConfigEntry serverConfig(string group, string name, T defaultValue, ConfigDescription description) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)0, true).SourceConfig; } private ConfigEntry config(string group, string name, T defaultValue, string description, bool synchronizedSetting = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } private ConfigEntry serverConfig(string group, string name, T defaultValue, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return serverConfig(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } 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() { 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (DisplayingWindow) { SetUnlockCursor(0, cursorVisible: true); } if (OverrideHotkey) { return; } KeyboardShortcut value = _keybindResetPosition.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ResetWindowSizeAndPosition(); } value = _keybindResetScale.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ResetWindowScale(); } if (!DisplayingWindow) { value = _keybind.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { DisplayingWindow = true; return; } } if (!DisplayingWindow) { return; } if (!UnityInput.Current.GetKeyDown((KeyCode)27)) { value = _keybind.Value; if (!((KeyboardShortcut)(ref value)).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() { _configLocked = serverConfig("Valheim", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only."); _pauseGame = config("Valheim", "Pause game", defaultValue: false, "Pause the game (if game can be paused) when window is open"); _preventInput = config("Valheim", "Prevent input", PreventInput.Player, "Prevent input when window is open\n Off - everything goes through\n Player - prevent player controls and HUD buttons (console will still operate)\n All - prevent all input events"); _showMainMenuButton = config("Valheim", "Main menu button", defaultValue: true, "Add button in main menu to open/close configuration manager window"); _mainMenuButtonCaption = config("Valheim", "Main menu button caption", "Mods settings", "Main menu button caption"); _useValheimGuiScaleFactor = config("Valheim", "Use Valheim GUI scaling", defaultValue: true, "Use Valheim scale factor from Accessibility - Scale GUI"); _showMainMenuButton.SettingChanged += delegate { SetupMenuButton(); }; _mainMenuButtonCaption.SettingChanged += delegate { SetupMenuButton(); }; ((ConditionalConfigSync)configSync).AddLockingConfigEntry(_configLocked); harmony.PatchAll(); DisplayingWindowChanged += ConfigurationManager_DisplayingWindowChanged; pluginDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent; configDirectory = new DirectoryInfo(Paths.ConfigPath); SetupHiddenSettingsWatcher(); } private void OnDisable() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } DisplayingWindowChanged -= ConfigurationManager_DisplayingWindowChanged; } public void ToggleWindow() { DisplayingWindow = !DisplayingWindow; } private static void SetupHiddenSettingsWatcher() { string[] array = hiddenSettingsFileNames; foreach (string filter in array) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(pluginDirectory.FullName, filter); fileSystemWatcher.Changed += ReadConfigs; fileSystemWatcher.Created += ReadConfigs; fileSystemWatcher.Renamed += ReadConfigs; fileSystemWatcher.Deleted += ReadConfigs; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; FileSystemWatcher fileSystemWatcher2 = new FileSystemWatcher(configDirectory.FullName, filter); fileSystemWatcher2.Changed += ReadConfigs; fileSystemWatcher2.Created += ReadConfigs; fileSystemWatcher2.Renamed += ReadConfigs; fileSystemWatcher2.Deleted += ReadConfigs; fileSystemWatcher2.IncludeSubdirectories = true; fileSystemWatcher2.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher2.EnableRaisingEvents = true; } ReadConfigs(); } private static void ReadConfigs(object sender = null, FileSystemEventArgs eargs = null) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List hiddenSettingsFiles = new List(); CollectionExtensions.Do((IEnumerable)hiddenSettingsFileNames, (Action)delegate(string filename) { hiddenSettingsFiles.AddRange(pluginDirectory.GetFiles(filename, SearchOption.AllDirectories)); }); CollectionExtensions.Do((IEnumerable)hiddenSettingsFileNames, (Action)delegate(string filename) { hiddenSettingsFiles.AddRange(configDirectory.GetFiles(filename, SearchOption.AllDirectories)); }); foreach (FileInfo item in hiddenSettingsFiles) { LogInfo("Loading " + item.FullName); try { using FileStream fileStream = new FileStream(item.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); using StreamReader streamReader = new StreamReader(fileStream); string text = streamReader.ReadToEnd(); if (!Utility.IsNullOrWhiteSpace(text)) { list.AddRange(new DeserializerBuilder().Build().Deserialize>(text)); streamReader.Close(); fileStream.Dispose(); } } catch (Exception ex) { LogInfo("Error reading file (" + item.FullName + ")! Error: " + ex.Message); } } hiddenSettings.AssignLocalValue(list); } private static bool PreventAllInput() { return _preventInput.Value == PreventInput.All; } private static bool PreventPlayerInput() { return PreventAllInput() || _preventInput.Value == PreventInput.Player; } private void ConfigurationManager_DisplayingWindowChanged(object sender, ValueChangedEventArgs e) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) 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)) { Menu.instance.m_closeMenuState = (CloseMenuState)((!DisplayingWindow) ? 2 : 0); Menu.instance.m_rebuildLayout = true; } if (_pauseGame.Value && Object.op_Implicit((Object)(object)Game.instance)) { if (DisplayingWindow && !Game.IsPaused() && Game.CanPause()) { Game.Pause(); } else if (!DisplayingWindow && !Menu.IsActive() && Game.IsPaused()) { Game.Unpause(); } } } private bool HideSettings() { return hiddenSettings.Value.Count > 0 && !((ConditionalConfigSync)configSync).IsAdmin; } private void SetupMenuButton() { if (Object.op_Implicit((Object)(object)FejdStartup.instance) && Object.op_Implicit((Object)(object)FejdStartup.instance.m_menuList) && FejdStartup.instance.m_menuButtons != null && FejdStartup.instance.m_menuButtons.Length != 0) { SetupMainMenuButton(FejdStartup.instance.m_menuList.transform.Find("MenuEntries")); FejdStartup.instance.m_menuButtons = FejdStartup.instance.m_menuList.GetComponentsInChildren