Decompiled source of KeybindsUnlocked v1.2.0
Mods/KeybindsUnlocked.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.RegularExpressions; using HarmonyLib; using Il2Cpp; using Il2CppInterop.Common; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using KeybindsUnlocked; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using SpellBrigade.ModMenu; using SpellBrigade.Shared; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Localization; using UnityEngine.Localization.Components; using UnityEngine.Localization.Settings; using UnityEngine.SceneManagement; using UnityEngine.U2D; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(KeybindsMod), "Keybinds Unlocked", "1.2.0", "Relsev", null)] [assembly: MelonGame("BoltBlasterGames", "TheSpellBrigade")] [assembly: MelonOptionalDependencies(new string[] { "ModMenu" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("KeybindsUnlocked")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+1856b18f4bf94ea33a9b586b39e9ee6f647e5453")] [assembly: AssemblyProduct("KeybindsUnlocked")] [assembly: AssemblyTitle("KeybindsUnlocked")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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 SpellBrigade.Shared { internal static class Hooks { public static bool Patch(Harmony harmony, Instance log, Type target, string method, Type patchClass, string prefix = null, string postfix = null) { return Patch(harmony, log, AccessTools.Method(target, method, (Type[])null, (Type[])null), patchClass, prefix, postfix, target.Name + "." + method); } public static bool Patch(Harmony harmony, Instance log, MethodBase original, Type patchClass, string prefix = null, string postfix = null, string name = null) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if (name == null) { name = ((original != null) ? (original.DeclaringType?.Name + "." + original.Name) : ((prefix ?? postfix) + " target")); } try { if (original == null) { throw new MissingMethodException(name + " not found"); } List<string> list = SharedCodeGuard.FindMethodsSharingCode(original); if (list.Count > 0) { log.Warning($"skipped {name}: its native code is shared with {list.Count} other method(s), patching would break them (e.g. {string.Join(", ", list.GetRange(0, Math.Min(5, list.Count)))})"); return false; } harmony.Patch(original, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(AccessTools.Method(patchClass, prefix, (Type[])null, (Type[])null)), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(AccessTools.Method(patchClass, postfix, (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } catch (Exception ex) { log.Error($"failed to hook {name} — this part is disabled. {ex.GetType().Name}: {ex.Message}"); return false; } } } internal sealed class Localizer { private readonly string[] _keys; private readonly Dictionary<string, string[]> _table; private readonly Func<Instance> _log; private readonly Dictionary<string, bool> _fontSupport = new Dictionary<string, bool>(); private readonly List<(TMP_Text text, Func<string> value)> _bound = new List<(TMP_Text, Func<string>)>(); private readonly List<Action> _listeners = new List<Action>(); private string[] _current; private string _code; private TMP_Text _fontSample; private bool _subscribed; public Localizer(string[] keys, Dictionary<string, string[]> table, Func<Instance> log) { _keys = keys; _table = table; _log = log; } public string Get(string key) { if (_current == null || _code != LocaleCode()) { _current = Resolve(_fontSample); } int num = Array.IndexOf(_keys, key); if (num < 0 || num >= _current.Length) { return key; } return _current[num]; } public void Bind(TMP_Text text, Func<string> value, TMP_Text fontSample = null) { if (!((Object)(object)text == (Object)null)) { EnsureSubscribed(); if (_current == null) { _current = Resolve(fontSample ?? text); } text.text = value(); _bound.Add((text, value)); } } public void Bind(TMP_Text text, string key, TMP_Text fontSample = null) { Bind(text, () => Get(key), fontSample); } public void OnLanguageChanged(Action listener) { EnsureSubscribed(); _listeners.Add(listener); } public void UseFont(TMP_Text sample) { _fontSample = sample; _current = null; EnsureSubscribed(); } private void EnsureSubscribed() { if (_subscribed) { return; } _subscribed = true; try { LocalizationSettings.SelectedLocaleChanged += Action<Locale>.op_Implicit((Action<Locale>)delegate { Refresh(); }); } catch (Exception ex) { Instance obj = _log(); if (obj != null) { obj.Warning("[lang] can't follow language changes: " + ex.Message); } } } private void Refresh() { _bound.RemoveAll(((TMP_Text text, Func<string> value) b) => (Object)(object)b.text == (Object)null); _current = Resolve((_bound.Count > 0) ? _bound[0].text : _fontSample); foreach (var (val, func) in _bound) { val.text = func(); } foreach (Action listener in _listeners) { try { listener(); } catch (Exception ex) { Instance obj = _log(); if (obj != null) { obj.Warning("[lang] " + ex.Message); } } } } private static string LocaleCode() { try { Locale selectedLocale = LocalizationSettings.SelectedLocale; return ((selectedLocale != null) ? selectedLocale.Identifier.Code : null) ?? "en"; } catch { return "en"; } } private string[] Resolve(TMP_Text fontSample) { string text = (_code = LocaleCode()); string text2 = TableKey(text); if (text2 != "en" && (Object)(object)fontSample != (Object)null && !FontHasAll(fontSample, text2)) { Instance obj = _log(); if (obj != null) { obj.Warning("[lang] font lacks glyphs for '" + text + "', using English"); } text2 = "en"; } return _table[text2]; } private string TableKey(string code) { code = code.ToLowerInvariant().Replace('_', '-'); string text = (code.StartsWith("zh") ? ((code.Contains("hant") || code.Contains("tw") || code.Contains("hk")) ? "zh-hant" : "zh-hans") : (code.StartsWith("pt") ? (code.Contains("br") ? "pt-br" : "pt") : ((!code.StartsWith("es")) ? code.Split('-')[0] : ((code == "es" || code.Contains("es-es")) ? "es" : "es-mx")))); if (_table.ContainsKey(text)) { return text; } string text2 = text.Split('-')[0]; if (!_table.ContainsKey(text2)) { return "en"; } return text2; } private bool FontHasAll(TMP_Text sample, string key) { if (_fontSupport.TryGetValue(key, out var value)) { return value; } value = true; try { TMP_FontAsset font = sample.font; if ((Object)(object)font != (Object)null) { string[] array = _table[key]; foreach (string text in array) { foreach (char c in text) { if (c > '\u007f' && !char.IsWhiteSpace(c) && !font.HasCharacter(c, true, true)) { value = false; break; } } if (!value) { break; } } } } catch { value = true; } _fontSupport[key] = value; return value; } } internal static class MatchmakingGuard { private const string BlockersKey = "SpellBrigade.Matchmaking.Blockers"; private const string OwnerKey = "SpellBrigade.Matchmaking.Owner"; private const string PanelName = "SpellBrigade_MatchmakingLock"; private static readonly Color Gold = new Color(0.96f, 0.78f, 0.35f); private static bool _owner; private static bool _wasBlocked; private static Instance _log; private static MatchmakingPreferencesModal _modal; private static TMP_Text _title; private static TMP_Text _body; private static float _pulse; private static float _nextCheck; private const string Title = "title"; private const string Intro = "intro"; private const string Footer = "footer"; private static readonly Localizer Text = new Localizer(new string[3] { "title", "intro", "footer" }, new Dictionary<string, string[]> { ["en"] = new string[3] { "Matchmaking is locked by mods", "These mods change the game for everyone in the lobby, so players without them can't be matched with you:", "Play with friends: invite them or share the lobby code. Matchmaking comes back as soon as nothing above applies." }, ["ru"] = new string[3] { "Подбор игроков заблокирован модами", "Эти моды меняют игру для всех в лобби, поэтому игроков без них к вам не подберёт:", "Играйте с друзьями: пригласите их или дайте код лобби. Подбор вернётся сам, как только ничего из списка не будет мешать." }, ["uk"] = new string[3] { "Підбір гравців заблоковано модами", "Ці моди змінюють гру для всіх у лобі, тому гравців без них до вас не підбере:", "Грайте з друзями: запросіть їх або дайте код лобі. Підбір повернеться сам, щойно нічого зі списку не заважатиме." }, ["de"] = new string[3] { "Matchmaking ist durch Mods gesperrt", "Diese Mods verändern das Spiel für alle in der Lobby, daher kannst du nicht mit Spielern ohne sie zusammengebracht werden:", "Spiele mit Freunden: Lade sie ein oder teile den Lobby-Code. Matchmaking kommt zurück, sobald nichts davon mehr zutrifft." }, ["fr"] = new string[3] { "Matchmaking bloqué par des mods", "Ces mods modifient la partie pour tout le salon, vous ne pouvez donc pas être associé à des joueurs qui ne les ont pas :", "Jouez avec des amis : invitez-les ou partagez le code du salon. Le matchmaking revient dès que plus rien ci-dessus ne s'applique." }, ["it"] = new string[3] { "Matchmaking bloccato dalle mod", "Queste mod cambiano la partita per tutta la lobby, quindi non puoi essere abbinato a chi non le ha:", "Gioca con gli amici: invitali o condividi il codice della lobby. Il matchmaking torna appena nulla di tutto ciò si applica." }, ["nl"] = new string[3] { "Matchmaking geblokkeerd door mods", "Deze mods veranderen het spel voor iedereen in de lobby, dus je wordt niet gekoppeld aan spelers zonder deze mods:", "Speel met vrienden: nodig ze uit of deel de lobbycode. Matchmaking komt terug zodra niets hiervan meer geldt." }, ["pl"] = new string[3] { "Dobieranie graczy zablokowane przez mody", "Te mody zmieniają grę wszystkim w lobby, więc gracze bez nich nie zostaną do ciebie dobrani:", "Graj ze znajomymi: zaproś ich lub podaj kod lobby. Dobieranie wróci samo, gdy nic z listy nie będzie przeszkadzać." }, ["pt-br"] = new string[3] { "Matchmaking bloqueado por mods", "Estes mods mudam o jogo para todos no lobby, então jogadores sem eles não serão pareados com você:", "Jogue com amigos: convide-os ou compartilhe o código do lobby. O matchmaking volta assim que nada acima se aplicar." }, ["pt"] = new string[3] { "Matchmaking bloqueado por mods", "Estes mods mudam o jogo para todos no lobby, por isso jogadores sem eles não serão emparelhados contigo:", "Joga com amigos: convida-os ou partilha o código do lobby. O matchmaking volta assim que nada acima se aplicar." }, ["es"] = new string[3] { "Emparejamiento bloqueado por mods", "Estos mods cambian la partida para toda la sala, así que no se te emparejará con jugadores que no los tengan:", "Juega con amigos: invítalos o comparte el código de sala. El emparejamiento vuelve en cuanto nada de lo anterior aplique." }, ["es-mx"] = new string[3] { "Emparejamiento bloqueado por mods", "Estos mods cambian la partida para toda la sala, así que no se te emparejará con jugadores que no los tengan:", "Juega con amigos: invítalos o comparte el código de sala. El emparejamiento regresa en cuanto nada de lo anterior aplique." }, ["ja"] = new string[3] { "MODによりマッチングがロックされています", "これらのMODはロビー全員のゲームを変えるため、MODのないプレイヤーとはマッチングしません:", "フレンドと遊びましょう:招待するかロビーコードを共有してください。上記が当てはまらなくなればマッチングは戻ります。" }, ["ko"] = new string[3] { "모드로 인해 매칭이 잠겼습니다", "이 모드들은 로비 전체의 게임을 바꾸므로, 모드가 없는 플레이어와는 매칭되지 않습니다:", "친구와 플레이하세요: 초대하거나 로비 코드를 공유하세요. 위 항목이 모두 해당되지 않으면 매칭이 다시 열립니다." }, ["zh-hans"] = new string[3] { "匹配已被模组锁定", "这些模组会改变大厅里所有人的游戏,因此不会为你匹配没有这些模组的玩家:", "和好友一起玩:邀请他们或分享大厅代码。只要上面各项都不再适用,匹配就会恢复。" }, ["zh-hant"] = new string[3] { "配對已被模組鎖定", "這些模組會改變大廳裡所有人的遊戲,因此不會為你配對沒有這些模組的玩家:", "和好友一起玩:邀請他們或分享大廳代碼。只要上面各項都不再適用,配對就會恢復。" }, ["th"] = new string[3] { "การจ\u0e31บค\u0e39\u0e48ถ\u0e39กล\u0e47อกโดยม\u0e47อด", "ม\u0e47อดเหล\u0e48าน\u0e35\u0e49เปล\u0e35\u0e48ยนเกมของท\u0e38กคนในล\u0e47อบบ\u0e35\u0e49 จ\u0e36งจะไม\u0e48จ\u0e31บค\u0e39\u0e48ค\u0e38ณก\u0e31บผ\u0e39\u0e49เล\u0e48นท\u0e35\u0e48ไม\u0e48ม\u0e35ม\u0e47อด:", "เล\u0e48นก\u0e31บเพ\u0e37\u0e48อน: เช\u0e34ญเพ\u0e37\u0e48อนหร\u0e37อแชร\u0e4cรห\u0e31สล\u0e47อบบ\u0e35\u0e49 การจ\u0e31บค\u0e39\u0e48จะกล\u0e31บมาเม\u0e37\u0e48อไม\u0e48ม\u0e35ข\u0e49อใดด\u0e49านบนเข\u0e49าเง\u0e37\u0e48อนไข" } }, () => _log); private static bool _prepareRestore; public static bool Blocked => Reasons().Count > 0; private static MatchmakingPreferencesManager Prefs => Singleton<MatchmakingPreferencesManager>.Instance; public static void Register(Harmony harmony, Instance log, string modName, Func<string> reason) { AppDomain currentDomain = AppDomain.CurrentDomain; List<Func<string>> list = currentDomain.GetData("SpellBrigade.Matchmaking.Blockers") as List<Func<string>>; if (list == null) { currentDomain.SetData("SpellBrigade.Matchmaking.Blockers", list = new List<Func<string>>()); } list.Add(delegate { string text = reason(); return (text == null) ? null : ("<b>" + modName + "</b> — " + text); }); object data = currentDomain.GetData("SpellBrigade.Matchmaking.Owner"); if (!(data is bool) || !(bool)data) { currentDomain.SetData("SpellBrigade.Matchmaking.Owner", true); _owner = true; _log = log; int num = 0; num += Hook(harmony, typeof(RunPreparationManager), "Prepare", "PreparePrefix", "PreparePostfix"); num += Hook(harmony, typeof(RunPreparationManager), "CanUseMatchmaking", "CanUsePrefix"); num += Hook(harmony, typeof(MatchmakingToggle), "Toggle", "TogglePrefix"); num += Hook(harmony, typeof(MatchmakingPreferencesModal), "OnIsMatchmakingEnabledChanged", "EnabledChangedPrefix"); num += Hook(harmony, typeof(MatchmakingPreferencesModal), "RefreshPanel", null, "RefreshPanelPostfix"); log.Msg($"matchmaking guard: {num}/5 hooks"); } } private static int Hook(Harmony harmony, Type type, string method, string prefix, string postfix = null) { return Hooks.Patch(harmony, _log, type, method, typeof(MatchmakingGuard), prefix, postfix) ? 1 : 0; } public static List<string> Reasons() { List<string> list = new List<string>(); if (!(AppDomain.CurrentDomain.GetData("SpellBrigade.Matchmaking.Blockers") is List<Func<string>> list2)) { return list; } foreach (Func<string> item in list2) { try { string text = item(); if (text != null) { list.Add(text); } } catch { } } return list; } private static void PreparePrefix() { List<string> list = Reasons(); MatchmakingPreferencesManager prefs = Prefs; if (list.Count != 0 && !((Object)(object)prefs == (Object)null) && prefs.IsMatchmakingEnabled) { prefs.IsMatchmakingEnabled = false; _prepareRestore = true; Instance log = _log; if (log != null) { log.Msg("run starts without matchmaking — " + StripTags(string.Join("; ", list))); } } } private static void PreparePostfix() { if (_prepareRestore) { _prepareRestore = false; MatchmakingPreferencesManager prefs = Prefs; if ((Object)(object)prefs != (Object)null) { prefs.IsMatchmakingEnabled = true; } } } private static bool CanUsePrefix(ref bool __result) { if (!Blocked) { return true; } __result = false; return false; } private static bool TogglePrefix(MatchmakingToggle __instance) { if (!Blocked || !IsMatchmakingToggle(__instance)) { return true; } _pulse = 1f; return false; } private static bool EnabledChangedPrefix(MatchmakingPreferencesModal __instance, bool isOn) { if (!isOn || !Blocked) { return true; } RefreshPanelPostfix(__instance); return false; } private static bool IsMatchmakingToggle(MatchmakingToggle toggle) { if ((Object)(object)_modal != (Object)null && (Object)(object)_modal.isMatchmakingEnabledToggle != (Object)null) { return ((Il2CppObjectBase)_modal.isMatchmakingEnabledToggle).Pointer == ((Il2CppObjectBase)toggle).Pointer; } return false; } private static void RefreshPanelPostfix(MatchmakingPreferencesModal __instance) { try { _modal = __instance; Apply(__instance, Reasons()); } catch (Exception ex) { Instance log = _log; if (log != null) { log.Warning("matchmaking window: " + ex.Message); } } } private static void Apply(MatchmakingPreferencesModal modal, List<string> reasons) { bool flag = reasons.Count > 0; MatchmakingToggle isMatchmakingEnabledToggle = modal.isMatchmakingEnabledToggle; if ((Object)(object)isMatchmakingEnabledToggle != (Object)null) { if (flag) { isMatchmakingEnabledToggle.isOn = false; isMatchmakingEnabledToggle.RefreshUI(); } (((Component)isMatchmakingEnabledToggle).GetComponent<CanvasGroup>() ?? ((Component)isMatchmakingEnabledToggle).gameObject.AddComponent<CanvasGroup>()).alpha = (flag ? 0.4f : 1f); } if (flag && (Object)(object)modal.matchmakingPreferencesObject != (Object)null) { modal.matchmakingPreferencesObject.SetActive(false); } Transform val = ((Component)modal).transform.Find("SpellBrigade_MatchmakingLock"); if ((Object)(object)val == (Object)null && flag) { val = BuildPanel(modal); } if ((Object)(object)val == (Object)null) { return; } ((Component)val).gameObject.SetActive(flag); if (!flag) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Text.Get("intro")).Append('\n'); foreach (string reason in reasons) { stringBuilder.Append("\n• ").Append(reason); } stringBuilder.Append("\n\n<alpha=#B3>").Append(Text.Get("footer")); _title.text = Text.Get("title"); _body.text = stringBuilder.ToString(); } private static Transform BuildPanel(MatchmakingPreferencesModal modal) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) Transform obj = ((Component)modal).transform.Find("Matchmaking_Description"); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null) ?? ((Component)modal).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)val == (Object)null) { return null; } RectTransform val2 = new GameObject("SpellBrigade_MatchmakingLock").AddComponent<RectTransform>(); ((Transform)val2).SetParent(((Component)modal).transform, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 1f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.anchoredPosition = new Vector2(250f, -1060f); val2.sizeDelta = new Vector2(2250f, 760f); float num = (val.enableAutoSizing ? val.fontSizeMax : val.fontSize); _title = CloneText(val, (Transform)(object)val2, "Title", num * 1.25f, Gold, (FontStyles)1); RectTransform rectTransform = _title.rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.sizeDelta = new Vector2(0f, num * 1.8f); rectTransform.anchoredPosition = Vector2.zero; _body = CloneText(val, (Transform)(object)val2, "Body", num, Color.white, (FontStyles)0); RectTransform rectTransform2 = _body.rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; rectTransform2.pivot = new Vector2(0f, 1f); rectTransform2.offsetMin = Vector2.zero; rectTransform2.offsetMax = new Vector2(0f, (0f - num) * 2f); _body.textWrappingMode = (TextWrappingModes)1; _body.enableAutoSizing = true; _body.fontSizeMin = num * 0.6f; _body.fontSizeMax = num; return (Transform)(object)val2; } private static TMP_Text CloneText(TMP_Text template, Transform parent, string name, float size, Color color, FontStyles style) { //IL_009b: 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) TMP_Text component = Object.Instantiate<GameObject>(((Component)template).gameObject, parent).GetComponent<TMP_Text>(); foreach (LocalizeStringEvent component2 in ((Component)component).GetComponents<LocalizeStringEvent>()) { Object.Destroy((Object)(object)component2); } foreach (MonoBehaviour component3 in ((Component)component).GetComponents<MonoBehaviour>()) { if ((Object)(object)component3 != (Object)null && (Object)(object)((Il2CppObjectBase)component3).TryCast<TMP_Text>() == (Object)null) { Object.Destroy((Object)(object)component3); } } ((Object)component).name = name; component.enableAutoSizing = false; component.fontSize = size; ((Graphic)component).color = color; component.fontStyle = style; component.alignment = (TextAlignmentOptions)257; component.textWrappingMode = (TextWrappingModes)0; component.overflowMode = (TextOverflowModes)0; ((Graphic)component).raycastTarget = false; return component; } private static string StripTags(string s) { return Regex.Replace(s, "<.*?>", ""); } public static void Tick() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) if (!_owner) { return; } if (_pulse > 0f && (Object)(object)_title != (Object)null) { _pulse = Mathf.Max(0f, _pulse - Time.unscaledDeltaTime * 2.5f); _title.transform.localScale = Vector3.one * (1f + 0.08f * _pulse); ((Graphic)_title).color = Color.Lerp(Gold, new Color(1f, 0.45f, 0.35f), _pulse); } if (Time.unscaledTime < _nextCheck) { return; } _nextCheck = Time.unscaledTime + 0.25f; List<string> list = Reasons(); bool flag = list.Count > 0; if (flag != _wasBlocked) { _wasBlocked = flag; Instance log = _log; if (log != null) { log.Msg(flag ? ("matchmaking locked — " + StripTags(string.Join("; ", list))) : "matchmaking unlocked"); } if ((Object)(object)_modal != (Object)null && ((Component)_modal).gameObject.activeInHierarchy) { try { _modal.RefreshPanel(); } catch { } } } else if (flag && (Object)(object)_modal != (Object)null && ((Component)_modal).gameObject.activeInHierarchy && (Object)(object)_body != (Object)null) { Apply(_modal, list); } } } internal static class SharedCodeGuard { private static Dictionary<IntPtr, List<IntPtr>> _methodsByCode; public static List<string> FindMethodsSharingCode(MethodBase generatedMethod) { List<string> list = new List<string>(); if (!(Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(generatedMethod)?.GetValue(null) is IntPtr intPtr) || intPtr == IntPtr.Zero) { return list; } IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr); if (intPtr2 == IntPtr.Zero) { return list; } if (_methodsByCode == null) { _methodsByCode = BuildIndex(); } if (!_methodsByCode.TryGetValue(intPtr2, out var value)) { return list; } foreach (IntPtr item in value) { if (item != intPtr) { list.Add(Describe(item)); } } return list; } private static string Describe(IntPtr method) { IntPtr intPtr = IL2CPP.il2cpp_method_get_class(method); string text = IL2CPP.il2cpp_class_get_namespace_(intPtr); return (string.IsNullOrEmpty(text) ? IL2CPP.il2cpp_class_get_name_(intPtr) : (text + "." + IL2CPP.il2cpp_class_get_name_(intPtr))) + "::" + IL2CPP.il2cpp_method_get_name_(method); } private unsafe static Dictionary<IntPtr, List<IntPtr>> BuildIndex() { Dictionary<IntPtr, List<IntPtr>> dictionary = new Dictionary<IntPtr, List<IntPtr>>(); uint num = 0u; IntPtr* ptr = IL2CPP.il2cpp_domain_get_assemblies(IL2CPP.il2cpp_domain_get(), ref num); for (uint num2 = 0u; num2 < num; num2++) { IntPtr intPtr = IL2CPP.il2cpp_assembly_get_image(ptr[num2]); uint num3 = IL2CPP.il2cpp_image_get_class_count(intPtr); for (uint num4 = 0u; num4 < num3; num4++) { IntPtr intPtr2 = IL2CPP.il2cpp_image_get_class(intPtr, num4); if (intPtr2 == IntPtr.Zero) { continue; } IntPtr zero = IntPtr.Zero; IntPtr intPtr3; while ((intPtr3 = IL2CPP.il2cpp_class_get_methods(intPtr2, ref zero)) != IntPtr.Zero) { IntPtr intPtr4 = Marshal.ReadIntPtr(intPtr3); if (!(intPtr4 == IntPtr.Zero)) { if (!dictionary.TryGetValue(intPtr4, out var value)) { value = (dictionary[intPtr4] = new List<IntPtr>(1)); } value.Add(intPtr3); } } } } return dictionary; } } internal static class WheelSelect { private sealed class State { public ScrollRect Blocked; public float BlockedSensitivity; public Vector2 LastMouse = new Vector2(-1f, -1f); } private const string FrameKey = "SpellBrigade.WheelSelect.Frame"; private const string CustomKey = "SpellBrigade.WheelSelect.Custom"; private static readonly State Own = new State(); private static List<(GameObject target, Action<int> step)> Custom { get { AppDomain currentDomain = AppDomain.CurrentDomain; if (currentDomain.GetData("SpellBrigade.WheelSelect.Custom") is List<(GameObject, Action<int>)> result) { return result; } List<(GameObject, Action<int>)> list = new List<(GameObject, Action<int>)>(); currentDomain.SetData("SpellBrigade.WheelSelect.Custom", list); return list; } } public static void Register(GameObject target, Action<int> step) { if ((Object)(object)target != (Object)null && step != null) { Custom.Add((target, step)); } } public static void Tick() { try { TickCore(); } catch { } } private static void TickCore() { //IL_0077: 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_0084: 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_0094: 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_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) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) int frameCount = Time.frameCount; AppDomain currentDomain = AppDomain.CurrentDomain; if (currentDomain.GetData("SpellBrigade.WheelSelect.Frame") is int num && num == frameCount) { return; } currentDomain.SetData("SpellBrigade.WheelSelect.Frame", frameCount); object data = currentDomain.GetData("SpellBrigade.Modal"); if (data is bool && (bool)data) { return; } Mouse current = Mouse.current; if (current == null) { return; } State own = Own; Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; Vector2 val2 = val - own.LastMouse; if (!(((Vector2)(ref val2)).sqrMagnitude > 0.25f) && Mathf.Abs(y) < 0.01f) { return; } own.LastMouse = val; var (val3, action, val4) = Hovered(val); BlockScroll(own, ((Object)(object)val4 != (Object)null) ? ScrollRectAbove(val4) : null); if (Mathf.Abs(y) < 0.01f || (Object)(object)val4 == (Object)null) { return; } int num2 = ((y > 0f) ? 1 : (-1)); try { if ((Object)(object)val3 != (Object)null) { if (num2 > 0) { val3.SelectNext(); } else { val3.SelectPrevious(); } } else { action?.Invoke(num2); } } catch { } } private static (Selector selector, Action<int> custom, RectTransform rect) Hovered(Vector2 position) { //IL_0055: 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) List<(GameObject target, Action<int> step)> custom = Custom; custom.RemoveAll(((GameObject target, Action<int> step) c) => (Object)(object)c.target == (Object)null); foreach (var (val, item) in custom) { if (val.activeInHierarchy && Contains(val.GetComponent<RectTransform>(), position)) { return (selector: null, custom: item, rect: val.GetComponent<RectTransform>()); } } foreach (Selector item2 in Object.FindObjectsOfType<Selector>()) { if (!((Object)(object)item2 == (Object)null) && ((Selectable)item2).IsInteractable()) { RectTransform component = ((Component)item2).GetComponent<RectTransform>(); if (Contains(component, position)) { return (selector: item2, custom: null, rect: component); } } } return (selector: null, custom: null, rect: null); } private static bool Contains(RectTransform rect, Vector2 position) { //IL_006e: 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_00ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rect == (Object)null) { return false; } Canvas val = null; Transform val2 = ((Component)rect).transform; while ((Object)(object)val2 != (Object)null) { CanvasGroup component = ((Component)val2).GetComponent<CanvasGroup>(); if ((Object)(object)component != (Object)null && (component.alpha < 0.01f || !component.blocksRaycasts)) { return false; } Canvas component2 = ((Component)val2).GetComponent<Canvas>(); if ((Object)(object)component2 != (Object)null) { val = component2; } val2 = val2.parent; } if ((Object)(object)val == (Object)null) { return false; } Camera val3 = (((int)val.renderMode == 0) ? null : val.worldCamera); if (!RectTransformUtility.RectangleContainsScreenPoint(rect, position, val3)) { return false; } Transform parent = ((Transform)rect).parent; while ((Object)(object)parent != (Object)null) { if ((Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null && !RectTransformUtility.RectangleContainsScreenPoint(((Component)parent).GetComponent<RectTransform>(), position, val3)) { return false; } parent = parent.parent; } return true; } private static ScrollRect ScrollRectAbove(RectTransform rect) { Transform parent = ((Transform)rect).parent; while ((Object)(object)parent != (Object)null) { ScrollRect component = ((Component)parent).GetComponent<ScrollRect>(); if ((Object)(object)component != (Object)null) { return component; } parent = parent.parent; } return null; } private static void BlockScroll(State state, ScrollRect scroll) { if (!((Object)(object)state.Blocked != (Object)null) || !((Object)(object)scroll != (Object)null) || !(((Il2CppObjectBase)state.Blocked).Pointer == ((Il2CppObjectBase)scroll).Pointer)) { if ((Object)(object)state.Blocked != (Object)null) { state.Blocked.scrollSensitivity = state.BlockedSensitivity; } state.Blocked = scroll; if (!((Object)(object)scroll == (Object)null)) { state.BlockedSensitivity = scroll.scrollSensitivity; scroll.scrollSensitivity = 0f; } } } } } namespace KeybindsUnlocked { internal sealed class Slot { public string Map; public string Action; public bool Gamepad; public int Composite = -1; public string Part; public string ControlType = "Button"; public List<Slot> Mirrors = new List<Slot>(); public string Id => $"{Map}/{Action}/{(Gamepad ? "gp" : "kb")}/{Composite}/{Part}"; public Slot(string mapAction, bool gamepad, int composite = -1, string part = null) { string[] array = mapAction.Split('/'); Map = array[0]; Action = array[1]; Gamepad = gamepad; Composite = composite; Part = part; } } internal static class Bindings { private sealed class BindingInfo { public string Name; public string Path; public bool IsComposite; public bool IsPart; } private const string ModelName = "KeybindsUnlocked_Model"; public const string ModMap = "KeybindsUnlocked"; public const string ToggleSpells = "ToggleSpells"; public const string HoldToDie = "HoldToDie"; private const string HoldToDieKey = "SpellBrigade.Input.HoldToDie"; private const string ModMapJson = "{\r\n \"name\": \"KeybindsUnlocked\", \"id\": \"6f1d7a52-3c1e-4b8e-9d57-0d3c2b6a9e11\",\r\n \"actions\": [\r\n { \"name\": \"ToggleSpells\", \"type\": \"Button\", \"id\": \"8a2f4c61-5b7d-4e19-a3c8-2e6d9f1b7c42\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false },\r\n { \"name\": \"HoldToDie\", \"type\": \"Button\", \"id\": \"5e9c1b3d-7a24-4f6e-b081-3c5d7e9f1a26\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false }\r\n ],\r\n \"bindings\": [\r\n { \"name\": \"\", \"id\": \"c3e5a7b9-1d2f-4a6c-8e0b-9f7d5c3a1e24\", \"path\": \"<Keyboard>/h\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"d4f6b8c0-2e3a-4b7d-9f1c-0a8e6d4b2f35\", \"path\": \"<Gamepad>/rightStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"a7c9e1f3-4b6d-4d8f-a2c4-6e8a0c2e4f68\", \"path\": \"<Keyboard>/k\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"b8d0f2a4-5c7e-4e9a-b3d5-7f9b1d3f5a79\", \"path\": \"<Gamepad>/leftStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false }\r\n ]\r\n }"; private static InputActionAsset _modAsset; private static InputAction _toggleSpells; private static int _modVersion; private static InputActionAsset _model; private static Dictionary<string, List<BindingInfo>> _layout; private static string _overrides = ""; private static int _version = 1; private static readonly Dictionary<int, int> AppliedVersion = new Dictionary<int, int>(); private static float _nextScan; private static bool _dirty = true; private static RebindingOperation _operation; private static readonly List<InputActionMap> SuspendedMaps = new List<InputActionMap>(); private static string FilePath => Path.Combine(MelonEnvironment.UserDataDirectory, "KeybindsUnlocked.json"); public static bool IsRebinding => _operation != null; public static bool Ready => (Object)(object)_model != (Object)null; public static event Action Changed; public static event Action Applied; public static void Init() { try { if (File.Exists(FilePath)) { _overrides = DropBrokenOverrides(File.ReadAllText(FilePath)); } } catch (Exception ex) { KeybindsMod.Log.Warning("can't read " + FilePath + ": " + ex.Message); } try { _modAsset = InputActionAsset.FromJson("{\"maps\":[{\r\n \"name\": \"KeybindsUnlocked\", \"id\": \"6f1d7a52-3c1e-4b8e-9d57-0d3c2b6a9e11\",\r\n \"actions\": [\r\n { \"name\": \"ToggleSpells\", \"type\": \"Button\", \"id\": \"8a2f4c61-5b7d-4e19-a3c8-2e6d9f1b7c42\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false },\r\n { \"name\": \"HoldToDie\", \"type\": \"Button\", \"id\": \"5e9c1b3d-7a24-4f6e-b081-3c5d7e9f1a26\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false }\r\n ],\r\n \"bindings\": [\r\n { \"name\": \"\", \"id\": \"c3e5a7b9-1d2f-4a6c-8e0b-9f7d5c3a1e24\", \"path\": \"<Keyboard>/h\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"d4f6b8c0-2e3a-4b7d-9f1c-0a8e6d4b2f35\", \"path\": \"<Gamepad>/rightStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"a7c9e1f3-4b6d-4d8f-a2c4-6e8a0c2e4f68\", \"path\": \"<Keyboard>/k\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"b8d0f2a4-5c7e-4e9a-b3d5-7f9b1d3f5a79\", \"path\": \"<Gamepad>/leftStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false }\r\n ]\r\n }]}"); ((Object)_modAsset).name = "KeybindsUnlocked_Mod"; ((Object)_modAsset).hideFlags = (HideFlags)61; _toggleSpells = _modAsset.FindAction("KeybindsUnlocked/ToggleSpells", false); _modAsset.Enable(); AppDomain.CurrentDomain.SetData("SpellBrigade.Input.HoldToDie", _modAsset.FindAction("KeybindsUnlocked/HoldToDie", false)); } catch (Exception ex2) { KeybindsMod.Log.Warning("can't create mod actions: " + ex2.Message); } try { InputSystem.onActionChange += Action<Object, InputActionChange>.op_Implicit((Action<Object, InputActionChange>)delegate(Object _, InputActionChange change) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)change == 2) { _dirty = true; } }); } catch (Exception ex3) { KeybindsMod.Log.Warning("can't watch input changes: " + ex3.Message); } } private static string DropBrokenOverrides(string json) { if (string.IsNullOrWhiteSpace(json) || !json.Contains("/press\"")) { return json; } try { using JsonDocument jsonDocument = JsonDocument.Parse(json); List<string> list = new List<string>(); foreach (JsonElement item in jsonDocument.RootElement.GetProperty("bindings").EnumerateArray()) { JsonElement value; string text = (item.TryGetProperty("path", out value) ? (value.GetString() ?? "") : ""); if (!text.EndsWith("/press", StringComparison.OrdinalIgnoreCase) && !text.Contains("anyKey", StringComparison.OrdinalIgnoreCase)) { list.Add(item.GetRawText()); } } string text2 = "{\"bindings\":[" + string.Join(",", list) + "]}"; File.WriteAllText(FilePath, text2); return text2; } catch { return json; } } public static void Tick() { if (_dirty || !(Time.unscaledTime < _nextScan)) { _dirty = false; _nextScan = Time.unscaledTime + 1f; ApplyToAll(); } } private static bool IsGameAsset(InputActionAsset a) { if ((Object)(object)a != (Object)null && ((Object)a).name != "KeybindsUnlocked_Model" && a.FindActionMap("Gameplay", false) != null) { return a.FindActionMap("UI", false) != null; } return false; } private static void ApplyToAll() { bool flag = false; foreach (InputActionAsset item in Resources.FindObjectsOfTypeAll<InputActionAsset>()) { if (!IsGameAsset(item)) { continue; } EnsureModel(item); int instanceID = ((Object)item).GetInstanceID(); if (!AppliedVersion.TryGetValue(instanceID, out var value) || value != _version) { try { ApplyOverrides(item); AppliedVersion[instanceID] = _version; flag = true; } catch (Exception ex) { KeybindsMod.Log.Warning("can't apply keybinds to '" + ((Object)item).name + "': " + ex.Message); } } } if ((Object)(object)_modAsset != (Object)null && _modVersion != _version) { try { ApplyOverrides(_modAsset); _modVersion = _version; } catch (Exception ex2) { KeybindsMod.Log.Warning("can't apply keybinds to mod actions: " + ex2.Message); } } if (flag && !string.IsNullOrEmpty(_overrides)) { Bindings.Applied?.Invoke(); } } private static void ApplyOverrides(InputActionAsset asset) { IInputActionCollection2 val = ((Il2CppObjectBase)asset).Cast<IInputActionCollection2>(); InputActionRebindingExtensions.RemoveAllBindingOverrides(val); if (!string.IsNullOrEmpty(_overrides)) { InputActionRebindingExtensions.LoadBindingOverridesFromJson(val, _overrides, true); } } private static void EnsureModel(InputActionAsset template) { if (!((Object)(object)_model != (Object)null)) { string text = WithModMap(template.ToJson()); _model = InputActionAsset.FromJson(text); ((Object)_model).name = "KeybindsUnlocked_Model"; ((Object)_model).hideFlags = (HideFlags)61; _layout = ParseLayout(text); ApplyOverrides(_model); } } public static bool ToggleSpellsPressed() { if (_operation == null && _toggleSpells != null) { return _toggleSpells.WasPressedThisFrame(); } return false; } private static string WithModMap(string json) { try { JsonNode? jsonNode = JsonNode.Parse(json); jsonNode["maps"].AsArray().Add(JsonNode.Parse("{\r\n \"name\": \"KeybindsUnlocked\", \"id\": \"6f1d7a52-3c1e-4b8e-9d57-0d3c2b6a9e11\",\r\n \"actions\": [\r\n { \"name\": \"ToggleSpells\", \"type\": \"Button\", \"id\": \"8a2f4c61-5b7d-4e19-a3c8-2e6d9f1b7c42\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false },\r\n { \"name\": \"HoldToDie\", \"type\": \"Button\", \"id\": \"5e9c1b3d-7a24-4f6e-b081-3c5d7e9f1a26\",\r\n \"expectedControlType\": \"Button\", \"processors\": \"\", \"interactions\": \"\", \"initialStateCheck\": false }\r\n ],\r\n \"bindings\": [\r\n { \"name\": \"\", \"id\": \"c3e5a7b9-1d2f-4a6c-8e0b-9f7d5c3a1e24\", \"path\": \"<Keyboard>/h\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"d4f6b8c0-2e3a-4b7d-9f1c-0a8e6d4b2f35\", \"path\": \"<Gamepad>/rightStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"ToggleSpells\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"a7c9e1f3-4b6d-4d8f-a2c4-6e8a0c2e4f68\", \"path\": \"<Keyboard>/k\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false },\r\n { \"name\": \"\", \"id\": \"b8d0f2a4-5c7e-4e9a-b3d5-7f9b1d3f5a79\", \"path\": \"<Gamepad>/leftStickPress\", \"interactions\": \"\",\r\n \"processors\": \"\", \"groups\": \"\", \"action\": \"HoldToDie\", \"isComposite\": false, \"isPartOfComposite\": false }\r\n ]\r\n }")); return jsonNode.ToJsonString(); } catch (Exception ex) { KeybindsMod.Log.Warning("can't add mod actions to the keybind list: " + ex.Message); return json; } } private static Dictionary<string, List<BindingInfo>> ParseLayout(string json) { Dictionary<string, List<BindingInfo>> dictionary = new Dictionary<string, List<BindingInfo>>(); using JsonDocument jsonDocument = JsonDocument.Parse(json); foreach (JsonElement item in jsonDocument.RootElement.GetProperty("maps").EnumerateArray()) { string text = item.GetProperty("name").GetString(); foreach (JsonElement item2 in item.GetProperty("bindings").EnumerateArray()) { string key = text + "/" + item2.GetProperty("action").GetString(); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List<BindingInfo>()); } value.Add(new BindingInfo { Name = (item2.TryGetProperty("name", out var value2) ? value2.GetString() : ""), Path = (item2.TryGetProperty("path", out var value3) ? value3.GetString() : ""), IsComposite = (item2.TryGetProperty("isComposite", out var value4) && value4.GetBoolean()), IsPart = (item2.TryGetProperty("isPartOfComposite", out var value5) && value5.GetBoolean()) }); } } return dictionary; } public static int Resolve(Slot slot) { if (_layout == null || !_layout.TryGetValue(slot.Map + "/" + slot.Action, out var value)) { return -1; } if (slot.Composite >= 0) { int num = -1; for (int i = 0; i < value.Count; i++) { if (value[i].IsComposite) { num++; } else if (num == slot.Composite && value[i].IsPart && string.Equals(value[i].Name, slot.Part, StringComparison.OrdinalIgnoreCase)) { return i; } } return -1; } string[] array = ((!slot.Gamepad) ? new string[2] { "<Keyboard>", "<Mouse>" } : new string[1] { "<Gamepad>" }); foreach (string value2 in array) { for (int k = 0; k < value.Count; k++) { if (!value[k].IsComposite && !value[k].IsPart && value[k].Path.StartsWith(value2, StringComparison.OrdinalIgnoreCase)) { return k; } } } return -1; } private static InputAction ModelAction(Slot slot) { InputActionAsset model = _model; if (model == null) { return null; } return model.FindAction(slot.Map + "/" + slot.Action, false); } public static string Display(Slot slot) { InputAction val = ModelAction(slot); int num = Resolve(slot); if (val == null || num < 0) { return "—"; } try { string text = KeyName(val, num, slot.Gamepad); return string.IsNullOrWhiteSpace(text) ? "—" : text; } catch { return "?"; } } public static (string Path, bool Overridden) State(Slot slot) { InputAction val = ModelAction(slot); int num = Resolve(slot); if (val == null || num < 0) { return (Path: null, Overridden: false); } InputBinding val2 = val.bindings[num]; string overridePath = val2.overridePath; return (Path: val2.effectivePath, Overridden: !string.IsNullOrEmpty(overridePath) && overridePath != val2.path); } public static string KeyName(InputAction action, int index, bool gamepad) { if (gamepad) { return InputActionRebindingExtensions.GetBindingDisplayString(action, index, (DisplayStringOptions)0); } return InputControlPath.ToHumanReadableString(action.bindings[index].effectivePath, (HumanReadableStringOptions)6, (InputControl)null); } public static bool CanRebind(Slot slot) { if (ModelAction(slot) != null) { return Resolve(slot) >= 0; } return false; } public static void Rebind(Slot slot, Action<bool> done) { InputAction action = ModelAction(slot); int index = Resolve(slot); if (action == null || index < 0 || _operation != null) { done?.Invoke(obj: false); return; } SuspendGameInput(); try { RebindingOperation val = InputActionRebindingExtensions.PerformInteractiveRebinding(action, index).WithExpectedControlType(slot.ControlType).WithCancelingThrough("<Keyboard>/escape") .WithTimeout(10f) .OnMatchWaitForAnother(0.1f); val = ((!slot.Gamepad) ? val.WithControlsHavingToMatchPath("<Keyboard>").WithControlsHavingToMatchPath("<Mouse>/rightButton").WithControlsHavingToMatchPath("<Mouse>/middleButton") .WithControlsHavingToMatchPath("<Mouse>/forwardButton") .WithControlsHavingToMatchPath("<Mouse>/backButton") .WithControlsExcluding("<Pointer>/press") .WithControlsExcluding("<Keyboard>/anyKey") : val.WithControlsHavingToMatchPath("<Gamepad>")); (_operation = val.OnComplete(Action<RebindingOperation>.op_Implicit((Action<RebindingOperation>)delegate { Finish(slot, action, index, success: true, done); })).OnCancel(Action<RebindingOperation>.op_Implicit((Action<RebindingOperation>)delegate { Finish(slot, action, index, success: false, done); }))).Start(); } catch (Exception value) { KeybindsMod.Log.Error($"rebinding failed: {value}"); _operation = null; ResumeGameInput(); done?.Invoke(obj: false); } } public static void CancelRebind() { try { RebindingOperation operation = _operation; if (operation != null) { operation.Cancel(); } } catch { } } private static void Finish(Slot slot, InputAction action, int index, bool success, Action<bool> done) { try { RebindingOperation operation = _operation; if (operation != null) { operation.Dispose(); } } catch { } _operation = null; ResumeGameInput(); if (success) { try { string effectivePath = action.bindings[index].effectivePath; foreach (Slot mirror in slot.Mirrors) { InputAction val = ModelAction(mirror); int num = Resolve(mirror); if (val != null && num >= 0) { InputActionRebindingExtensions.ApplyBindingOverride(val, num, effectivePath); } } Commit(); } catch (Exception value) { KeybindsMod.Log.Error($"can't save keybind: {value}"); } } done?.Invoke(success); } public static void ResetAll() { if (!((Object)(object)_model == (Object)null)) { InputActionRebindingExtensions.RemoveAllBindingOverrides(((Il2CppObjectBase)_model).Cast<IInputActionCollection2>()); Commit(); } } private static void Commit() { _overrides = InputActionRebindingExtensions.SaveBindingOverridesAsJson(((Il2CppObjectBase)_model).Cast<IInputActionCollection2>()) ?? ""; try { File.WriteAllText(FilePath, _overrides); } catch (Exception ex) { KeybindsMod.Log.Warning("can't write " + FilePath + ": " + ex.Message); } _version++; ApplyToAll(); Bindings.Changed?.Invoke(); } private static void SuspendGameInput() { SuspendedMaps.Clear(); foreach (InputActionAsset item in Resources.FindObjectsOfTypeAll<InputActionAsset>()) { if (!IsGameAsset(item)) { continue; } string[] array = new string[2] { "Gameplay", "UI" }; foreach (string text in array) { InputActionMap val = item.FindActionMap(text, false); if (val != null && val.enabled) { val.Disable(); SuspendedMaps.Add(val); } } } } private static void ResumeGameInput() { foreach (InputActionMap suspendedMap in SuspendedMaps) { try { if (suspendedMap != null) { suspendedMap.Enable(); } } catch { } } SuspendedMaps.Clear(); } } internal static class ControlsUi { private sealed class Row { public string LabelKey; public string LabelSuffix; public Slot Keyboard; public Slot Gamepad; public bool IsSection; } private sealed class Cell { public Slot Slot; public Button Button; public TMP_Text Text; public Color NormalColor; public bool Waiting; } private sealed class Screen { public GameObject Root; public ScrollRect Scroll; public List<GameObject> HiddenLayouts = new List<GameObject>(); public Dictionary<IntPtr, RectTransform> RowOfCell = new Dictionary<IntPtr, RectTransform>(); public bool WasActive; } private const string RootName = "KeybindsUnlocked_Root"; private const float CellWidth = 340f; private const float CellHeight = 68f; private const float RowHeight = 80f; private const float ColumnGap = 24f; private const float ScrollbarWidth = 6f; private const float LabelScale = 0.72f; private const float SectionGap = 26f; private static readonly Color Gold = new Color(0.96f, 0.78f, 0.35f); private static readonly List<Cell> Cells = new List<Cell>(); private static readonly List<TMP_Text> Hints = new List<TMP_Text>(); private static readonly Color ConflictColor = new Color(1f, 0.6f, 0.2f); private static readonly List<Screen> Screens = new List<Screen>(); private static IntPtr _lastSelected; private static bool _subscribed; public static void InjectPostfix(SettingsPanel __instance) { try { Inject(__instance); } catch (Exception value) { KeybindsMod.Log.Error($"can't build keybind list: {value}"); } } private static void Inject(SettingsPanel settings) { //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_0820: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_0894: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_091e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0948: Unknown result type (might be due to invalid IL or missing references) //IL_0952: Unknown result type (might be due to invalid IL or missing references) //IL_0989: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0528: 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_0554: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) List<SubPanel> subPanels = settings.subPanels; if (subPanels == null) { return; } Panel val = null; Panel val2 = null; for (int i = 0; i < subPanels.Count; i++) { Panel panel = subPanels[i].Panel; if (!((Object)(object)panel == (Object)null)) { if (((Object)panel).name.StartsWith("Controls")) { val = panel; } if (((Object)panel).name.StartsWith("General")) { val2 = panel; } } } if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)((Component)val).transform.Find("KeybindsUnlocked_Root") != (Object)null) { return; } ClickableButton componentInChildren = ((Component)val2).GetComponentInChildren<ClickableButton>(true); Transform obj = ((Component)val).transform.Find("KeyboardLayout_Panel/Title_Text"); TMP_Text val3 = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null); Transform obj2 = ((Component)val).transform.Find("KeyboardLayout_Panel/Prompts_Panel/Prompt_Panel (2)/Action_Text"); TMP_Text val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null) ?? ((Component)val).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { throw new InvalidOperationException("templates not found"); } Bindings.Tick(); if (!_subscribed) { _subscribed = true; Bindings.Changed += RefreshAll; Strings.OnLanguageChanged(RefreshAll); } Screen screen = new Screen(); for (int j = 0; j < ((Component)val).transform.childCount; j++) { GameObject gameObject = ((Component)((Component)val).transform.GetChild(j)).gameObject; if (((Object)gameObject).name.Contains("Layout_Panel")) { gameObject.SetActive(false); screen.HiddenLayouts.Add(gameObject); } } RectTransform val5 = NewRect("KeybindsUnlocked_Root", ((Component)val).transform); Stretch(val5, new Vector2(100f, 30f), new Vector2(-40f, -50f)); screen.Root = ((Component)val5).gameObject; RectTransform val6 = NewRect("Header", (Transform)(object)val5); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); val6.sizeDelta = new Vector2(0f, 70f); val6.anchoredPosition = Vector2.zero; float num = -22f; ColumnTitle(val3, val6, "kb", num - 364f); ColumnTitle(val3, val6, "gp", num); RectTransform val7 = NewRect("Viewport", (Transform)(object)val5); Stretch(val7, new Vector2(0f, 110f), new Vector2(-22f, -80f)); ((Component)val7).gameObject.AddComponent<RectMask2D>(); ((Graphic)((Component)val7).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.001f); RectTransform val8 = NewRect("Content", (Transform)(object)val7); val8.anchorMin = new Vector2(0f, 1f); val8.anchorMax = new Vector2(1f, 1f); val8.pivot = new Vector2(0.5f, 1f); val8.sizeDelta = Vector2.zero; val8.anchoredPosition = Vector2.zero; VerticalLayoutGroup obj3 = ((Component)val8).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj3).spacing = 4f; ((Component)val8).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; ScrollRect val9 = ((Component)val7).gameObject.AddComponent<ScrollRect>(); val9.content = val8; val9.viewport = val7; val9.horizontal = false; val9.vertical = true; val9.movementType = (MovementType)2; val9.scrollSensitivity = 60f; val9.verticalScrollbar = BuildScrollbar(val5); val9.verticalScrollbarVisibility = (ScrollbarVisibility)1; screen.Scroll = val9; float num2 = (val4.enableAutoSizing ? val4.fontSizeMax : val4.fontSize) * 0.72f; List<(Selectable, Selectable)> list = new List<(Selectable, Selectable)>(); int num3 = 0; bool flag = true; foreach (Row item in Rows()) { RectTransform val10 = NewRect(item.IsSection ? "Section" : "Row", (Transform)(object)val8); float preferredHeight = (item.IsSection ? (80f + (flag ? 0f : 26f)) : 80f); ((Component)val10).gameObject.AddComponent<LayoutElement>().preferredHeight = preferredHeight; TMP_Text component = Object.Instantiate<GameObject>(((Component)val4).gameObject, (Transform)(object)val10).GetComponent<TMP_Text>(); StripLocalization(component); component.enableAutoSizing = false; component.fontSize = num2; component.textWrappingMode = (TextWrappingModes)0; component.overflowMode = (TextOverflowModes)1; RectTransform rectTransform = component.rectTransform; rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.offsetMin = new Vector2(16f, 0f); rectTransform.offsetMax = new Vector2(-728f, 0f); component.alignment = (TextAlignmentOptions)4097; string key = item.LabelKey; string suffix = item.LabelSuffix; Strings.Bind(component, () => Strings.Get(key) + suffix); if (item.IsSection) { component.fontStyle = (FontStyles)(component.fontStyle | 1); component.fontSize = num2 * 1.05f; ((Graphic)component).color = Gold; component.alignment = (TextAlignmentOptions)1025; rectTransform.offsetMin = new Vector2(0f, 14f); rectTransform.offsetMax = Vector2.zero; Image obj4 = ((Component)NewRect("Line", (Transform)(object)val10)).gameObject.AddComponent<Image>(); ((Graphic)obj4).color = new Color(Gold.r, Gold.g, Gold.b, 0.25f); ((Graphic)obj4).raycastTarget = false; RectTransform rectTransform2 = ((Graphic)obj4).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = new Vector2(1f, 0f); rectTransform2.pivot = new Vector2(0.5f, 0f); rectTransform2.sizeDelta = new Vector2(0f, 2f); rectTransform2.anchoredPosition = new Vector2(0f, 4f); num3 = 0; flag = false; } else { if (num3++ % 2 == 1) { Image obj5 = ((Component)val10).gameObject.AddComponent<Image>(); ((Graphic)obj5).color = new Color(1f, 1f, 1f, 0.035f); ((Graphic)obj5).raycastTarget = false; } Selectable val11 = AddCell(componentInChildren, val4, val10, item.Keyboard, -364f, screen); Selectable val12 = AddCell(componentInChildren, val4, val10, item.Gamepad, 0f, screen); if ((Object)(object)val11 != (Object)null) { screen.RowOfCell[((Il2CppObjectBase)((Component)val11).gameObject).Pointer] = val10; } if ((Object)(object)val12 != (Object)null) { screen.RowOfCell[((Il2CppObjectBase)((Component)val12).gameObject).Pointer] = val10; } if ((Object)(object)val11 != (Object)null || (Object)(object)val12 != (Object)null) { list.Add((val11, val12)); } } } RectTransform val13 = NewRect("Footer", (Transform)(object)val5); val13.anchorMin = new Vector2(0f, 0f); val13.anchorMax = new Vector2(1f, 0f); val13.pivot = new Vector2(0.5f, 0f); val13.sizeDelta = new Vector2(0f, 100f); val13.anchoredPosition = Vector2.zero; GameObject obj6 = NewButton(componentInChildren, (Transform)(object)val13, "Reset"); RectTransform component2 = obj6.GetComponent<RectTransform>(); Vector2 val14 = default(Vector2); ((Vector2)(ref val14))..ctor(0f, 0.5f); component2.anchorMax = val14; component2.anchorMin = val14; component2.pivot = new Vector2(0f, 0.5f); component2.sizeDelta = new Vector2(340f, 68f); component2.anchoredPosition = Vector2.zero; Strings.Bind(obj6.GetComponentInChildren<TMP_Text>(true), "reset"); OnClick(obj6, delegate { if (!Bindings.IsRebinding) { Bindings.ResetAll(); } }); Button component3 = obj6.GetComponent<Button>(); TMP_Text component4 = Object.Instantiate<GameObject>(((Component)val4).gameObject, (Transform)(object)val13).GetComponent<TMP_Text>(); StripLocalization(component4); RectTransform rectTransform3 = component4.rectTransform; rectTransform3.anchorMin = new Vector2(0f, 0f); rectTransform3.anchorMax = new Vector2(1f, 1f); rectTransform3.pivot = new Vector2(0f, 0.5f); rectTransform3.offsetMin = new Vector2(364f, 0f); rectTransform3.offsetMax = Vector2.zero; component4.enableAutoSizing = false; component4.fontSize = num2 * 0.8f; ((Graphic)component4).color = new Color(1f, 1f, 1f, 0.6f); component4.alignment = (TextAlignmentOptions)4097; component4.textWrappingMode = (TextWrappingModes)1; Hints.Add(component4); LinkNavigation(list, (Selectable)(object)component3); NavigateablePanel val15 = ((Il2CppObjectBase)val).TryCast<NavigateablePanel>(); if ((Object)(object)val15 != (Object)null && list.Count > 0) { val15.firstSelected = ((Component)(list[0].Item1 ?? list[0].Item2)).gameObject; } Screens.Add(screen); RefreshAll(); } private static IEnumerable<Row> Rows() { yield return Section("game"); (string, string)[] array = new(string, string)[4] { ("move_up", "up"), ("move_down", "down"), ("move_left", "left"), ("move_right", "right") }; for (int i = 0; i < array.Length; i++) { var (labelKey, part) = array[i]; yield return new Row { LabelKey = labelKey, Keyboard = new Slot("Gameplay/Move", gamepad: false, 0, part) }; } yield return new Row { LabelKey = "move", Gamepad = new Slot("Gameplay/Move", gamepad: true) { ControlType = "Vector2" } }; yield return R("pause", "Gameplay/OpenPauseMenu"); yield return R("stats", "Gameplay/ShowStats"); yield return R("tooltips", "Gameplay/ShowTooltips"); yield return R("emote", "Gameplay/ShowRadialMenu"); yield return R("ping", "Gameplay/SmartPing"); array = new(string, string)[4] { ("1", "up"), ("2", "left"), ("3", "right"), ("4", "down") }; for (int i = 0; i < array.Length; i++) { var (text, part2) = array[i]; yield return new Row { LabelKey = "chat", LabelSuffix = " " + text, Keyboard = new Slot("Gameplay/QuickChat", gamepad: false, 1, part2), Gamepad = new Slot("Gameplay/QuickChat", gamepad: true, 0, part2) }; } yield return R("chat_close", "Gameplay/QuickChatCancel"); yield return R("toggle_spells", "KeybindsUnlocked/ToggleSpells"); if (MelonBase.FindMelon("Hold to Die", "Relsev") != null) { yield return R("hold_to_die", "KeybindsUnlocked/HoldToDie"); } yield return Section("menus"); yield return Mirrored(R("next_tab", "UI/NextCategory"), "UI/NextStatCategory"); yield return Mirrored(R("prev_tab", "UI/PreviousCategory"), "UI/PreviousStatCategory"); yield return R("next_page", "UI/NextSubCategory"); yield return R("prev_page", "UI/PreviousSubCategory"); yield return R("ready", "UI/Ready"); yield return R("invite", "UI/Invite"); yield return R("matchmaking", "UI/MatchmakingPreferences"); yield return R("lobby", "UI/LobbyCode"); yield return R("select", "UI/SelectCharacter"); yield return R("lore", "UI/ToggleLoreDisplay"); yield return R("prestige", "UI/Prestige"); yield return R("refund", "UI/SingleUpgradeRefund"); yield return R("options", "UI/Options"); yield return R("report", "UI/Report"); yield return R("continue", "UI/ContinueGameOver"); static Row R(string key, string mapAction, bool kb = true, bool gp = true) { return new Row { LabelKey = key, Keyboard = (kb ? new Slot(mapAction, gamepad: false) : null), Gamepad = (gp ? new Slot(mapAction, gamepad: true) : null) }; } static Row Section(string key) { return new Row { LabelKey = key, IsSection = true }; } } private static Row Mirrored(Row row, string mirror) { row.Keyboard?.Mirrors.Add(new Slot(mirror, gamepad: false)); row.Gamepad?.Mirrors.Add(new Slot(mirror, gamepad: true)); return row; } private static Selectable AddCell(ClickableButton template, TMP_Text label, RectTransform row, Slot slot, float x, Screen screen) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (slot == null || !Bindings.CanRebind(slot)) { TMP_Text component = Object.Instantiate<GameObject>(((Component)label).gameObject, (Transform)(object)row).GetComponent<TMP_Text>(); StripLocalization(component); component.text = "—"; ((Graphic)component).color = new Color(1f, 1f, 1f, 0.25f); component.alignment = (TextAlignmentOptions)514; PlaceCell(component.rectTransform, x); return null; } GameObject val = NewButton(template, (Transform)(object)row, "Cell"); PlaceCell(val.GetComponent<RectTransform>(), x); Cell cell = new Cell { Slot = slot, Button = val.GetComponent<Button>(), Text = val.GetComponentInChildren<TMP_Text>(true) }; cell.NormalColor = ((Graphic)cell.Text).color; cell.Text.enableAutoSizing = true; cell.Text.fontSizeMax = cell.Text.fontSize; cell.Text.fontSizeMin = cell.Text.fontSize * 0.5f; OnClick(val, delegate { MelonCoroutines.Start(StartRebind(cell)); }); Cells.Add(cell); return (Selectable)(object)cell.Button; } private static IEnumerator StartRebind(Cell cell) { if (!Bindings.IsRebinding && !((Object)(object)cell.Button == (Object)null)) { cell.Waiting = true; cell.Text.text = Strings.Get("press"); float until = Time.unscaledTime + 0.2f; while (Time.unscaledTime < until) { yield return null; } Bindings.Rebind(cell.Slot, delegate { cell.Waiting = false; RefreshAll(); }); } } private static void RefreshAll() { //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) Cells.RemoveAll((Cell c) => (Object)(object)c.Button == (Object)null || (Object)(object)c.Text == (Object)null); Dictionary<string, List<(Cell, bool)>> dictionary = new Dictionary<string, List<(Cell, bool)>>(); foreach (Cell cell in Cells) { var (text, item) = Bindings.State(cell.Slot); if (!string.IsNullOrEmpty(text)) { string key = $"{cell.Slot.Map}|{cell.Slot.Gamepad}|{text.ToLowerInvariant()}"; if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List<(Cell, bool)>()); } value.Add((cell, item)); } } HashSet<Cell> hashSet = new HashSet<Cell>(); foreach (List<(Cell, bool)> value2 in dictionary.Values) { if (value2.Count <= 1 || !value2.Exists(((Cell cell, bool overridden) e) => e.overridden)) { continue; } foreach (var item2 in value2) { hashSet.Add(item2.Item1); } } foreach (Cell cell2 in Cells) { if (!cell2.Waiting) { cell2.Text.text = Bindings.Display(cell2.Slot); } ((Graphic)cell2.Text).color = (hashSet.Contains(cell2) ? ConflictColor : cell2.NormalColor); } Hints.RemoveAll((TMP_Text h) => (Object)(object)h == (Object)null); string text2 = Strings.Get("hint"); if (hashSet.Count > 0) { text2 = text2 + "\n<color=#FF9A33>" + Strings.Get("conflict") + "</color>"; } foreach (TMP_Text hint in Hints) { hint.text = text2; } } public static void Tick() { Screens.RemoveAll((Screen s) => (Object)(object)s.Root == (Object)null); foreach (Screen screen in Screens) { bool activeInHierarchy = screen.Root.activeInHierarchy; if (activeInHierarchy && !screen.WasActive) { RefreshAll(); } screen.WasActive = activeInHierarchy; if (!activeInHierarchy) { continue; } foreach (GameObject hiddenLayout in screen.HiddenLayouts) { if ((Object)(object)hiddenLayout != (Object)null && hiddenLayout.activeSelf) { hiddenLayout.SetActive(false); } } } GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null); IntPtr intPtr = (((Object)(object)val != (Object)null) ? ((Il2CppObjectBase)val).Pointer : IntPtr.Zero); if (intPtr == _lastSelected) { return; } _lastSelected = intPtr; if (intPtr == IntPtr.Zero) { return; } foreach (Screen screen2 in Screens) { if (screen2.RowOfCell.TryGetValue(intPtr, out var value)) { ScrollTo(screen2.Scroll, value); } } } private static void ScrollTo(ScrollRect scroll, RectTransform row) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)scroll == (Object)null) && !((Object)(object)row == (Object)null)) { RectTransform content = scroll.content; Rect rect = scroll.viewport.rect; float height = ((Rect)(ref rect)).height; float num = 0f - ((Transform)content).InverseTransformPoint(((Transform)row).position).y; rect = row.rect; float num2 = num - ((Rect)(ref rect)).height * (1f - row.pivot.y); rect = row.rect; float num3 = num2 + ((Rect)(ref rect)).height; float num4 = content.anchoredPosition.y; if (num2 < num4) { num4 = num2 - 10f; } else if (num3 > num4 + height) { num4 = num3 - height + 10f; } float num5 = num4; rect = content.rect; num4 = Mathf.Clamp(num5, 0f, Mathf.Max(0f, ((Rect)(ref rect)).height - height)); content.anchoredPosition = new Vector2(content.anchoredPosition.x, num4); } } private static void LinkNavigation(List<(Selectable kb, Selectable gp)> grid, Selectable reset) { for (int i = 0; i < grid.Count; i++) { var (val, val2) = grid[i]; if ((Object)(object)val != (Object)null) { SetNav(val, Find(i - 1, -1, gamepadColumn: false), Find(i + 1, 1, gamepadColumn: false) ?? reset, null, val2); } if ((Object)(object)val2 != (Object)null) { SetNav(val2, Find(i - 1, -1, gamepadColumn: true), Find(i + 1, 1, gamepadColumn: true) ?? reset, val, null); } } if ((Object)(object)reset != (Object)null && grid.Count > 0) { List<(Selectable kb, Selectable gp)> list = grid; Selectable obj = list[list.Count - 1].kb; if (obj == null) { List<(Selectable kb, Selectable gp)> list2 = grid; obj = list2[list2.Count - 1].gp; } SetNav(reset, obj, null, null, null); } Selectable Find(int from, int step, bool gamepadColumn) { for (int j = from; j >= 0 && j < grid.Count; j += step) { Selectable val3 = (gamepadColumn ? grid[j].gp : grid[j].kb); if ((Object)(object)val3 != (Object)null) { return val3; } Selectable val4 = (gamepadColumn ? grid[j].kb : grid[j].gp); if ((Object)(object)val4 != (Object)null) { return val4; } } return null; } } private static void SetNav(Selectable s, Selectable up, Selectable down, Selectable left, Selectable right) { Navigation navigation = s.navigation; navigation.mode = (Mode)4; navigation.selectOnUp = up; navigation.selectOnDown = down; navigation.selectOnLeft = left; navigation.selectOnRight = right; s.navigation = navigation; } private static GameObject NewButton(ClickableButton template, Transform parent, string name) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent); ((Object)val).name = name; Button component = val.GetComponent<Button>(); for (int i = 0; i < ((UnityEventBase)component.onClick).GetPersistentEventCount(); i++) { ((UnityEventBase)component.onClick).SetPersistentListenerState(i, (UnityEventCallState)0); } foreach (TMP_Text componentsInChild in val.GetComponentsInChildren<TMP_Text>(true)) { StripLocalization(componentsInChild); } foreach (Image componentsInChild2 in val.GetComponentsInChildren<Image>(true)) { Color color = ((Graphic)componentsInChild2).color; ((Graphic)componentsInChild2).color = new Color(1f, 1f, 1f, color.a); } return val; } private static void OnClick(GameObject button, Action action) { ((ButtonInteractionHook)button.GetComponent<ClickableButton>()).OnClicked += Action.op_Implicit((Action)delegate { try { action(); } catch (Exception ex) { KeybindsMod.Log.Error(ex.ToString()); } }); } private static Scrollbar BuildScrollbar(RectTransform root) { //IL_0017: 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_0041: 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_0094: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRect("Scrollbar", (Transform)(object)root); val.anchorMin = new Vector2(1f, 0f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(1f, 0.5f); val.offsetMin = new Vector2(-6f, 110f); val.offsetMax = new Vector2(0f, -80f); ((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0.05f); RectTransform val2 = NewRect("Sliding Area", (Transform)(object)val); Stretch(val2, Vector2.zero, Vector2.zero); RectTransform val3 = NewRect("Handle", (Transform)(object)val2); Stretch(val3, Vector2.zero, Vector2.zero); Image val4 = ((Component)val3).gameObject.AddComponent<Image>(); ((Graphic)val4).color = Color.white; Scrollbar obj = ((Component)val).gameObject.AddComponent<Scrollbar>(); obj.handleRect = val3; ((Selectable)obj).targetGraphic = (Graphic)(object)val4; obj.direction = (Direction)2; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.3f); ((ColorBlock)(ref colors)).highlightedColor = Gold; ((ColorBlock)(ref colors)).pressedColor = Gold; ((ColorBlock)(ref colors)).selectedColor = new Color(1f, 1f, 1f, 0.3f); ((Selectable)obj).colors = colors; Navigation navigation = ((Selectable)obj).navigation; navigation.mode = (Mode)0; ((Selectable)obj).navigation = navigation; return obj; } private static void PlaceCell(RectTransform rect, float x) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0050: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(1f, 0.5f); rect.anchorMax = val; rect.anchorMin = val; rect.pivot = new Vector2(1f, 0.5f); rect.sizeDelta = new Vector2(340f, 68f); rect.anchoredPosition = new Vector2(x, 0f); } private static void ColumnTitle(TMP_Text template, RectTransform header, string key, float x) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) TMP_Text component = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)header).GetComponent<TMP_Text>(); StripLocalization(component); component.fontSize *= 0.6f; component.alignment = (TextAlignmentOptions)514; component.textWrappingMode = (TextWrappingModes)0; component.enableAutoSizing = true; component.fontSizeMax = component.fontSize; component.fontSizeMin = component.fontSize * 0.5f; RectTransform rectTransform = component.rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(1f, 0.5f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(1f, 0.5f); rectTransform.sizeDelta = new Vector2(340f, 70f); rectTransform.anchoredPosition = new Vector2(x, 0f); Strings.Bind(component, key); } private static void StripLocalization(TMP_Text text) { foreach (LocalizeStringEvent component in ((Component)text).GetComponents<LocalizeStringEvent>()) { Object.DestroyImmediate((Object)(object)component); } } private static RectTransform NewRect(string name, Transform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent(parent, false); return obj; } private static void Stretch(RectTransform rect, Vector2 offsetMin, Vector2 offsetMax) { //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_0021: 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_0033: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.pivot = new Vector2(0.5f, 0.5f); rect.offsetMin = offsetMin; rect.offsetMax = offsetMax; } } internal static class MenuPage { [MethodImpl(MethodImplOptions.NoInlining)] public static void Register() { Menu.AddPage("KeybindsUnlocked", "Keybinds Unlocked").Button((Func<string>)(() => Strings.Get("reset")), (Action)delegate { if (!Bindings.IsRebinding) { Bindings.ResetAll(); } }, (ButtonLayout)2); } } public class KeybindsMod : MelonMod { public static Instance Log; public override void OnInitializeMelon() { Log = ((MelonBase)this).LoggerInstance; Bindings.Init(); Bindings.Changed += Prompts.RefreshAll; Bindings.Applied += Prompts.RefreshAll; bool flag = Hooks.Patch(((MelonBase)this).HarmonyInstance, Log, typeof(SettingsPanel), "SetupSubPanels", typeof(ControlsUi), null, "InjectPostfix"); bool flag2 = Hooks.Patch(((MelonBase)this).HarmonyInstance, Log, typeof(ButtonPromptUpdater), "UpdateIcon", typeof(Prompts), null, "UpdateIconPostfix"); if (flag && flag2) { Log.Msg("ready — Options → Controls"); } else { Log.Warning("partially loaded: key list " + (flag ? "ok" : "unavailable") + ", on-screen key icons " + (flag2 ? "ok" : "unavailable")); } if (MelonBase.FindMelon("Mod Menu", "Relsev") != null) { try { MenuPage.Register(); } catch (Exception ex) { Log.Warning("Mod Menu page: " + ex.Message); } } } public override void OnUpdate() { WheelSelect.Tick(); try { Bindings.Tick(); ControlsUi.Tick(); Prompts.Tick(); if (Bindings.ToggleSpellsPressed()) { object data = AppDomain.CurrentDomain.GetData("SpellBrigade.Typing"); if (!(data is bool) || !(bool)data) { SpellVisibility.Toggle(); } } } catch (Exception ex) { Log.Error(ex.ToString()); } } } internal static class Prompts { private const string LabelName = "KeybindsUnlocked_Label"; private static readonly Dictionary<IntPtr, InputDeviceType> LastDevice = new Dictionary<IntPtr, InputDeviceType>(); private static Dictionary<string, List<Sprite>> _sprites; private static float _spritesBuiltAt = -100f; private static Sprite _keycap; private static readonly List<TMP_Text> Unstyled = new List<TMP_Text>(); private static readonly List<(TMP_Text Text, ContentSizeFitter Fitter)> PromptTexts = new List<(TMP_Text, ContentSizeFitter)>(); private static float _nextPromptScan; private static float _nextWidthCheck; private static readonly HashSet<IntPtr> Reported = new HashSet<IntPtr>(); private static Sprite _blank; private static Rect _inner = new Rect(0.11f, 0.11f, 0.78f, 0.78f); public static void UpdateIconPostfix(ButtonPromptUpdater __instance, InputDeviceType inputDeviceType) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_00d6: Unknown result type (might be due to invalid IL or missing references) try { LastDevice[((Il2CppObjectBase)__instance).Pointer] = inputDeviceType; Image image = __instance.image; if ((Object)(object)image == (Object)null || (Object)(object)__instance.configuration == (Object)null) { return; } InputAction inputAction = __instance.configuration.GetInputAction(__instance.actionType); if (inputAction == null || inputAction.actionMap == null) { SetLabel(image, null); return; } bool gamepad = (int)inputDeviceType > 0; int num = Bindings.Resolve(new Slot(inputAction.actionMap.name + "/" + inputAction.name, gamepad)); if (num < 0) { SetLabel(image, null); return; } InputBinding val = inputAction.bindings[num]; string overridePath = val.overridePath; if (string.IsNullOrEmpty(overridePath) || overridePath == val.path) { SetLabel(image, null); return; } Sprite val2 = FindSprite(overridePath, inputDeviceType, image.sprite); if ((Object)(object)val2 != (Object)null) { image.sprite = val2; SetLabel(image, null); } else { image.sprite = BlankKeycap(); SetLabel(image, Bindings.KeyName(inputAction, num, gamepad)); } } catch (Exception ex) { KeybindsMod.Log.Warning("prompt icon: " + ex.Message); } } public static void RefreshAll() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0045: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) InputDeviceType val = (InputDeviceType)0; try { UINavigator instance = SingletonPersistent<UINavigator>.Instance; if ((Object)(object)instance != (Object)null) { val = instance.CurrentInputDeviceType; } } catch { } foreach (ButtonPromptUpdater item in Resources.FindObjectsOfTypeAll<ButtonPromptUpdater>()) { if ((Object)(object)item == (Object)null) { continue; } Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).name != null) { InputDeviceType value; InputDeviceType val2 = (LastDevice.TryGetValue(((Il2CppObjectBase)item).Pointer, out value) ? value : val); try { item.UpdateIcon(val2); } catch { } } } } private static void EnsureSprites() { if (_sprites != null && Time.unscaledTime - _spritesBuiltAt <= 5f) { return; } _sprites = new Dictionary<string, List<Sprite>>(); foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>()) { if ((Object)(object)item != (Object)null && ((Object)item).name.StartsWith("key_", StringComparison.OrdinalIgnoreCase)) { string key = ((Object)item).name.ToLowerInvariant(); if (!_sprites.TryGetValue(key, out var value)) { value = (_sprites[key] = new List<Sprite>()); } value.Add(item); } } _spritesBuiltAt = Time.unscaledTime; } private static Sprite FindSprite(string path, InputDeviceType device, Sprite reference) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) EnsureSprites(); foreach (string item in Candidates(path, device)) { if (_sprites.TryGetValue(item.ToLowerInvariant(), out var value)) { Sprite val = BestMatch(value, reference); if ((Object)(object)val != (Object)null) { return val; } } } foreach (SpriteAtlas item2 in Resources.FindObjectsOfTypeAll<SpriteAtlas>()) { if ((Object)(object)item2 == (Object)null) { continue; } foreach (string item3 in Candidates(path, device)) { Sprite val2 = null; try { val2 = item2.GetSprite(item3); } catch { } if (!((Object)(object)val2 == (Object)null)) { ((Object)val2).hideFlags = (HideFlags)32; _sprites[item3.ToLowerInvariant()] = new List<Sprite> { val2 }; return val2; } } } return null; } private static Sprite BestMatch(List<Sprite> list, Sprite reference) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) list.RemoveAll((Sprite s) => (Object)(object)s == (Object)null); if (list.Count == 0) { return null; } if ((Object)(object)reference != (Object)null) { foreach (Sprite item in list) { if ((Object)(object)item.texture == (Object)(object)reference.texture) { return item; } } foreach (Sprite item2 in list) { Rect rect = item2.rect; float width = ((Rect)(ref rect)).width; rect = reference.rect; if (!(Mathf.Abs(width - ((Rect)(ref rect)).width) < 1f)) { continue; } rect = item2.rect; float height = ((Rect)(ref rect)).height; rect = reference.rect; if (Mathf.Abs(height - ((Rect)(ref rect)).height) < 1f) { Vector2 val = item2.pivot - reference.pivot; if (((Vector2)(ref val)).sqrMagnitude < 1f) { return item2; } } } } return list[0]; } private static IEnumerable<string> Candidates(string path, InputDeviceType device) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) int num = path.IndexOf('/'); if (num < 0) { yield break; } string text = path.Substring(0, num).Trim('<', '>').ToLowerInvariant(); string text2 = path.Substring(num + 1).ToLowerInvariant(); if (text == "keyboard") { string text3; switch (text2) { case "leftshift": case "shift": case "rightshift": text3 = "shift"; break; case "rightctrl": case "leftctrl": case "ctrl": text3 = "ctrl"; break; case "rightalt": case "leftalt": case "alt": text3 = "alt"; break; case "escape": text3 = "esc"; break; case "enter": case "numpadenter": text3 = "enter"; break; default: text3 = text2; break; } string text4 = text3; yield return "key_pc_" + text4; } else if (text == "mouse") { yield return "key_pc_" + text2 switch { "leftbutton" => "mouse1", "rightbutto