Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ModSettings v1.0.1
ModSettings.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ModSettings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9c9b66a5276507f9030bc2b34b501037b1111166")] [assembly: AssemblyProduct("ModSettings")] [assembly: AssemblyTitle("ModSettings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ModSettings { internal sealed class ModEntry { public string Guid; public string Name; public string Version; public ConfigFile Config; public string FileName { get { if (Config == null || Config.ConfigFilePath == null) { return ""; } return Path.GetFileName(Config.ConfigFilePath); } } } internal static class ModCatalog { public static List<ModEntry> Mods() { List<ModEntry> list = new List<ModEntry>(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value != null && !((Object)(object)value.Instance == (Object)null) && value.Metadata != null) { ConfigFile config; try { config = value.Instance.Config; } catch (Exception ex) { Plugin.Log.LogDebug((object)(value.Metadata.GUID + ": its config could not be read (" + ex.GetType().Name + "); not listed")); continue; } if (config != null && config.Count != 0) { list.Add(new ModEntry { Guid = value.Metadata.GUID, Name = value.Metadata.Name, Version = ((value.Metadata.Version != null) ? value.Metadata.Version.ToString() : ""), Config = config }); } } } list.Sort((ModEntry a, ModEntry b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); return list; } } [BepInPlugin("rhenn.modsettings", "ModSettings", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "rhenn.modsettings"; public const string PluginName = "ModSettings"; public const string PluginVersion = "1.0.1"; internal static ManualLogSource Log; private readonly Harmony harmony = new Harmony("rhenn.modsettings"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"ModSettings 1.0.1 loaded"); } private void Update() { SettingsWindow.Tick(); } private void OnDestroy() { harmony.UnpatchSelf(); } } internal static class SettingsWindow { [CompilerGenerated] private static class <>O { public static UnityAction <0>__ShowList; public static UnityAction <1>__Toggle; } private const string FramePath = "SkillsFrame"; private const string TopicPath = "SkillsFrame/topic"; private const string ListTitle = "Mod settings"; private const float HeaderHeight = 34f; private const float ControlWidth = 250f; private const float ButtonHeight = 26f; private const float FontSize = 14f; private const float SmallFontSize = 12f; private const float Inset = 12f; private const float LineHeight = 20f; private const float RangeHintHeight = 14f; private const float RowPadding = 6f; private const float RowGap = 2f; private const float OpenButtonWidth = 90f; private static readonly Color RowColor = new Color(0f, 0f, 0f, 0.12f); private static readonly Color ButtonColor = new Color(0.3f, 0.3f, 0.3f, 0.95f); private static readonly Color OnColor = new Color(0.2f, 0.5f, 0.25f, 0.95f); private static readonly Color InputColor = new Color(0.08f, 0.08f, 0.08f, 0.95f); private static readonly Color DimTextColor = new Color(1f, 1f, 1f, 0.6f); private static readonly Color HeaderTextColor = new Color(1f, 0.85f, 0.5f, 1f); private static readonly KeyCode[] ModifierKeys; private static ModEntry current; private static RectTransform root; private static RectTransform frame; private static RectTransform content; private static ScrollRect scroll; private static TMP_Text topic; private static TMP_FontAsset font; private static readonly List<Action> refreshers; private static readonly List<TMP_InputField> inputs; private static readonly List<GameObject> rows; private static ConfigEntryBase capturing; private static TextMeshProUGUI capturingLabel; private static int captureEndedFrame; private static int escapeSwallowFrame; private static RectTransform infoPanel; private static RectTransform settingsButton; private static bool placeButtonPending; private const string IconPath = "Icon"; private const int GearSize = 64; private static Sprite gearSprite; private const float RowExtension = 20f; public static bool IsOpen { get { if ((Object)(object)root != (Object)null) { return ((Component)root).gameObject.activeSelf; } return false; } } public static bool IsTyping { get { if (capturing != null || captureEndedFrame == Time.frameCount) { return true; } foreach (TMP_InputField input in inputs) { if ((Object)(object)input != (Object)null && input.isFocused) { return true; } } return false; } } private static float TextWidth { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect = content.rect; return Mathf.Max(100f, ((Rect)(ref rect)).width - 24f); } } public static void Attach(InventoryGui gui) { Forget(); if (!((Object)(object)gui == (Object)null) && Build(gui)) { AddButton(gui); } } public static void Forget() { current = null; root = null; frame = null; content = null; scroll = null; topic = null; font = null; capturing = null; capturingLabel = null; captureEndedFrame = -1; escapeSwallowFrame = -1; infoPanel = null; settingsButton = null; placeButtonPending = false; refreshers.Clear(); inputs.Clear(); rows.Clear(); } public static void Toggle() { if (IsOpen) { Close(); } else { Open(); } } public static void Open() { if (!((Object)(object)root == (Object)null)) { ((Component)root).gameObject.SetActive(true); ShowList(); } } public static void Close() { capturing = null; if ((Object)(object)root != (Object)null && ((Component)root).gameObject.activeSelf) { ((Component)root).gameObject.SetActive(false); } } public static bool TakeEscape() { if (escapeSwallowFrame == Time.frameCount) { return true; } if (IsOpen && !IsTyping && UnityInput.Current.GetKeyDown((KeyCode)27)) { Close(); escapeSwallowFrame = Time.frameCount; return true; } return false; } public static void Tick() { if (placeButtonPending) { placeButtonPending = false; PlaceButton(); } if (IsOpen && capturing != null) { CaptureShortcut(); } } private static void StartCapture(ConfigEntryBase entry, TextMeshProUGUI label) { capturing = entry; capturingLabel = label; ((TMP_Text)label).text = "Press keys... (Esc cancels, Backspace clears)"; } private static void CaptureShortcut() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0057: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) IInputSystem val = UnityInput.Current; if (val.GetKeyDown((KeyCode)27)) { EndCapture(); return; } if (val.GetKeyDown((KeyCode)8)) { capturing.BoxedValue = KeyboardShortcut.Empty; EndCapture(); return; } foreach (KeyCode supportedKeyCode in val.SupportedKeyCodes) { if ((int)supportedKeyCode == 0 || (int)supportedKeyCode == 27 || (int)supportedKeyCode == 8 || IsModifier(supportedKeyCode) || IsMouse(supportedKeyCode) || !val.GetKeyDown(supportedKeyCode)) { continue; } List<KeyCode> list = new List<KeyCode>(); KeyCode[] modifierKeys = ModifierKeys; foreach (KeyCode val3 in modifierKeys) { if (val.GetKey(val3)) { list.Add(val3); } } capturing.BoxedValue = (object)new KeyboardShortcut(supportedKeyCode, list.ToArray()); EndCapture(); break; } } private static void EndCapture() { capturing = null; capturingLabel = null; captureEndedFrame = Time.frameCount; RefreshAll(); } private static bool IsModifier(KeyCode key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Array.IndexOf(ModifierKeys, key) >= 0; } private static bool IsMouse(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)key >= 323) { return (int)key <= 329; } return false; } private static bool Build(InventoryGui gui) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) SkillsDialog skillsDialog = gui.m_skillsDialog; if ((Object)(object)skillsDialog == (Object)null || (Object)(object)skillsDialog.m_listRoot == (Object)null) { Plugin.Log.LogWarning((object)"Settings window: the inventory screen has no Skills dialog to copy (the game changed); there is no settings window"); return false; } GameObject val = Object.Instantiate<GameObject>(((Component)skillsDialog).gameObject, ((Component)skillsDialog).transform.parent); ((Object)val).name = "ModSettings_Window"; val.SetActive(false); val.transform.SetSiblingIndex(((Component)skillsDialog).transform.GetSiblingIndex() + 1); SkillsDialog component = val.GetComponent<SkillsDialog>(); ((Behaviour)component).enabled = false; Transform transform = val.transform; root = (RectTransform)(object)((transform is RectTransform) ? transform : null); content = component.m_listRoot; scroll = component.skillListScrollRect; if ((Object)(object)component.m_totalSkillText != (Object)null) { ((Component)component.m_totalSkillText).gameObject.SetActive(false); } foreach (Transform item in (Transform)content) { ((Component)item).gameObject.SetActive(false); } Transform val2 = val.transform.Find("SkillsFrame/topic"); topic = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<TMP_Text>() : null); TMP_Text val3 = (((Object)(object)component.m_elementPrefab != (Object)null) ? component.m_elementPrefab.GetComponentInChildren<TMP_Text>(true) : null); if ((Object)(object)val3 == (Object)null) { val3 = component.m_totalSkillText; } font = (((Object)(object)val3 != (Object)null && (Object)(object)val3.font != (Object)null) ? val3.font : FindFont(gui)); Transform obj = val.transform.Find("SkillsFrame"); frame = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)frame == (Object)null) { Transform parent = (Transform)(object)content; while ((Object)(object)parent != (Object)null && (Object)(object)parent.parent != (Object)(object)val.transform) { parent = parent.parent; } frame = (RectTransform)(object)((parent is RectTransform) ? parent : null); } if ((Object)(object)frame == (Object)null) { frame = root; } return true; } private static void ClearRows() { capturing = null; capturingLabel = null; refreshers.Clear(); inputs.Clear(); foreach (GameObject row in rows) { if ((Object)(object)row != (Object)null) { Object.Destroy((Object)(object)row); } } rows.Clear(); } private static void SetTitle(string text) { if ((Object)(object)topic != (Object)null) { topic.text = text; } } private static void FinishRows(float y) { content.SetSizeWithCurrentAnchors((Axis)1, y + 12f); if ((Object)(object)scroll != (Object)null) { scroll.verticalNormalizedPosition = 1f; } RefreshAll(); } private static void ShowList() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)content == (Object)null) { return; } current = null; ClearRows(); SetTitle("Mod settings"); List<ModEntry> list = ModCatalog.Mods(); float num = 12f; if (list.Count == 0) { RectTransform obj = CreateRow(content, "Empty", num, null); TextMeshProUGUI val = CreateText(obj, "Text", 14f, (TextAlignmentOptions)257); ((Graphic)val).color = DimTextColor; ((TMP_Text)val).text = "No loaded mod has settings."; float num2 = 6f + PlaceText(val, 12f, 6f, TextWidth) + 6f; SetRowHeight(obj, num2); num += num2 + 2f; } float width = TextWidth - 90f - 12f; foreach (ModEntry item in list) { ModEntry captured = item; RectTransform obj2 = CreateRow(content, item.Guid, num, RowColor); TextMeshProUGUI val2 = CreateText(obj2, "Name", 14f, (TextAlignmentOptions)257); ((TMP_Text)val2).fontStyle = (FontStyles)1; ((TMP_Text)val2).text = (string.IsNullOrEmpty(item.Version) ? item.Name : (item.Name + " " + item.Version)); float num3 = 6f + PlaceText(val2, 12f, 6f, width); TextMeshProUGUI val3 = CreateText(obj2, "Description", 12f, (TextAlignmentOptions)257); ((Graphic)val3).color = DimTextColor; ((TMP_Text)val3).text = string.Format("{0} {1} · {2}", item.Config.Count, (item.Config.Count == 1) ? "setting" : "settings", item.FileName); num3 += 2f + PlaceText(val3, 12f, num3 + 2f, width); num3 = Mathf.Max(num3 + 6f, 38f); Transform transform = ((Component)CreateButton(obj2, "Open", "Open", 0f, 0f, 90f, 26f, (UnityAction)delegate { ShowMod(captured); })).transform; Transform obj3 = ((transform is RectTransform) ? transform : null); ((RectTransform)obj3).anchorMin = new Vector2(1f, 1f); ((RectTransform)obj3).anchorMax = new Vector2(1f, 1f); ((RectTransform)obj3).pivot = new Vector2(1f, 1f); ((RectTransform)obj3).anchoredPosition = new Vector2(-12f, -6f); SetRowHeight(obj2, num3); num += num3 + 2f; } FinishRows(num); } private static void ShowMod(ModEntry mod) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)content == (Object)null || mod == null || mod.Config == null) { return; } current = mod; ClearRows(); SetTitle(mod.Name + " settings"); float num = 12f; float textWidth = TextWidth; RectTransform obj = CreateRow(content, "Back", num, null); object obj2 = <>O.<0>__ShowList; if (obj2 == null) { UnityAction val = ShowList; <>O.<0>__ShowList = val; obj2 = (object)val; } CreateButton(obj, "BackButton", "< All mods", 12f, 6f, 120f, 26f, (UnityAction)obj2); TextMeshProUGUI val2 = CreateText(obj, "File", 12f, (TextAlignmentOptions)257); ((Graphic)val2).color = DimTextColor; ((TMP_Text)val2).text = mod.FileName; float num2 = 38f; num2 += PlaceText(val2, 12f, num2, textWidth) + 6f; SetRowHeight(obj, num2); num += num2 + 6f; string text = null; foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in mod.Config) { ConfigDefinition key = item.Key; ConfigEntryBase value = item.Value; if (key.Section != text) { text = key.Section; RectTransform obj3 = CreateRow(content, "Section", num, null); SetRowHeight(obj3, 34f); TextMeshProUGUI obj4 = CreateText(obj3, "Text", 16f, (TextAlignmentOptions)1025); Stretch(((TMP_Text)obj4).rectTransform, 12f, 0f); ((TMP_Text)obj4).fontStyle = (FontStyles)1; ((Graphic)obj4).color = HeaderTextColor; ((TMP_Text)obj4).text = key.Section; num += 34f; } RectTransform obj5 = CreateRow(content, key.Key, num, RowColor); TextMeshProUGUI val3 = CreateText(obj5, "Name", 14f, (TextAlignmentOptions)257); ((TMP_Text)val3).fontStyle = (FontStyles)1; ((TMP_Text)val3).text = key.Key; float num3 = 6f + PlaceText(val3, 12f, 6f, textWidth); TextMeshProUGUI obj6 = CreateText(obj5, "Description", 12f, (TextAlignmentOptions)257); ((Graphic)obj6).color = DimTextColor; ((TMP_Text)obj6).text = ((value.Description != null) ? value.Description.Description : string.Empty); float num4 = PlaceText(obj6, 12f, num3 + 2f, textWidth); if (num4 > 0f) { num3 += 2f + num4; } RectTransform control = CreateRect(obj5, "Control", 12f, num3 + 6f, 250f, 26f, null); num3 += 6f + BuildControl(control, value) + 6f; SetRowHeight(obj5, num3); num += num3 + 2f; } FinishRows(num); } private static RectTransform CreateRow(RectTransform parent, string name, float y, Color? color) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0075: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CreateRect(parent, name, 0f, y, 0f, 0f, color); val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(0f, 0f - y); val.sizeDelta = new Vector2(0f, 0f); rows.Add(((Component)val).gameObject); return val; } private static void SetRowHeight(RectTransform row, float height) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) row.sizeDelta = new Vector2(0f, height); } private static float PlaceText(TextMeshProUGUI text, float x, float y, float width) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)text).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; ((TMP_Text)text).rectTransform.anchoredPosition = new Vector2(x, 0f - y); ((TMP_Text)text).rectTransform.sizeDelta = new Vector2(width, 20f); if (string.IsNullOrEmpty(((TMP_Text)text).text)) { ((TMP_Text)text).rectTransform.sizeDelta = new Vector2(width, 0f); return 0f; } ((TMP_Text)text).ForceMeshUpdate(true, true); float num = Mathf.Max(20f, Mathf.Ceil(((TMP_Text)text).preferredHeight)); ((TMP_Text)text).rectTransform.sizeDelta = new Vector2(width, num); return num; } private static float BuildControl(RectTransform control, ConfigEntryBase entry) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Expected O, but got Unknown //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Expected O, but got Unknown //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) Type settingType = entry.SettingType; float x = control.sizeDelta.x; float num = 26f; object[] choices = TryGetChoices(entry); if (IsLockedKey(entry.Definition.Key)) { TextMeshProUGUI locked = CreateText(control, "Text", 12f, (TextAlignmentOptions)4097); Stretch(((TMP_Text)locked).rectTransform, 0f, 0f); ((Graphic)locked).color = DimTextColor; refreshers.Add(delegate { ((TMP_Text)locked).text = entry.GetSerializedValue() + " (not editable)"; }); } else if (choices != null && choices.Length != 0) { Button button = CreateButton(control, "Choice", "", 0f, 0f, x, 26f, (UnityAction)delegate { int num2 = Array.IndexOf(choices, entry.BoxedValue); entry.BoxedValue = choices[(num2 + 1) % choices.Length]; RefreshAll(); }); refreshers.Add(delegate { ((TMP_Text)LabelOf(button)).text = Convert.ToString(entry.BoxedValue, CultureInfo.InvariantCulture); }); } else if (settingType == typeof(bool)) { Button button2 = CreateButton(control, "Toggle", "", 0f, 0f, 90f, 26f, (UnityAction)delegate { entry.BoxedValue = !(bool)entry.BoxedValue; RefreshAll(); }); refreshers.Add(delegate { //IL_004a: 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) bool flag2 = (bool)entry.BoxedValue; ((TMP_Text)LabelOf(button2)).text = (flag2 ? "On" : "Off"); ((Graphic)((Component)button2).GetComponent<Image>()).color = (flag2 ? OnColor : ButtonColor); }); } else if (settingType == typeof(int) || settingType == typeof(float) || settingType == typeof(double)) { double min; double max; bool flag = TryGetRange(entry, out min, out max); bool integer = settingType == typeof(int); double step = ((flag && min > 0.0 && !IsSizeKey(entry.Definition.Key)) ? min : 1.0); if (integer) { step = Math.Max(1.0, Math.Round(step)); } CreateButton(control, "Minus", "-", 0f, 0f, 26f, 26f, (UnityAction)delegate { Nudge(entry, 0.0 - step, integer); }); TMP_InputField input = CreateInput(control, "Value", 30f, 0f, x - 52f - 8f); input.contentType = (ContentType)(integer ? 2 : 3); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string text3) { if (double.TryParse(text3.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { SetNumber(entry, result, integer); } RefreshAll(); }); CreateButton(control, "Plus", "+", x - 26f, 0f, 26f, 26f, (UnityAction)delegate { Nudge(entry, step, integer); }); refreshers.Add(delegate { if (!input.isFocused) { input.SetTextWithoutNotify(FormatNumber(entry.BoxedValue, integer)); } }); string text = ((!flag) ? null : (integer ? $"{min:0} to {max:0}" : $"{min:0.##} to {max:0.##}")); if (text != null) { TextMeshProUGUI obj = CreateText(control, "Range", 11f, (TextAlignmentOptions)260); ((TMP_Text)obj).rectTransform.anchoredPosition = new Vector2(0f, -27f); ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(x, 14f); ((Graphic)obj).color = DimTextColor; ((TMP_Text)obj).text = text; num += 15f; } } else if (settingType == typeof(KeyboardShortcut)) { Button button3 = null; button3 = CreateButton(control, "Shortcut", "", 0f, 0f, x, 26f, (UnityAction)delegate { if (capturing == null) { StartCapture(entry, LabelOf(button3)); } }); refreshers.Add(delegate { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (capturing != entry) { ((TMP_Text)LabelOf(button3)).text = Describe((KeyboardShortcut)entry.BoxedValue); } }); } else if (settingType.IsEnum) { Array values = Enum.GetValues(settingType); Button button4 = CreateButton(control, "Enum", "", 0f, 0f, x, 26f, (UnityAction)delegate { int num2 = Array.IndexOf(values, entry.BoxedValue); entry.BoxedValue = values.GetValue((num2 + 1) % values.Length); RefreshAll(); }); refreshers.Add(delegate { ((TMP_Text)LabelOf(button4)).text = entry.BoxedValue.ToString(); }); } else if (settingType == typeof(string)) { TMP_InputField input2 = CreateInput(control, "Text", 0f, 0f, x); ((UnityEvent<string>)(object)input2.onEndEdit).AddListener((UnityAction<string>)delegate(string boxedValue) { entry.BoxedValue = boxedValue; RefreshAll(); }); refreshers.Add(delegate { if (!input2.isFocused) { input2.SetTextWithoutNotify((string)entry.BoxedValue); } }); } else { TextMeshProUGUI text2 = CreateText(control, "Text", 12f, (TextAlignmentOptions)4100); Stretch(((TMP_Text)text2).rectTransform, 0f, 0f); ((Graphic)text2).color = DimTextColor; refreshers.Add(delegate { ((TMP_Text)text2).text = entry.GetSerializedValue() + " (edit in the file)"; }); } return num; } private static bool IsLockedKey(string key) { if (string.IsNullOrEmpty(key)) { return false; } string text = key.Replace(" ", "").Replace("_", "").Replace("-", "") .ToLowerInvariant(); if (!(text == "nexusid")) { return text == "nexusmodid"; } return true; } private static bool IsSizeKey(string key) { if (string.IsNullOrEmpty(key)) { return false; } string text = key.Replace(" ", "").Replace("_", "").Replace("-", "") .ToLowerInvariant(); if (!text.Contains("font")) { return text.EndsWith("size", StringComparison.Ordinal); } return true; } private static void RefreshAll() { foreach (Action refresher in refreshers) { refresher(); } } private static bool TryGetRange(ConfigEntryBase entry, out double min, out double max) { min = 0.0; max = 0.0; AcceptableValueBase val = ((entry.Description != null) ? entry.Description.AcceptableValues : null); if (val == null) { return false; } Type type = ((object)val).GetType(); PropertyInfo property = type.GetProperty("MinValue"); PropertyInfo property2 = type.GetProperty("MaxValue"); if (property == null || property2 == null) { return false; } min = Convert.ToDouble(property.GetValue(val, null), CultureInfo.InvariantCulture); max = Convert.ToDouble(property2.GetValue(val, null), CultureInfo.InvariantCulture); return true; } private static object[] TryGetChoices(ConfigEntryBase entry) { AcceptableValueBase val = ((entry.Description != null) ? entry.Description.AcceptableValues : null); if (val == null) { return null; } PropertyInfo property = ((object)val).GetType().GetProperty("AcceptableValues"); if (property == null) { return null; } if (!(property.GetValue(val, null) is Array array)) { return null; } object[] array2 = new object[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = array.GetValue(i); } return array2; } private static void Nudge(ConfigEntryBase entry, double delta, bool integer) { double num = Convert.ToDouble(entry.BoxedValue, CultureInfo.InvariantCulture); SetNumber(entry, num + delta, integer); RefreshAll(); } private static void SetNumber(ConfigEntryBase entry, double value, bool integer) { if (integer) { entry.BoxedValue = (int)Math.Round(value); } else if (entry.SettingType == typeof(double)) { entry.BoxedValue = Math.Round(value, 3); } else { entry.BoxedValue = (float)Math.Round(value, 3); } } private static string FormatNumber(object value, bool integer) { if (!integer) { return Convert.ToDouble(value, CultureInfo.InvariantCulture).ToString("0.###", CultureInfo.InvariantCulture); } return Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture); } public static string Describe(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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 ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0) { return "(none)"; } string text = string.Empty; foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { text = text + KeyName(modifier) + "+"; } return text + KeyName(((KeyboardShortcut)(ref shortcut)).MainKey); } private unsafe static string KeyName(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: 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_0031: Expected I4, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected I4, but got Unknown if ((int)key != 13) { switch (key - 303) { default: switch (key - 323) { case 0: return "LMB"; case 1: return "RMB"; case 2: return "MMB"; default: { string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha", StringComparison.Ordinal) && text.Length == 6) { return text.Substring(5); } if (text.StartsWith("Keypad", StringComparison.Ordinal) && text.Length == 7) { return "Num " + text.Substring(6); } if (text.StartsWith("Mouse", StringComparison.Ordinal)) { return "Mouse " + text.Substring(5); } return text; } } case 4: case 5: return "Alt"; case 2: case 3: return "Ctrl"; case 0: case 1: return "Shift"; case 6: case 7: return "Cmd"; } } return "Enter"; } private static void AddButton(InventoryGui gui) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown if ((Object)(object)gui.m_info == (Object)null) { return; } Button val = null; Button val2 = null; Button[] componentsInChildren = ((Component)gui.m_info).GetComponentsInChildren<Button>(true); foreach (Button val3 in componentsInChildren) { for (int j = 0; j < ((UnityEventBase)val3.onClick).GetPersistentEventCount(); j++) { string persistentMethodName = ((UnityEventBase)val3.onClick).GetPersistentMethodName(j); if (persistentMethodName != null && persistentMethodName.StartsWith("OnOpen", StringComparison.Ordinal)) { val2 = val3; if (persistentMethodName == "OnOpenTexts") { val = val3; } break; } } } if ((Object)(object)val == (Object)null) { val = val2; } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Settings window: no Skills or Compendium button was found in the info panel (the game changed); the window has no button"); return; } GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val4).name = "ModSettings_Button"; val4.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); Button component = val4.GetComponent<Button>(); for (int k = 0; k < ((UnityEventBase)component.onClick).GetPersistentEventCount(); k++) { ((UnityEventBase)component.onClick).SetPersistentListenerState(k, (UnityEventCallState)0); } ButtonClickedEvent onClick = component.onClick; object obj = <>O.<1>__Toggle; if (obj == null) { UnityAction val5 = Toggle; <>O.<1>__Toggle = val5; obj = (object)val5; } ((UnityEvent)onClick).AddListener((UnityAction)obj); UITooltip component2 = val4.GetComponent<UITooltip>(); if ((Object)(object)component2 != (Object)null) { component2.m_topic = "Settings"; component2.m_text = "Mod settings"; } TMP_Text componentInChildren = val4.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = "Settings"; } Transform val6 = val4.transform.Find("Icon"); Image val7 = (((Object)(object)val6 != (Object)null) ? ((Component)val6).GetComponent<Image>() : null); if ((Object)(object)val7 != (Object)null) { val7.sprite = GearSprite(); } else { Plugin.Log.LogDebug((object)"Settings window: the copied button has no Icon child; it keeps the Compendium's icon"); } infoPanel = gui.m_info; Transform transform = val4.transform; settingsButton = (RectTransform)(object)((transform is RectTransform) ? transform : null); placeButtonPending = true; Plugin.Log.LogDebug((object)("Settings window: button copied from " + ((Object)val).name + " in the info panel")); } private static void PlaceButton() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)infoPanel == (Object)null || (Object)(object)settingsButton == (Object)null || (Object)(object)((Component)infoPanel).GetComponent<LayoutGroup>() != (Object)null) { return; } List<RectTransform> list = new List<RectTransform>(); foreach (Transform item in (Transform)infoPanel) { Transform val = item; if (((Component)val).gameObject.activeSelf && (Object)(object)((Component)val).GetComponent<Selectable>() != (Object)null && (Object)(object)((val is RectTransform) ? val : null) != (Object)null) { list.Add((RectTransform)(object)((val is RectTransform) ? val : null)); } } if (!list.Contains(settingsButton) || list.Count < 2) { return; } float num = float.MaxValue; float num2 = float.MinValue; foreach (RectTransform item2 in list) { if ((Object)(object)item2 != (Object)(object)settingsButton) { num = Mathf.Min(num, item2.anchoredPosition.x); num2 = Mathf.Max(num2, item2.anchoredPosition.x); } } list.Remove(settingsButton); list.Sort((RectTransform a, RectTransform b) => a.anchoredPosition.x.CompareTo(b.anchoredPosition.x)); list.Add(settingsButton); float num3 = num - 20f; float num4 = (num2 + 20f - num3) / (float)(list.Count - 1); float y = list[0].anchoredPosition.y; for (int num5 = 0; num5 < list.Count; num5++) { RectTransform val3 = list[num5]; val3.anchoredPosition = new Vector2(num3 + (float)num5 * num4, ((Object)(object)val3 == (Object)(object)settingsButton) ? y : val3.anchoredPosition.y); } Plugin.Log.LogDebug((object)$"Settings window: {list.Count} info panel controls spread across the panel, {num4:0} apart"); } private static Sprite GearSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gearSprite != (Object)null) { return gearSprite; } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { float num2 = ((float)j + ((float)l + 0.5f) / 4f) / 64f * 2f - 1f; float num3 = ((float)i + ((float)k + 0.5f) / 4f) / 64f * 2f - 1f; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = ((Mathf.Repeat(Mathf.Atan2(num3, num2) * 8f / ((float)Math.PI * 2f), 1f) < 0.5f) ? 0.9f : 0.62f); if (num4 >= 0.2f && num4 <= num5) { num++; } } } float num6 = (float)num / 16f; array[i * 64 + j] = new Color(1f, 1f, 1f, num6); } } val.SetPixels(array); val.Apply(false, true); gearSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); ((Object)gearSprite).name = "ModSettings_Gear"; return gearSprite; } private static TMP_FontAsset FindFont(InventoryGui gui) { TMP_Text componentInChildren = ((Component)gui).GetComponentInChildren<TMP_Text>(true); if (!((Object)(object)componentInChildren != (Object)null) || !((Object)(object)componentInChildren.font != (Object)null)) { return TMP_Settings.defaultFontAsset; } return componentInChildren.font; } private static RectTransform CreateRect(RectTransform parent, string name, float x, float y, float width, float height, Color? color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_003d: 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_0067: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)parent, false); Transform transform = val.transform; Transform obj = ((transform is RectTransform) ? transform : null); ((RectTransform)obj).anchorMin = new Vector2(0f, 1f); ((RectTransform)obj).anchorMax = new Vector2(0f, 1f); ((RectTransform)obj).pivot = new Vector2(0f, 1f); ((RectTransform)obj).anchoredPosition = new Vector2(x, 0f - y); ((RectTransform)obj).sizeDelta = new Vector2(width, height); if (color.HasValue) { ((Graphic)val.AddComponent<Image>()).color = color.Value; } return (RectTransform)(object)obj; } private static TextMeshProUGUI CreateText(RectTransform parent, string name, float size, TextAlignmentOptions alignment) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.SetActive(false); val.transform.SetParent((Transform)(object)parent, false); Transform transform = val.transform; Transform obj = ((transform is RectTransform) ? transform : null); ((RectTransform)obj).anchorMin = new Vector2(0f, 1f); ((RectTransform)obj).anchorMax = new Vector2(0f, 1f); ((RectTransform)obj).pivot = new Vector2(0f, 1f); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)font != (Object)null) { ((TMP_Text)val2).font = font; } ((TMP_Text)val2).fontSize = size; ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)1; ((TMP_Text)val2).richText = false; ((Graphic)val2).raycastTarget = false; ((Graphic)val2).color = Color.white; val.SetActive(true); return val2; } private static Button CreateButton(RectTransform parent, string name, string label, float x, float y, float width, float height, UnityAction onClick) { //IL_0009: 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_0041: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CreateRect(parent, name, x, y, width, height, ButtonColor); Button obj = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>(); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1.5f, 1.5f, 1.5f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(2f, 2f, 2f, 1f); ((ColorBlock)(ref colors)).selectedColor = Color.white; ((Selectable)obj).colors = colors; ((UnityEvent)obj.onClick).AddListener(onClick); TextMeshProUGUI obj2 = CreateText(val, "Text", 14f, (TextAlignmentOptions)514); Stretch(((TMP_Text)obj2).rectTransform, 4f, 0f); ((TMP_Text)obj2).text = label; return obj; } private static TextMeshProUGUI LabelOf(Button button) { return ((Component)button).GetComponentInChildren<TextMeshProUGUI>(true); } private static TMP_InputField CreateInput(RectTransform parent, string name, float x, float y, float width) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_0133: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CreateRect(parent, name, x, y, width, 26f, InputColor); GameObject gameObject = ((Component)val).gameObject; gameObject.SetActive(false); RectTransform val2 = CreateRect(val, "TextArea", 0f, 0f, 0f, 0f, null); Stretch(val2, 6f, 0f); ((Component)val2).gameObject.AddComponent<RectMask2D>(); TextMeshProUGUI val3 = CreateText(val2, "Text", 14f, (TextAlignmentOptions)4097); Stretch(((TMP_Text)val3).rectTransform, 0f, 0f); ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; TMP_InputField val4 = gameObject.AddComponent<TMP_InputField>(); val4.textViewport = val2; val4.textComponent = (TMP_Text)(object)val3; ((Selectable)val4).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>(); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val4).navigation = navigation; val4.fontAsset = ((TMP_Text)val3).font; val4.pointSize = 14f; val4.lineType = (LineType)0; val4.richText = false; val4.restoreOriginalTextOnEscape = true; val4.customCaretColor = true; val4.caretColor = Color.white; val4.caretWidth = 2; val4.selectionColor = new Color(0.25f, 0.6f, 1f, 0.5f); gameObject.SetActive(true); inputs.Add(val4); return val4; } private static void Stretch(RectTransform rt, float insetX, float insetY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = new Vector2(insetX, insetY); rt.offsetMax = new Vector2(0f - insetX, 0f - insetY); } static SettingsWindow() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) KeyCode[] array = new KeyCode[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); ModifierKeys = (KeyCode[])(object)array; refreshers = new List<Action>(); inputs = new List<TMP_InputField>(); rows = new List<GameObject>(); captureEndedFrame = -1; escapeSwallowFrame = -1; } } } namespace ModSettings.Patches { [HarmonyPatch(typeof(InventoryGui), "Awake")] internal static class InventoryGui_Awake_Patch { private static void Postfix(InventoryGui __instance) { SettingsWindow.Attach(__instance); } } [HarmonyPatch(typeof(Hud), "OnDestroy")] internal static class Hud_OnDestroy_Patch { private static void Postfix() { SettingsWindow.Forget(); } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal static class InventoryGui_Hide_Patch { private static void Postfix() { SettingsWindow.Close(); } } [HarmonyPatch(typeof(ZInput), "GetKeyDown", new Type[] { typeof(KeyCode), typeof(bool) })] internal static class ZInput_GetKeyDown_Escape_Patch { private static bool Prefix(KeyCode key, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)key == 27 && SettingsWindow.TakeEscape()) { __result = false; return false; } return true; } } [HarmonyPatch] internal static class ZInput_KeyReads_Patch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(ZInput), "GetButtonDown", new Type[1] { typeof(string) }, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButton", new Type[1] { typeof(string) }, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetButtonUp", new Type[1] { typeof(string) }, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKeyDown", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKey", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null); yield return AccessTools.Method(typeof(ZInput), "GetKeyUp", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null); } private static bool Prefix(ref bool __result) { if (!SettingsWindow.IsTyping) { return true; } __result = false; return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }