using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurationManager.Utilities;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyProduct("BepInEx.ConfigurationManager")]
[assembly: AssemblyTitle("BepInEx.ConfigurationManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("https://github.com/BepInEx/BepInEx.ConfigurationManager")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace ConfigurationManager
{
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 ((object)property != null)
{
base.AcceptableValues = ((IEnumerable)property.GetValue(values, null)).Cast<object>().ToArray();
return;
}
PropertyInfo property2 = type.GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public);
if ((object)property2 != null)
{
PropertyInfo property3 = type.GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public);
if ((object)property3 == null)
{
throw new ArgumentNullException("maxProp");
}
base.AcceptableValueRange = new KeyValuePair<object, object>(property2.GetValue(values, null), property3.GetValue(values, null));
base.ShowRangeAsPercent = ((base.AcceptableValueRange.Key.Equals(0) || base.AcceptableValueRange.Key.Equals(1)) && base.AcceptableValueRange.Value.Equals(100)) || (base.AcceptableValueRange.Key.Equals(0f) && base.AcceptableValueRange.Value.Equals(1f));
}
}
public override object Get()
{
return Entry.BoxedValue;
}
protected override void SetValue(object newVal)
{
Entry.BoxedValue = newVal;
}
}
internal class PropertySettingEntry : SettingEntryBase
{
private Type _settingType;
public object Instance { get; internal set; }
public PropertyInfo Property { get; internal set; }
public override string DispName
{
get
{
return string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName;
}
protected internal set
{
base.DispName = value;
}
}
public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType);
public PropertySettingEntry(object instance, PropertyInfo settingProp, BaseUnityPlugin pluginInstance)
{
SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance);
if (!base.Browsable.HasValue)
{
base.Browsable = settingProp.CanRead && settingProp.CanWrite;
}
base.ReadOnly = settingProp.CanWrite;
Property = settingProp;
Instance = instance;
}
public override object Get()
{
return Property.GetValue(Instance, null);
}
protected override void SetValue(object newVal)
{
Property.SetValue(Instance, newVal, null);
}
}
internal static class SettingSearcher
{
private static readonly ICollection<string> _updateMethodNames = new string[4] { "Update", "FixedUpdate", "LateUpdate", "OnGUI" };
public static void CollectSettings(out IEnumerable<SettingEntryBase> results, out List<string> modsWithoutSettings, bool showDebug)
{
modsWithoutSettings = new List<string>();
try
{
results = GetBepInExCoreConfig();
}
catch (Exception ex)
{
results = Enumerable.Empty<SettingEntryBase>();
ConfigurationManager.Logger.LogError((object)ex);
}
foreach (BaseUnityPlugin item in Utils.FindPlugins())
{
Type type = ((object)item).GetType();
PluginInfo info = item.Info;
if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => !x.Browsable))
{
modsWithoutSettings.Add(info.Metadata.Name);
continue;
}
List<SettingEntryBase> list = new List<SettingEntryBase>();
list.AddRange(GetPluginConfig(item).Cast<SettingEntryBase>());
list.RemoveAll((SettingEntryBase x) => x.Browsable == false);
if (list.Count == 0)
{
modsWithoutSettings.Add(info.Metadata.Name);
}
if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo x) => _updateMethodNames.Contains(x.Name)))
{
PropertySettingEntry propertySettingEntry = new PropertySettingEntry(item, type.GetProperty("enabled"), item);
propertySettingEntry.DispName = "!Allow plugin to run on every frame";
propertySettingEntry.Description = "Disabling this will disable some or all of the plugin's functionality.\nHooks and event-based functionality will not be disabled.\nThis setting will be lost after game restart.";
propertySettingEntry.IsAdvanced = true;
list.Add(propertySettingEntry);
}
if (list.Count > 0)
{
results = results.Concat(list);
}
}
}
private static IEnumerable<SettingEntryBase> GetBepInExCoreConfig()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
PropertyInfo property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic);
if ((object)property == null)
{
throw new ArgumentNullException("coreConfigProp");
}
ConfigFile source = (ConfigFile)property.GetValue(null, null);
BepInPlugin bepinMeta = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString());
return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)source).Select((Func<KeyValuePair<ConfigDefinition, ConfigEntryBase>, SettingEntryBase>)((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, null)
{
IsAdvanced = true,
PluginInfo = bepinMeta
}));
}
private static IEnumerable<ConfigSettingEntry> GetPluginConfig(BaseUnityPlugin plugin)
{
return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, plugin));
}
}
[BepInPlugin("aedenthorn.configurationmanager", "Configuration Manager", "0.1.0")]
public class ConfigurationManager : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public const string GUID = "aedenthorn.configurationmanager";
public const string Version = "0.1.0";
public ConfigurationManager()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Creating update poller");
GameObject val = new GameObject("ConfigurationManager");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Updater updater = val.AddComponent<Updater>();
updater.Config = ((BaseUnityPlugin)this).Config;
updater.Context = this;
updater.Logger = Logger;
}
}
public class Updater : MonoBehaviour
{
private sealed class PluginSettingsData
{
public sealed class PluginSettingsGroupData
{
public string Name;
public List<SettingEntryBase> Settings;
}
public BepInPlugin Info;
public List<PluginSettingsGroupData> Categories;
public int Height;
public string Website;
private bool _collapsed;
public bool Collapsed
{
get
{
return _collapsed;
}
set
{
_collapsed = value;
Height = 0;
}
}
}
internal ManualLogSource Logger;
private static SettingFieldDrawer _fieldDrawer;
private static readonly Color _advancedSettingColor = new Color(1f, 0.95f, 0.67f, 1f);
private const int WindowId = -68;
private const string SearchBoxName = "searchBox";
private bool _focusSearchBox;
private string _searchString = string.Empty;
public bool OverrideHotkey;
private bool _displayingWindow;
private bool _obsoleteCursor;
private string _modsWithoutSettings;
private List<SettingEntryBase> _allSettings;
private List<PluginSettingsData> _filteredSettings = new List<PluginSettingsData>();
private Rect _screenRect;
private Vector2 _settingWindowScrollPos;
private int _tipsHeight;
private Rect currentWindowRect;
private PropertyInfo _curLockState;
private PropertyInfo _curVisible;
private int _previousCursorLockState;
private bool _previousCursorVisible;
private static ConfigEntry<bool> _showAdvanced;
private static ConfigEntry<bool> _showKeybinds;
private static ConfigEntry<bool> _showSettings;
private static ConfigEntry<KeyboardShortcut> _keybind;
private static ConfigEntry<bool> _hideSingleSection;
private static ConfigEntry<bool> _pluginConfigCollapsedDefault;
private bool _showDebug;
private static ConfigEntry<Vector2> _windowPosition;
private static ConfigEntry<Vector2> _windowSize;
private static ConfigEntry<string> _windowTitle;
private static ConfigEntry<string> _showText;
private static ConfigEntry<string> _normalText;
private static ConfigEntry<string> _shortcutsText;
private static ConfigEntry<string> _advancedText;
private static ConfigEntry<string> _searchText;
private static ConfigEntry<string> _reloadText;
private static ConfigEntry<string> _resetText;
private static ConfigEntry<string> _resetSettingText;
private static ConfigEntry<string> _expandText;
private static ConfigEntry<string> _collapseText;
private static ConfigEntry<string> _tipText;
private static ConfigEntry<string> _clearText;
private static ConfigEntry<string> _debugText;
private static ConfigEntry<string> _logText;
private static ConfigEntry<int> _textSize;
private static ConfigEntry<Color> _windowBackgroundColor;
private static ConfigEntry<Color> _entryBackgroundColor;
private static ConfigEntry<Color> _fontColor;
private static ConfigEntry<Color> _disabledColor;
private static ConfigEntry<Color> _widgetBackgroundColor;
public static GUIStyle windowStyle;
public static GUIStyle headerStyle;
public static GUIStyle entryStyle;
public static GUIStyle labelStyle;
public static GUIStyle textStyle;
public static GUIStyle toggleStyle;
public static GUIStyle buttonStyle;
public static GUIStyle boxStyle;
public static GUIStyle sliderStyle;
public static GUIStyle thumbStyle;
public static GUIStyle categoryHeaderSkin;
public static GUIStyle pluginHeaderSkin;
public static int fontSize = 14;
public static bool closedThisFrame;
public ConfigFile Config { get; internal set; }
public ConfigurationManager Context { get; internal set; }
internal Rect SettingWindowRect { get; private set; }
internal static Texture2D TooltipBg { get; private set; }
internal static Texture2D WindowBackground { get; private set; }
internal static Texture2D EntryBackground { get; private set; }
internal static Texture2D WidgetBackground { get; private set; }
internal int LeftColumnWidth { get; private set; }
internal int RightColumnWidth { get; private set; }
public bool DisplayingWindow
{
get
{
return _displayingWindow;
}
set
{
if (_displayingWindow == value)
{
return;
}
_displayingWindow = value;
SettingFieldDrawer.ClearCache();
if (_displayingWindow)
{
CalculateDefaultWindowRect();
BuildSettingList();
_focusSearchBox = true;
if ((object)_curLockState != null)
{
_previousCursorLockState = (_obsoleteCursor ? Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : ((int)_curLockState.GetValue(null, null)));
_previousCursorVisible = (bool)_curVisible.GetValue(null, null);
}
}
else if (!_previousCursorVisible || _previousCursorLockState != 0)
{
SetUnlockCursor(_previousCursorLockState, _previousCursorVisible);
}
this.DisplayingWindowChanged?.Invoke(this, new ValueChangedEventArgs<bool>(value));
}
}
public string SearchString
{
get
{
return _searchString;
}
private set
{
if (value == null)
{
value = string.Empty;
}
if (!(_searchString == value))
{
_searchString = value;
BuildFilteredSettingList();
}
}
}
public event EventHandler<ValueChangedEventArgs<bool>> DisplayingWindowChanged;
private void Start()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Expected O, but got Unknown
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Expected O, but got Unknown
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Expected O, but got Unknown
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Expected O, but got Unknown
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Expected O, but got Unknown
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Expected O, but got Unknown
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Expected O, but got Unknown
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Expected O, but got Unknown
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Expected O, but got Unknown
//IL_038b: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Expected O, but got Unknown
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Expected O, but got Unknown
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Expected O, but got Unknown
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
//IL_0496: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0506: Unknown result type (might be due to invalid IL or missing references)
//IL_053e: Unknown result type (might be due to invalid IL or missing references)
//IL_0576: Unknown result type (might be due to invalid IL or missing references)
//IL_05be: Unknown result type (might be due to invalid IL or missing references)
//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
CalculateDefaultWindowRect();
_fieldDrawer = new SettingFieldDrawer(this);
_showAdvanced = Config.Bind<bool>("Filtering", "Show advanced", false, (ConfigDescription)null);
_showKeybinds = Config.Bind<bool>("Filtering", "Show keybinds", true, (ConfigDescription)null);
_showSettings = Config.Bind<bool>("Filtering", "Show settings", true, (ConfigDescription)null);
_keybind = Config.Bind<KeyboardShortcut>("General", "Show config manager", new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[0]), new ConfigDescription("The shortcut used to toggle the config manager window on and off.\nThe key can be overridden by a game-specific plugin if necessary, in that case this setting is ignored.", (AcceptableValueBase)null, new object[0]));
_hideSingleSection = Config.Bind<bool>("General", "Hide single sections", false, new ConfigDescription("Show section title for plugins with only one section", (AcceptableValueBase)null, new object[0]));
_pluginConfigCollapsedDefault = Config.Bind<bool>("General", "Plugin collapsed default", true, new ConfigDescription("If set to true plugins will be collapsed when opening the configuration manager window", (AcceptableValueBase)null, new object[0]));
_windowTitle = Config.Bind<string>("Text", "WindowTitle", "Configuration Manager", new ConfigDescription("Window title text", (AcceptableValueBase)null, new object[0]));
_normalText = Config.Bind<string>("Text", "NormalText", "Normal", new ConfigDescription("Normal settings toggle text", (AcceptableValueBase)null, new object[0]));
_showText = Config.Bind<string>("Text", "ShowText", "Show: ", new ConfigDescription("Show label text", (AcceptableValueBase)null, new object[0]));
_shortcutsText = Config.Bind<string>("Text", "ShortcutsText", "Keybinds", new ConfigDescription("Shortcut key settings toggle text", (AcceptableValueBase)null, new object[0]));
_advancedText = Config.Bind<string>("Text", "AdvancedText", "Advanced", new ConfigDescription("Advanced settings toggle text", (AcceptableValueBase)null, new object[0]));
_searchText = Config.Bind<string>("Text", "SearchText", "Search Settings: ", new ConfigDescription("Search label text", (AcceptableValueBase)null, new object[0]));
_reloadText = Config.Bind<string>("Text", "ReloadText", "Reload From File", new ConfigDescription("Reload mod config from file text", (AcceptableValueBase)null, new object[0]));
_resetText = Config.Bind<string>("Text", "ResetText", "Reset To Default", new ConfigDescription("Reset mod config to default text", (AcceptableValueBase)null, new object[0]));
_resetSettingText = Config.Bind<string>("Text", "ResetSettingText", "Reset", new ConfigDescription("Reset setting text", (AcceptableValueBase)null, new object[0]));
_expandText = Config.Bind<string>("Text", "ExpandText", "Expand", new ConfigDescription("Expand button text", (AcceptableValueBase)null, new object[0]));
_collapseText = Config.Bind<string>("Text", "CollapseText", "Collapse", new ConfigDescription("Collapse button text", (AcceptableValueBase)null, new object[0]));
_tipText = Config.Bind<string>("Text", "TipText", "Tip: Click plugin names to expand. Hover over setting names to see their descriptions.", new ConfigDescription("Tip text", (AcceptableValueBase)null, new object[0]));
_clearText = Config.Bind<string>("Text", "ClearText", "Clear", new ConfigDescription("Clear search text", (AcceptableValueBase)null, new object[0]));
_debugText = Config.Bind<string>("Text", "DebugText", "Debug mode", new ConfigDescription("Debug text", (AcceptableValueBase)null, new object[0]));
_logText = Config.Bind<string>("Text", "LogText", "Log", new ConfigDescription("Log text", (AcceptableValueBase)null, new object[0]));
_pluginConfigCollapsedDefault = Config.Bind<bool>("General", "Plugin collapsed default", true, new ConfigDescription("If set to true plugins will be collapsed when opening the configuration manager window", (AcceptableValueBase)null, new object[0]));
_windowPosition = Config.Bind<Vector2>("General", "WindowPosition", new Vector2(55f, 35f), "Window position");
ConfigFile config = Config;
Rect settingWindowRect = SettingWindowRect;
_windowSize = config.Bind<Vector2>("General", "WindowSize", ((Rect)(ref settingWindowRect)).size, "Window size");
_textSize = Config.Bind<int>("General", "FontSize", 14, "Font Size");
_windowBackgroundColor = Config.Bind<Color>("Colors", "WindowBackgroundColor", new Color(0f, 0f, 0f, 0.75f), "Window background color");
_entryBackgroundColor = Config.Bind<Color>("Colors", "EntryBackgroundColor", new Color(0.5f, 0.5f, 0.5f, 0.75f), "Entry background color");
_fontColor = Config.Bind<Color>("Colors", "FontColor", new Color(1f, 1f, 1f, 1f), "Font color");
_disabledColor = Config.Bind<Color>("Colors", "DisabledColor", new Color(0.7f, 0.7f, 0.7f, 1f), "Disabled color");
_widgetBackgroundColor = Config.Bind<Color>("Colors", "WidgetColor", new Color(0f, 0f, 0f, 0.75f), "Widget color");
_windowBackgroundColor.SettingChanged += Background_SettingChanged;
_entryBackgroundColor.SettingChanged += Background_SettingChanged;
currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value);
CreateBackgrounds();
Type typeFromHandle = typeof(Cursor);
_curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public);
_curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public);
if ((object)_curLockState == null && (object)_curVisible == null)
{
_obsoleteCursor = true;
_curLockState = typeof(Screen).GetProperty("lockCursor", BindingFlags.Static | BindingFlags.Public);
_curVisible = typeof(Screen).GetProperty("showCursor", BindingFlags.Static | BindingFlags.Public);
}
try
{
Config.Save();
}
catch (IOException ex)
{
Logger.Log((LogLevel)12, (object)("WARNING: Failed to write to config directory, expect issues!\nError message:" + ex.Message));
}
catch (UnauthorizedAccessException ex2)
{
Logger.Log((LogLevel)12, (object)("WARNING: Permission denied to write to config directory, expect issues!\nError message:" + ex2.Message));
}
}
private void Background_SettingChanged(object sender, EventArgs e)
{
CreateBackgrounds();
}
public void RegisterCustomSettingDrawer(Type settingType, Action<SettingEntryBase> onGuiDrawer)
{
if ((object)settingType == null)
{
throw new ArgumentNullException("settingType");
}
if (onGuiDrawer == null)
{
throw new ArgumentNullException("onGuiDrawer");
}
if (SettingFieldDrawer.SettingDrawHandlers.ContainsKey(settingType))
{
Logger.LogWarning((object)("Tried to add a setting drawer for type " + settingType.FullName + " while one already exists."));
}
else
{
SettingFieldDrawer.SettingDrawHandlers[settingType] = onGuiDrawer;
}
}
public void BuildSettingList()
{
SettingSearcher.CollectSettings(out var results, out var modsWithoutSettings, _showDebug);
_modsWithoutSettings = string.Join(", ", (from x in modsWithoutSettings
select x.TrimStart(new char[1] { '!' }) into x
orderby x
select x).ToArray());
_allSettings = results.ToList();
BuildFilteredSettingList();
}
private void BuildFilteredSettingList()
{
IEnumerable<SettingEntryBase> source = _allSettings;
string[] searchStrings = SearchString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (searchStrings.Length != 0)
{
source = source.Where((SettingEntryBase x) => ContainsSearchString(x, searchStrings));
}
else
{
if (!_showAdvanced.Value)
{
source = source.Where((SettingEntryBase x) => x.IsAdvanced != true);
}
if (!_showKeybinds.Value)
{
source = source.Where((SettingEntryBase x) => !IsKeyboardShortcut(x));
}
if (!_showSettings.Value)
{
source = source.Where((SettingEntryBase x) => x.IsAdvanced == true || IsKeyboardShortcut(x));
}
}
bool settingsAreCollapsed = _pluginConfigCollapsedDefault.Value;
HashSet<string> nonDefaultCollpasingStateByPluginName = new HashSet<string>();
foreach (PluginSettingsData filteredSetting in _filteredSettings)
{
if (filteredSetting.Collapsed != settingsAreCollapsed)
{
nonDefaultCollpasingStateByPluginName.Add(filteredSetting.Info.Name);
}
}
_filteredSettings = (from x in (from x in source
group x by x.PluginInfo).Select(delegate(IGrouping<BepInPlugin, SettingEntryBase> pluginSettings)
{
IEnumerable<PluginSettingsData.PluginSettingsGroupData> source2 = from eb in pluginSettings
group eb by eb.Category into x
orderby string.Equals(x.Key, "Keyboard shortcuts", StringComparison.Ordinal), x.Key
select new PluginSettingsData.PluginSettingsGroupData
{
Name = x.Key,
Settings = (from set in x
orderby set.Order descending, set.DispName
select set).ToList()
};
string website = Utils.GetWebsite(pluginSettings.First().PluginInstance);
return new PluginSettingsData
{
Info = pluginSettings.Key,
Categories = source2.ToList(),
Collapsed = (nonDefaultCollpasingStateByPluginName.Contains(pluginSettings.Key.Name) ? (!settingsAreCollapsed) : settingsAreCollapsed),
Website = website
};
})
orderby x.Info.Name
select x).ToList();
}
private static bool IsKeyboardShortcut(SettingEntryBase x)
{
return (object)x.SettingType == typeof(KeyboardShortcut);
}
private static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings)
{
string combinedSearchTarget = setting.PluginInfo.Name + "\n" + setting.PluginInfo.GUID + "\n" + setting.DispName + "\n" + setting.Category + "\n" + setting.Description + "\n" + setting.DefaultValue?.ToString() + "\n" + setting.Get();
return searchStrings.All((string s) => combinedSearchTarget.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0);
}
private void CalculateDefaultWindowRect()
{
//IL_005e: 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_008c: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
int num = Mathf.Min(Screen.width, 650);
int num2 = ((Screen.height < 560) ? Screen.height : (Screen.height - 100));
int num3 = Mathf.RoundToInt((float)(Screen.width - num) / 2f);
int num4 = Mathf.RoundToInt((float)(Screen.height - num2) / 2f);
SettingWindowRect = new Rect((float)num3, (float)num4, (float)num, (float)num2);
_screenRect = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height);
Rect settingWindowRect = SettingWindowRect;
LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref settingWindowRect)).width / 2.5f);
settingWindowRect = SettingWindowRect;
RightColumnWidth = (int)((Rect)(ref settingWindowRect)).width - LeftColumnWidth - 115;
}
private void OnGUI()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_0021: 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)
//IL_0033: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Expected O, but got Unknown
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: 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_023f: Unknown result type (might be due to invalid IL or missing references)
if (!DisplayingWindow)
{
return;
}
if ((int)Event.current.type == 5)
{
KeyCode keyCode = Event.current.keyCode;
KeyboardShortcut value = _keybind.Value;
if (keyCode == ((KeyboardShortcut)(ref value)).MainKey)
{
DisplayingWindow = false;
closedThisFrame = true;
return;
}
}
CreateStyles();
if (_textSize.Value > 9 && _textSize.Value < 100)
{
fontSize = Mathf.Clamp(_textSize.Value, 10, 30);
}
SetUnlockCursor(0, cursorVisible: true);
GUI.Box(currentWindowRect, GUIContent.none, new GUIStyle());
GUI.backgroundColor = _windowBackgroundColor.Value;
if (_windowSize.Value.x > 200f && _windowSize.Value.x < (float)Screen.width && _windowSize.Value.y > 200f && _windowSize.Value.y < (float)Screen.height)
{
((Rect)(ref currentWindowRect)).size = _windowSize.Value;
}
RightColumnWidth = Mathf.RoundToInt(((Rect)(ref currentWindowRect)).width / 2.5f * (float)fontSize / 12f);
LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref currentWindowRect)).width - (float)RightColumnWidth - 115f);
currentWindowRect = GUILayout.Window(-68, currentWindowRect, new WindowFunction(SettingsWindow), _windowTitle.Value, windowStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (!SettingFieldDrawer.SettingKeyboardShortcut)
{
UnityInput.Current.ResetInputAxes();
}
if (!UnityInput.Current.GetKey((KeyCode)323) && (((Rect)(ref currentWindowRect)).x != _windowPosition.Value.x || ((Rect)(ref currentWindowRect)).y != _windowPosition.Value.y))
{
_windowPosition.Value = ((Rect)(ref currentWindowRect)).position;
Config.Save();
}
}
private void CreateBackgrounds()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false);
val.SetPixel(0, 0, _windowBackgroundColor.Value);
val.Apply();
WindowBackground = val;
Texture2D val2 = new Texture2D(1, 1, (TextureFormat)5, false);
val2.SetPixel(0, 0, _entryBackgroundColor.Value);
val2.Apply();
EntryBackground = val2;
}
private void CreateStyles()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00aa: 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_00d9: Expected O, but got Unknown
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Expected O, but got Unknown
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Expected O, but got Unknown
windowStyle = new GUIStyle(GUI.skin.window);
windowStyle.normal.textColor = _fontColor.Value;
windowStyle.active.textColor = _fontColor.Value;
labelStyle = new GUIStyle(GUI.skin.label);
labelStyle.normal.textColor = _fontColor.Value;
labelStyle.fontSize = fontSize;
textStyle = new GUIStyle(GUI.skin.textArea);
textStyle.normal.textColor = _fontColor.Value;
textStyle.fontSize = fontSize;
buttonStyle = new GUIStyle(GUI.skin.button);
buttonStyle.normal.textColor = _fontColor.Value;
buttonStyle.fontSize = fontSize;
categoryHeaderSkin = new GUIStyle(labelStyle)
{
alignment = (TextAnchor)1,
wordWrap = true,
stretchWidth = true
};
pluginHeaderSkin = new GUIStyle(categoryHeaderSkin);
toggleStyle = new GUIStyle(GUI.skin.toggle);
toggleStyle.normal.textColor = _disabledColor.Value;
toggleStyle.onNormal.textColor = _fontColor.Value;
toggleStyle.fontSize = fontSize;
boxStyle = new GUIStyle(GUI.skin.box);
boxStyle.normal.textColor = _fontColor.Value;
boxStyle.fontSize = fontSize;
sliderStyle = new GUIStyle(GUI.skin.horizontalSlider);
thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb);
}
private static void DrawTooltip(Rect area)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_006b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
if (!string.IsNullOrEmpty(GUI.tooltip))
{
Event current = Event.current;
GUIStyle val = new GUIStyle(boxStyle)
{
wordWrap = true,
alignment = (TextAnchor)4
};
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = _entryBackgroundColor.Value;
float num = val.CalcHeight(new GUIContent(GUI.tooltip), 400f) + 10f;
float num2 = ((current.mousePosition.x + 400f > ((Rect)(ref area)).width) ? (((Rect)(ref area)).width - 400f) : current.mousePosition.x);
float num3 = ((current.mousePosition.y + 25f + num > ((Rect)(ref area)).height) ? (current.mousePosition.y - num) : (current.mousePosition.y + 25f));
GUI.Box(new Rect(num2, num3, 400f, num), GUI.tooltip, val);
GUI.backgroundColor = backgroundColor;
}
}
private void SettingsWindow(int id)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Invalid comparison between Unknown and I4
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Invalid comparison between Unknown and I4
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref currentWindowRect)).width, 20f));
DrawWindowHeader();
_settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[0]);
float y = _settingWindowScrollPos.y;
float height = ((Rect)(ref currentWindowRect)).height;
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
Rect lastRect;
if (string.IsNullOrEmpty(SearchString))
{
DrawTips();
if (_tipsHeight == 0 && (int)Event.current.type == 7)
{
lastRect = GUILayoutUtility.GetLastRect();
_tipsHeight = (int)((Rect)(ref lastRect)).height;
}
}
int num = _tipsHeight;
foreach (PluginSettingsData filteredSetting in _filteredSettings)
{
if (filteredSetting.Height == 0 || ((float)(num + filteredSetting.Height) >= y && (float)num <= y + height))
{
try
{
DrawSinglePlugin(filteredSetting);
}
catch (ArgumentException)
{
}
if (filteredSetting.Height == 0 && (int)Event.current.type == 7)
{
lastRect = GUILayoutUtility.GetLastRect();
filteredSetting.Height = (int)((Rect)(ref lastRect)).height;
}
}
else
{
try
{
GUILayout.Space((float)filteredSetting.Height);
}
catch (ArgumentException)
{
}
}
num += filteredSetting.Height;
}
if (_showDebug)
{
GUILayout.Space(10f);
GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
}
else
{
GUILayout.Space(70f);
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
if (!SettingFieldDrawer.DrawCurrentDropdown())
{
DrawTooltip(currentWindowRect);
}
}
private void DrawTips()
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Label(_tipText.Value, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
if (GUILayoutButton(_pluginConfigCollapsedDefault.Value ? _expandText.Value : _collapseText.Value, buttonStyle, GUILayout.ExpandWidth(false)))
{
bool flag = !_pluginConfigCollapsedDefault.Value;
_pluginConfigCollapsedDefault.Value = flag;
foreach (PluginSettingsData filteredSetting in _filteredSettings)
{
filteredSetting.Collapsed = flag;
}
}
GUILayout.EndHorizontal();
}
private void DrawWindowHeader()
{
GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Label(_showText.Value, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
GUI.enabled = SearchString == string.Empty;
bool flag = GUILayoutToggle(_showSettings.Value, _normalText.Value, toggleStyle);
if (_showSettings.Value != flag)
{
_showSettings.Value = flag;
BuildFilteredSettingList();
}
flag = GUILayoutToggle(_showKeybinds.Value, _shortcutsText.Value, toggleStyle);
if (_showKeybinds.Value != flag)
{
_showKeybinds.Value = flag;
BuildFilteredSettingList();
}
flag = GUILayoutToggle(_showAdvanced.Value, _advancedText.Value, toggleStyle);
if (_showAdvanced.Value != flag)
{
_showAdvanced.Value = flag;
BuildFilteredSettingList();
}
GUI.enabled = true;
flag = GUILayout.Toggle(_showDebug, _debugText.Value, toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (_showDebug != flag)
{
_showDebug = flag;
BuildSettingList();
}
if (GUILayoutButton(_logText.Value, buttonStyle, GUILayout.ExpandWidth(false)))
{
try
{
Utils.OpenLog();
}
catch (SystemException ex)
{
Logger.Log((LogLevel)10, (object)ex.Message);
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Label(_searchText.Value, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
GUI.SetNextControlName("searchBox");
SearchString = GUILayout.TextField(SearchString, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if (_focusSearchBox)
{
GUI.FocusWindow(-68);
GUI.FocusControl("searchBox");
_focusSearchBox = false;
}
if (GUILayoutButton(_clearText.Value, buttonStyle, GUILayout.ExpandWidth(false)))
{
SearchString = string.Empty;
}
GUILayout.EndHorizontal();
}
internal static bool GUILayoutToggle(bool value1, string value2, GUIStyle toggleStyle, params GUILayoutOption[] options)
{
return GUILayout.Toggle(value1, value2, toggleStyle, options);
}
private void DrawSinglePlugin(PluginSettingsData plugin)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected O, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle(GUI.skin.box);
val.normal.textColor = _fontColor.Value;
val.normal.background = EntryBackground;
val.fontSize = fontSize;
GUI.backgroundColor = _entryBackgroundColor.Value;
GUILayout.BeginVertical(val, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUIContent content = (_showDebug ? new GUIContent($"{plugin.Info.Name.TrimStart(new char[1] { '!' })} {plugin.Info.Version}", "GUID: " + plugin.Info.GUID) : new GUIContent($"{plugin.Info.Name.TrimStart(new char[1] { '!' })} {plugin.Info.Version}"));
bool flag = !string.IsNullOrEmpty(SearchString);
bool flag2 = plugin.Website != null;
if (flag2)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(29f);
}
if (SettingFieldDrawer.DrawPluginHeader(content, plugin.Collapsed && !flag) && !flag)
{
plugin.Collapsed = !plugin.Collapsed;
}
if (flag2)
{
Color color = GUI.color;
GUI.color = Color.gray;
if (GUILayoutButton(new GUIContent("URL", plugin.Website), buttonStyle, GUILayout.ExpandWidth(false)))
{
Utils.OpenWebsite(plugin.Website);
}
GUI.color = color;
GUILayout.EndHorizontal();
}
if (flag || !plugin.Collapsed)
{
foreach (PluginSettingsData.PluginSettingsGroupData category in plugin.Categories)
{
if (!string.IsNullOrEmpty(category.Name) && (plugin.Categories.Count > 1 || !_hideSingleSection.Value))
{
SettingFieldDrawer.DrawCategoryHeader(category.Name);
}
foreach (SettingEntryBase setting in category.Settings)
{
DrawSingleSetting(setting);
GUILayout.Space(2f);
}
}
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayoutButton(_reloadText.Value, buttonStyle, GUILayout.ExpandWidth(true)))
{
using (List<PluginSettingsData.PluginSettingsGroupData>.Enumerator enumerator3 = plugin.Categories.GetEnumerator())
{
if (enumerator3.MoveNext())
{
PluginSettingsData.PluginSettingsGroupData current3 = enumerator3.Current;
using List<SettingEntryBase>.Enumerator enumerator4 = current3.Settings.GetEnumerator();
if (enumerator4.MoveNext())
{
SettingEntryBase current4 = enumerator4.Current;
current4.PluginInstance.Config.Reload();
}
}
}
BuildFilteredSettingList();
}
if (GUILayoutButton(_resetText.Value, buttonStyle, GUILayout.ExpandWidth(true)))
{
foreach (PluginSettingsData.PluginSettingsGroupData category2 in plugin.Categories)
{
foreach (SettingEntryBase setting2 in category2.Settings)
{
setting2.Set(setting2.DefaultValue);
}
}
BuildFilteredSettingList();
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
public static bool GUILayoutButton(string value, GUIStyle buttonStyle, GUILayoutOption gUILayoutOption)
{
//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_0029: Unknown result type (might be due to invalid IL or missing references)
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = _widgetBackgroundColor.Value;
bool result = GUILayout.Button(value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { gUILayoutOption });
GUI.backgroundColor = backgroundColor;
return result;
}
public static bool GUILayoutButton(GUIContent value, GUIStyle buttonStyle, GUILayoutOption gUILayoutOption)
{
//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_0029: Unknown result type (might be due to invalid IL or missing references)
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = _widgetBackgroundColor.Value;
bool result = GUILayout.Button(value, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { gUILayoutOption });
GUI.backgroundColor = backgroundColor;
return result;
}
private void DrawSingleSetting(SettingEntryBase setting)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
try
{
DrawSettingName(setting);
_fieldDrawer.DrawSettingValue(setting);
DrawDefaultButton(setting);
}
catch (Exception arg)
{
Logger.Log((LogLevel)2, (object)$"Failed to draw setting {setting.DispName} - {arg}");
GUILayout.Label("Failed to draw this field, check log for details.", (GUILayoutOption[])(object)new GUILayoutOption[0]);
}
GUILayout.EndHorizontal();
}
private void DrawSettingName(SettingEntryBase setting)
{
//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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_0092: 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)
if (!setting.HideSettingName)
{
Color color = GUI.color;
if (setting.IsAdvanced == true)
{
GUI.color = _advancedSettingColor;
}
GUILayout.Label(new GUIContent(setting.DispName.TrimStart(new char[1] { '!' }), setting.Description), labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width((float)LeftColumnWidth),
GUILayout.MaxWidth((float)LeftColumnWidth)
});
GUI.color = color;
}
}
private void DrawDefaultButton(SettingEntryBase setting)
{
if (setting.HideDefaultButton)
{
return;
}
if (setting.DefaultValue != null)
{
GUILayout.Space(5f);
if (GUILayoutButton(_resetSettingText.Value, buttonStyle, GUILayout.ExpandWidth(false)))
{
setting.Set(setting.DefaultValue);
}
}
else if (setting.SettingType.IsClass)
{
GUILayout.Space(5f);
if (GUILayoutButton(_resetSettingText.Value, buttonStyle, GUILayout.ExpandWidth(false)))
{
setting.Set(null);
}
}
}
private void Update()
{
//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)
if (DisplayingWindow)
{
SetUnlockCursor(0, cursorVisible: true);
}
if (!OverrideHotkey)
{
KeyboardShortcut value = _keybind.Value;
if (((KeyboardShortcut)(ref value)).IsUp() && !closedThisFrame)
{
DisplayingWindow = !DisplayingWindow;
}
closedThisFrame = false;
}
}
private void LateUpdate()
{
if (DisplayingWindow)
{
SetUnlockCursor(0, cursorVisible: true);
}
}
private void SetUnlockCursor(int lockState, bool cursorVisible)
{
if ((object)_curLockState != null)
{
if (_obsoleteCursor)
{
_curLockState.SetValue(null, Convert.ToBoolean(lockState), null);
}
else
{
_curLockState.SetValue(null, lockState, null);
}
_curVisible.SetValue(null, cursorVisible, null);
}
}
}
public abstract class SettingEntryBase
{
private static readonly PropertyInfo[] _myProperties = typeof(SettingEntryBase).GetProperties(BindingFlags.Instance | BindingFlags.Public);
public object[] AcceptableValues { get; protected set; }
public KeyValuePair<object, object> AcceptableValueRange { get; protected set; }
public bool? ShowRangeAsPercent { get; protected set; }
public Action<ConfigEntryBase> CustomDrawer { get; private set; }
public bool? Browsable { get; protected set; }
public string Category { get; protected set; }
public object DefaultValue { get; protected set; }
public bool HideDefaultButton { get; protected set; }
public bool HideSettingName { get; protected set; }
public string Description { get; protected internal set; }
public virtual string DispName { get; protected internal set; }
public BepInPlugin PluginInfo { get; protected internal set; }
public bool? ReadOnly { get; protected set; }
public abstract Type SettingType { get; }
public BaseUnityPlugin PluginInstance { get; private set; }
public bool? IsAdvanced { get; internal set; }
public int Order { get; protected set; }
public Func<object, string> ObjToStr { get; internal set; }
public Func<string, object> StrToObj { get; internal set; }
public abstract object Get();
public void Set(object newVal)
{
if (ReadOnly != true)
{
SetValue(newVal);
}
}
protected abstract void SetValue(object newVal);
internal void SetFromAttributes(object[] attribs, BaseUnityPlugin pluginInstance)
{
PluginInstance = pluginInstance;
PluginInfo = ((pluginInstance != null) ? pluginInstance.Info.Metadata : null);
if (attribs == null || attribs.Length == 0)
{
return;
}
foreach (object obj in attribs)
{
object obj2 = obj;
object obj3 = obj2;
if (obj3 == null)
{
continue;
}
if (!(obj3 is DisplayNameAttribute displayNameAttribute))
{
if (!(obj3 is CategoryAttribute categoryAttribute))
{
if (!(obj3 is DescriptionAttribute descriptionAttribute))
{
if (!(obj3 is DefaultValueAttribute defaultValueAttribute))
{
if (!(obj3 is ReadOnlyAttribute readOnlyAttribute))
{
if (!(obj3 is BrowsableAttribute browsableAttribute))
{
Action<SettingEntryBase> action = obj3 as Action<SettingEntryBase>;
if (action == null)
{
if (obj3 is string text)
{
switch (text)
{
case "ReadOnly":
ReadOnly = true;
break;
case "Browsable":
Browsable = true;
break;
case "Unbrowsable":
case "Hidden":
Browsable = false;
break;
case "Advanced":
IsAdvanced = true;
break;
}
continue;
}
Type type = obj.GetType();
if (!(type.Name == "ConfigurationManagerAttributes"))
{
break;
}
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
foreach (var item in from my in _myProperties
join other in fields on my.Name equals other.Name
select new { my, other })
{
try
{
object value = item.other.GetValue(obj);
if (value != null)
{
item.my.SetValue(this, value, null);
}
}
catch (Exception ex)
{
ConfigurationManager.Logger.LogWarning((object)("Failed to copy value " + item.my.Name + " from provided tag object " + type.FullName + " - " + ex.Message));
}
}
}
else
{
CustomDrawer = delegate
{
action(this);
};
}
}
else
{
Browsable = browsableAttribute.Browsable;
}
}
else
{
ReadOnly = readOnlyAttribute.IsReadOnly;
}
}
else
{
DefaultValue = defaultValueAttribute.Value;
}
}
else
{
Description = descriptionAttribute.Description;
}
}
else
{
Category = categoryAttribute.Category;
}
}
else
{
DispName = displayNameAttribute.DisplayName;
}
}
}
}
internal class SettingFieldDrawer
{
private sealed class ColorCacheEntry
{
public Color Last;
public Texture2D Tex;
}
private static IEnumerable<KeyCode> _keysToCheck;
private static readonly Dictionary<SettingEntryBase, ComboBox> _comboBoxCache;
private static readonly Dictionary<SettingEntryBase, ColorCacheEntry> _colorCache;
private static Updater _instance;
private static SettingEntryBase _currentKeyboardShortcutToSet;
private readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>();
public static Dictionary<Type, Action<SettingEntryBase>> SettingDrawHandlers { get; }
public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null;
static SettingFieldDrawer()
{
_comboBoxCache = new Dictionary<SettingEntryBase, ComboBox>();
_colorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>();
SettingDrawHandlers = new Dictionary<Type, Action<SettingEntryBase>>
{
{
typeof(bool),
DrawBoolField
},
{
typeof(KeyboardShortcut),
DrawKeyboardShortcut
},
{
typeof(KeyCode),
DrawKeyCode
},
{
typeof(Color),
DrawColor
},
{
typeof(Vector2),
DrawVector2
},
{
typeof(Vector3),
DrawVector3
},
{
typeof(Vector4),
DrawVector4
},
{
typeof(Quaternion),
DrawQuaternion
}
};
}
public SettingFieldDrawer(Updater instance)
{
_instance = instance;
}
public void DrawSettingValue(SettingEntryBase setting)
{
if (setting.CustomDrawer != null)
{
setting.CustomDrawer((setting is ConfigSettingEntry configSettingEntry) ? configSettingEntry.Entry : null);
}
else if (setting.ShowRangeAsPercent.HasValue && setting.AcceptableValueRange.Key != null)
{
DrawRangeField(setting);
}
else if (setting.AcceptableValues != null)
{
DrawListField(setting);
}
else if (!DrawFieldBasedOnValueType(setting))
{
if (setting.SettingType.IsEnum)
{
DrawEnumField(setting);
}
else
{
DrawUnknownField(setting, _instance.RightColumnWidth);
}
}
}
public static void ClearCache()
{
_comboBoxCache.Clear();
foreach (KeyValuePair<SettingEntryBase, ColorCacheEntry> item in _colorCache)
{
Object.Destroy((Object)(object)item.Value.Tex);
}
_colorCache.Clear();
}
public static void DrawCenteredLabel(string text, params GUILayoutOption[] options)
{
GUILayout.BeginHorizontal(options);
GUILayout.FlexibleSpace();
GUILayout.Label(text, Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
public static void DrawCategoryHeader(string text)
{
GUILayout.Label(text, Updater.categoryHeaderSkin, (GUILayoutOption[])(object)new GUILayoutOption[0]);
}
public static bool DrawPluginHeader(GUIContent content, bool isCollapsed)
{
if (isCollapsed)
{
content.text += "\n...";
}
return Updater.GUILayoutButton(content, Updater.pluginHeaderSkin, GUILayout.ExpandWidth(true));
}
public static bool DrawCurrentDropdown()
{
if (ComboBox.CurrentDropdownDrawer != null)
{
ComboBox.CurrentDropdownDrawer();
ComboBox.CurrentDropdownDrawer = null;
return true;
}
return false;
}
private static void DrawListField(SettingEntryBase setting)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
object[] acceptableValues = setting.AcceptableValues;
if (acceptableValues.Length == 0)
{
throw new ArgumentException("AcceptableValueListAttribute returned an empty list of acceptable values. You need to supply at least 1 option.");
}
if (!setting.SettingType.IsInstanceOfType(acceptableValues.FirstOrDefault((object x) => x != null)))
{
throw new ArgumentException("AcceptableValueListAttribute returned a list with items of type other than the settng type itself.");
}
if ((object)setting.SettingType == typeof(KeyCode))
{
DrawKeyCode(setting);
return;
}
Rect settingWindowRect = _instance.SettingWindowRect;
DrawComboboxField(setting, acceptableValues, ((Rect)(ref settingWindowRect)).yMax);
}
private static bool DrawFieldBasedOnValueType(SettingEntryBase setting)
{
if (SettingDrawHandlers.TryGetValue(setting.SettingType, out var value))
{
value(setting);
return true;
}
return false;
}
private static void DrawBoolField(SettingEntryBase setting)
{
//IL_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)
bool flag = (bool)setting.Get();
Color color = GUI.color;
bool flag2 = Updater.GUILayoutToggle(flag, flag ? "Enabled" : "Disabled", Updater.toggleStyle, GUILayout.ExpandWidth(true));
if (flag2 != flag)
{
setting.Set(flag2);
}
}
private static void DrawEnumField(SettingEntryBase setting)
{
//IL_004f: 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)
if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any())
{
DrawFlagsField(setting, Enum.GetValues(setting.SettingType), _instance.RightColumnWidth);
return;
}
Array values = Enum.GetValues(setting.SettingType);
Rect settingWindowRect = _instance.SettingWindowRect;
DrawComboboxField(setting, values, ((Rect)(ref settingWindowRect)).yMax);
}
private static void DrawFlagsField(SettingEntryBase setting, IList enumValues, int maxWidth)
{
//IL_0097: 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)
long num = Convert.ToInt64(setting.Get());
var array = (from Enum x in enumValues
select new
{
name = x.ToString(),
val = Convert.ToInt64(x)
}).ToArray();
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)maxWidth) });
int i = 0;
while (i < array.Length)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
int num2 = 0;
for (; i < array.Length; i++)
{
var anon = array[i];
if (anon.val != 0)
{
int num3 = (int)Updater.toggleStyle.CalcSize(new GUIContent(anon.name)).x;
num2 += num3;
if (num2 > maxWidth)
{
break;
}
GUI.changed = false;
bool flag = GUILayout.Toggle((num & anon.val) == anon.val, anon.name, Updater.toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
if (GUI.changed)
{
long value = (flag ? (num | anon.val) : (num & ~anon.val));
setting.Set(Enum.ToObject(setting.SettingType, value));
}
}
}
GUILayout.EndHorizontal();
}
GUI.changed = false;
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
}
private static void DrawComboboxField(SettingEntryBase setting, IList list, float windowYmax)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = ObjectToGuiContent(setting.Get());
Rect rect = GUILayoutUtility.GetRect(val, Updater.buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if (!_comboBoxCache.TryGetValue(setting, out var value))
{
value = new ComboBox(rect, val, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), Updater.buttonStyle, windowYmax);
_comboBoxCache[setting] = value;
}
else
{
value.Rect = rect;
value.ButtonContent = val;
}
value.Show(delegate(int id)
{
if (id >= 0 && id < list.Count)
{
setting.Set(list[id]);
}
});
}
private static GUIContent ObjectToGuiContent(object x)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
if (x is Enum)
{
Type type = x.GetType();
DescriptionAttribute descriptionAttribute = type.GetMember(x.ToString()).FirstOrDefault()?.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false).Cast<DescriptionAttribute>().FirstOrDefault();
if (descriptionAttribute != null)
{
return new GUIContent(descriptionAttribute.Description);
}
return new GUIContent(x.ToString().ToProperCase());
}
return new GUIContent(x.ToString());
}
private static void DrawRangeField(SettingEntryBase setting)
{
object obj = setting.Get();
float num = (float)Convert.ToDouble(obj, CultureInfo.InvariantCulture);
float num2 = (float)Convert.ToDouble(setting.AcceptableValueRange.Key, CultureInfo.InvariantCulture);
float num3 = (float)Convert.ToDouble(setting.AcceptableValueRange.Value, CultureInfo.InvariantCulture);
float num4 = GUILayout.HorizontalSlider(num, num2, num3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if (Math.Abs(num4 - num) > Mathf.Abs(num3 - num2) / 1000f)
{
object newVal = Convert.ChangeType(num4, setting.SettingType, CultureInfo.InvariantCulture);
setting.Set(newVal);
}
if (setting.ShowRangeAsPercent == true)
{
DrawCenteredLabel(Mathf.Round(100f * Mathf.Abs(num4 - num2) / Mathf.Abs(num3 - num2)) + "%", GUILayout.Width(50f));
return;
}
string text = obj.ToString().AppendZeroIfFloat(setting.SettingType);
string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
if (!(text2 != text))
{
return;
}
try
{
float num5 = (float)Convert.ToDouble(text2, CultureInfo.InvariantCulture);
float num6 = Mathf.Clamp(num5, num2, num3);
setting.Set(Convert.ChangeType(num6, setting.SettingType, CultureInfo.InvariantCulture));
}
catch (FormatException)
{
}
}
private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth)
{
if (setting.ObjToStr != null && setting.StrToObj != null)
{
string text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType);
string text2 = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width((float)rightColumnWidth),
GUILayout.MaxWidth((float)rightColumnWidth)
});
if (text2 != text)
{
setting.Set(setting.StrToObj(text2));
}
}
else
{
object obj = setting.Get();
string text3 = ((obj == null) ? "NULL" : obj.ToString().AppendZeroIfFloat(setting.SettingType));
if (CanCovert(text3, setting.SettingType))
{
string text4 = GUILayout.TextField(text3, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width((float)rightColumnWidth),
GUILayout.MaxWidth((float)rightColumnWidth)
});
if (text4 != text3)
{
setting.Set(Convert.ChangeType(text4, setting.SettingType, CultureInfo.InvariantCulture));
}
}
else
{
GUILayout.TextArea(text3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) });
}
}
GUILayout.FlexibleSpace();
}
private bool CanCovert(string value, Type type)
{
if (_canCovertCache.ContainsKey(type))
{
return _canCovertCache[type];
}
try
{
object obj = Convert.ChangeType(value, type);
_canCovertCache[type] = true;
return true;
}
catch
{
_canCovertCache[type] = false;
return false;
}
}
private static void DrawKeyCode(SettingEntryBase setting)
{
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
if (_currentKeyboardShortcutToSet == setting)
{
GUILayout.Label("Press any key", Updater.labelStyle, (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))
{
setting.Set(item);
_currentKeyboardShortcutToSet = null;
break;
}
}
if (Updater.GUILayoutButton("Cancel", Updater.buttonStyle, GUILayout.ExpandWidth(false)))
{
_currentKeyboardShortcutToSet = null;
}
}
else
{
object[] acceptableValues = setting.AcceptableValues;
Array list = ((acceptableValues != null && acceptableValues.Length > 1) ? setting.AcceptableValues : Enum.GetValues(setting.SettingType));
Rect settingWindowRect = _instance.SettingWindowRect;
DrawComboboxField(setting, list, ((Rect)(ref settingWindowRect)).yMax);
if (Updater.GUILayoutButton(new GUIContent("Set...", "Set the key by pressing any key on your keyboard."), Updater.buttonStyle, GUILayout.ExpandWidth(false)))
{
_currentKeyboardShortcutToSet = setting;
}
}
}
private static void DrawKeyboardShortcut(SettingEntryBase setting)
{
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if (_currentKeyboardShortcutToSet == setting)
{
GUILayout.Label("Press any key combination", Updater.labelStyle, (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))
{
setting.Set((object)new KeyboardShortcut(item, _keysToCheck.Where((Func<KeyCode, bool>)current.GetKey).ToArray()));
_currentKeyboardShortcutToSet = null;
break;
}
}
if (Updater.GUILayoutButton("Cancel", Updater.buttonStyle, GUILayout.ExpandWidth(false)))
{
_currentKeyboardShortcutToSet = null;
}
}
else
{
if (Updater.GUILayoutButton(setting.Get().ToString(), Updater.buttonStyle, GUILayout.ExpandWidth(true)))
{
_currentKeyboardShortcutToSet = setting;
}
if (Updater.GUILayoutButton("Clear", Updater.buttonStyle, GUILayout.ExpandWidth(false)))
{
setting.Set(KeyboardShortcut.Empty);
_currentKeyboardShortcutToSet = null;
}
}
}
private static void DrawVector2(SettingEntryBase obj)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = (Vector2)obj.Get();
Vector2 val2 = val;
val.x = DrawSingleVectorSlider(val.x, "X");
val.y = DrawSingleVectorSlider(val.y, "Y");
if (val != val2)
{
obj.Set(val);
}
}
private static void DrawVector3(SettingEntryBase obj)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (Vector3)obj.Get();
Vector3 val2 = val;
val.x = DrawSingleVectorSlider(val.x, "X");
val.y = DrawSingleVectorSlider(val.y, "Y");
val.z = DrawSingleVectorSlider(val.z, "Z");
if (val != val2)
{
obj.Set(val);
}
}
private static void DrawVector4(SettingEntryBase obj)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0077: Unknown result type (might be due to invalid IL or missing references)
Vector4 val = (Vector4)obj.Get();
Vector4 val2 = val;
val.x = DrawSingleVectorSlider(val.x, "X");
val.y = DrawSingleVectorSlider(val.y, "Y");
val.z = DrawSingleVectorSlider(val.z, "Z");
val.w = DrawSingleVectorSlider(val.w, "W");
if (val != val2)
{
obj.Set(val);
}
}
private static void DrawQuaternion(SettingEntryBase obj)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0077: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = (Quaternion)obj.Get();
Quaternion val2 = val;
val.x = DrawSingleVectorSlider(val.x, "X");
val.y = DrawSingleVectorSlider(val.y, "Y");
val.z = DrawSingleVectorSlider(val.z, "Z");
val.w = DrawSingleVectorSlider(val.w, "W");
if (val != val2)
{
obj.Set(val);
}
}
private static float DrawSingleVectorSlider(float setting, string label)
{
GUILayout.Label(label, Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
float.TryParse(GUILayout.TextField(setting.ToString("F", CultureInfo.InvariantCulture), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), NumberStyles.Any, CultureInfo.InvariantCulture, out var result);
return result;
}
private static void DrawColor(SettingEntryBase obj)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
Color val = (Color)obj.Get();
if (!_colorCache.TryGetValue(obj, out var value))
{
value = new ColorCacheEntry
{
Tex = new Texture2D(40, 10, (TextureFormat)5, false),
Last = val
};
value.Tex.FillTexture(val);
_colorCache[obj] = value;
}
GUILayout.Label("R", Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
val.r = GUILayout.HorizontalSlider(val.r, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.Label("G", Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
val.g = GUILayout.HorizontalSlider(val.g, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.Label("B", Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
val.b = GUILayout.HorizontalSlider(val.b, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.Label("A", Updater.labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
val.a = GUILayout.HorizontalSlider(val.a, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.Space(4f);
if (val != value.Last)
{
obj.Set(val);
value.Tex.FillTexture(val);
value.Last = val;
}
GUILayout.Label((Texture)(object)value.Tex, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
}
}
public sealed class ValueChangedEventArgs<TValue> : EventArgs
{
public TValue NewValue { get; }
public ValueChangedEventArgs(TValue newValue)
{
NewValue = newValue;
}
}
}
namespace ConfigurationManager.Utilities
{
internal class ComboBox
{
private static bool forceToUnShow;
private static int useControlID = -1;
private readonly string buttonStyle;
private bool isClickedComboButton;
private readonly GUIContent[] listContent;
private readonly GUIStyle listStyle;
private readonly int _windowYmax;
private Vector2 _scrollPosition = Vector2.zero;
public Rect Rect { get; set; }
public GUIContent ButtonContent { get; set; }
public static Action CurrentDropdownDrawer { get; set; }
public ComboBox(Rect rect, GUIContent buttonContent, GUIContent[] listContent, GUIStyle listStyle, float windowYmax)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Rect = rect;
ButtonContent = buttonContent;
this.listContent = listContent;
buttonStyle = "button";
this.listStyle = listStyle;
_windowYmax = (int)windowYmax;
}
public void Show(Action<int> onItemSelected)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
if (forceToUnShow)
{
forceToUnShow = false;
isClickedComboButton = false;
}
bool flag = false;
int controlID = GUIUtility.GetControlID((FocusType)2);
Vector2 val = Vector2.zero;
if ((int)Event.current.GetTypeForControl(controlID) == 1 && isClickedComboButton)
{
flag = true;
val = Event.current.mousePosition;
}
if (GUI.Button(Rect, ButtonContent, GUIStyle.op_Implicit(buttonStyle)))
{
if (useControlID == -1)
{
useControlID = controlID;
isClickedComboButton = false;
}
if (useControlID != controlID)
{
forceToUnShow = true;
useControlID = controlID;
}
isClickedComboButton = true;
}
if (isClickedComboButton)
{
GUI.enabled = false;
GUI.color = new Color(1f, 1f, 1f, 2f);
Rect rect = Rect;
float x = ((Rect)(ref rect)).x;
rect = Rect;
Vector2 location = GUIUtility.GUIToScreenPoint(new Vector2(x, ((Rect)(ref rect)).y + listStyle.CalcHeight(listContent[0], 1f)));
rect = Rect;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(((Rect)(ref rect)).width, listStyle.CalcHeight(listContent[0], 1f) * (float)listContent.Length);
Rect innerRect = new Rect(0f, 0f, val2.x, val2.y);
Rect outerRectScreen = new Rect(location.x, location.y, val2.x, val2.y);
if (((Rect)(ref outerRectScreen)).yMax > (float)_windowYmax)
{
((Rect)(ref outerRectScreen)).height = (float)_windowYmax - ((Rect)(ref outerRectScreen)).y;
ref Rect reference = ref outerRectScreen;
((Rect)(ref reference)).width = ((Rect)(ref reference)).width + 20f;
}
if (val != Vector2.zero && ((Rect)(ref outerRectScreen)).Contains(GUIUtility.GUIToScreenPoint(val)))
{
flag = false;
}
CurrentDropdownDrawer = delegate
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_0049: 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_005f: Expected O, but got Unknown
//IL_0065: Expected O, but got Unknown
//IL_0071: 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_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_008f: 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)
GUI.enabled = true;
Vector2 val3 = GUIUtility.ScreenToGUIPoint(location);
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(val3.x, val3.y, ((Rect)(ref outerRectScreen)).width, ((Rect)(ref outerRectScreen)).height);
GUI.Box(val4, GUIContent.none, new GUIStyle
{
normal = new GUIStyleState
{
background = Updater.WindowBackground
}
});
_scrollPosition = GUI.BeginScrollView(val4, _scrollPosition, innerRect, false, false);
int num = GUI.SelectionGrid(innerRect, -1, listContent, 1, listStyle);
if (num != -1)
{
onItemSelected(num);
isClickedComboButton = false;
}
GUI.EndScrollView(true);
};
}
if (flag)
{
isClickedComboButton = false;
}
}
}
internal static class Utils
{
public static string ToProperCase(this string str)
{
if (string.IsNullOrEmpty(str))
{
return string.Empty;
}
if (str.Length < 2)
{
return str;
}
string text = str.Substring(0, 1).ToUpper();
for (int i = 1; i < str.Length; i++)
{
if (char.IsUpper(str[i]))
{
text += " ";
}
text += str[i];
}
return text;
}
public static IEnumerable<BaseUnityPlugin> FindPlugins()
{
List<BaseUnityPlugin> list = Chainloader.PluginInfos.Values.Select((PluginInfo i) => i.Instance).ToList();
int count = list.Count;
BaseUnityPlugin[] array = Array.ConvertAll(Object.FindObjectsOfType(typeof(BaseUnityPlugin)), (Converter<Object, BaseUnityPlugin>)((Object input) => (BaseUnityPlugin)input));
BaseUnityPlugin[] array2 = array;
foreach (BaseUnityPlugin val in array2)
{
if (!Chainloader.PluginInfos.ContainsKey(val.Info.Metadata.GUID))
{
list.Add(val);
}
}
ConfigurationManager.Logger.LogInfo((object)$"Chainloader.PluginInfos: {count}; FindObjectsOfType: {list.Count - count}");
return list;
}
public static string AppendZero(this string s)
{
return (!s.Contains(".")) ? (s + ".0") : s;
}
public static string AppendZeroIfFloat(this string s, Type type)
{
return ((object)type == typeof(float) || (object)type == typeof(double) || (object)type == typeof(decimal)) ? s.AppendZero() : s;
}
public static void FillTexture(this Texture2D tex, Color color)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < ((Texture)tex).width; i++)
{
for (int j = 0; j < ((Texture)tex).height; j++)
{
tex.SetPixel(i, j, color);
}
}
tex.Apply(false);
}
public static void OpenLog()
{
List<string> list = new List<string>();
string text = Path.Combine(Application.dataPath, "..");
list.Add(Path.Combine(text, "output_log.txt"));
list.Add(Path.Combine(Application.dataPath, "output_log.txt"));
PropertyInfo property = typeof(Application).GetProperty("consoleLogPath", BindingFlags.Static | BindingFlags.Public);
if ((object)property != null)
{
string item = property.GetValue(null, null) as string;
list.Add(item);
}
if (Directory.Exists(Application.persistentDataPath))
{
string item2 = Directory.GetFiles(Application.persistentDataPath, "output_log.txt", SearchOption.AllDirectories).FirstOrDefault();
list.Add(item2);
}
string path2 = list.Where(File.Exists).OrderByDescending(File.GetLastWriteTimeUtc).FirstOrDefault();
if (!TryOpen(path2))
{
list.Clear();
list.AddRange(Directory.GetFiles(text, "LogOutput.log*", SearchOption.AllDirectories));
list.AddRange(Directory.GetFiles(text, "output_log.txt", SearchOption.AllDirectories));
path2 = list.Where(File.Exists).OrderByDescending(File.GetLastWriteTimeUtc).FirstOrDefault();
if (!TryOpen(path2))
{
throw new FileNotFoundException("No log files were found");
}
}
static bool TryOpen(string path)
{
if (path != null)
{
try
{
Process.Start(path);
return true;
}
catch
{
return false;
}
}
return false;
}
}
public static string GetWebsite(BaseUnityPlugin bepInPlugin)
{
if ((Object)(object)bepInPlugin == (Object)null)
{
return null;
}
try
{
string location = ((object)bepInPlugin).GetType().Assembly.Location;
if (!File.Exists(location))
{
return null;
}
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(location);
return new string[5] { versionInfo.CompanyName, versionInfo.FileDescription, versionInfo.Comments, versionInfo.LegalCopyright, versionInfo.LegalTrademarks }.FirstOrDefault((string x) => Uri.IsWellFormedUriString(x, UriKind.Absolute));
}
catch (Exception ex)
{
ManualLogSource logger = ConfigurationManager.Logger;
object obj;
if (bepInPlugin == null)
{
obj = null;
}
else
{
PluginInfo info = bepInPlugin.Info;
if (info == null)
{
obj = null;
}
else
{
BepInPlugin metadata = info.Metadata;
obj = ((metadata != null) ? metadata.Name : null);
}
}
logger.LogWarning((object)("Failed to get URI for " + (string?)obj + " - " + ex.Message));
return null;
}
}
public static void OpenWebsite(string url)
{
try
{
if (string.IsNullOrEmpty(url))
{
throw new Exception("Empty URL");
}
Process.Start(url);
}
catch (Exception ex)
{
ConfigurationManager.Logger.Log((LogLevel)12, (object)("Failed to open URL " + url + "\nCause: " + ex.Message));
}
}
}
}