Decompiled source of Rebinds Mod v0.1.16
BepInEx/plugins/FateRebind/ZombieGhost.Rebind.dll
Decompiled a day 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.Reflection.Emit; 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 Cleverous.Prodigy; using Cleverous.Prodigy.Input; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Tableflip; 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.16.0")] [assembly: AssemblyInformationalVersion("0.1.16")] [assembly: AssemblyProduct("ZombieGhost.Rebind")] [assembly: AssemblyTitle("ZombieGhost.Rebind")] [assembly: AssemblyVersion("0.1.16.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(); } } [BepInPlugin("zombieghost.rebind", "FATE Rebind", "0.1.16")] public sealed class RebindPlugin : BaseUnityPlugin { private sealed class ZoomRoute { internal int Direction; internal ButtonControl[] Buttons; } private sealed class ControllerRowView { internal GameObject Marker; internal Outline Primary; internal Outline Secondary; internal Toggle Toggle; internal EditorOption Option; } private sealed class BindingRow { internal string Label; internal string Category; internal string Owner; internal string OwnerName; internal BindingSlot[] Inputs; internal EditorOption Option; internal bool IsOption => Option != EditorOption.None; } 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 wheelZoomEnabled = true; private bool invertCameraX; private bool invertCameraY; private static readonly FieldRef<ProdigyCamera, Vector3> ZoomTarget = AccessTools.FieldRefAccess<ProdigyCamera, Vector3>("targetZoomAmount"); private static readonly FieldRef<ProdigyCamera, Vector3> ZoomMinimum = AccessTools.FieldRefAccess<ProdigyCamera, Vector3>("camMinZoom"); private static readonly FieldRef<ProdigyCamera, Vector3> ZoomMaximum = AccessTools.FieldRefAccess<ProdigyCamera, Vector3>("camMaxZoom"); private static readonly FieldRef<ProdigyCamera, IAgent> ZoomFollow = AccessTools.FieldRefAccess<ProdigyCamera, IAgent>("m_follow"); private InputAction zoomAction; private ZoomRoute[] zoomRoutes = Array.Empty<ZoomRoute>(); private bool zoomRoutesDirty = true; private int zoomWheelFrame = -1; 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 void LoadCameraOptions() { wheelZoomEnabled = ReadOption(EditorOption.WheelZoom); invertCameraX = ReadOption(EditorOption.InvertCameraX); invertCameraY = ReadOption(EditorOption.InvertCameraY); } private bool ReadOption(EditorOption option) { if (!store.TryGet(EditorPreferencePolicy.Key(option), out var path)) { return EditorPreferencePolicy.Default(option); } return path == "1"; } private bool OptionValue(EditorOption option) { return option switch { EditorOption.InvertCameraX => invertCameraX, EditorOption.WheelZoom => wheelZoomEnabled, EditorOption.SwapSticks => swapControllerSticks, _ => invertCameraY, }; } private void AssignOption(EditorOption option, bool value) { switch (option) { case EditorOption.WheelZoom: wheelZoomEnabled = value; break; case EditorOption.InvertCameraX: invertCameraX = value; break; case EditorOption.InvertCameraY: invertCameraY = value; break; } } private void SetEditorOption(EditorOption option, bool value) { switch (option) { case EditorOption.SwapSticks: SetSwapSticks(value); return; case EditorOption.None: return; } if (OptionValue(option) == value) { return; } string key = EditorPreferencePolicy.Key(option); bool value2 = OptionValue(option); string path; bool flag = store.TryGet(key, out path); try { store.Set(key, value ? "1" : "0"); store.Save(); AssignOption(option, value); status = ((option != EditorOption.WheelZoom) ? "Camera axis preference saved." : (value ? "Wheel zoom on. Zoom bindings are hidden." : "Wheel zoom off. Assign zoom buttons under Camera.")); } catch (Exception ex) { if (flag) { store.Set(key, path); } else { store.Remove(key); } AssignOption(option, value2); status = "Could not save camera option: " + ex.Message; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } zoomRoutesDirty = true; nativeSignature = (controllerSignature = null); } private void InstallCameraAxisHooks() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.PropertyGetter(typeof(InputBroker), "CameraRotateInputValue"), (HarmonyMethod)null, new HarmonyMethod(typeof(RebindPlugin), "CameraHorizontalAxis", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.PropertyGetter(typeof(InputBroker), "CameraZoomInputValue"), (HarmonyMethod)null, new HarmonyMethod(typeof(RebindPlugin), "CameraVerticalAxis", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void CameraHorizontalAxis(InputBroker __instance, ref float __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 if (instance != null) { __result = EditorPreferencePolicy.Axis(__result, (int)__instance.LocalInputBehavior == 0, horizontal: true, instance.invertCameraX); } } private static void CameraVerticalAxis(InputBroker __instance, ref float __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 if (instance != null) { __result = EditorPreferencePolicy.Axis(__result, (int)__instance.LocalInputBehavior == 0, horizontal: false, instance.invertCameraY); } } private void InstallZoomBindings() { //IL_002d: 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_004e: Expected O, but got Unknown //IL_004e: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(ProdigyCamera), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RebindPlugin), "ApplyNormalizedZoom", (Type[])null), new HarmonyMethod(typeof(RebindPlugin), "RewriteZoomKeyGate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ProdigyCamera), "OnCamZoomInput", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RebindPlugin), "AllowNativeZoomEvent", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"REBIND_ZOOM_INSTALLED: directional wheel and consistent keyboard/mouse zoom."); } private static IEnumerable<CodeInstruction> RewriteZoomKeyGate(IEnumerable<CodeInstruction> instructions) { return ZoomKeyGate.Rewrite(instructions, AccessTools.Method(typeof(Input), "GetKey", new Type[1] { typeof(KeyCode) }, (Type[])null), AccessTools.Method(typeof(RebindPlugin), "DisableNativeHeldZoom", (Type[])null, (Type[])null)); } private static bool DisableNativeHeldZoom(KeyCode unused) { return false; } private static bool AllowNativeZoomEvent() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 InputBroker val = SingletonBehaviour<InputBroker>.Instance; if (!((Object)(object)val == (Object)null)) { return (int)val.LocalInputBehavior != 1; } return true; } private static bool NativeZoom(InputAction action) { if (((action != null) ? action.name : null) == "CameraZoom") { InputActionMap actionMap = action.actionMap; return ((actionMap != null) ? actionMap.name : null) == "CharacterInputs"; } return false; } private void PrepareZoomRoutes(InputAction action) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references) if (action == zoomAction && !zoomRoutesDirty) { return; } zoomAction = action; List<ZoomRoute> list = new List<ZoomRoute>(); Enumerator<InputBinding> enumerator = action.bindings.GetEnumerator(); try { while (enumerator.MoveNext()) { InputBinding current = enumerator.Current; int num = ZoomInputPolicy.Direction(((InputBinding)(ref current)).name); if (((InputBinding)(ref current)).isComposite || num == 0) { continue; } string text = ZoomInputPolicy.CanonicalWheel(((InputBinding)(ref current)).effectivePath, ((InputBinding)(ref current)).name); if (!BindingPresentation.IsMouseKeyboardPath(text) || string.IsNullOrEmpty(text) || ZoomInputPolicy.WheelPath(text)) { continue; } InputControlList<InputControl> val = InputSystem.FindControls(text); try { ButtonControl[] array = (from c in ((IEnumerable)(object)val).OfType<ButtonControl>() where ((InputControl)c).device is Keyboard || ((InputControl)c).device is Mouse select c).ToArray(); if (array.Length != 0) { list.Add(new ZoomRoute { Direction = num, Buttons = array }); } } finally { ((IDisposable)val/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } zoomRoutes = list.ToArray(); zoomRoutesDirty = false; } private static void ApplyNormalizedZoom(ProdigyCamera __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) RebindPlugin rebindPlugin = instance; if (rebindPlugin == null || BlocksInput || InputBlocker.AnyBlockingUiMenuIsOpen || InventoryUI.IsDraggingItem) { return; } InputBroker val = SingletonBehaviour<InputBroker>.Instance; if ((Object)(object)val == (Object)null || (int)val.LocalInputBehavior != 1) { return; } ProdigyControls inputs = val.Inputs; object obj; if (inputs == null) { obj = null; } else { CharacterInputsActions characterInputs = inputs.CharacterInputs; obj = ((CharacterInputsActions)(ref characterInputs)).CameraZoom; } InputAction val2 = (InputAction)obj; if (val2 == null || !val2.enabled) { return; } IAgent val3 = ZoomFollow.Invoke(__instance); if (val3 == null || (Object)(object)val3.Vitals == (Object)null || val3.Vitals.IsDead || (Object)(object)val3.MyTransform == (Object)null) { return; } bool zoomIn = false; bool zoomOut = false; float wheelIn = 0f; float wheelOut = 0f; bool flag = rebindPlugin.zoomWheelFrame != Time.frameCount; rebindPlugin.zoomWheelFrame = Time.frameCount; if (rebindPlugin.wheelZoomEnabled) { Mouse current = Mouse.current; if (current != null && flag) { float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; wheelIn = ZoomInputPolicy.WheelAmount(y, up: true); wheelOut = ZoomInputPolicy.WheelAmount(y, up: false); } } else { rebindPlugin.PrepareZoomRoutes(val2); ZoomRoute[] array = rebindPlugin.zoomRoutes; foreach (ZoomRoute zoomRoute in array) { if (zoomRoute.Buttons == null) { continue; } ButtonControl[] buttons = zoomRoute.Buttons; for (int j = 0; j < buttons.Length; j++) { if (buttons[j].isPressed) { if (zoomRoute.Direction > 0) { zoomIn = true; } else { zoomOut = true; } break; } } } } float num = ZoomInputPolicy.Distance(zoomIn, zoomOut, wheelIn, wheelOut, Time.unscaledDeltaTime); if (num != 0f) { Vector3 val4 = ZoomTarget.Invoke(__instance); float z = ZoomMinimum.Invoke(__instance).z; float z2 = ZoomMaximum.Invoke(__instance).z; val4.z = Mathf.Clamp(val4.z + num, Math.Min(z, z2), Math.Max(z, z2)); ZoomTarget.Invoke(__instance) = val4; } } 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: 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 + "|" + invertCameraX + "|" + invertCameraY + "|" + 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.IsOption) ? (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 { Option = entry.Option }; 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.IsOption) { controllerRowView.Toggle = ControllerCheckbox((Transform)(object)val, entry.Option, operation == null && captureAt == 0f && candidate == null); 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_00f2: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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(OptionValue(controllerRowView.Option)); } 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].IsOption) { EditorOption option = controllerRows[controllerIndex].Option; SetEditorOption(option, !OptionValue(option)); 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_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: 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_0429: 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].IsOption) { int num2 = ((val.x > 0.55f) ? 1 : ((val.x < -0.55f) ? (-1) : 0)); if (num2 != 0 && num2 != swapAxisDirection) { SetEditorOption(controllerRows[controllerIndex].Option, 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].IsOption) { SetEditorOption(controllerRows[controllerIndex].Option, EditorPreferencePolicy.Default(controllerRows[controllerIndex].Option)); } 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, EditorOption option, bool idle = true) { //IL_0054: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Box(parent, option.ToString() + " 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(OptionValue(option)); ((Selectable)obj2).interactable = idle; ((UnityEvent<bool>)(object)obj2.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value) { SetEditorOption(option, value); }); 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 static BindingRow OptionRow(string label, EditorOption option, string category) { return new BindingRow { Label = label, Option = option, Category = category, Owner = "game", Inputs = Array.Empty<BindingSlot>() }; } private BindingRow[] VisibleRows() { if (!controllerMode) { return new BindingRow[1] { OptionRow("Use scroll wheel for zoom", EditorOption.WheelZoom, "Camera options") }.Concat(BindingRows()).ToArray(); } return new BindingRow[3] { OptionRow("Swap sticks", EditorOption.SwapSticks, "Controller options"), OptionRow("Invert camera left/right", EditorOption.InvertCameraX, "Controller options"), OptionRow("Invert camera up/down", EditorOption.InvertCameraY, "Controller options") }.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) { bool flag = slot != null && NativeZoom(slot.Action) && ZoomInputPolicy.WheelPath(slot.Path); string value = ((slot == null) ? "Not provided" : ((string.IsNullOrEmpty(slot.Path) || flag) ? "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 && !flag && !string.IsNullOrEmpty(slot.Path); } private void RefreshNativeEditor(bool force = false) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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 + "|" + wheelZoomEnabled + "|" + 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; TextMeshProUGUI val4 = Caption((Transform)(object)val3, entry.Label, 0.035f, 0f, 0.32f, 1f); ((Graphic)val4).color = new Color(0.91f, 0.87f, 0.79f); if (entry.IsOption) { ((TMP_Text)val4).rectTransform.anchorMax = new Vector2(0.65f, 1f); ControllerCheckbox((Transform)(object)val3, entry.Option, flag); continue; } 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 (NativeZoom(slot.Action) && slot.Group != "Controller") { val.WithControlsExcluding("<Mouse>/scroll").WithControlsExcluding("<Mouse>/scroll/*"); } 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(IsEditableMous