Decompiled source of FATE Rebind v0.1.13
BepInEx/plugins/FateRebind/ZombieGhost.Rebind.dll
Decompiled 15 hours 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Xml; using System.Xml.Linq; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ZombieGhost.Rebind")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.13.0")] [assembly: AssemblyInformationalVersion("0.1.13")] [assembly: AssemblyProduct("ZombieGhost.Rebind")] [assembly: AssemblyTitle("ZombieGhost.Rebind")] [assembly: AssemblyVersion("0.1.13.0")] [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 ZombieGhost.Rebind { internal static class BindingPresentation { private static readonly Dictionary<string, string> Names = new Dictionary<string, string>(StringComparer.Ordinal) { ["Fire1"] = "Attack / interact", ["Fire2"] = "Cast spell", ["RightClick"] = "Secondary click", ["Interact"] = "Interact", ["Rage"] = "Activate rage", ["CycleWeapon"] = "Switch weapon", ["Stationary"] = "Stand still", ["Map"] = "Toggle map", ["HotbarOne"] = "Hotbar 1", ["HotbarTwo"] = "Hotbar 2", ["HotbarThree"] = "Hotbar 3", ["HotbarFour"] = "Hotbar 4", ["ToggleRun"] = "Toggle running", ["ToggleItems"] = "Show item labels", ["SpellWheel"] = "Open spell wheel", ["PetAndAllyFocus"] = "Focus pet / ally", ["CameraZoom"] = "Camera zoom", ["CameraRotate"] = "Camera rotation", ["Cancel"] = "Back / cancel", ["ScrollWheel"] = "Scroll", ["Click"] = "Confirm click", ["RightToggle"] = "Next tab", ["LeftToggle"] = "Previous tab", ["Navigate"] = "Menu navigation", ["Submit"] = "Confirm selection", ["Point"] = "Pointer position", ["Look"] = "Aim / pointer", ["SortInventory"] = "Sort inventory", ["QuickMoveItems"] = "Quick move / sell items", ["LockItems"] = "Lock items", ["AltInteract"] = "Alternate interaction", ["Skills"] = "Stats & skills", ["Spellbook"] = "Spellbook", ["Quest"] = "Quest journal", ["Inventory"] = "Inventory", ["Menu"] = "Pause menu", ["Move"] = "Movement" }; internal static bool IsMouseKeyboardPath(string path) { if (!string.IsNullOrEmpty(path) && !path.StartsWith("<Keyboard>/", StringComparison.OrdinalIgnoreCase)) { return path.StartsWith("<Mouse>/", StringComparison.OrdinalIgnoreCase); } return true; } internal static string Pretty(string value) { return Regex.Replace(value ?? "", "([a-z])([A-Z])", "$1 $2"); } internal static string Name(string action, string part, bool native, string label) { if (!native) { return Pretty(label) + (string.IsNullOrEmpty(part) ? "" : (" / " + Pretty(part))); } if (action == "CameraRotate" && (part == "negative" || part == "positive")) { if (!(part == "negative")) { return "Camera right"; } return "Camera left"; } if (action == "CameraZoom" && (part == "negative" || part == "positive")) { if (!(part == "negative")) { return "Zoom in"; } return "Zoom out"; } if ((action == "Move" || action == "Navigate") && !string.IsNullOrEmpty(part)) { return ((action == "Move") ? "Move " : "Navigate ") + part; } if (action.StartsWith("SpellSlot", StringComparison.Ordinal)) { return "Select spell " + action.Substring(9); } string value; return (Names.TryGetValue(action, out value) ? value : Pretty(action)) + (string.IsNullOrEmpty(part) ? "" : (" / " + Pretty(part))); } internal static string Category(string action, string map, bool native, string category) { if (!native) { if (!string.IsNullOrWhiteSpace(category)) { return Pretty(category); } return "Mod controls"; } if (!action.StartsWith("Camera", StringComparison.Ordinal)) { switch (action) { case "Look": break; case "Move": case "Stationary": case "ToggleRun": return "Movement"; case "PetAndAllyFocus": return "Party & pet"; default: if (!action.StartsWith("Fire", StringComparison.Ordinal) && !action.StartsWith("SpellSlot", StringComparison.Ordinal)) { switch (action) { case "Rage": case "SpellWheel": case "CycleWeapon": break; default: if (!action.StartsWith("Hotbar", StringComparison.Ordinal)) { switch (action) { case "ToggleItems": case "SortInventory": case "QuickMoveItems": case "LockItems": case "Interact": case "AltInteract": break; default: return "Menus & interface"; } } return "Items & interaction"; } } return "Combat & spells"; } } return "Camera"; } } public sealed class BindingStore { private readonly Dictionary<string, string> values = new Dictionary<string, string>(StringComparer.Ordinal); private readonly string file; public int Count => values.Count; public BindingStore(string file) { this.file = file; } public bool TryGet(string key, out string path) { return values.TryGetValue(key, out path); } public void Set(string key, string path) { if (string.IsNullOrEmpty(key) || key.Length > 600 || path == null || path.Length > 512 || (!values.ContainsKey(key) && values.Count >= 4096)) { throw new ArgumentException("Invalid binding entry"); } values[key] = path; } public void Remove(string key) { values.Remove(key); } public void Load() { if (!File.Exists(file)) { return; } using XmlReader reader = XmlReader.Create(file, new XmlReaderSettings { DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null, MaxCharactersInDocument = 2000000L }); XDocument xDocument = XDocument.Load(reader); if (xDocument.Root?.Name != "FateRebind" || (string?)xDocument.Root.Attribute("version") != "1") { throw new InvalidDataException("Unsupported rebind settings format"); } Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); foreach (XElement item in xDocument.Root.Elements("Binding")) { string text = (string?)item.Attribute("key"); string text2 = (string?)item.Attribute("path"); if (string.IsNullOrEmpty(text) || text.Length > 600 || text2 == null || text2.Length > 512 || dictionary.Count >= 4096 || dictionary.ContainsKey(text)) { throw new InvalidDataException("Invalid rebind settings entry"); } dictionary[text] = text2; } values.Clear(); foreach (KeyValuePair<string, string> item2 in dictionary) { values[item2.Key] = item2.Value; } } public void Save() { Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(file))); XElement xElement = new XElement("FateRebind", new XAttribute("version", "1"), from p in values.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> p) => p.Key, StringComparer.Ordinal) select new XElement("Binding", new XAttribute("key", p.Key), new XAttribute("path", p.Value))); string text = file + ".tmp"; new XDocument(xElement).Save(text); if (File.Exists(file)) { File.Replace(text, file, file + ".bak"); } else { File.Move(text, file); } } } public static class BindingIdentity { public static string Key(string provider, string action, string binding) { return provider + "|" + action + "|" + binding; } public static bool Overlaps(string ownerA, string mapA, string ownerB, string mapB) { if (!(ownerA != "game") && !(ownerB != "game") && !(mapA == mapB) && !(mapA == "Persistent") && !(mapB == "Persistent") && !string.IsNullOrEmpty(mapA)) { return string.IsNullOrEmpty(mapB); } return true; } public static bool SameControl(string a, string b) { if (!string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b)) { return string.Equals(a, b, StringComparison.OrdinalIgnoreCase); } return false; } public static string StableToken(string text) { using SHA256 sHA = SHA256.Create(); return BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(text))).Replace("-", "").ToLowerInvariant(); } } internal static class ControllerBindingRules { internal const string SwapKey = "settings.controller.swap-sticks"; internal const string ProviderId = "ControllerProvider"; internal const string CategoryId = "ControllerCategory"; internal static bool NativeButtonAction(string map, string action) { if (VanillaBindingPolicy.Allows(map, action) && action != "CameraRotate") { return action != "CameraZoom"; } return false; } internal static string IconField(string path) { if (!EditorInputPolicy.GamepadPath(path)) { return null; } string text = path.Substring(path.IndexOf('/') + 1); switch (text) { case "{Submit}": return "buttonSouth"; case "{Cancel}": return "buttonEast"; case "start": return "startButton"; case "select": return "selectButton"; case "dpad/up": return "dpadUp"; case "dpad/down": return "dpadDown"; case "dpad/left": return "dpadLeft"; case "dpad/right": return "dpadRight"; default: if (text.IndexOf('/') >= 0) { return null; } return text; } } internal static bool DirectChildId(string id) { if (!string.IsNullOrEmpty(id)) { return id.IndexOf('/') < 0; } return false; } internal static bool ButtonPath(string path) { if (!EditorInputPolicy.GamepadPath(path)) { return false; } int num = path.IndexOf('/'); switch (path.Substring(num + 1)) { case "buttonNorth": case "buttonSouth": case "leftTrigger": case "buttonEast": case "buttonWest": case "dpad/right": case "{Cancel}": case "{Submit}": case "leftShoulder": case "rightTrigger": case "dpad/down": case "dpad/left": case "rightShoulder": case "leftStickPress": case "rightStickPress": case "select": case "start": case "dpad/up": return true; default: return false; } } internal static bool StickAxis(string path) { if (EditorInputPolicy.GamepadPath(path)) { return StickPath(path, swap: true) != path; } return false; } internal static string StickPath(string path, bool swap) { if (!swap || !EditorInputPolicy.GamepadPath(path)) { return path; } int num = path.IndexOf('/'); string text = path.Substring(0, num + 1); string text2 = path.Substring(num + 1); if (text2 == "leftStick" || text2.StartsWith("leftStick/", StringComparison.Ordinal)) { return text + "rightStick" + text2.Substring(9); } if (text2 == "rightStick" || text2.StartsWith("rightStick/", StringComparison.Ordinal)) { return text + "leftStick" + text2.Substring(10); } return path; } } [BepInPlugin("zombieghost.rebind", "FATE Rebind", "0.1.13")] public sealed class RebindPlugin : BaseUnityPlugin { private sealed class ControllerRowView { internal GameObject Marker; internal Outline Primary; internal Outline Secondary; internal Toggle Toggle; } private sealed class BindingRow { internal string Label; internal string Category; internal string Owner; internal string OwnerName; internal BindingSlot[] Inputs; internal bool StickSwap; } private sealed class BindingSlot { internal RegisteredAction Entry; internal int Index; internal string Key; internal string Label; internal string Map; internal string Original; internal string Group; internal string Category; internal bool ReadOnly; internal InputAction Action => Entry.Action; internal string Path { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) InputBinding val = Action.bindings[Index]; return ((InputBinding)(ref val)).effectivePath; } } } private bool controllerMode; private string controllerSignature; private int controllerIndex; private int controllerColumn; private int controllerDialog; private int focusDrawIndex = -1; private int focusDrawColumn = -1; private int focusDrawDialog = -1; private int detectionFrame = -1; private int navDirection; private int swapAxisDirection; private float inputGuardUntil; private float nextNavAt; private float cancelHold; private Vector2 previousLeft; private Vector2 previousRight; private BindingRow[] controllerRows = Array.Empty<BindingRow>(); private readonly List<ControllerRowView> controllerViews = new List<ControllerRowView>(); private readonly List<RectTransform> controllerRects = new List<RectTransform>(); private readonly List<Button> controllerDialogButtons = new List<Button>(); private readonly Dictionary<string, Sprite> padIcons = new Dictionary<string, Sprite>(); private Object gamepadIconSet; private GameObject nativeRoot; private string nativeSignature; private static readonly Color Gold = new Color(0.92f, 0.72f, 0.38f); private static readonly Color Panel = new Color(0.1f, 0.075f, 0.055f, 0.99f); private TextMeshProUGUI nativeFont; private Button nativeButton; private Button nativeFancyButton; private RebindingOperation operation; private BindingSlot captureSlot; private BindingSlot candidate; private string candidatePath; private float captureAt; private string search = ""; private static RebindPlugin instance; private BindingStore store; private readonly Dictionary<InputAction, RegisteredAction> tracked = new Dictionary<InputAction, RegisteredAction>(); private readonly Dictionary<InputAction, Dictionary<string, string>> baselines = new Dictionary<InputAction, Dictionary<string, string>>(); private readonly HashSet<InputAction> suspended = new HashSet<InputAction>(); private readonly List<BindingSlot> slots = new List<BindingSlot>(); private bool open; private bool changing; private bool suspending; private float cancelHandledUntil; private float nextDiscover; private float releaseAt; private Harmony harmony; private string status = "Click a binding to change it. Changes save automatically."; private static bool quitting; private Component controlsScreen; private Component settingsTabs; private readonly HashSet<int> reportedUiErrors = new HashSet<int>(); private readonly Dictionary<GameObject, GameObject> installedScreens = new Dictionary<GameObject, GameObject>(); private readonly Dictionary<Graphic, bool> referenceGraphics = new Dictionary<Graphic, bool>(); private bool swapControllerSticks; private Transform ControllerSurface => nativeRoot.transform.Find("ControllerSurface"); private Transform KeyboardSurface => nativeRoot.transform.Find("MouseKeyboardSurface"); public static bool BlocksInput { get { if (instance != null) { if (!instance.open) { return Time.unscaledTime < instance.releaseAt; } return true; } return false; } } private bool NativeEditorActive { get { if ((Object)(object)nativeRoot != (Object)null && (Object)(object)controlsScreen != (Object)null) { return controlsScreen.gameObject.activeInHierarchy; } return false; } } private bool IsControllerSlot(BindingSlot slot) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 if (!slot.ReadOnly && slot.Group == "Controller") { if (!ControllerBindingRules.ButtonPath(slot.Original)) { if (string.IsNullOrEmpty(slot.Original)) { if (!(slot.Entry.Owner == "game")) { return (int)slot.Action.type == 1; } return ControllerBindingRules.NativeButtonAction(slot.Map, slot.Action.name); } return false; } return true; } return false; } private BindingSlot[] ControllerSlots() { return slots.Where(IsControllerSlot).ToArray(); } private void InstallControllerInput() { InputSystem.onAfterUpdate += TickInputMode; } private void TickInputMode() { //IL_0054: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if (detectionFrame == Time.frameCount) { return; } detectionFrame = Time.frameCount; Gamepad current = Gamepad.current; Mouse current2 = Mouse.current; Keyboard current3 = Keyboard.current; if (controllerMode && current == null) { CancelCapture(); SetControllerMode(value: false); return; } Vector2 val = ((current != null) ? ((InputControl<Vector2>)(object)current.leftStick).ReadValue() : Vector2.zero); Vector2 val2 = ((current != null) ? ((InputControl<Vector2>)(object)current.rightStick).ReadValue() : Vector2.zero); Vector2 val3; int num; if (current != null) { if (((IEnumerable)(object)((InputDevice)current).allControls).OfType<ButtonControl>().Any((ButtonControl button) => button.wasPressedThisFrame)) { goto IL_0107; } if (((Vector2)(ref val)).magnitude > 0.55f) { val3 = val - previousLeft; if (((Vector2)(ref val3)).magnitude > 0.25f) { goto IL_0107; } } if (((Vector2)(ref val2)).magnitude > 0.55f) { val3 = val2 - previousRight; num = ((((Vector2)(ref val3)).magnitude > 0.25f) ? 1 : 0); } else { num = 0; } } else { num = 0; } goto IL_010b; IL_010b: bool flag = (byte)num != 0; previousLeft = val; previousRight = val2; if (operation != null || captureAt > 0f || candidate != null) { return; } int num2; if (current2 != null) { if (!current2.leftButton.wasPressedThisFrame && !current2.rightButton.wasPressedThisFrame && !current2.middleButton.wasPressedThisFrame) { val3 = ((InputControl<Vector2>)(object)current2.scroll).ReadValue(); if (!(((Vector2)(ref val3)).sqrMagnitude > 0f)) { val3 = ((InputControl<Vector2>)(object)((Pointer)current2).delta).ReadValue(); num2 = ((((Vector2)(ref val3)).sqrMagnitude > 36f) ? 1 : 0); goto IL_01a0; } } num2 = 1; } else { num2 = 0; } goto IL_01a0; IL_01a0: bool flag2 = (byte)num2 != 0; bool flag3 = current3 != null && ((ButtonControl)current3.anyKey).wasPressedThisFrame; if (flag) { SetControllerMode(value: true); } else if (flag2 || flag3) { SetControllerMode(value: false); } return; IL_0107: num = 1; goto IL_010b; } private void SetControllerMode(bool value) { if (controllerMode == value) { return; } controllerMode = value; controllerIndex = (controllerColumn = (controllerDialog = 0)); navDirection = (swapAxisDirection = 0); controllerSignature = (nativeSignature = null); inputGuardUntil = Time.unscaledTime + 0.18f; ((BaseUnityPlugin)this).Logger.LogInfo((object)("REBIND_INPUT_MODE: " + (value ? "controller" : "keyboard/mouse"))); if (open && value) { EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject((GameObject)null); } } if (!open) { return; } RestoreActions(); foreach (InputAction item in InputSystem.ListEnabledActions()) { Suspend(item); } ApplyInputSurface(); } private void ApplyInputSurface() { if (!((Object)(object)nativeRoot == (Object)null)) { ((Component)KeyboardSurface).gameObject.SetActive(!controllerMode); ((Component)ControllerSurface).gameObject.SetActive(controllerMode); } } private void BuildControllerSurface(Transform parent) { RectTransform parent2 = Box(parent, "ControllerSurface", 0f, 0f, 1f, 1f); Caption((Transform)(object)parent2, "FATE REBIND — CONTROLLER", 0.02f, 0.92f, 0.98f, 0.99f, 24); Caption((Transform)(object)parent2, "Action", 0.03f, 0.86f, 0.39f, 0.91f, 16); Caption((Transform)(object)parent2, "Primary", 0.43f, 0.86f, 0.61f, 0.91f, 16); Caption((Transform)(object)parent2, "Secondary", 0.68f, 0.86f, 0.86f, 0.91f, 16); CreateScrollList((Transform)(object)parent2, "Actions", 0.02f, 0.2f, 0.98f, 0.86f); ((Object)Caption((Transform)(object)parent2, "", 0.02f, 0.11f, 0.98f, 0.18f, 16)).name = "Controller status"; Box((Transform)(object)parent2, "Dialog", 0.02f, 0.11f, 0.98f, 0.18f); RectTransform parent3 = Box((Transform)(object)parent2, "Hints", 0.02f, 0.015f, 0.98f, 0.09f); ControllerHints((Transform)(object)parent3); } private void RefreshControllerEditor(bool force = false) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_036b: 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_06a9: 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_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) BindingSlot[] source = ControllerSlots(); bool flag = (Object)(object)GamepadIcon("<Gamepad>/buttonSouth") != (Object)null; string text = flag + "|" + swapControllerSticks + "|" + status + "|" + captureSlot?.Key + "|" + candidate?.Key + "|" + string.Join(";", source.Select((BindingSlot s) => s.Key + ":" + s.Path)); if (!force && text == controllerSignature) { UpdateControllerFocus(scrollTo: false); return; } controllerSignature = text; ScrollRect component = ((Component)ControllerSurface.Find("Actions")).GetComponent<ScrollRect>(); float y = component.content.anchoredPosition.y; RectTransform content = component.content; ClearChildren((Transform)(object)content); controllerViews.Clear(); controllerRects.Clear(); controllerRows = VisibleRows(); controllerIndex = Mathf.Clamp(controllerIndex, 0, Math.Max(0, controllerRows.Length - 1)); float num = 0f; string text2 = null; for (int num2 = 0; num2 < controllerRows.Length; num2++) { BindingRow entry = controllerRows[num2]; int index = num2; string text3 = ((entry.Owner != "game" && !entry.StickSwap) ? (entry.OwnerName + " / ") : "") + entry.Category; if (text3 != text2) { if (text2 != null) { num += 18f; } RectTransform parent = PixelRow((Transform)(object)content, "Controller section", num, 40f); ((TMP_Text)Caption((Transform)(object)parent, text3, 0.015f, 0f, 0.99f, 1f, 24)).fontStyle = (FontStyles)1; ((Graphic)((Component)Box((Transform)(object)parent, "Divider", 0.015f, 0f, 0.99f, 0.025f, (Color?)new Color(0.68f, 0.49f, 0.24f, 0.6f))).GetComponent<Image>()).raycastTarget = false; num += 48f; text2 = text3; } RectTransform val = PixelRow((Transform)(object)content, "Controller action", num, 55f); num += 62f; controllerRects.Add(val); ControllerRowView controllerRowView = new ControllerRowView(); controllerViews.Add(controllerRowView); RectTransform val2 = Box((Transform)(object)val, "Controller focus", 0f, 0.1f, 0.008f, 0.9f, Gold); ((Graphic)((Component)val2).GetComponent<Image>()).raycastTarget = false; controllerRowView.Marker = ((Component)val2).gameObject; ((Graphic)Caption((Transform)(object)val, entry.Label, 0.025f, 0f, 0.37f, 1f, 18)).color = new Color(0.91f, 0.87f, 0.79f); if (entry.StickSwap) { controllerRowView.Toggle = ControllerCheckbox((Transform)(object)val); continue; } for (int num3 = 0; num3 < 2; num3++) { int slotIndex = num3; BindingSlot bindingSlot = entry.Inputs.ElementAtOrDefault(num3); float left = ((num3 == 0) ? 0.4f : 0.66f); float right = ((num3 == 0) ? 0.62f : 0.88f); Button val3 = Control((Transform)(object)val, "", left, 0.06f, right, 0.94f, delegate { if (!(Time.unscaledTime < inputGuardUntil) && operation == null && !(captureAt > 0f) && candidate == null) { controllerIndex = index; controllerColumn = slotIndex; QueueControllerBinding(); } }, ornate: true); ((Selectable)val3).interactable = bindingSlot != null; FillGamepadCell(val3, bindingSlot); if (num3 == 0) { controllerRowView.Primary = ((Component)val3).GetComponentInChildren<Outline>(); } else { controllerRowView.Secondary = ((Component)val3).GetComponentInChildren<Outline>(); } } ((Selectable)Control((Transform)(object)val, "Reset", 0.9f, 0.12f, 1f, 0.88f, delegate { BindingSlot[] inputs = entry.Inputs; foreach (BindingSlot slot in inputs) { Change(slot, null, reset: true); } })).interactable = operation == null && captureAt == 0f && candidate == null; } content.sizeDelta = new Vector2(0f, Mathf.Max(70f, num)); Transform parent2 = ControllerSurface.Find("Dialog"); ClearChildren(parent2); controllerDialogButtons.Clear(); if (candidate != null) { controllerDialogButtons.Add(Control(parent2, "Keep both", 0f, 0f, 0.32f, 1f, delegate { Change(candidate, candidatePath); candidate = null; })); BindingSlot[] array = Conflicts(candidate, candidatePath); Button val4 = Control(parent2, "Swap", 0.34f, 0f, 0.66f, 1f, delegate { BindingSlot[] array2 = Conflicts(candidate, candidatePath); if (array2.Length == 1) { SwapBindings(candidate, array2[0], candidatePath, candidate.Path); } candidate = null; }); ((Selectable)val4).interactable = array.Length == 1 && !array[0].ReadOnly; controllerDialogButtons.Add(val4); controllerDialogButtons.Add(Control(parent2, "Cancel", 0.68f, 0f, 1f, 1f, delegate { CancelCapture(); status = "Previous binding kept."; })); } ((TMP_Text)((Component)ControllerSurface.Find("Controller status")).GetComponent<TextMeshProUGUI>()).text = ((candidate != null) ? "" : ((operation != null || captureAt > 0f) ? status : (status.StartsWith("Click a binding", StringComparison.Ordinal) ? "" : status))); Transform parent3 = ControllerSurface.Find("Hints"); ClearChildren(parent3); ControllerHints(parent3); Canvas.ForceUpdateCanvases(); RectTransform content2 = component.content; Rect rect = content.rect; float height = ((Rect)(ref rect)).height; rect = component.viewport.rect; content2.anchoredPosition = new Vector2(0f, Mathf.Clamp(y, 0f, Mathf.Max(0f, height - ((Rect)(ref rect)).height))); focusDrawIndex = -1; UpdateControllerFocus(scrollTo: false); } private void UpdateControllerFocus(bool scrollTo) { //IL_00eb: 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) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if (!NativeEditorActive || !controllerMode || (!scrollTo && focusDrawIndex == controllerIndex && focusDrawColumn == controllerColumn && focusDrawDialog == controllerDialog)) { return; } focusDrawIndex = controllerIndex; focusDrawColumn = controllerColumn; focusDrawDialog = controllerDialog; for (int i = 0; i < controllerViews.Count; i++) { ControllerRowView controllerRowView = controllerViews[i]; bool flag = i == controllerIndex; controllerRowView.Marker.SetActive(flag); if ((Object)(object)controllerRowView.Toggle != (Object)null) { controllerRowView.Toggle.SetIsOnWithoutNotify(swapControllerSticks); } if ((Object)(object)controllerRowView.Primary != (Object)null) { ((Shadow)controllerRowView.Primary).effectColor = (Color)((flag && controllerColumn == 0) ? Gold : new Color(0.47f, 0.37f, 0.24f, 0.85f)); } if ((Object)(object)controllerRowView.Secondary != (Object)null) { ((Shadow)controllerRowView.Secondary).effectColor = (Color)((flag && controllerColumn == 1) ? Gold : new Color(0.47f, 0.37f, 0.24f, 0.85f)); } } for (int j = 0; j < controllerDialogButtons.Count; j++) { ((TMP_Text)((Component)controllerDialogButtons[j]).GetComponentInChildren<TextMeshProUGUI>()).fontStyle = (FontStyles)((j == controllerDialog) ? 1 : 0); } if (!scrollTo || controllerIndex >= controllerRects.Count) { return; } ScrollRect component = ((Component)ControllerSurface.Find("Actions")).GetComponent<ScrollRect>(); RectTransform val = controllerRects[controllerIndex]; float num = 0f - val.anchoredPosition.y; Rect rect = val.rect; float num2 = num + ((Rect)(ref rect)).height; float num3 = component.content.anchoredPosition.y; if (num < num3) { num3 = num; } else { float num4 = num3; rect = component.viewport.rect; if (num2 > num4 + ((Rect)(ref rect)).height) { rect = component.viewport.rect; num3 = num2 - ((Rect)(ref rect)).height; } } component.StopMovement(); RectTransform content = component.content; float num5 = num3; rect = component.content.rect; float height = ((Rect)(ref rect)).height; rect = component.viewport.rect; content.anchoredPosition = new Vector2(0f, Mathf.Clamp(num5, 0f, Mathf.Max(0f, height - ((Rect)(ref rect)).height))); } private void ScrollController(float axis) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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) float num = EditorInputPolicy.StickScroll(axis, Time.unscaledDeltaTime); if (num == 0f) { return; } ScrollRect component = ((Component)ControllerSurface.Find("Actions")).GetComponent<ScrollRect>(); component.StopMovement(); float num2 = component.content.anchoredPosition.y + num; Rect rect = component.content.rect; float height = ((Rect)(ref rect)).height; rect = component.viewport.rect; float num3 = Mathf.Clamp(num2, 0f, Mathf.Max(0f, height - ((Rect)(ref rect)).height)); component.content.anchoredPosition = new Vector2(0f, num3); rect = component.viewport.rect; float num4 = num3 + ((Rect)(ref rect)).height * 0.5f; float num5 = float.MaxValue; int num6 = controllerIndex; for (int i = 0; i < controllerRects.Count; i++) { RectTransform val = controllerRects[i]; float num7 = 0f - val.anchoredPosition.y; rect = val.rect; float num8 = Mathf.Abs(num7 + ((Rect)(ref rect)).height * 0.5f - num4); if (num8 < num5) { num5 = num8; num6 = i; } } controllerIndex = num6; UpdateControllerFocus(scrollTo: false); } private BindingSlot ControllerSelection() { if (controllerRows.Length != 0) { return controllerRows[Mathf.Clamp(controllerIndex, 0, controllerRows.Length - 1)].Inputs.ElementAtOrDefault(controllerColumn); } return null; } private void QueueControllerBinding() { if (controllerRows.Length != 0 && controllerRows[controllerIndex].StickSwap) { SetSwapSticks(!swapControllerSticks); return; } BindingSlot bindingSlot = ControllerSelection(); if (bindingSlot != null) { QueueCapture(bindingSlot); } else { status = "This mod has not provided that binding slot."; } } private void TickController() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) if (!controllerMode || !NativeEditorActive) { return; } Gamepad current = Gamepad.current; if (current == null) { return; } if (operation != null || captureAt > 0f) { cancelHold = ((operation != null && current.buttonEast.isPressed) ? (cancelHold + Time.unscaledDeltaTime) : 0f); if (cancelHold > 0.65f) { CancelCapture(); cancelHold = 0f; status = "Rebinding cancelled; previous binding kept."; } return; } cancelHold = 0f; if (Time.unscaledTime < inputGuardUntil) { return; } Vector2 val = ((InputControl<Vector2>)(object)current.dpad).ReadValue(); if (((Vector2)(ref val)).sqrMagnitude < 0.2f) { val = ((InputControl<Vector2>)(object)current.leftStick).ReadValue(); } int num = ((val.y > 0.55f) ? (-1) : ((val.y < -0.55f) ? 1 : 0)); bool flag = num != 0 && (num != navDirection || Time.unscaledTime >= nextNavAt); if (flag) { nextNavAt = Time.unscaledTime + ((num != navDirection) ? 0.35f : 0.14f); if (candidate != null) { controllerDialog = (controllerDialog + num + 3) % 3; for (int i = 0; i < 3; i++) { if (controllerDialogButtons.Count != 3) { break; } if (((Selectable)controllerDialogButtons[controllerDialog]).interactable) { break; } controllerDialog = (controllerDialog + num + 3) % 3; } } else { controllerIndex = Mathf.Clamp(controllerIndex + num, 0, Math.Max(0, controllerRows.Length - 1)); } } navDirection = num; if (candidate != null) { if (current.buttonEast.wasPressedThisFrame) { CancelCapture(); status = "Previous binding kept."; } else if (current.buttonSouth.wasPressedThisFrame && controllerDialog < controllerDialogButtons.Count && ((Selectable)controllerDialogButtons[controllerDialog]).interactable) { ((UnityEvent)controllerDialogButtons[controllerDialog].onClick).Invoke(); } UpdateControllerFocus(scrollTo: false); return; } if (controllerRows.Length != 0 && controllerRows[controllerIndex].StickSwap) { int num2 = ((val.x > 0.55f) ? 1 : ((val.x < -0.55f) ? (-1) : 0)); if (num2 != 0 && num2 != swapAxisDirection) { SetSwapSticks(num2 > 0); } swapAxisDirection = num2; } else { swapAxisDirection = 0; if (val.x > 0.55f) { controllerColumn = 1; } else if (val.x < -0.55f) { controllerColumn = 0; } } if (current.leftShoulder.wasPressedThisFrame || current.rightShoulder.wasPressedThisFrame) { NavigateNativeTab((!current.leftShoulder.wasPressedThisFrame) ? 1 : (-1)); return; } if (current.buttonEast.wasPressedThisFrame) { CloseControlsMenu(); return; } if (current.buttonSouth.wasPressedThisFrame) { QueueControllerBinding(); } else if (current.buttonWest.wasPressedThisFrame) { BindingSlot bindingSlot = ControllerSelection(); if (bindingSlot != null) { Change(bindingSlot, ""); } } else if (current.buttonNorth.wasPressedThisFrame && controllerRows.Length != 0) { if (controllerRows[controllerIndex].StickSwap) { SetSwapSticks(value: false); } else { BindingSlot[] inputs = controllerRows[controllerIndex].Inputs; foreach (BindingSlot slot in inputs) { Change(slot, null, reset: true); } } } if (captureAt > 0f) { UpdateControllerFocus(scrollTo: true); return; } if (!flag) { ScrollController(((InputControl<Vector2>)(object)current.rightStick).ReadValue().y); } UpdateControllerFocus(flag); } private Sprite GamepadIcon(string path) { string text = ControllerBindingRules.IconField(path); if (text == null) { return null; } if (padIcons.TryGetValue(text, out var value) && (Object)(object)value != (Object)null) { return value; } Type type = AccessTools.TypeByName("Tableflip.GamepadIcons"); if (gamepadIconSet == (Object)null && type != null) { gamepadIconSet = ((IEnumerable<Object>)Resources.FindObjectsOfTypeAll(type)).FirstOrDefault((Func<Object, bool>)delegate(Object set) { object? obj = AccessTools.Field(type, "buttonSouth")?.GetValue(set); object? obj2 = ((obj is Sprite) ? obj : null); return ((obj2 != null) ? ((Object)obj2).name : null) == "Icon-Xbox_A"; }); } Sprite val = (Sprite)((gamepadIconSet != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null && text == "selectButton") { val = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite item) => (Object)(object)item != (Object)null && ((Object)item).name == "SteamDeck_Select")); } if ((Object)(object)val != (Object)null) { padIcons[text] = val; } return val; } private void FillGamepadCell(Button button, BindingSlot slot) { //IL_009a: 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) TextMeshProUGUI componentInChildren = ((Component)button).GetComponentInChildren<TextMeshProUGUI>(); Sprite val = ((slot == null) ? null : GamepadIcon(slot.Path)); ((TMP_Text)componentInChildren).text = (((Object)(object)val != (Object)null) ? "" : ((slot == null) ? "—" : (string.IsNullOrEmpty(slot.Path) ? "+" : EditorInputPolicy.ControllerLabel(slot.Path)))); if (!((Object)(object)val == (Object)null)) { RectTransform obj = Box(((Component)button).transform, "Input glyph", 0.5f, 0.5f, 0.5f, 0.5f); obj.sizeDelta = new Vector2(38f, 38f); obj.anchoredPosition = Vector2.zero; Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); obj2.sprite = val; obj2.preserveAspect = true; ((Graphic)obj2).raycastTarget = false; } } private Toggle ControllerCheckbox(Transform parent) { //IL_002a: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Box(parent, "Swap sticks checkbox", 0.75f, 0.5f, 0.75f, 0.5f, (Color?)new Color(0.13f, 0.1f, 0.075f)); val.sizeDelta = new Vector2(34f, 34f); Outline obj = ((Component)val).gameObject.AddComponent<Outline>(); ((Shadow)obj).effectColor = Gold; ((Shadow)obj).effectDistance = new Vector2(1f, -1f); Image val2 = ((Component)Box((Transform)(object)val, "Native checkmark", 0.1f, 0.1f, 0.9f, 0.9f)).gameObject.AddComponent<Image>(); val2.sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => (Object)(object)sprite != (Object)null && ((Object)sprite).name == "Icon_Checkmark-Options")); val2.preserveAspect = true; ((Graphic)val2).raycastTarget = false; Toggle obj2 = ((Component)val).gameObject.AddComponent<Toggle>(); ((Selectable)obj2).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>(); obj2.graphic = (Graphic)(object)val2; obj2.SetIsOnWithoutNotify(swapControllerSticks); ((UnityEvent<bool>)(object)obj2.onValueChanged).AddListener((UnityAction<bool>)SetSwapSticks); return obj2; } private void ControllerHints(Transform parent) { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) bool flag = operation != null || captureAt > 0f; string[] array = ((!flag) ? ((candidate == null) ? new string[6] { "buttonSouth", "buttonWest", "buttonNorth", "rightStick", "leftShoulder", "buttonEast" } : new string[3] { "dpad", "buttonSouth", "buttonEast" }) : new string[1] { "buttonEast" }); string[] array2 = ((!flag) ? ((candidate == null) ? new string[6] { "Assign", "Clear", "Reset", "Scroll", "Tabs", "Close" } : new string[3] { "Choose", "Confirm", "Cancel" }) : new string[1] { "Hold to cancel" }); for (int i = 0; i < array.Length; i++) { float num = (float)i / (float)array.Length; RectTransform parent2 = Box(parent, "Hint", num, 0f, num + 1f / (float)array.Length, 1f); Image val = ((Component)Box((Transform)(object)parent2, "Glyph", 0f, 0.05f, 0.23f, 0.95f)).gameObject.AddComponent<Image>(); val.sprite = GamepadIcon("<Gamepad>/" + array[i]); val.preserveAspect = true; ((Graphic)val).raycastTarget = false; ((Behaviour)val).enabled = (Object)(object)val.sprite != (Object)null; if (array.Length == 6 && i == 4) { ((Graphic)val).rectTransform.anchorMax = new Vector2(0.17f, 0.95f); Image obj = ((Component)Box((Transform)(object)parent2, "Next tab glyph", 0.18f, 0.05f, 0.35f, 0.95f)).gameObject.AddComponent<Image>(); obj.sprite = GamepadIcon("<Gamepad>/rightShoulder"); obj.preserveAspect = true; ((Graphic)obj).raycastTarget = false; Caption((Transform)(object)parent2, array2[i], 0.38f, 0f, 0.99f, 1f, 14); } else { Caption((Transform)(object)parent2, array2[i], 0.26f, 0f, 0.99f, 1f, 14); } } } private void EnsureSecondaryBindings(RegisteredAction entry) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Invalid comparison between Unknown and I4 //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) if (entry.Owner != "game" && !entry.Owned) { return; } if (entry.Owner == "game") { InputActionMap actionMap = entry.Action.actionMap; if (!EditorInputPolicy.NativeControllerAction((actionMap != null) ? actionMap.name : null, entry.Action.name)) { return; } } BindingDefinition[] original = ((IEnumerable<InputBinding>)(object)entry.Action.bindings).Select((InputBinding b) => new BindingDefinition { Id = ((InputBinding)(ref b)).id.ToString("D"), Name = ((InputBinding)(ref b)).name, Path = ((InputBinding)(ref b)).path, Groups = ((InputBinding)(ref b)).groups, Processors = ((InputBinding)(ref b)).processors, Interactions = ((InputBinding)(ref b)).interactions, Composite = ((InputBinding)(ref b)).isComposite, Part = ((InputBinding)(ref b)).isPartOfComposite }).ToArray(); BindingDefinition[] first; if (!(entry.Owner != "game")) { InputActionMap actionMap2 = entry.Action.actionMap; if (!VanillaBindingPolicy.Allows((actionMap2 != null) ? actionMap2.name : null, entry.Action.name)) { first = Array.Empty<BindingDefinition>(); goto IL_00d9; } } first = SecondaryBindingPlanner.Plan(original); goto IL_00d9; IL_00d9: string id = entry.Id; bool createEmptyButtons; if (!(entry.Owner == "game")) { createEmptyButtons = (int)entry.Action.type == 1; } else { InputActionMap actionMap3 = entry.Action.actionMap; createEmptyButtons = ControllerBindingRules.NativeButtonAction((actionMap3 != null) ? actionMap3.name : null, entry.Action.name); } BindingDefinition[] array = first.Concat(SecondaryBindingPlanner.PlanController(original, id, createEmptyButtons)).ToArray(); if (array.Length == 0) { return; } InputAction action = entry.Action; InputActionMap actionMap4 = action.actionMap; InputActionAsset val = ((actionMap4 != null) ? actionMap4.asset : null); InputAction[] array2 = (InputAction[])(((Object)(object)val != (Object)null) ? (from a in ((IEnumerable<InputActionMap>)(object)val.actionMaps).SelectMany((InputActionMap m) => (IEnumerable<InputAction>)(object)m.actions) where a.enabled select a).ToArray() : ((action.actionMap != null) ? ((IEnumerable<InputAction>)(object)action.actionMap.actions).Where((InputAction a) => a.enabled).ToArray() : ((!action.enabled) ? ((Array)Array.Empty<InputAction>()) : ((Array)new InputAction[1] { action })))); bool flag = changing; changing = true; try { InputAction[] array3 = array2; for (int num = 0; num < array3.Length; num++) { array3[num].Disable(); } BindingDefinition[] array4 = array; foreach (BindingDefinition bindingDefinition in array4) { InputBinding val2 = default(InputBinding); ((InputBinding)(ref val2)).path = bindingDefinition.Path; ((InputBinding)(ref val2)).name = bindingDefinition.Name; ((InputBinding)(ref val2)).groups = bindingDefinition.Groups; ((InputBinding)(ref val2)).processors = bindingDefinition.Processors; ((InputBinding)(ref val2)).interactions = bindingDefinition.Interactions; ((InputBinding)(ref val2)).id = Guid.Parse(bindingDefinition.Id); ((InputBinding)(ref val2)).isComposite = bindingDefinition.Composite; ((InputBinding)(ref val2)).isPartOfComposite = bindingDefinition.Part; InputBinding val3 = val2; InputActionSetupExtensions.AddBinding(action, val3); } } finally { InputAction[] array3 = array2; for (int num = 0; num < array3.Length; num++) { array3[num].Enable(); } changing = flag; } } private BindingRow[] VisibleRows() { if (!controllerMode) { return BindingRows(); } return new BindingRow[1] { new BindingRow { Label = "Swap sticks", Category = "Controller options", Inputs = Array.Empty<BindingSlot>(), StickSwap = true } }.Concat(BindingRows()).ToArray(); } private BindingRow[] BindingRows() { return (from slot in controllerMode ? ((IEnumerable<BindingSlot>)(from s in ControllerSlots() orderby (!(s.Entry.Owner == "game")) ? 1 : 0, s.Entry.OwnerName, s.Category, s.Label select s).ToArray()) : ((IEnumerable<BindingSlot>)VisibleSlots()) group slot by slot.Entry.Owner + "|" + slot.Entry.Id + "|" + slot.Label into @group select new BindingRow { Label = @group.First().Label, Category = @group.First().Category, Owner = @group.First().Entry.Owner, OwnerName = @group.First().Entry.OwnerName, Inputs = @group.Take(2).ToArray() }).ToArray(); } private RectTransform Box(Transform parent, string name, float left, float bottom, float right, float top, Color? color = null) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_002d: 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_0036: 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_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0076: 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(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(left, bottom); val2.anchorMax = new Vector2(right, top); val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; if (color.HasValue) { ((Graphic)val.AddComponent<Image>()).color = color.Value; } return val2; } private TextMeshProUGUI Caption(Transform parent, string value, float left, float bottom, float right, float top, int size = 17) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)Box(parent, "Label", left, bottom, right, top)).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)nativeFont != (Object)null) { ((TMP_Text)val).font = ((TMP_Text)nativeFont).font; ((TMP_Text)val).fontSharedMaterial = ((TMP_Text)nativeFont).fontSharedMaterial; } ((TMP_Text)val).fontSize = size; ((Graphic)val).color = Gold; ((TMP_Text)val).text = value; ((TMP_Text)val).alignment = (TextAlignmentOptions)4097; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).richText = false; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)val).overflowMode = (TextOverflowModes)1; return val; } private Button Control(Transform parent, string value, float left, float bottom, float right, float top, Action clicked, bool ornate = false) { //IL_0027: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown RectTransform val = Box(parent, value, left, bottom, right, top, (Color?)new Color(0.25f, 0.19f, 0.12f)); Button val2 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)val2).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>(); ColorBlock colors = ((Selectable)val2).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.78f, 0.42f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.47f, 0.16f); ((Selectable)val2).colors = colors; StyleNativeButton(val2, ornate); ((TMP_Text)Caption((Transform)(object)val, value, 0.03f, 0f, 0.97f, 1f)).alignment = (TextAlignmentOptions)514; ((UnityEvent)val2.onClick).AddListener((UnityAction)delegate { clicked(); }); return val2; } private GameObject BuildNativeEditor(Transform parent) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) FindNativeTheme(); RectTransform val = Box(parent, "FATE Rebind Editor", 0.1f, 0.14f, 0.9f, 0.855f, Panel); FitInsideNativeFrame(parent, val); RectTransform val2 = Box((Transform)(object)val, "MouseKeyboardSurface", 0f, 0f, 1f, 1f); Caption((Transform)(object)val2, "FATE REBIND", 0.02f, 0.92f, 0.78f, 0.99f, 22); RectTransform val3 = Box((Transform)(object)val2, "Search", 0.02f, 0.85f, 0.98f, 0.91f, (Color?)new Color(0.19f, 0.15f, 0.11f)); TMP_InputField obj = ((Component)val3).gameObject.AddComponent<TMP_InputField>(); TextMeshProUGUI textComponent = Caption((Transform)(object)val3, "", 0.02f, 0f, 0.98f, 1f); obj.textComponent = (TMP_Text)(object)textComponent; obj.textViewport = val3; obj.lineType = (LineType)0; TextMeshProUGUI val4 = Caption((Transform)(object)val3, "Search actions…", 0.02f, 0f, 0.98f, 1f); ((Graphic)val4).color = new Color(0.55f, 0.5f, 0.4f); obj.placeholder = (Graphic)(object)val4; ((UnityEvent<string>)(object)obj.onValueChanged).AddListener((UnityAction<string>)delegate(string value) { search = value; RefreshNativeEditor(force: true); }); Caption((Transform)(object)val2, "Action", 0.03f, 0.79f, 0.47f, 0.84f, 16); Caption((Transform)(object)val2, "Primary", 0.34f, 0.79f, 0.54f, 0.84f, 16); Caption((Transform)(object)val2, "Secondary", 0.6f, 0.79f, 0.8f, 0.84f, 16); CreateScrollList((Transform)(object)val2, "Actions", 0.02f, 0.21f, 0.98f, 0.79f); ((Object)Caption((Transform)(object)val2, "", 0.02f, 0.075f, 0.98f, 0.19f, 16)).name = "Status"; Box((Transform)(object)val2, "Footer", 0.02f, 0.01f, 0.98f, 0.07f); BuildControllerSurface((Transform)(object)val); ((Component)val2).gameObject.SetActive(!controllerMode); ((Component)((Transform)val).Find("ControllerSurface")).gameObject.SetActive(controllerMode); return ((Component)val).gameObject; } private RectTransform CreateScrollList(Transform parent, string name, float left, float bottom, float right, float top) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00fa: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Box(parent, name, left, bottom, right, top); RectTransform val2 = Box((Transform)(object)val, "Viewport", 0f, 0f, 0.965f, 1f, (Color?)new Color(0.07f, 0.055f, 0.04f, 0.98f)); ((Component)val2).gameObject.AddComponent<RectMask2D>(); RectTransform val3 = Box((Transform)(object)val2, "Rows", 0f, 1f, 1f, 1f); val3.pivot = new Vector2(0.5f, 1f); RectTransform val4 = Box((Transform)(object)val, "Scrollbar", 0.97f, 0f, 1f, 1f, (Color?)new Color(0.1f, 0.08f, 0.055f)); RectTransform val5 = Box((Transform)(object)val4, "Handle", 0f, 0f, 1f, 1f, Gold); Scrollbar val6 = ((Component)val4).gameObject.AddComponent<Scrollbar>(); val6.handleRect = val5; ((Selectable)val6).targetGraphic = (Graphic)(object)((Component)val5).GetComponent<Image>(); val6.direction = (Direction)2; RebindScrollRect rebindScrollRect = ((Component)val).gameObject.AddComponent<RebindScrollRect>(); ((ScrollRect)rebindScrollRect).viewport = val2; ((ScrollRect)rebindScrollRect).content = val3; ((ScrollRect)rebindScrollRect).horizontal = false; ((ScrollRect)rebindScrollRect).vertical = true; ((ScrollRect)rebindScrollRect).scrollSensitivity = 60f; ((ScrollRect)rebindScrollRect).inertia = false; ((ScrollRect)rebindScrollRect).movementType = (MovementType)2; ((ScrollRect)rebindScrollRect).verticalScrollbar = val6; return val3; } private RectTransform PixelRow(Transform parent, string name, float offset, float height) { //IL_0030: 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_0054: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Box(parent, name, 0f, 1f, 1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = new Vector2(0f, 0f - offset); obj.sizeDelta = new Vector2(0f, height); return obj; } private void ClearChildren(Transform parent) { for (int num = parent.childCount - 1; num >= 0; num--) { GameObject gameObject = ((Component)parent.GetChild(num)).gameObject; gameObject.SetActive(false); Object.Destroy((Object)(object)gameObject); } } private void BindingCell(Transform row, BindingSlot slot, float left, float right, bool idle) { string value = ((slot == null) ? "Not provided" : (string.IsNullOrEmpty(slot.Path) ? "Unbound" : InputActionRebindingExtensions.GetBindingDisplayString(slot.Action, slot.Index, (DisplayStringOptions)0))); if (string.IsNullOrEmpty(value)) { value = slot?.Path ?? "Unbound"; } ((Selectable)Control(row, value, left, 0.08f, right - 0.05f, 0.92f, delegate { if (slot != null) { QueueCapture(slot); } }, ornate: true)).interactable = idle && slot != null; ((Selectable)Control(row, "x", right - 0.045f, 0.08f, right, 0.92f, delegate { if (slot != null) { Change(slot, ""); } })).interactable = idle && slot != null && !string.IsNullOrEmpty(slot.Path); } private void RefreshNativeEditor(bool force = false) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) if (!open || (Object)(object)nativeRoot == (Object)null) { return; } ApplyInputSurface(); if (controllerMode) { RefreshControllerEditor(force); return; } string text = search + "|" + status + "|" + captureSlot?.Key + "|" + candidate?.Key + "|" + string.Join(";", slots.Select((BindingSlot s) => s.Key + ":" + s.Path)); if (!force && text == nativeSignature) { return; } nativeSignature = text; ((TMP_Text)((Component)KeyboardSurface.Find("Status")).GetComponent<TextMeshProUGUI>()).text = status; bool flag = operation == null && captureAt == 0f && candidate == null; RectTransform val = (RectTransform)KeyboardSurface.Find("Actions/Viewport/Rows"); ClearChildren((Transform)(object)val); BindingRow[] array = VisibleRows(); float num = 0f; string text2 = null; BindingRow[] array2 = array; foreach (BindingRow entry in array2) { string text3 = ((entry.Owner != "game") ? (entry.OwnerName + " / ") : "") + entry.Category; if (text3 != text2) { if (text2 != null) { num += 22f; } RectTransform val2 = PixelRow((Transform)(object)val, "Category heading", num, 46f); Image obj = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)obj).color = new Color(0.25f, 0.18f, 0.1f, 0.75f); ((Graphic)obj).raycastTarget = false; ((TMP_Text)Caption((Transform)(object)val2, text3, 0.015f, 0.08f, 1f, 1f, 26)).fontStyle = (FontStyles)1; ((Graphic)((Component)Box((Transform)(object)val2, "Category divider", 0.015f, 0f, 0.985f, 0.025f, (Color?)new Color(0.68f, 0.49f, 0.24f, 0.7f))).GetComponent<Image>()).raycastTarget = false; num += 56f; text2 = text3; } RectTransform val3 = PixelRow((Transform)(object)val, "Binding pair", num, 52f); num += 60f; ((Graphic)Caption((Transform)(object)val3, entry.Label, 0.035f, 0f, 0.32f, 1f)).color = new Color(0.91f, 0.87f, 0.79f); BindingCell((Transform)(object)val3, entry.Inputs.ElementAtOrDefault(0), 0.33f, 0.59f, flag); BindingCell((Transform)(object)val3, entry.Inputs.ElementAtOrDefault(1), 0.6f, 0.86f, flag); ((Selectable)Control((Transform)(object)val3, "Reset", 0.88f, 0.08f, 1f, 0.92f, delegate { BindingSlot[] inputs = entry.Inputs; foreach (BindingSlot slot in inputs) { Change(slot, null, reset: true); } })).interactable = flag; } val.sizeDelta = new Vector2(0f, Mathf.Max(60f, num)); if (array.Length == 0) { Caption((Transform)(object)val, "No matching bindings. Load a character for gameplay actions.", 0f, 0f, 1f, 1f); } Transform parent = KeyboardSurface.Find("Footer"); ClearChildren(parent); if (candidate != null) { Control(parent, "Keep both", 0f, 0f, 0.25f, 1f, delegate { Change(candidate, candidatePath); candidate = null; RefreshNativeEditor(force: true); }); BindingSlot[] array3 = Conflicts(candidate, candidatePath); ((Selectable)Control(parent, "Swap bindings", 0.26f, 0f, 0.51f, 1f, delegate { BindingSlot[] array4 = Conflicts(candidate, candidatePath); if (array4.Length == 1) { SwapBindings(candidate, array4[0], candidatePath, candidate.Path); } candidate = null; RefreshNativeEditor(force: true); })).interactable = array3.Length == 1 && array3[0].Group == candidate.Group && !array3[0].ReadOnly; Control(parent, "Cancel", 0.52f, 0f, 0.77f, 1f, delegate { CancelCapture(); status = "Previous binding kept."; RefreshNativeEditor(force: true); }); } else if (captureSlot != null) { Control(parent, "Cancel rebinding", 0f, 0f, 0.4f, 1f, delegate { CancelCapture(); status = "Previous binding kept."; RefreshNativeEditor(force: true); }); } } private static bool IsOurEditor(Transform transform) { while ((Object)(object)transform != (Object)null) { if (((Object)transform).name == "FATE Rebind Editor") { return true; } transform = transform.parent; } return false; } private static bool IsNativeWindowDecoration(Graphic graphic, Transform parent) { //IL_0046: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) Image val = (Image)(object)((graphic is Image) ? graphic : null); if (val == null || (Object)(object)val.sprite == (Object)null || IsOurEditor(((Component)val).transform) || (Object)(object)((Component)val).GetComponentInParent<Selectable>() != (Object)null) { return false; } RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val2 == (Object)null)) { Rect rect = val2.rect; if (!(((Rect)(ref rect)).width <= 0f)) { rect = val2.rect; if (!(((Rect)(ref rect)).height <= 0f)) { string text = (((Object)val).name + " " + ((Object)val.sprite).name).ToLowerInvariant(); bool num = text.Contains("frame") || text.Contains("border") || text.Contains("corner") || text.Contains("ornament") || text.Contains("divider"); rect = ((Graphic)val).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = val2.rect; int num2; if (width >= ((Rect)(ref rect)).width * 0.75f) { rect = ((Graphic)val).rectTransform.rect; float height = ((Rect)(ref rect)).height; rect = val2.rect; num2 = ((height >= ((Rect)(ref rect)).height * 0.6f) ? 1 : 0); } else { num2 = 0; } bool flag = (byte)num2 != 0; return num || flag; } } } return false; } private void FitInsideNativeFrame(Transform parent, RectTransform editor) { //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_004d: 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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) RectTransform bounds = default(RectTransform); ref RectTransform reference = ref bounds; Transform obj = parent; reference = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)bounds == (Object)null) { return; } Rect rect = bounds.rect; if (((Rect)(ref rect)).width <= 0f) { return; } rect = bounds.rect; if (((Rect)(ref rect)).height <= 0f) { return; } Image val = ((Component)parent).GetComponentsInChildren<Image>(true).Where(delegate(Image image) { //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_0027: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (IsNativeWindowDecoration((Graphic)(object)image, parent)) { Rect rect3 = ((Graphic)image).rectTransform.rect; float width = ((Rect)(ref rect3)).width; rect3 = bounds.rect; if (width >= ((Rect)(ref rect3)).width * 0.6f) { rect3 = ((Graphic)image).rectTransform.rect; float height = ((Rect)(ref rect3)).height; rect3 = bounds.rect; return height >= ((Rect)(ref rect3)).height * 0.5f; } } return false; }).OrderByDescending(delegate(Image image) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Rect rect3 = ((Graphic)image).rectTransform.rect; float width = ((Rect)(ref rect3)).width; rect3 = ((Graphic)image).rectTransform.rect; return width * ((Rect)(ref rect3)).height; }) .FirstOrDefault(); if (!((Object)(object)val == (Object)null)) { Vector3[] array = (Vector3[])(object)new Vector3[4]; ((Graphic)val).rectTransform.GetWorldCorners(array); Vector3 val2 = ((Transform)bounds).InverseTransformPoint(array[0]); Vector3 val3 = ((Transform)bounds).InverseTransformPoint(array[2]); Rect rect2 = bounds.rect; editor.anchorMin = new Vector2((val2.x - ((Rect)(ref rect2)).xMin) / ((Rect)(ref rect2)).width, (val2.y - ((Rect)(ref rect2)).yMin) / ((Rect)(ref rect2)).height); editor.anchorMax = new Vector2((val3.x - ((Rect)(ref rect2)).xMin) / ((Rect)(ref rect2)).width, (val3.y - ((Rect)(ref rect2)).yMin) / ((Rect)(ref rect2)).height); editor.offsetMin = new Vector2(18f, 18f); editor.offsetMax = new Vector2(-18f, -18f); } } private void FindNativeTheme() { nativeFont = ((IEnumerable<TextMeshProUGUI>)Resources.FindObjectsOfTypeAll<TextMeshProUGUI>()).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => (Object)(object)t != (Object)null && (Object)(object)((TMP_Text)t).font != (Object)null && !Ours(((TMP_Text)t).transform))); Type pauseType = AccessTools.TypeByName("Tableflip.PauseUI"); nativeFancyButton = ((pauseType == null) ? null : Resources.FindObjectsOfTypeAll(pauseType).OfType<Component>().Select(delegate(Component pause) { object? obj = AccessTools.Field(pauseType, "resumeButton")?.GetValue(pause); return (Button)((obj is Button) ? obj : null); }) .FirstOrDefault((Func<Button, bool>)delegate(Button button) { if ((Object)(object)button != (Object)null) { Graphic targetGraphic = ((Selectable)button).targetGraphic; Image val = (Image)(object)((targetGraphic is Image) ? targetGraphic : null); if (val != null) { return (Object)(object)val.sprite != (Object)null; } } return false; })); Type entryType = AccessTools.TypeByName("Tableflip.QuestEntryUI"); nativeButton = ((entryType == null) ? null : Resources.FindObjectsOfTypeAll(entryType).OfType<Component>().Select(delegate(Component entry) { object? obj = AccessTools.Field(entryType, "cancelButton")?.GetValue(entry); return (Button)((obj is Button) ? obj : null); }) .FirstOrDefault((Func<Button, bool>)delegate(Button button) { if ((Object)(object)button != (Object)null) { Graphic targetGraphic = ((Selectable)button).targetGraphic; Image val = (Image)(object)((targetGraphic is Image) ? targetGraphic : null); if (val != null) { return (Object)(object)val.sprite != (Object)null; } } return false; })); if (!((Object)(object)nativeButton == (Object)null)) { return; } nativeButton = (from b in Resources.FindObjectsOfTypeAll<Button>().Where(delegate(Button b) { if ((Object)(object)b != (Object)null && !Ours(((Component)b).transform)) { Graphic targetGraphic = ((Selectable)b).targetGraphic; Image val = (Image)(object)((targetGraphic is Image) ? targetGraphic : null); if (val != null) { return (Object)(object)val.sprite != (Object)null; } } return false; }) orderby ((Component)b).GetComponentsInChildren<Image>(true).Length select b).FirstOrDefault(); static bool Ours(Transform t) { while ((Object)(object)t != (Object)null) { if (((Object)t).name == "FATE Rebind Editor") { return true; } t = t.parent; } return false; } } private void StyleNativeButton(Button target, bool ornate) { //IL_0046: 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_009a: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown Button val = (ornate ? nativeFancyButton : nativeButton); RectTransform obj = Box(((Component)target).transform, "Button backing", 0f, 0f, 1f, 1f, (Color?)new Color(0.16f, 0.13f, 0.1f, 0.98f)); ((Transform)obj).SetAsFirstSibling(); ((Graphic)((Component)obj).GetComponent<Image>()).raycastTarget = false; Outline obj2 = ((Component)obj).gameObject.AddComponent<Outline>(); ((Shadow)obj2).effectColor = new Color(0.47f, 0.37f, 0.24f, 0.85f); ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); if ((Object)(object)val == (Object)null) { return; } Graphic targetGraphic = ((Selectable)val).targetGraphic; Image val2 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null); Image val3 = (Image)((Selectable)target).targetGraphic; val3.sprite = val2.sprite; val3.type = val2.type; ((Graphic)val3).color = ((Graphic)val2).color; val3.fillCenter = val2.fillCenter; val3.pixelsPerUnitMultiplier = val2.pixelsPerUnitMultiplier; ((Selectable)target).transition = ((Selectable)val).transition; ((Selectable)target).colors = ((Selectable)val).colors; ((Selectable)target).spriteState = ((Selectable)val).spriteState; ColorBlock colors = ((Selectable)target).colors; ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 1f); ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.86f, 0.62f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.59f, 0.32f, 1f); ((Selectable)target).colors = colors; if (!ornate) { return; } foreach (Transform item in ((Component)val).transform) { Transform source = item; CopyButtonDecoration(source, ((Component)target).transform, val2); } } private void CopyButtonDecoration(Transform source, Transform parent, Image excluded) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown RectTransform val = (RectTransform)(object)((source is RectTransform) ? source : null); if (val == null || (Object)(object)((Component)source).GetComponent<TMP_Text>() != (Object)null || (Object)(object)((Component)source).GetComponent<Selectable>() != (Object)null) { return; } string text = ((Object)source).name.ToLowerInvariant(); if (text.Contains("select") || text.Contains("highlight") || text.Contains("pressed") || text.Contains("arrow")) { return; } Image component = ((Component)source).GetComponent<Image>(); if ((Object)(object)component == (Object)null && source.childCount == 0) { return; } RectTransform val2 = Box(parent, "Native ornament", 0f, 0f, 1f, 1f); Transform parent2 = ((Transform)val).parent; RectTransform val3 = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); if ((Object)(object)val3 != (Object)null) { Rect rect = val3.rect; if (((Rect)(ref rect)).width > 0f) { rect = val3.rect; if (((Rect)(ref rect)).height > 0f) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Vector3 val4 = ((Transform)val3).InverseTransformPoint(array[0]); Vector3 val5 = ((Transform)val3).InverseTransformPoint(array[2]); Rect rect2 = val3.rect; val2.anchorMin = new Vector2((val4.x - ((Rect)(ref rect2)).xMin) / ((Rect)(ref rect2)).width, (val4.y - ((Rect)(ref rect2)).yMin) / ((Rect)(ref rect2)).height); val2.anchorMax = new Vector2((val5.x - ((Rect)(ref rect2)).xMin) / ((Rect)(ref rect2)).width, (val5.y - ((Rect)(ref rect2)).yMin) / ((Rect)(ref rect2)).height); } } } if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)excluded) { Image obj = ((Component)val2).gameObject.AddComponent<Image>(); obj.sprite = component.sprite; obj.type = component.type; ((Graphic)obj).color = ((Graphic)component).color; obj.fillCenter = component.fillCenter; obj.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier; ((Graphic)obj).raycastTarget = false; } ((Component)val2).gameObject.SetActive(((Component)source).gameObject.activeSelf); foreach (Transform item in source) { Transform source2 = item; CopyButtonDecoration(source2, (Transform)(object)val2, excluded); } } private void MarkSelected(Button button, bool selected) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (selected) { ((Graphic)((Component)Box(((Component)button).transform, "Selected filter", 0f, 0.15f, 0.018f, 0.85f, Gold)).GetComponent<Image>()).raycastTarget = false; TextMeshProUGUI componentInChildren = ((Component)button).GetComponentInChildren<TextMeshProUGUI>(); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).fontStyle = (FontStyles)1; } } } private void QueueCapture(BindingSlot slot) { CancelCapture(); captureSlot = slot; captureAt = Time.unscaledTime + 0.25f; status = "Release the mouse, then press a key or control. Escape cancels."; } private void StartCapture() { BindingSlot slot = captureSlot; if (slot == null || !open) { return; } try { if (slot.Action.enabled) { suspended.Add(slot.Action); } slot.Action.Disable(); RebindingOperation val = InputActionRebindingExtensions.PerformInteractiveRebinding(slot.Action, slot.Index).WithCancelingThrough("<Keyboard>/escape").WithControlsExcluding("<Mouse>/position") .WithControlsExcluding("<Mouse>/delta") .WithControlsExcluding("<Pointer>/position") .WithControlsExcluding("<Pointer>/delta") .WithTimeout(15f) .OnMatchWaitForAnother(0.1f) .OnApplyBinding((Action<RebindingOperation, string>)delegate(RebindingOperation op, string path) { candidate = slot; candidatePath = path; }) .OnComplete((Action<RebindingOperation>)delegate(RebindingOperation op) { operation = null; captureSlot = null; op.Dispose(); RestoreCaptureAction(slot.Action); if (!((slot.Group == "Controller") ? ControllerBindingRules.ButtonPath(candidatePath) : BindingPresentation.IsMouseKeyboardPath(candidatePath))) { candidate = null; status = ((slot.Group == "Controller") ? "Choose a controller button. Stick axes are configured with Swap sticks." : "Choose a keyboard key or mouse button."); } else { BindingSlot[] array = Conflicts(candidate, candidatePath); if (array.Length == 0) { Change(candidate, candidatePath); candidate = null; } else { status = "Also used by: " + string.Join(", ", from s in array.Take(4) select s.Entry.OwnerName + " / " + s.Label) + ". Keep both or cancel."; } } }) .OnCancel((Action<RebindingOperation>)delegate(RebindingOperation op) { operation = null; captureSlot = null; op.Dispose(); RestoreCaptureAction(slot.Action); cancelHandledUntil = Time.unscaledTime + 0.1f; status = "Rebinding cancelled; previous binding kept."; }); if (slot.Group == "Controller") { val.WithExpectedControlType("Button").WithControlsHavingToMatchPath("<Gamepad>").WithMatchingEventsBeingSuppressed(false) .OnMatchWaitForAnother(1f); } else { val.WithControlsExcluding("<Gamepad>").WithControlsExcluding("<Joystick>").WithControlsExcluding("<Pen>") .WithControlsExcluding("<Touchscreen>") .WithControlsExcluding("<XRController>"); } operation = val; val.Start(); status = "Listening: " + slot.Label + ((slot.Group == "Controller") ? " — tap a control; hold B to cancel." : " — press a key or mouse control; Escape cancels."); } catch (Exception ex) { RebindingOperation obj = operation; if (obj != null) { obj.Dispose(); } operation = null; captureSlot = null; RestoreCaptureAction(slot.Action); status = "Could not start rebind: " + ex.Message; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private BindingSlot[] Conflicts(BindingSlot target, string path) { if (target == null) { return Array.Empty<BindingSlot>(); } return slots.Where((BindingSlot s) => s.Key != target.Key && (!(s.Entry.Owner == target.Entry.Owner) || !(s.Entry.Id == target.Entry.Id)) && ((target.Group == "Controller") ? IsControllerSlot(s) : IsEditableMouseKeyboard(s)) && BindingIdentity.SameControl(s.Path, path) && BindingIdentity.Overlaps(s.Entry.Owner, s.Map, target.Entry.Owner, target.Map)).ToArray(); } private void RestoreCaptureAction(InputAction action) { if (action == null) { return; } if (BlocksInput) { if (!NativeEditorActive || controllerMode) { return; } InputActionMap actionMap = action.actionMap; if (!(((actionMap != null) ? actionMap.name : null) == "Menu")) { InputActionMap actionMap2 = action.actionMap; if (!(((actionMap2 != null) ? actionMap2.name : null) == "UI")) { return; } } } if (suspended.Remove(action)) { action.Enable(); } } private void CancelCapture() { InputAction action = captureSlot?.Action; captureAt = 0f; captureSlot = null; candidate = null; candidatePath = null; RebindingOperation val = operation; operation = null; if (val != null) { val.Cancel(); val.Dispose(); } RestoreCaptureAction(action); } private bool IsEditableMouseKeyboard(BindingSlot slot) { if (slot.Group != "Controller" && !slot.ReadOnly && (slot.Entry.Owner != "game" || VanillaBindingPolicy.Allows(slot.Map, slot.Action.name))) { return BindingPresentation.IsMouseKeyboardPath(slot.Original); } return false; } private BindingSlot[] MouseKeyboardSlots() { return slots.Where(IsEditableMouseKeyboard).ToArray(); } private BindingSlot[] VisibleSlots() { return (from s in slots where IsEditableMouseKeyboard(s) && (string.IsNullOrWhiteSpace(search) || (s.Label + " " + s.Category + " " + s.Entry.OwnerName + " " + s.Path).IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) orderby (!(s.Entry.Owner == "game")) ? 1 : 0, s.Entry.OwnerName select s).ThenBy<BindingSlot, string>((BindingSlot s) => s.Category, StringComparer.Ordinal).ThenBy<BindingSlot, string>((BindingSlot s) => s.Label, StringComparer.Ordinal).ThenBy<BindingSlot, string>((BindingSlot s) => s.Group, StringComparer.Ordinal) .ToArray(); } private static string Pretty(string value) { return Regex.Replace(value ?? "", "([a-z])([A-Z])", "$1 $2"); } internal static void RequestRefresh() { if (instance != null) { instance.nextDiscover = 0f; } } private static string Key(RegisteredAction entry, int index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00fd: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) InputBinding val = entry.Action.bindings[index]; bool flag = entry.Owner != "game" && !entry.Owner.StartsWith("auto.", StringComparison.Ordinal); string text = entry.BindingKey?.Invoke(index); string text2 = ((InputBinding)(ref val)).name + "|" + ((InputBinding)(ref val)).path + "|" + ((InputBinding)(ref val)).groups; InputBinding val2; for (int num = index - 1; num >= 0; num--) { val2 = entry.Action.bindings[num]; if (((InputBinding)(ref val2)).isComposite) { string[] obj = new string[5] { text2, "|", null, null, null }; val2 = entry.Action.bindings[num]; obj[2] = ((InputBinding)(ref val2)).name; obj[3] = "|"; val2 = entry.Action.bindings[num]; obj[4] = ((InputBinding)(ref val2)).path; text2 = string.Concat(obj); break; } } int num2 = 0; for (int i = 0; i < index; i++) { InputBinding val3 = entry.Action.bindings[i]; if (((InputBinding)(ref val3)).name == ((InputBinding)(ref val)).name && ((InputBinding)(ref val3)).path == ((InputBinding)(ref val)).path && ((InputBinding)(ref val3)).groups == ((InputBinding)(ref val)).groups) { num2++; } } string owner = entry.Owner; string id = entry.Id; object binding; if (!entry.Owned) { binding = text ?? (flag ? BindingIdentity.StableToken(text2 + "|" + num2) : ((((InputBinding)(ref val)).id != Guid.Empty) ? ((InputBinding)(ref val)).id.ToString("D") : (index + ":" + ((InputBinding)(ref val)).path))); } else if (!(((InputBinding)(ref val)).name == "FATE.Rebind.Controller.Primary")) { if (((InputBinding)(ref val)).name == "FATE.Rebind.Controller.Secondary") { val2 = entry.Action.bindings[0]; if (!EditorInputPolicy.GamepadPath(((InputBinding)(ref val2)).path)) { binding = "controller.secondary"; goto IL_0287; } } binding = ((index == 0) ? "primary" : "secondary"); } else { binding = "controller.primary"; } goto IL_0287; IL_0287: return BindingIdentity.Key(owner, id, (string)binding); } private void Awake() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown instance = this; store = new BindingStore(Path.Combine(Paths.ConfigPath, "ZombieGhost.Rebind", "bindings.xml")); try { store.Load(); } catch (Exception ex) { status = "Settings could not be loaded; original file preserved. " + ex.Message; ((BaseUnityPlugin)this).Logger.LogError((object)status); } swapControllerSticks = store.TryGet("settings.controller.swap-sticks", out var path) && path == "1"; harmony = new Harmony("zombieghost.rebind"); MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("Cleverous.Prodigy.Input.InputBroker"), "ManagedTick", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RebindPlugin), "BeforeBroker", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.PropertyGetter(AccessTools.TypeByName("Tableflip.InputBlocker"), "Blocked"); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(RebindPlugin), "BlockInput", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo3 = AccessTools.PropertyGetter(AccessTools.TypeByName("Cleverous.Prodigy.ProdigyPlayer"), "IsInputBlocked"); if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(RebindPlugin), "BlockInput", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } InputSystem.onActionChange += ActionChanged; Discover(); InstallSettingsHooks(); InstallDriver(); InstallControllerInput(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FATE Rebind ready: Controls editor ready."); } private static bool BeforeBroker(object __instance) { if (!BlocksInput) { return true; } AccessTools.Method(__instance.GetType(), "ResetInputs", (Type[])null, (Type[])null)?.Invoke(__instance, null); return false; } private static void BlockInput(ref bool __result) { if (BlocksInput) { __result = true; } } private void ActionChanged(object subject, InputActionChange change) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0082: 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_0087: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) if (changing || suspending) { return; } if ((int)change == 0 && BlocksInput) { InputAction val = (InputAction)((subject is InputAction) ? subject : null); if (val != null) { Suspend(val); goto IL_007e; } } if ((int)change == 2 && BlocksInput) { InputActionMap val2 = (InputActionMap)((subject is InputActionMap) ? subject : null); if (val2 != null) { Enumerator<InputAction> enumerator = val2.actions.GetEnumerator(); try { while (enumerator.MoveNext()) { InputAction current = enumerator.Current; Suspend(current); } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } goto IL_007e; IL_007e: if ((int)change == 8 || (int)change == 0 || (int)change == 2) { nextDiscover = 0f; } } private void Tick() { TickInputMode(); Keyboard current = Keyboard.current; BindingSlot bindingSlot = captureSlot; if (bindingSlot == null || !bindingSlot.Entry.Removed) { BindingSlot bindingSlot2 = candidate; if (bindingSlot2 == null || !bindingSlot2.Entry.Removed) { goto IL_004f; } } CancelCapture(); status = "That mod's controls were removed; saved settings were kept."; goto IL_004f; IL_004f: if (open && current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame && operation == null && Time.unscaledTime >= cancelHandledUntil) { if (captureAt > 0f) { CancelCapture(); cancelHandledUntil = Time.unscaledTime + 0.1f; } else { CloseControlsMenu(); } } if (open && (Object)(object)nativeRoot != (Object)null && !nativeRoot.activeInHierarchy) { DetachControls(); } if (captureAt > 0f && Time.unscaledTime >= captureAt) { captureAt = 0f; StartCapture(); } if (!open && suspended.Count > 0 && Time.unscaledTime >= releaseAt) { RestoreActions(); } if (Time.unscaledTime >= nextDiscover && operation == null && captureAt == 0f && candidate == null) { nextDiscover = Time.unscaledTime + 1f; Discover(); RefreshControlsTab(); } RefreshNativeEditor(); TickController(); } private void Suspend(InputAction action) { if (!action.enabled) { return; } if (NativeEditorActive && !controllerMode) { InputActionMap actionMap = action.actionMap; if (((actionMap != null) ? actionMap.name : null) == "Menu") { return; } InputActionMap actionMap2 = action.actionMap; if (((actionMap2 != null) ? actionMap2.name : null) == "UI") { return; } } suspended.Add(action); suspending = true; try { action.Disable(); } finally { suspending = false; } } private void RestoreActions() { suspending = true; try { InputAction[]