Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ConfigurationManager v1.1.13
ConfigurationManager.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; 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 ConfigurationManager.Utilities; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using ServerSync; 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.13")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.13.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 num5; float num4; float num3; if (s == 0f) { num5 = (num4 = (num3 = l)); } else { num5 = Value(n, num2, h + 120f); num4 = Value(n, num2, h); num3 = Value(n, num2, h - 120f); } return new Color(num5, num4, num3, 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<string, bool> _folderStates = new Dictionary<string, bool>(); 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<string, string[]> _cachedFileTree = new Dictionary<string, string[]>(); private readonly Dictionary<string, string[]> _cachedDirectories = new Dictionary<string, string[]>(); 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<string> 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 flag2 = (_folderStates[directory] = GUILayout.Toggle(_folderStates[directory], Path.GetFileName(directory), ConfigurationManagerStyles.GetDirectoryStyle(directory == _activeDirectory), Array.Empty<GUILayoutOption>())); if (num != flag2 && _folderStates[directory]) { _activeDirectory = directory; SetFileEditState(FileEditState.None); } if (_folderStates[directory]) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); DrawDirectory(directory); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } } } private void DrawFileNameField() { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); 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<string>()); _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<string>()); _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<GUILayoutOption>())) { 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<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(ConfigurationManager._newFolderButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty<GUILayoutOption>())) { SetFileEditState(FileEditState.CreatingFolder); } if (GUILayout.Button(ConfigurationManager._newFileButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty<GUILayoutOption>())) { SetFileEditState(FileEditState.CreatingFile); } if (GUILayout.Button(ConfigurationManager._renameFileButtonTextEditor.Value, ConfigurationManagerStyles.GetButtonStyle(), Array.Empty<GUILayoutOption>())) { SetFileEditState(FileEditState.RenamingFile); _newItemName = Path.GetFileName(_activeFile); } if (GUILayout.Button(new GUIContent(ConfigurationManager._deleteFileButtonTextEditor.Value, ConfigurationManager._deleteFileTooltipTextEditor.Value), ConfigurationManagerStyles.GetButtonStyle(), Array.Empty<GUILayoutOption>())) { MoveActiveFileToTrash(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); 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<GUILayoutOption>()); ConfigurationManager._showTrashBin.Value = GUILayout.Toggle(ConfigurationManager._showTrashBin.Value, ConfigurationManager._showTrashBinTextEditor.Value, ConfigurationManagerStyles.GetToggleStyle(), Array.Empty<GUILayoutOption>()); 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<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); val.Deserialize<object>(text); return ConfigurationManager._fileIsValidYamlTextEditor.Value; } catch { return ConfigurationManager._fileIsNotValidYamlTextEditor.Value; } } } internal sealed class ConfigSettingEntry : SettingEntryBase { public ConfigEntryBase Entry { get; } public override Type SettingType => Entry.SettingType; public ConfigSettingEntry(ConfigEntryBase entry, BaseUnityPlugin owner) { Entry = entry; DispName = entry.Definition.Key; base.Category = entry.Definition.Section; ConfigDescription description = entry.Description; base.Description = ((description != null) ? description.Description : null); TypeConverter converter = TomlTypeConverter.GetConverter(entry.SettingType); if (converter != null) { base.ObjToStr = (object o) => converter.ConvertToString(o, entry.SettingType); base.StrToObj = (string s) => converter.ConvertToObject(s, entry.SettingType); } ConfigDescription description2 = entry.Description; AcceptableValueBase val = ((description2 != null) ? description2.AcceptableValues : null); if (val != null) { GetAcceptableValues(val); } base.DefaultValue = entry.DefaultValue; ConfigDescription description3 = entry.Description; SetFromAttributes((description3 != null) ? description3.Tags : null, owner); } private void GetAcceptableValues(AcceptableValueBase values) { Type type = ((object)values).GetType(); PropertyInfo property = type.GetProperty("AcceptableValues", BindingFlags.Instance | BindingFlags.Public); if (property != null) { base.AcceptableValues = ((IEnumerable)property.GetValue(values, null)).Cast<object>().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<object, object>(property2.GetValue(values, null), property3.GetValue(values, null)); } } public override object Get() { return Entry.BoxedValue; } protected override void SetValue(object newVal) { Entry.BoxedValue = newVal; } internal bool ShouldBeHidden() { return ConfigurationManager.hiddenSettings.Value.Contains(base.PluginInfo.GUID + "=" + Entry.Definition.Section + "=" + Entry.Definition.Key); } } 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<KeyCode> _keysToCheck; private static readonly Dictionary<SettingEntryBase, ColorCacheEntry> ColorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>(); 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<string> vectorParts = new List<string>(); private readonly List<float> vectorFloats = new List<float>(); private readonly List<float> vectorDefault = new List<float>(); private string colorAsHEX; private List<string> separatedStringDefault = new List<string>(); private List<string> separatedString = new List<string>(); private string separator; private int editStringView; private string newItem; private ConfigEntryBase dummyCustomDrawerConfigEntry; private static readonly Dictionary<Type, string> typeMappings = new Dictionary<Type, string> { { 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<Key, Value>" }, { typeof(object), "Object" } }; private readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>(); public Dictionary<Type, Action> SettingDrawHandlers { get; } private bool IsStringList => setting != null && setting.SettingType != null && typeof(IList<string>).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<Type, Action> { { 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_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_00a1: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { ((Rect)(ref _windowRect)).size = ConfigurationManager._windowSizeEditSetting.Value; ((Rect)(ref _windowRect)).position = ConfigurationManager._windowPositionEditSetting.Value; Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ConfigurationManager._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<string>); } 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<string>).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<Vector2>(vectorFloats, (Vector2)valueToSet); FillVectorList<Vector2>(vectorDefault, (Vector2)setting.DefaultValue); } else if (setting.SettingType == typeof(Vector3)) { FillVectorList<Vector3>(vectorFloats, (Vector3)valueToSet); FillVectorList<Vector3>(vectorDefault, (Vector3)setting.DefaultValue); } else if (setting.SettingType == typeof(Vector4)) { FillVectorList<Vector4>(vectorFloats, (Vector4)valueToSet); FillVectorList<Vector4>(vectorDefault, (Vector4)setting.DefaultValue); } else if (setting.SettingType == typeof(Quaternion)) { FillVectorList<Quaternion>(vectorFloats, (Quaternion)valueToSet); FillVectorList<Quaternion>(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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0260: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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<GUILayoutOption>()); GUILayout.Space(1f); GUILayout.Label("<b>" + setting.Category + "</b>", 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); DrawSettingValue(); if (!Utility.IsNullOrWhiteSpace(errorOnSetting)) { GUILayout.Label(errorOnSetting, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty<GUILayoutOption>()); } 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<GUILayoutOption>()); } 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<Type, string>((IDictionary<Type, string>)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() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); bool enabled = GUI.enabled; GUI.enabled = enabled && !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 && !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<GUILayoutOption>()); if (!DrawCustomField() && !DrawKnownDrawer()) { if (errorText.Length > 0) { GUILayout.Label("Error:\n" + errorText, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty<GUILayoutOption>()); } DrawUnknownField(out drawStringMenu); } GUILayout.EndScrollView(); if (drawStringMenu) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); 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<GUILayoutOption>()))) { 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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.GetValueOrDefault()) { 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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<string> list = separatedString; List<string> 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<SettingEntryBase, ColorCacheEntry> 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 i = 0; while (i < array.Length) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num4 = 0; for (; i < array.Length; i++) { var anon = array[i]; 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 num5 = (int)buttonStyle.CalcSize(new GUIContent(anon.name)).x; num4 += num5; if ((float)num4 > 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<object>().Select(SettingFieldDrawer.ObjectToGuiContent).ToArray(); _scrollPositionEnum = GUILayout.BeginScrollView(_scrollPositionEnum, false, false, Array.Empty<GUILayoutOption>()); try { listIndex = GUILayout.SelectionGrid(listIndex, array, 1, ConfigurationManagerStyles.GetComboBoxStyle(), Array.Empty<GUILayoutOption>()); 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<KeyCode>)(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<KeyCode>)(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<KeyCode, bool>)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<GUILayoutOption>()); 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<GUILayoutOption>()); 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_026a: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawHexField(ref value, val); GUILayout.Space(3f); GUIHelper.BeginColor(value); GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!ColorCache.TryGetValue(setting, out var value2)) { value2 = new ColorCacheEntry { Tex = new Texture2D(40, 10, (TextureFormat)5, false), Last = value }; value2.Tex.FillTexture(value); ColorCache[setting] = value2; } if ((int)Event.current.type == 7) { GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)value2.Tex); } GUIHelper.EndColor(); GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(2f); DrawColorField("Red", ref value, ref value.r, Utils.RoundColor(value.r) == Utils.RoundColor(val.r)); DrawColorField("Green", ref value, ref value.g, Utils.RoundColor(value.g) == Utils.RoundColor(val.g)); DrawColorField("Blue", ref value, ref value.b, Utils.RoundColor(value.b) == Utils.RoundColor(val.b)); DrawColorField("Alpha", ref value, ref value.a, Utils.RoundColor(value.a) == Utils.RoundColor(val.a)); HSLColor hSLColor = val; HSLColor settingColor = value; DrawHSLField("Hue", ref settingColor, ref settingColor.h, Utils.RoundWithPrecision(settingColor.h, 1) == Utils.RoundWithPrecision(hSLColor.h, 1)); DrawHSLField("Saturation", ref settingColor, ref settingColor.s, Utils.RoundColor(settingColor.s) == Utils.RoundColor(hSLColor.s)); DrawHSLField("Lightness", ref settingColor, ref settingColor.l, Utils.RoundColor(settingColor.l) == Utils.RoundColor(hSLColor.l)); value = settingColor; if (value != value2.Last) { valueToSet = value; value2.Tex.FillTexture(value); value2.Last = value; colorAsHEX = "#" + ColorUtility.ToHtmlStringRGBA(value); } GUILayout.EndVertical(); } private bool DrawHexField(ref Color value, Color defaultValue) { //IL_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<GUILayoutOption>()); 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<GUILayoutOption>()); 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<T>(List<float> 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) { return; } if (value is Vector2) { object obj = value; Vector2 val = (Vector2)((obj is Vector2) ? obj : null); if (true) { list.Add(val.x); list.Add(val.y); return; } } if (value is Vector3) { object obj2 = value; Vector3 val2 = (Vector3)((obj2 is Vector3) ? obj2 : null); if (true) { list.Add(val2.x); list.Add(val2.y); list.Add(val2.z); return; } } if (value is Vector4) { object obj3 = value; Vector4 val3 = (Vector4)((obj3 is Vector4) ? obj3 : null); if (true) { list.Add(val3.x); list.Add(val3.y); list.Add(val3.z); list.Add(val3.w); return; } } if (value is Quaternion) { object obj4 = value; Quaternion val4 = (Quaternion)((obj4 is Quaternion) ? obj4 : null); if (true) { 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 !=