using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ComfyLib;
using ConfigurationManager;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Configula")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Configula")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ff24fe7d-507c-44cf-bc1a-0e493e13aed4")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace ComfyLib
{
public static class ConfigFileExtensions
{
internal sealed class ConfigurationManagerAttributes
{
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public bool? HideDefaultButton;
public bool? HideSettingName;
public bool? IsAdvanced;
public int? Order;
public bool? ReadOnly;
}
private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();
private static int GetSettingOrder(string section)
{
if (!_sectionToSettingOrder.TryGetValue(section, out var value))
{
value = 0;
}
_sectionToSettingOrder[section] = value - 1;
return value;
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
{
new ConfigurationManagerAttributes
{
Order = GetSettingOrder(section)
}
}));
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Browsable = browsable,
CustomDrawer = customDrawer,
HideDefaultButton = hideDefaultButton,
HideSettingName = hideSettingName,
IsAdvanced = isAdvanced,
Order = GetSettingOrder(section),
ReadOnly = readOnly
}
}));
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
{
configEntry.SettingChanged += delegate
{
settingChangedHandler();
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
}
}
namespace Configula
{
[BepInPlugin("redseiko.valheim.configula", "Configula", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Configula : BaseUnityPlugin
{
public const string PluginGuid = "redseiko.valheim.configula";
public const string PluginName = "Configula";
public const string PluginVersion = "1.1.0";
private Harmony _harmony;
private void Awake()
{
PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
BindSettingDrawHandlers();
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.configula");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private static void BindSettingDrawHandlers()
{
Dictionary<Type, Action<SettingEntryBase>> settingDrawHandlers = SettingFieldDrawer.SettingDrawHandlers;
settingDrawHandlers[typeof(string)] = StringSettingField.DrawString;
settingDrawHandlers[typeof(float)] = FloatSettingField.DrawFloat;
settingDrawHandlers[typeof(Vector2)] = Vector2SettingField.DrawVector2;
settingDrawHandlers[typeof(Vector3)] = Vector3SettingField.DrawVector3;
settingDrawHandlers[typeof(Vector4)] = Vector4SettingField.DrawVector4;
settingDrawHandlers[typeof(Quaternion)] = QuaternionSettingField.DrawQuaternion;
settingDrawHandlers[typeof(Color)] = ColorSettingField.DrawColor;
}
}
public sealed class ColorFloatInputField
{
private string _fieldText;
private Color _fieldColor;
public string FieldLabel { get; set; }
public float CurrentValue { get; private set; }
public float MinValue { get; private set; }
public float MaxValue { get; private set; }
public void SetValue(float value)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
CurrentValue = Mathf.Clamp(value, MinValue, MaxValue);
_fieldText = value.ToString("F3", CultureInfo.InvariantCulture);
_fieldColor = GUI.color;
}
public void SetValueRange(float minValue, float maxValue)
{
MinValue = Mathf.Min(minValue, minValue);
MaxValue = Mathf.Max(maxValue, maxValue);
}
public ColorFloatInputField(string label)
{
FieldLabel = label;
SetValueRange(0f, 1f);
}
public void DrawField()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(FieldLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUIHelper.BeginColor(_fieldColor);
string text = GUILayout.TextField(_fieldText, (GUILayoutOption[])(object)new GUILayoutOption[3]
{
GUILayout.MinWidth(45f),
GUILayout.MaxWidth(55f),
GUILayout.ExpandWidth(true)
});
GUIHelper.EndColor();
GUILayout.EndHorizontal();
GUILayout.Space(2f);
float num = GUILayout.HorizontalSlider(CurrentValue, MinValue, MaxValue, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.EndVertical();
if (num != CurrentValue)
{
SetValue(num);
}
else if (!(text == _fieldText))
{
if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var result) && result >= MinValue && result <= MaxValue)
{
CurrentValue = result;
_fieldColor = GUI.color;
}
else
{
_fieldColor = Color.red;
}
_fieldText = text;
}
}
}
public sealed class ColorSettingField
{
public readonly ColorFloatInputField RedInput = new ColorFloatInputField("R");
public readonly ColorFloatInputField GreenInput = new ColorFloatInputField("G");
public readonly ColorFloatInputField BlueInput = new ColorFloatInputField("B");
public readonly ColorFloatInputField AlphaInput = new ColorFloatInputField("A");
public readonly HexColorInputField HexInput = new HexColorInputField();
private Color _value;
private bool _showSliders;
private static readonly Dictionary<SettingEntryBase, ColorSettingField> _colorSettingFieldCache = new Dictionary<SettingEntryBase, ColorSettingField>();
private static readonly Texture2D _colorTexture = GUIHelper.CreateColorTexture(10, 10, Color.white);
public void SetValue(Color value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
_value = value;
RedInput.SetValue(value.r);
GreenInput.SetValue(value.g);
BlueInput.SetValue(value.b);
AlphaInput.SetValue(value.a);
HexInput.SetValue(value);
}
public Color GetValue()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
return new Color(RedInput.CurrentValue, GreenInput.CurrentValue, BlueInput.CurrentValue, AlphaInput.CurrentValue);
}
public void DrawField()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
HexInput.DrawField();
GUILayout.Space(3f);
GUIHelper.BeginColor(_value);
GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if ((int)Event.current.type == 7)
{
GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)_colorTexture);
}
GUIHelper.EndColor();
GUILayout.Space(3f);
if (GUILayout.Button(_showSliders ? "∇" : "≡", (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.MinWidth(45f),
GUILayout.ExpandWidth(false)
}))
{
_showSliders = !_showSliders;
}
GUILayout.EndHorizontal();
if (_showSliders)
{
GUILayout.Space(4f);
GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
RedInput.DrawField();
GUILayout.Space(3f);
GreenInput.DrawField();
GUILayout.Space(3f);
BlueInput.DrawField();
GUILayout.Space(3f);
AlphaInput.DrawField();
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
public static void DrawColor(SettingEntryBase configEntry)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0075: 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_0085: 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)
Color val = (Color)configEntry.Get();
if (!_colorSettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new ColorSettingField();
value.SetValue(val);
_colorSettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != val)
{
value.SetValue(val);
}
value.DrawField();
Color val2 = value.GetValue();
if (val2 == val)
{
val2 = value.HexInput.CurrentValue;
}
if (val2 != val)
{
configEntry.Set((object)val2);
value.SetValue(val2);
}
}
}
public sealed class FloatSettingField
{
public readonly FloatInputField ValueInput = new FloatInputField(string.Empty);
private static readonly Dictionary<SettingEntryBase, FloatSettingField> _floatSettingFieldCache = new Dictionary<SettingEntryBase, FloatSettingField>();
public void SetValue(float value)
{
ValueInput.SetValue(value);
}
public float GetValue()
{
return ValueInput.CurrentValue;
}
public void DrawField()
{
ValueInput.DrawField();
}
public static void DrawFloat(SettingEntryBase configEntry)
{
float num = (float)configEntry.Get();
if (!_floatSettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new FloatSettingField();
value.SetValue(num);
_floatSettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != num)
{
value.SetValue(num);
}
value.DrawField();
float value2 = value.GetValue();
if (value2 != num)
{
configEntry.Set((object)value2);
}
}
}
public sealed class FloatInputField
{
public string FieldLabel;
public float CurrentValue;
public string CurrentText;
public Color CurrentColor;
public FloatInputField(string label)
{
//IL_0024: 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)
FieldLabel = label;
CurrentValue = 0f;
CurrentText = string.Empty;
CurrentColor = GUI.color;
}
public void SetValue(float value)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
CurrentValue = value;
CurrentText = value.ToString(NumberFormatInfo.InvariantInfo);
CurrentColor = GUI.color;
}
public void DrawField()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_0094: Unknown result type (might be due to invalid IL or missing references)
GUILayout.Label(FieldLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
GUIHelper.BeginColor(CurrentColor);
string text = GUILayout.TextField(CurrentText, GUIResources.WordWrapTextField.Value, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.MinWidth(45f),
GUILayout.ExpandWidth(true)
});
GUIHelper.EndColor();
if (!(text == CurrentText))
{
if (ShouldParse(text) && float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
CurrentValue = result;
CurrentColor = GUI.color;
}
else
{
CurrentColor = Color.red;
}
CurrentText = text;
}
}
private static bool ShouldParse(string text)
{
if (text == null || text.Length <= 0)
{
return false;
}
switch (text[text.Length - 1])
{
case '+':
case ',':
case '-':
case '.':
case 'E':
case 'e':
return false;
default:
return true;
}
}
}
public sealed class HexColorInputField
{
private Color _textColor = GUI.color;
public Color CurrentValue { get; private set; }
public string CurrentText { get; private set; }
public void SetValue(Color value)
{
//IL_0001: 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_0022: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
CurrentValue = value;
CurrentText = "#" + ((value.a == 1f) ? ColorUtility.ToHtmlStringRGB(value) : ColorUtility.ToHtmlStringRGBA(value));
_textColor = GUI.color;
}
public void DrawField()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
GUIHelper.BeginColor(_textColor);
string text = GUILayout.TextField(CurrentText, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(90f),
GUILayout.ExpandWidth(false)
});
GUIHelper.EndColor();
if (!(text == CurrentText))
{
CurrentText = text;
Color currentValue = default(Color);
if (ColorUtility.TryParseHtmlString(text, ref currentValue))
{
CurrentValue = currentValue;
}
else
{
_textColor = Color.red;
}
}
}
}
public sealed class QuaternionSettingField
{
public readonly FloatInputField XInput = new FloatInputField("X");
public readonly FloatInputField YInput = new FloatInputField("Y");
public readonly FloatInputField ZInput = new FloatInputField("Z");
public readonly FloatInputField WInput = new FloatInputField("W");
private static readonly Dictionary<SettingEntryBase, QuaternionSettingField> _quaternionSettingFieldCache = new Dictionary<SettingEntryBase, QuaternionSettingField>();
public void SetValue(Quaternion value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
XInput.SetValue(value.x);
YInput.SetValue(value.y);
ZInput.SetValue(value.z);
WInput.SetValue(value.w);
}
public Quaternion GetValue()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
return new Quaternion(XInput.CurrentValue, YInput.CurrentValue, ZInput.CurrentValue, WInput.CurrentValue);
}
public void DrawField()
{
XInput.DrawField();
YInput.DrawField();
ZInput.DrawField();
WInput.DrawField();
}
public static void DrawQuaternion(SettingEntryBase configEntry)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = (Quaternion)configEntry.Get();
if (!_quaternionSettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new QuaternionSettingField();
value.SetValue(val);
_quaternionSettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != val)
{
value.SetValue(val);
}
value.DrawField();
Quaternion value2 = value.GetValue();
if (value2 != val)
{
configEntry.Set((object)value2);
}
}
}
public sealed class Vector4SettingField
{
public readonly FloatInputField XInput = new FloatInputField("X");
public readonly FloatInputField YInput = new FloatInputField("Y");
public readonly FloatInputField ZInput = new FloatInputField("Z");
public readonly FloatInputField WInput = new FloatInputField("W");
private static readonly Dictionary<SettingEntryBase, Vector4SettingField> _vector4SettingFieldCache = new Dictionary<SettingEntryBase, Vector4SettingField>();
public void SetValue(Vector4 value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
XInput.SetValue(value.x);
YInput.SetValue(value.y);
ZInput.SetValue(value.z);
WInput.SetValue(value.w);
}
public Vector4 GetValue()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
return new Vector4(XInput.CurrentValue, YInput.CurrentValue, ZInput.CurrentValue, WInput.CurrentValue);
}
public void DrawField()
{
XInput.DrawField();
YInput.DrawField();
ZInput.DrawField();
WInput.DrawField();
}
public static void DrawVector4(SettingEntryBase configEntry)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
Vector4 val = (Vector4)configEntry.Get();
if (!_vector4SettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new Vector4SettingField();
value.SetValue(val);
_vector4SettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != val)
{
value.SetValue(val);
}
value.DrawField();
Vector4 value2 = value.GetValue();
if (value2 != val)
{
configEntry.Set((object)value2);
}
}
}
public static class GUIFocus
{
private static int _lastFrameCount;
private static int _lastHotControl;
private static int _lastKeyboardControl;
private static bool _hasChanged;
public static bool HasChanged()
{
int frameCount = Time.frameCount;
if (_lastFrameCount == frameCount)
{
return _hasChanged;
}
_lastFrameCount = frameCount;
int hotControl = GUIUtility.hotControl;
int keyboardControl = GUIUtility.keyboardControl;
_hasChanged = hotControl != _lastHotControl || keyboardControl != _lastKeyboardControl;
if (_hasChanged)
{
_lastHotControl = hotControl;
_lastKeyboardControl = keyboardControl;
}
return _hasChanged;
}
}
public static class GUIHelper
{
private static readonly Stack<Color> _colorStack = new Stack<Color>();
public static void BeginColor(Color color)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
_colorStack.Push(GUI.color);
GUI.color = color;
}
public static void EndColor()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
GUI.color = _colorStack.Pop();
}
public static Texture2D CreateColorTexture(int width, int height, Color color)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
val.SetPixel(i, j, color);
}
}
val.Apply();
return val;
}
public static bool IsEnterPressed()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
if (Event.current.isKey)
{
if ((int)Event.current.keyCode != 13)
{
return (int)Event.current.keyCode == 271;
}
return true;
}
return false;
}
}
public sealed class StringSettingField
{
public static void DrawString(SettingEntryBase configEntry)
{
string text = (string)configEntry.Get();
string text2 = GUILayout.TextField(text, GUIResources.WordWrapTextField.Value, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.MinWidth(75f),
GUILayout.ExpandWidth(true)
});
if (text2 != text)
{
configEntry.Set((object)text2);
}
}
}
public sealed class Vector3SettingField
{
public readonly FloatInputField XInput = new FloatInputField("X");
public readonly FloatInputField YInput = new FloatInputField("Y");
public readonly FloatInputField ZInput = new FloatInputField("Z");
private static readonly Dictionary<SettingEntryBase, Vector3SettingField> _vector3SettingFieldCache = new Dictionary<SettingEntryBase, Vector3SettingField>();
public void SetValue(Vector3 value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
XInput.SetValue(value.x);
YInput.SetValue(value.y);
ZInput.SetValue(value.z);
}
public Vector3 GetValue()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(XInput.CurrentValue, YInput.CurrentValue, ZInput.CurrentValue);
}
public void DrawField()
{
XInput.DrawField();
YInput.DrawField();
ZInput.DrawField();
}
public static void DrawVector3(SettingEntryBase configEntry)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (Vector3)configEntry.Get();
if (!_vector3SettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new Vector3SettingField();
value.SetValue(val);
_vector3SettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != val)
{
value.SetValue(val);
}
value.DrawField();
Vector3 value2 = value.GetValue();
if (value2 != val)
{
configEntry.Set((object)value2);
}
}
}
public static class GUIResources
{
public static readonly Lazy<GUIStyle> WordWrapTextField = new Lazy<GUIStyle>((Func<GUIStyle>)(() => new GUIStyle(GUI.skin.textField)
{
wordWrap = true
}));
}
public static class PluginConfig
{
public static ConfigEntry<bool> IsModEnabled { get; private set; }
public static ConfigEntry<int> WindowWidth { get; private set; }
public static ConfigEntry<int> WindowHeightOffset { get; private set; }
public static void BindConfig(ConfigFile config)
{
IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
WindowWidth = config.BindInOrder("Window", "windowWidth", 650, "Width of the ConfigurationManager window.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(650, 1920));
WindowHeightOffset = config.BindInOrder("Window", "windowHeightOffset", 100, "Height (offset) of the ConfigurationManager window.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 540));
}
}
[HarmonyPatch(typeof(ConfigurationManager))]
internal static class ConfigurationManagerPatch
{
[HarmonyTranspiler]
[HarmonyPatch("CalculateWindowRect")]
private static IEnumerable<CodeInstruction> CalculateWindowRectTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: 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_0037: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Screen), "get_width", (Type[])null, (Type[])null), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)null, (string)null)
}).ThrowIfInvalid("Could not patch CalculateWindowRect() width value!").Advance(2)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetWidthDelegate) })
.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Screen), "get_height", (Type[])null, (Type[])null), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null)
})
.ThrowIfInvalid("Could not patch CalculateWindowRect() height value!")
.Advance(2)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetHeightDelegate) })
.InstructionEnumeration();
}
private static int GetWidthDelegate(int width)
{
if (!PluginConfig.IsModEnabled.Value)
{
return width;
}
return PluginConfig.WindowWidth.Value;
}
private static int GetHeightDelegate(int heightOffset)
{
if (!PluginConfig.IsModEnabled.Value)
{
return heightOffset;
}
return PluginConfig.WindowHeightOffset.Value;
}
}
public sealed class Vector2SettingField
{
public readonly FloatInputField XInput = new FloatInputField("X");
public readonly FloatInputField YInput = new FloatInputField("Y");
private static readonly Dictionary<SettingEntryBase, Vector2SettingField> _vector2SettingFieldCache = new Dictionary<SettingEntryBase, Vector2SettingField>();
public void SetValue(Vector2 value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
XInput.SetValue(value.x);
YInput.SetValue(value.y);
}
public Vector2 GetValue()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
return new Vector2(XInput.CurrentValue, YInput.CurrentValue);
}
public void DrawField()
{
XInput.DrawField();
YInput.DrawField();
}
public static void DrawVector2(SettingEntryBase configEntry)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = (Vector2)configEntry.Get();
if (!_vector2SettingFieldCache.TryGetValue(configEntry, out var value))
{
value = new Vector2SettingField();
value.SetValue(val);
_vector2SettingFieldCache[configEntry] = value;
}
else if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || value.GetValue() != val)
{
value.SetValue(val);
}
value.DrawField();
Vector2 value2 = value.GetValue();
if (value2 != val)
{
configEntry.Set((object)value2);
}
}
}
}