Decompiled source of Coop KBnM v1.0.3
CoopKBnM.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using InControl; using Mono.Cecil.Cil; using MonoMod.Cil; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CoopKBnM")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CoopKBnM")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("825bc8e2-2faf-496c-803c-3f3e31eba1a0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CoopKBnM; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("kleirof.etg.coopkbnm", "Coop KB&M", "1.0.3")] public class CoopKBnMModule : BaseUnityPlugin { public const string GUID = "kleirof.etg.coopkbnm"; public const string NAME = "Coop KB&M"; public const string VERSION = "1.0.3"; public const string TEXT_COLOR = "#FFFFCC"; public static bool isCoopViewLoaded; public static bool secondWindowActive; private static GameObject rawInputObject; public void Start() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown OptionsManager.OnStart(); ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart); rawInputObject = new GameObject("Raw Input Object"); Object.DontDestroyOnLoad((Object)(object)rawInputObject); rawInputObject.AddComponent<RawInputHandler>(); if (Chainloader.PluginInfos.TryGetValue("kleirof.etg.coopview", out var _)) { isCoopViewLoaded = true; } Harmony val = new Harmony("kleirof.etg.coopkbnm"); val.PatchAll(); } private void Update() { if ((Object)(object)OptionsManager.masterControlsOptionsScrollablePanelObject == (Object)null && !OptionsManager.isInitializingOptions) { ((MonoBehaviour)this).StartCoroutine(OptionsManager.InitializeOptions()); } } public static void Log(string text, string color = "FFFFFF") { ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false); } public void GMStart(GameManager g) { Log("Coop KB&M v1.0.3 started successfully.", "#FFFFCC"); } } public static class CoopKBnMPatches { [HarmonyPatch(typeof(FoyerCharacterSelectFlag), "Update")] public class FoyerCharacterSelectFlagUpdatePatchClass { [HarmonyILManipulator] public static void FoyerCharacterSelectFlagUpdatePatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Brfalse) }), 2)) { crs.EmitCall<FoyerCharacterSelectFlagUpdatePatchClass>("FoyerCharacterSelectFlagUpdatePatchCall"); } } private static bool FoyerCharacterSelectFlagUpdatePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(BraveInput), "AssignActionsDevice")] public class AssignActionsDevicePatchClass { [HarmonyILManipulator] public static void AssignActionsDevicePatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") }), 2)) { crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<AssignActionsDevicePatchClass>("AssignActionsDevicePatchCall"); } } private static bool AssignActionsDevicePatchCall(bool orig, BraveInput self) { return orig && ((PlayerActionSet)self.m_activeGungeonActions).Device != null; } } [HarmonyPatch(typeof(PlayerAction), "UpdateBindings")] public class UpdateBindingsPatchClass { [HarmonyILManipulator] public static void UpdateBindingsPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Brfalse) }), 2)) { crs.Emit(OpCodes.Ldloca_S, (byte)11); crs.Emit(OpCodes.Ldloc_S, (byte)8); crs.Emit(OpCodes.Ldarg_1); crs.Emit(OpCodes.Ldarg_2); crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<UpdateBindingsPatchClass>("UpdateBindingsPatchCall_1"); } if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BindingSource>(x, "GetValue") })) { crs.Emit(OpCodes.Ldloc_S, (byte)8); crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<UpdateBindingsPatchClass>("UpdateBindingsPatchCall_2"); } } private static bool UpdateBindingsPatchCall_1(bool orig, ref float value, BindingSource bindingSource, ulong updateTick, float deltaTime, PlayerAction self) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (orig && GameManager.HasInstance && (int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false) && bindingSource is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && (self.Name == "Cancel" || self.Name == "Pause" || self.Name == "Menu Select" || self.Name == "Select Left" || self.Name == "Select Right" || self.Name == "Select Up" || self.Name == "Select Down")) { value = bindingSource.GetValue(self.Device); ((OneAxisInputControl)self).UpdateWithValue(value, updateTick, deltaTime); } return orig; } private static float UpdateBindingsPatchCall_2(float orig, BindingSource bindingSource, PlayerAction self) { if (bindingSource is KeyBindingSource && OptionsManager.restrictKeyboardInputPort) { return RawInputHandler.GetValue((KeyBindingSource)(object)((bindingSource is KeyBindingSource) ? bindingSource : null), self.Device, RawInputHandler.IsFirstKeyboard(self)); } if (bindingSource is MouseBindingSource) { if (OptionsManager.restrictMouseInputPort) { return RawInputHandler.GetValue((MouseBindingSource)(object)((bindingSource is MouseBindingSource) ? bindingSource : null), self.Device, RawInputHandler.IsFirstMouse(self)); } return RawInputHandler.GetValue((MouseBindingSource)(object)((bindingSource is MouseBindingSource) ? bindingSource : null), self.Device); } return orig; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "DetermineAvailableOptions")] public class DetermineAvailableOptionsPatchClass { [HarmonyPrefix] public static bool DetermineAvailableOptionsPrefix(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 256) { if ((int)val == 257) { List<string> list = (((int)GameManager.Options.CurrentLanguage == 11) ? new List<string> { "鼠标 1", "鼠标 2" } : new List<string> { "Mouse 1", "Mouse 2" }); __instance.labelOptions = list.ToArray(); } } else { List<string> list2 = (((int)GameManager.Options.CurrentLanguage == 11) ? new List<string> { "键盘 1", "键盘 2" } : new List<string> { "Keyboard 1", "Keyboard 2" }); __instance.labelOptions = list2.ToArray(); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleLeftRightArrowValueChanged")] public class HandleLeftRightArrowValueChangedPatchClass { [HarmonyPostfix] public static void HandleLeftRightArrowValueChangedPostfix(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 256) { if ((int)val == 257) { OptionsManager.currentPlayerOneMousePort = __instance.m_selectedIndex; ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); Debug.Log((object)$"Coop KBnM: Current player two keyboard port set to {__instance.m_selectedIndex}"); if (!OptionsManager.isInitializingOptions) { float normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerOneMouseSensitivity; OptionsManager.normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerTwoMouseSensitivity; OptionsManager.normalizedPlayerTwoMouseSensitivity = normalizedPlayerOneMouseSensitivity; } if ((Object)(object)OptionsManager.playerOneMouseSensitivityPanelObject != (Object)null) { ((Component)OptionsManager.playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = OptionsManager.normalizedPlayerOneMouseSensitivity; } if ((Object)(object)OptionsManager.playerTwoMouseSensitivityPanelObject != (Object)null) { ((Component)OptionsManager.playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = OptionsManager.normalizedPlayerTwoMouseSensitivity; } RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * OptionsManager.normalizedPlayerOneMouseSensitivity + 0.4f, 0.4f, 4.4f); RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * OptionsManager.normalizedPlayerTwoMouseSensitivity + 0.4f, 0.4f, 4.4f); } } else { OptionsManager.currentPlayerOneKeyboardPort = __instance.m_selectedIndex; ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); Debug.Log((object)$"Coop KBnM: Current player one keyboard port set to {__instance.m_selectedIndex}"); } } [HarmonyILManipulator] public static void HandleLeftRightArrowValueChangedPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameOptions>(x, "set_CurrentPreferredFullscreenMode") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<HandleLeftRightArrowValueChangedPatchClass>("HandleLeftRightArrowValueChangedPatchCall"); } } private static void HandleLeftRightArrowValueChangedPatchCall(BraveOptionsMenuItem self) { GameManager.Options.CurrentPreferredFullscreenMode = (PreferredFullscreenMode)((self.m_selectedIndex == 0) ? 1 : 2); } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleCheckboxValueChanged")] public class HandleCheckboxValueChangedPatchClass { [HarmonyPrefix] public static bool HandleCheckboxValueChangedPrefix(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val == 258) { bool flag = __instance.m_selectedIndex != 0; if (OptionsManager.isShareOneKeyboardMode != flag) { OptionsManager.isShareOneKeyboardMode = flag; Debug.Log((object)$"Coop KBnM: Is share one keyboard mode set to {flag}"); if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.SaveBindingData(saveSharingBindingData: false); OptionsManager.LoadBindingData(saveSharingBindingData: true); OptionsManager.RemoveDuplicateBindings(); } else { OptionsManager.SaveBindingData(saveSharingBindingData: true); OptionsManager.LoadBindingData(saveSharingBindingData: false); } OptionsManager.SaveBindingInfoToCachedOptions(); BraveInput.SaveBindingInfoToOptions(); GameOptions.Save(); } ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "HandleFillbarValueChanged")] public class HandleFillbarValueChangedPatchClass { [HarmonyPrefix] public static bool HandleFillbarValueChangedPrefix(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 BraveOptionsOptionType optionType = __instance.optionType; BraveOptionsOptionType val = optionType; if ((int)val != 259) { if ((int)val == 260) { RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * __instance.m_actualFillbarValue + 0.4f, 0.4f, 4.4f); OptionsManager.normalizedPlayerTwoMouseSensitivity = __instance.m_actualFillbarValue; Debug.Log((object)$"Coop KBnM: Normalized player two mouse sensitivity set to {__instance.m_actualFillbarValue}"); } } else { RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * __instance.m_actualFillbarValue + 0.4f, 0.4f, 4.4f); OptionsManager.normalizedPlayerOneMouseSensitivity = __instance.m_actualFillbarValue; Debug.Log((object)$"Coop KBnM: Normalized player one mouse sensitivity set to {__instance.m_actualFillbarValue}"); } return true; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "DoSelectedAction")] public class DoSelectedActionPatchClass { [HarmonyILManipulator] public static void DoSelectedActionPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStsfld<FullOptionsMenuController>(x, "CurrentBindingPlayerTargetIndex") })) { crs.Emit(OpCodes.Ldarg_0); crs.EmitCall<DoSelectedActionPatchClass>("DoSelectedActionPatchCall_1"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 4)) { crs.EmitCall<DoSelectedActionPatchClass>("DoSelectedActionPatchCall_2"); } } private static int DoSelectedActionPatchCall_1(int orig, BraveOptionsMenuItem self) { return (!(((Object)self).name == "EditKeyboardBindingsButtonPanel")) ? 1 : 0; } private static int DoSelectedActionPatchCall_2(int orig) { return 1; } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "InitializeKeyboard")] public class InitializeKeyboardPatchClass { [HarmonyILManipulator] public static void InitializeKeyboardPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameManager>(x, "get_CurrentGameType") })) { val.EmitCall<InitializeKeyboardPatchClass>("InitializeKeyboardPatchCall"); } } private static int InitializeKeyboardPatchCall(int orig) { return 0; } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "EnterAssignmentMode")] public class EnterAssignmentModePatchClass { [HarmonyPostfix] public static void EnterAssignmentModePostfix(KeyboardBindingMenuOption __instance, bool isAlternateKey) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) GungeonActions activeActions = __instance.GetBestInputInstance().ActiveActions; PlayerAction actionFromType = activeActions.GetActionFromType(__instance.ActionType); BindingListenOptions bindingOptions = actionFromType.ListenOptions; bindingOptions.OnBindingFound = delegate(PlayerAction action, BindingSource binding) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) if (binding == (BindingSource)new KeyBindingSource((Key[])(object)new Key[1] { (Key)13 })) { action.StopListeningForBinding(); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ClearModalKeyBindingDialog((dfControl)null, (dfControlEventArgs)null); return false; } if (binding == (BindingSource)new KeyBindingSource((Key[])(object)new Key[1] { (Key)78 })) { action.StopListeningForBinding(); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ClearModalKeyBindingDialog((dfControl)null, (dfControlEventArgs)null); return false; } if (__instance.IsControllerMode && binding is KeyBindingSource) { return false; } if (binding is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && BraveInput.m_instances.Count > 1 && action.Owner == BraveInput.GetInstanceForPlayer(1).ActiveActions && ((PlayerActionSet)BraveInput.GetInstanceForPlayer(0).ActiveActions).HasBinding(binding)) { return false; } if (binding is KeyBindingSource && OptionsManager.isShareOneKeyboardMode && BraveInput.m_instances.Count > 1 && action.Owner == BraveInput.GetInstanceForPlayer(0).ActiveActions && ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).HasBinding(binding)) { int count = ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).Actions.Count; for (int i = 0; i < count; i++) { ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).Actions[i].HardRemoveBinding(binding); } } action.StopListeningForBinding(); if (!__instance.m_parentOptionsMenu.ActionIsMultibindable(__instance.ActionType, activeActions)) { __instance.m_parentOptionsMenu.ClearBindingFromAllControls(FullOptionsMenuController.CurrentBindingPlayerTargetIndex, binding); } action.SetBindingOfTypeByNumber(binding, binding.BindingSourceType, isAlternateKey ? 1 : 0, bindingOptions.OnBindingAdded); ((Component)GameUIRoot.Instance.PauseMenuPanel).GetComponent<PauseMenuController>().OptionsMenu.ToggleKeyBindingDialogState(binding); __instance.Initialize(); return false; }; } } [HarmonyPatch(typeof(GungeonActions), "ReinitializeDefaults")] public class ReinitializeDefaultsPatchClass { [HarmonyPostfix] public static void ReinitializeDefaultsPostfix() { if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.RemoveDuplicateBindings(); } } } [HarmonyPatch(typeof(GungeonActions), "InitializeSwappedTriggersPreset")] public class InitializeSwappedTriggersPresetPatchClass { [HarmonyPostfix] public static void InitializeSwappedTriggersPresetPostfix() { if (OptionsManager.isShareOneKeyboardMode) { OptionsManager.RemoveDuplicateBindings(); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class Get_MousePositionPatchClass { [HarmonyPrefix] public static bool Get_MousePositionPrefix(ref Vector3 __result) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) __result = Vector2.op_Implicit(RawInputHandler.firstMousePosition); return false; } } [HarmonyPatch(typeof(MouseBindingSource), "PositiveScrollWheelIsActive")] public class PositiveScrollWheelIsActivePatchClass { [HarmonyPrefix] public static bool PositiveScrollWheelIsActivePrefix(float threshold, ref bool __result) { float num = Mathf.Max(0f, (float)RawInputHandler.GetPublicWheel() * MouseBindingSource.ScaleZ); __result = num > threshold; return false; } } [HarmonyPatch(typeof(MouseBindingSource), "NegativeScrollWheelIsActive")] public class NegativeScrollWheelIsActivePatchClass { [HarmonyPrefix] public static bool NegativeScrollWheelIsActivePrefix(float threshold, ref bool __result) { float num = Mathf.Min((float)RawInputHandler.GetPublicWheel() * MouseBindingSource.ScaleZ, 0f); __result = num < 0f - threshold; return false; } } [HarmonyPatch(typeof(Input), "GetAxis")] public class GetAxisPatchClass { [HarmonyPrefix] public static bool GetAxisPrefix(string axisName, ref float __result) { if (axisName == "Mouse ScrollWheel") { __result = RawInputHandler.GetPublicSmoothWheelValue(); return false; } return true; } } [HarmonyPatch(typeof(GameCursorController), "DrawCursor")] public class DrawCursorPatchClass { [HarmonyILManipulator] public static void DrawCursorPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<GameCursorController>(x, "get_showMouseCursor") })) { val.EmitCall<DrawCursorPatchClass>("DrawCursorPatchCall_1"); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<BraveInput>(x, "IsKeyboardAndMouse") })) { val.EmitCall<DrawCursorPatchClass>("DrawCursorPatchCall_2"); } } [HarmonyPostfix] public static void DrawCursorPostfix(GameCursorController __instance) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041c: 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) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Invalid comparison between Unknown and I4 //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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) //IL_00ef: 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_010a: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Invalid comparison between Unknown and I4 //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033a: 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_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) if (!GameManager.HasInstance) { return; } Texture2D val = __instance.normalCursor; int currentCursorIndex = GameManager.Options.CurrentCursorIndex; if (currentCursorIndex >= 0 && currentCursorIndex < __instance.cursors.Length) { val = __instance.cursors[currentCursorIndex]; } if (!GameCursorController.showMouseCursor || !GameManager.HasInstance || (int)GameManager.Instance.CurrentGameType != 1) { return; } if (!CoopKBnMModule.isCoopViewLoaded || !CoopKBnMModule.secondWindowActive) { if (RawInputHandler.ShowPublicCursor) { Vector2 firstMousePosition = RawInputHandler.firstMousePosition; firstMousePosition.y = (float)Screen.height - firstMousePosition.y; Vector2 val2 = new Vector2((float)((Texture)val).width, (float)((Texture)val).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(firstMousePosition.x + 0.5f - val2.x / 2f, firstMousePosition.y + 0.5f - val2.y / 2f, val2.x, val2.y); if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { Graphics.DrawTexture(val3, (Texture)(object)val, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(0.402f, 0.111f, 0.32f)); } else { Graphics.DrawTexture(val3, (Texture)(object)val); } return; } if (RawInputHandler.ShowPlayerOneMouseCursor) { Vector2 val4 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((OptionsManager.currentPlayerOneMousePort != 1) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition)); val4.y = (float)Screen.height - val4.y; Vector2 val5 = new Vector2((float)((Texture)val).width, (float)((Texture)val).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)); Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(val4.x + 0.5f - val5.x / 2f, val4.y + 0.5f - val5.y / 2f, val5.x, val5.y); Graphics.DrawTexture(val6, (Texture)(object)val); } if (RawInputHandler.ShowPlayerTwoMouseCursor) { Vector2 val7 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((OptionsManager.currentPlayerOneMousePort != 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition)); val7.y = (float)Screen.height - val7.y; Vector2 val8 = new Vector2((float)((Texture)val).width, (float)((Texture)val).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)); Rect val9 = default(Rect); ((Rect)(ref val9))..ctor(val7.x + 0.5f - val8.x / 2f, val7.y + 0.5f - val8.y / 2f, val8.x, val8.y); Graphics.DrawTexture(val9, (Texture)(object)val, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(0.402f, 0.111f, 0.32f)); } } else if (RawInputHandler.ShowPublicCursor) { Vector2 firstMousePosition2 = RawInputHandler.firstMousePosition; firstMousePosition2.y = (float)Screen.height - firstMousePosition2.y; Vector2 val10 = new Vector2((float)((Texture)val).width, (float)((Texture)val).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)); Rect val11 = default(Rect); ((Rect)(ref val11))..ctor(firstMousePosition2.x + 0.5f - val10.x / 2f, firstMousePosition2.y + 0.5f - val10.y / 2f, val10.x, val10.y); if ((int)GameManager.Instance.CurrentGameType == 1 && !BraveInput.GetInstanceForPlayer(0).IsKeyboardAndMouse(false) && BraveInput.GetInstanceForPlayer(1).IsKeyboardAndMouse(false)) { Graphics.DrawTexture(val11, (Texture)(object)val, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(0.402f, 0.111f, 0.32f)); } else { Graphics.DrawTexture(val11, (Texture)(object)val); } } else if ((RawInputHandler.ShowPlayerOneMouseCursor && OptionsManager.isPrimaryPlayerOnMainCamera) || (RawInputHandler.ShowPlayerTwoMouseCursor && !OptionsManager.isPrimaryPlayerOnMainCamera)) { Vector2 val12 = ((!OptionsManager.restrictMouseInputPort) ? RawInputHandler.firstMousePosition : ((!OptionsManager.isPrimaryPlayerOnMainCamera) ? ((OptionsManager.currentPlayerOneMousePort != 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition) : ((OptionsManager.currentPlayerOneMousePort == 0) ? RawInputHandler.firstMousePosition : RawInputHandler.secondMousePosition))); val12.y = (float)Screen.height - val12.y; Vector2 val13 = new Vector2((float)((Texture)val).width, (float)((Texture)val).height) * (float)((!((Object)(object)Pixelator.Instance != (Object)null)) ? 3 : ((int)Pixelator.Instance.ScaleTileScale)); Rect val14 = default(Rect); ((Rect)(ref val14))..ctor(val12.x + 0.5f - val13.x / 2f, val12.y + 0.5f - val13.y / 2f, val13.x, val13.y); if (!OptionsManager.isPrimaryPlayerOnMainCamera) { Graphics.DrawTexture(val14, (Texture)(object)val, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(0.402f, 0.111f, 0.32f)); } else { Graphics.DrawTexture(val14, (Texture)(object)val); } } } private static bool DrawCursorPatchCall_1(bool orig) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 return orig && (!GameManager.HasInstance || (int)GameManager.Instance.CurrentGameType != 1); } private static bool DrawCursorPatchCall_2(bool orig) { return orig && !OptionsManager.restrictMouseInputPort; } } [HarmonyPatch(typeof(PlayerController), "DetermineAimPointInWorld")] public class DetermineAimPointInWorldPatchClass { [HarmonyILManipulator] public static void DetermineAimPointInWorldPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "x") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<DetermineAimPointInWorldPatchClass>("DetermineAimPointInWorldPatchCall_1"); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "y") })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<DetermineAimPointInWorldPatchClass>("DetermineAimPointInWorldPatchCall_2"); } } private static float DetermineAimPointInWorldPatchCall_1(float orig, PlayerController self) { if (OptionsManager.restrictMouseInputPort) { if (self.IsPrimaryPlayer) { if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.firstMousePosition.x; } return RawInputHandler.secondMousePosition.x; } if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.secondMousePosition.x; } return RawInputHandler.firstMousePosition.x; } return orig; } private static float DetermineAimPointInWorldPatchCall_2(float orig, PlayerController self) { if (OptionsManager.restrictMouseInputPort) { if (self.IsPrimaryPlayer) { if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.firstMousePosition.y; } return RawInputHandler.secondMousePosition.y; } if (OptionsManager.currentPlayerOneMousePort == 0) { return RawInputHandler.secondMousePosition.y; } return RawInputHandler.firstMousePosition.y; } return orig; } } [HarmonyPatch(typeof(FullOptionsMenuController), "ToggleToPanel")] public class ToggleToPanelPatchClass { [HarmonyPostfix] public static void ToggleToPanelPostfix(FullOptionsMenuController __instance, dfScrollPanel targetPanel, bool doFocus) { OptionsManager.fullOptionsMenuController = __instance; if ((Object)(object)targetPanel == (Object)(object)__instance.TabControls) { int i; for (i = 0; i < ((dfControl)targetPanel).Controls.Count && !((dfControl)targetPanel).Controls[i].CanFocus; i++) { } if (((dfControl)targetPanel).Controls.Count > 0 && i < ((dfControl)targetPanel).Controls.Count) { ((Component)__instance.PrimaryCancelButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)__instance.PrimaryConfirmButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)__instance.PrimaryResetDefaultsButton).GetComponent<UIKeyControls>().down = ((dfControl)targetPanel).Controls[i]; ((Component)((dfControl)targetPanel).Controls[i]).GetComponent<BraveOptionsMenuItem>().up = (dfControl)(object)__instance.PrimaryConfirmButton; ((dfControl)targetPanel).Controls[i].Focus(true); } } } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "Awake")] public class BraveOptionsMenuItemAwakePatchClass { [HarmonyPostfix] public static void BraveOptionsMenuItemAwake_Post(BraveOptionsMenuItem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)__instance.optionType == 8) { __instance.labelOptions = new string[2] { "Borderless", "Windowed" }; } } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "GetIndexFromFullscreenMode")] public class GetIndexFromFullscreenModePatchClass { [HarmonyPrefix] public static bool GetIndexFromFullscreenModePrefix(PreferredFullscreenMode fMode, ref int __result) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 __result = (((int)fMode == 2) ? 1 : 0); return false; } } [HarmonyPatch(typeof(BraveOptionsMenuItem), "Update")] public class BraveOptionsMenuItemUpdatePatchClass { [HarmonyILManipulator] public static void BraveOptionsMenuItemUpdatePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameOptions>(x, "get_CurrentPreferredFullscreenMode") })) { val.EmitCall<BraveOptionsMenuItemUpdatePatchClass>("BraveOptionsMenuItemUpdatePatchCall"); } } private static PreferredFullscreenMode BraveOptionsMenuItemUpdatePatchCall(PreferredFullscreenMode orig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return (PreferredFullscreenMode)0; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class Set_CurrentVisualPresetPatchClass { [HarmonyILManipulator] public static void Set_CurrentVisualPresetPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ILCursor crs = new ILCursor(ctx); if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<GameOptions>(x, "m_visualPresetMode") }), 3)) { crs.EmitCall<Set_CurrentVisualPresetPatchClass>("Set_CurrentVisualPresetPatchCall"); } } private static VisualPresetMode Set_CurrentVisualPresetPatchCall(VisualPresetMode orig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return (VisualPresetMode)1; } } [HarmonyPatch(typeof(dfInputManager), "Update")] public class DfInputManagerUpdatePatchClass { [HarmonyILManipulator] public static void DfInputManagerUpdatePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: 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) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 3) })) { val.Emit(OpCodes.Ldloca_S, (byte)3); val.Emit(OpCodes.Ldloc_2); val.EmitCall<DfInputManagerUpdatePatchClass>("DfInputManagerUpdatePatchCall"); } } private static void DfInputManagerUpdatePatchCall(ref bool orig, Vector2 vector) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 orig = ((Object)(object)BraveInput.SecondaryPlayerInstance != (Object)null && BraveInput.SecondaryPlayerInstance.ActiveActions != null && ((int)((PlayerActionSet)BraveInput.SecondaryPlayerInstance.ActiveActions).LastInputType == 3 || ((int)((PlayerActionSet)BraveInput.SecondaryPlayerInstance.ActiveActions).LastInputType == 2 && ((Vector2)(ref vector)).magnitude > float.Epsilon))) || (int)((PlayerActionSet)BraveInput.PrimaryPlayerInstance.ActiveActions).LastInputType == 3 || ((int)((PlayerActionSet)BraveInput.PrimaryPlayerInstance.ActiveActions).LastInputType == 2 && ((Vector2)(ref vector)).magnitude > float.Epsilon) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0); } } [HarmonyPatch(typeof(KeyboardBindingMenuOption), "GetBestInputInstance")] public class KeyboardBindingMenuOptionGetBestInputInstancePatchClass { [HarmonyILManipulator] public static void KeyboardBindingMenuOptionGetBestInputInstancePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<Foyer>(x, "DoMainMenu") })) { val.EmitCall<KeyboardBindingMenuOptionGetBestInputInstancePatchClass>("KeyboardBindingMenuOptionGetBestInputInstancePatchCall"); } } private static bool KeyboardBindingMenuOptionGetBestInputInstancePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(GameOptions), "GetBestInputInstance")] public class GameOptionsGetBestInputInstancePatchClass { [HarmonyILManipulator] public static void GameOptionsGetBestInputInstancePatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<Foyer>(x, "DoMainMenu") })) { val.EmitCall<GameOptionsGetBestInputInstancePatchClass>("GameOptionsGetBestInputInstancePatchCall"); } } private static bool GameOptionsGetBestInputInstancePatchCall(bool orig) { return false; } } [HarmonyPatch(typeof(BraveInput), "CheckForActionInitialization")] public class CheckForActionInitializationPatchClass { [HarmonyILManipulator] public static void CheckForActionInitializationPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<GameManager>(x, "PreventGameManagerExistence") })) { val.EmitCall<CheckForActionInitializationPatchClass>("CheckForActionInitializationPatchCall_1"); } val.Index = 0; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) })) { val.Emit(OpCodes.Ldarg_0); val.EmitCall<CheckForActionInitializationPatchClass>("CheckForActionInitializationPatchCall_2"); } } private static bool CheckForActionInitializationPatchCall_1(bool orig) { return true; } private static int CheckForActionInitializationPatchCall_2(int orig, BraveInput self) { return (!GameManager.PreventGameManagerExistence && (!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || self.m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || self.m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "SaveBindingInfoToOptions")] public class SaveBindingInfoToOptionsPatchClass { [HarmonyILManipulator] public static void SaveBindingInfoToOptionsPatch(ILContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(ctx); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Equality") })) { val.EmitCall<SaveBindingInfoToOptionsPatchClass>("SaveBindingInfoToOptionsPatchCall"); } } private static bool SaveBindingInfoToOptionsPatchCall(bool orig) { if (orig) { for (int i = 0; i < BraveInput.m_instances.Count; i++) { if (BraveInput.m_instances[i].m_playerID == 0) { GameManager.Options.playerOneBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } else { GameManager.Options.playerTwoBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } } } return orig; } } [HarmonyPatch(typeof(FullOptionsMenuController), "CloseAndApplyChanges")] public class CloseAndApplyChangesPatchClass { [HarmonyPostfix] public static void CloseAndApplyChangesPostfix() { CoopKBnMPreferences.SavePreferences(); } } [HarmonyPatch(typeof(FullOptionsMenuController), "CloseAndRevertChanges")] public class CloseAndRevertChangesPatchClass { [HarmonyPostfix] public static void CloseAndRevertChangesPostfix() { CoopKBnMPreferences.SavePreferences(); } } [HarmonyPatch(typeof(PlayerActionSet), "Load")] public class LoadPatchClass { [HarmonyPostfix] public static void LoadPostfix() { ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.DelayedRemoveDuplicateBindingsCrt()); } } [HarmonyPatch(typeof(GameManager), "HandleDeviceShift")] public class HandleDeviceShiftPatchClass { [HarmonyPostfix] public static void HandleDeviceShiftPostfix() { ((MonoBehaviour)GameManager.Instance).StartCoroutine(OptionsManager.ReassignKeyboardAndMouseCrt()); } } [HarmonyPatch(typeof(BraveInput), "ForceLoadBindingInfoFromOptions")] public class ForceLoadBindingInfoFromOptionsPatchClass { [HarmonyILManipulator] public static void ForceLoadBindingInfoFromOptionsPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld<GameManager>(x, "PreventGameManagerExistence") })) { crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_1"); } crs.Index = 0; if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") })) { crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_2"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 2)) { crs.Emit(OpCodes.Ldloc_0); crs.EmitCall<ForceLoadBindingInfoFromOptionsPatchClass>("ForceLoadBindingInfoFromOptionsPatchCall_3"); } } private static bool ForceLoadBindingInfoFromOptionsPatchCall_1(bool orig) { return true; } private static int ForceLoadBindingInfoFromOptionsPatchCall_2(int orig) { return 0; } private static int ForceLoadBindingInfoFromOptionsPatchCall_3(int orig, int i) { return (!GameManager.PreventGameManagerExistence && (!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || BraveInput.m_instances[i].m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || BraveInput.m_instances[i].m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "ReassignAllControllers")] public class ReassignAllControllersPatchClass { [HarmonyILManipulator] public static void ReassignAllControllersPatch(ILContext ctx) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) ILCursor crs = new ILCursor(ctx); if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Equality") })) { crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_1"); } crs.Index = 0; if (crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<BraveInput>(x, "m_playerID") })) { crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_2"); } crs.Index = 0; if (TheNthTime(() => crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0) }), 4)) { crs.Emit(OpCodes.Ldloc_S, (byte)4); crs.EmitCall<ReassignAllControllersPatchClass>("ReassignAllControllersPatchCall_3"); } } private static bool ReassignAllControllersPatchCall_1(bool orig) { return true; } private static int ReassignAllControllersPatchCall_2(int orig) { return 0; } private static int ReassignAllControllersPatchCall_3(int orig, int i) { return ((!((Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) || BraveInput.m_instances[i].m_playerID != 0) && (!((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null) || BraveInput.m_instances[i].m_playerID != GameManager.Instance.PrimaryPlayer.PlayerIDX)) ? 1 : 0; } } [HarmonyPatch(typeof(BraveInput), "SavePlayerlessBindingsToOptions")] public class SavePlayerlessBindingsToOptionsPatchClass { [HarmonyPostfix] public static void SavePlayerlessBindingsToOptionsPostfix() { if (BraveInput.m_instances.Count > 1 && BraveInput.m_instances[1].m_playerID == 1) { GameManager.Options.playerTwoBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[1].ActiveActions).Save(); } } } public static void EmitCall<T>(this ILCursor iLCursor, string methodName, Type[] parameters = null, Type[] generics = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) MethodInfo methodInfo = AccessTools.Method(typeof(T), methodName, parameters, generics); iLCursor.Emit(OpCodes.Call, (MethodBase)methodInfo); } public static T GetFieldInEnumerator<T>(object instance, string fieldNamePattern) { return (T)instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => f.Name.Contains("$" + fieldNamePattern) || f.Name.Contains("<" + fieldNamePattern + ">")) .GetValue(instance); } public static bool TheNthTime(this Func<bool> predict, int n = 1) { for (int i = 0; i < n; i++) { if (!predict()) { return false; } } return true; } } public class CoopKBnMPreferences { public class PreferencesData : ScriptableObject { public bool isShareOneKeyboardMode; public int currentPlayerOneKeyboardPort; public int currentPlayerOneMousePort; public float normalizedPlayerOneMouseSensitivity; public float normalizedPlayerTwoMouseSensitivity; public string sharingBindingData; public string nonSharingBindingData; public PreferencesData() { isShareOneKeyboardMode = OptionsManager.isShareOneKeyboardMode; currentPlayerOneKeyboardPort = OptionsManager.currentPlayerOneKeyboardPort; currentPlayerOneMousePort = OptionsManager.currentPlayerOneMousePort; normalizedPlayerOneMouseSensitivity = OptionsManager.normalizedPlayerOneMouseSensitivity; normalizedPlayerTwoMouseSensitivity = OptionsManager.normalizedPlayerTwoMouseSensitivity; sharingBindingData = OptionsManager.sharingBindingData; nonSharingBindingData = OptionsManager.nonSharingBindingData; } } private const string fileName = "CoopKBnM_Preferences.txt"; public static void LoadPreferences() { if (File.Exists(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"))) { string text = File.ReadAllText(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt")); PreferencesData preferencesData = ScriptableObject.CreateInstance<PreferencesData>(); JsonUtility.FromJsonOverwrite(text, (object)preferencesData); OptionsManager.isShareOneKeyboardMode = preferencesData.isShareOneKeyboardMode; OptionsManager.currentPlayerOneKeyboardPort = preferencesData.currentPlayerOneKeyboardPort; OptionsManager.currentPlayerOneMousePort = preferencesData.currentPlayerOneMousePort; OptionsManager.normalizedPlayerOneMouseSensitivity = preferencesData.normalizedPlayerOneMouseSensitivity; OptionsManager.normalizedPlayerTwoMouseSensitivity = preferencesData.normalizedPlayerTwoMouseSensitivity; OptionsManager.sharingBindingData = preferencesData.sharingBindingData; OptionsManager.nonSharingBindingData = preferencesData.nonSharingBindingData; } else { SavePreferences(); } } public static void SavePreferences() { string value = JsonUtility.ToJson((object)ScriptableObject.CreateInstance<PreferencesData>(), true); if (File.Exists(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"))) { File.Delete(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt")); } using StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, "CoopKBnM_Preferences.txt"), append: true); streamWriter.WriteLine(value); } } internal static class KeyCodeMaps { public enum Keys { Modifiers = -65536, None = 0, Back = 8, Tab = 9, Clear = 12, Enter = 13, Shift = 16, Control = 17, Alt = 18, Pause = 19, Capital = 20, CapsLock = 20, Escape = 27, Space = 32, PageUp = 33, PageDown = 34, End = 35, Home = 36, Left = 37, Up = 38, Right = 39, Down = 40, Print = 42, PrintScreen = 44, Insert = 45, Delete = 46, D0 = 48, D1 = 49, D2 = 50, D3 = 51, D4 = 52, D5 = 53, D6 = 54, D7 = 55, D8 = 56, D9 = 57, A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90, NumPad0 = 96, NumPad1 = 97, NumPad2 = 98, NumPad3 = 99, NumPad4 = 100, NumPad5 = 101, NumPad6 = 102, NumPad7 = 103, NumPad8 = 104, NumPad9 = 105, Multiply = 106, Add = 107, Separator = 108, Subtract = 109, Decimal = 110, Divide = 111, F1 = 112, F2 = 113, F3 = 114, F4 = 115, F5 = 116, F6 = 117, F7 = 118, F8 = 119, F9 = 120, F10 = 121, F11 = 122, F12 = 123, F13 = 124, F14 = 125, F15 = 126, F16 = 127, F17 = 128, F18 = 129, F19 = 130, F20 = 131, F21 = 132, F22 = 133, F23 = 134, F24 = 135, NumLock = 144, Scroll = 145, OemSemicolon = 186, Oem1 = 186, Oemplus = 187, Oemcomma = 188, OemMinus = 189, OemPeriod = 190, OemQuestion = 191, Oem2 = 191, Oemtilde = 192, Oem3 = 192, OemOpenBrackets = 219, Oem4 = 219, OemPipe = 220, Oem5 = 220, OemCloseBrackets = 221, Oem6 = 221, OemQuotes = 222, Oem7 = 222, Oem8 = 223, OemBackslash = 226, KeyCode = 65535 } public static Dictionary<KeyCode, Keys> KeyCodeToKeysMap = new Dictionary<KeyCode, Keys> { { (KeyCode)97, Keys.A }, { (KeyCode)98, Keys.B }, { (KeyCode)99, Keys.C }, { (KeyCode)100, Keys.D }, { (KeyCode)101, Keys.E }, { (KeyCode)102, Keys.F }, { (KeyCode)103, Keys.G }, { (KeyCode)104, Keys.H }, { (KeyCode)105, Keys.I }, { (KeyCode)106, Keys.J }, { (KeyCode)107, Keys.K }, { (KeyCode)108, Keys.L }, { (KeyCode)109, Keys.M }, { (KeyCode)110, Keys.N }, { (KeyCode)111, Keys.O }, { (KeyCode)112, Keys.P }, { (KeyCode)113, Keys.Q }, { (KeyCode)114, Keys.R }, { (KeyCode)115, Keys.S }, { (KeyCode)116, Keys.T }, { (KeyCode)117, Keys.U }, { (KeyCode)118, Keys.V }, { (KeyCode)119, Keys.W }, { (KeyCode)120, Keys.X }, { (KeyCode)121, Keys.Y }, { (KeyCode)122, Keys.Z }, { (KeyCode)48, Keys.D0 }, { (KeyCode)49, Keys.D1 }, { (KeyCode)50, Keys.D2 }, { (KeyCode)51, Keys.D3 }, { (KeyCode)52, Keys.D4 }, { (KeyCode)53, Keys.D5 }, { (KeyCode)54, Keys.D6 }, { (KeyCode)55, Keys.D7 }, { (KeyCode)56, Keys.D8 }, { (KeyCode)57, Keys.D9 }, { (KeyCode)282, Keys.F1 }, { (KeyCode)283, Keys.F2 }, { (KeyCode)284, Keys.F3 }, { (KeyCode)285, Keys.F4 }, { (KeyCode)286, Keys.F5 }, { (KeyCode)287, Keys.F6 }, { (KeyCode)288, Keys.F7 }, { (KeyCode)289, Keys.F8 }, { (KeyCode)290, Keys.F9 }, { (KeyCode)291, Keys.F10 }, { (KeyCode)292, Keys.F11 }, { (KeyCode)293, Keys.F12 }, { (KeyCode)306, Keys.Control }, { (KeyCode)305, Keys.Control }, { (KeyCode)304, Keys.Shift }, { (KeyCode)303, Keys.Shift }, { (KeyCode)308, Keys.Alt }, { (KeyCode)307, Keys.Alt }, { (KeyCode)32, Keys.Space }, { (KeyCode)13, Keys.Enter }, { (KeyCode)8, Keys.Back }, { (KeyCode)27, Keys.Escape }, { (KeyCode)9, Keys.Tab }, { (KeyCode)301, Keys.Capital }, { (KeyCode)127, Keys.Delete }, { (KeyCode)277, Keys.Insert }, { (KeyCode)278, Keys.Home }, { (KeyCode)279, Keys.End }, { (KeyCode)280, Keys.PageUp }, { (KeyCode)281, Keys.PageDown }, { (KeyCode)273, Keys.Up }, { (KeyCode)274, Keys.Down }, { (KeyCode)276, Keys.Left }, { (KeyCode)275, Keys.Right }, { (KeyCode)59, Keys.OemSemicolon }, { (KeyCode)47, Keys.OemQuestion }, { (KeyCode)92, Keys.OemPipe }, { (KeyCode)91, Keys.OemOpenBrackets }, { (KeyCode)93, Keys.OemCloseBrackets }, { (KeyCode)39, Keys.OemQuotes }, { (KeyCode)96, Keys.Oemtilde }, { (KeyCode)45, Keys.OemMinus }, { (KeyCode)61, Keys.Oemplus }, { (KeyCode)44, Keys.Oemcomma }, { (KeyCode)46, Keys.OemPeriod }, { (KeyCode)256, Keys.NumPad0 }, { (KeyCode)257, Keys.NumPad1 }, { (KeyCode)258, Keys.NumPad2 }, { (KeyCode)259, Keys.NumPad3 }, { (KeyCode)260, Keys.NumPad4 }, { (KeyCode)261, Keys.NumPad5 }, { (KeyCode)262, Keys.NumPad6 }, { (KeyCode)263, Keys.NumPad7 }, { (KeyCode)264, Keys.NumPad8 }, { (KeyCode)265, Keys.NumPad9 }, { (KeyCode)267, Keys.Divide }, { (KeyCode)268, Keys.Multiply }, { (KeyCode)269, Keys.Subtract }, { (KeyCode)270, Keys.Add }, { (KeyCode)271, Keys.Enter }, { (KeyCode)266, Keys.Decimal }, { (KeyCode)316, Keys.PrintScreen }, { (KeyCode)302, Keys.Scroll }, { (KeyCode)19, Keys.Pause } }; public static Dictionary<KeyCode, string> KeyCodeToStringMap = new Dictionary<KeyCode, string> { { (KeyCode)97, "A" }, { (KeyCode)98, "B" }, { (KeyCode)99, "C" }, { (KeyCode)100, "D" }, { (KeyCode)101, "E" }, { (KeyCode)102, "F" }, { (KeyCode)103, "G" }, { (KeyCode)104, "H" }, { (KeyCode)105, "I" }, { (KeyCode)106, "J" }, { (KeyCode)107, "K" }, { (KeyCode)108, "L" }, { (KeyCode)109, "M" }, { (KeyCode)110, "N" }, { (KeyCode)111, "O" }, { (KeyCode)112, "P" }, { (KeyCode)113, "Q" }, { (KeyCode)114, "R" }, { (KeyCode)115, "S" }, { (KeyCode)116, "T" }, { (KeyCode)117, "U" }, { (KeyCode)118, "V" }, { (KeyCode)119, "W" }, { (KeyCode)120, "X" }, { (KeyCode)121, "Y" }, { (KeyCode)122, "Z" }, { (KeyCode)48, "0" }, { (KeyCode)49, "1" }, { (KeyCode)50, "2" }, { (KeyCode)51, "3" }, { (KeyCode)52, "4" }, { (KeyCode)53, "5" }, { (KeyCode)54, "6" }, { (KeyCode)55, "7" }, { (KeyCode)56, "8" }, { (KeyCode)57, "9" }, { (KeyCode)282, "F1" }, { (KeyCode)283, "F2" }, { (KeyCode)284, "F3" }, { (KeyCode)285, "F4" }, { (KeyCode)286, "F5" }, { (KeyCode)287, "F6" }, { (KeyCode)288, "F7" }, { (KeyCode)289, "F8" }, { (KeyCode)290, "F9" }, { (KeyCode)291, "F10" }, { (KeyCode)292, "F11" }, { (KeyCode)293, "F12" }, { (KeyCode)306, "Ctrl" }, { (KeyCode)305, "Ctrl" }, { (KeyCode)304, "Shift" }, { (KeyCode)303, "Shift" }, { (KeyCode)308, "Alt" }, { (KeyCode)307, "Alt" }, { (KeyCode)32, "Space" }, { (KeyCode)13, "Enter" }, { (KeyCode)8, "Backspace" }, { (KeyCode)27, "Escape" }, { (KeyCode)9, "Tab" }, { (KeyCode)301, "CapsLock" }, { (KeyCode)127, "Delete" }, { (KeyCode)277, "Insert" }, { (KeyCode)278, "Home" }, { (KeyCode)279, "End" }, { (KeyCode)280, "PageUp" }, { (KeyCode)281, "PageDown" }, { (KeyCode)273, "Up" }, { (KeyCode)274, "Down" }, { (KeyCode)276, "Left" }, { (KeyCode)275, "Right" }, { (KeyCode)59, ";" }, { (KeyCode)47, "/" }, { (KeyCode)92, "\\" }, { (KeyCode)91, "[" }, { (KeyCode)93, "]" }, { (KeyCode)39, "'" }, { (KeyCode)96, "`" }, { (KeyCode)45, "-" }, { (KeyCode)61, "=" }, { (KeyCode)44, "," }, { (KeyCode)46, "." }, { (KeyCode)256, "Num0" }, { (KeyCode)257, "Num1" }, { (KeyCode)258, "Num2" }, { (KeyCode)259, "Num3" }, { (KeyCode)260, "Num4" }, { (KeyCode)261, "Num5" }, { (KeyCode)262, "Num6" }, { (KeyCode)263, "Num7" }, { (KeyCode)264, "Num8" }, { (KeyCode)265, "Num9" }, { (KeyCode)267, "Num/" }, { (KeyCode)268, "Num*" }, { (KeyCode)269, "Num-" }, { (KeyCode)270, "Num+" }, { (KeyCode)271, "NumEnter" }, { (KeyCode)266, "Num." }, { (KeyCode)316, "PrintScreen" }, { (KeyCode)302, "Scroll" }, { (KeyCode)19, "Pause" } }; public static Dictionary<Keys, KeyCode> KeysToKeyCodeMap = new Dictionary<Keys, KeyCode> { { Keys.A, (KeyCode)97 }, { Keys.B, (KeyCode)98 }, { Keys.C, (KeyCode)99 }, { Keys.D, (KeyCode)100 }, { Keys.E, (KeyCode)101 }, { Keys.F, (KeyCode)102 }, { Keys.G, (KeyCode)103 }, { Keys.H, (KeyCode)104 }, { Keys.I, (KeyCode)105 }, { Keys.J, (KeyCode)106 }, { Keys.K, (KeyCode)107 }, { Keys.L, (KeyCode)108 }, { Keys.M, (KeyCode)109 }, { Keys.N, (KeyCode)110 }, { Keys.O, (KeyCode)111 }, { Keys.P, (KeyCode)112 }, { Keys.Q, (KeyCode)113 }, { Keys.R, (KeyCode)114 }, { Keys.S, (KeyCode)115 }, { Keys.T, (KeyCode)116 }, { Keys.U, (KeyCode)117 }, { Keys.V, (KeyCode)118 }, { Keys.W, (KeyCode)119 }, { Keys.X, (KeyCode)120 }, { Keys.Y, (KeyCode)121 }, { Keys.Z, (KeyCode)122 }, { Keys.D0, (KeyCode)48 }, { Keys.D1, (KeyCode)49 }, { Keys.D2, (KeyCode)50 }, { Keys.D3, (KeyCode)51 }, { Keys.D4, (KeyCode)52 }, { Keys.D5, (KeyCode)53 }, { Keys.D6, (KeyCode)54 }, { Keys.D7, (KeyCode)55 }, { Keys.D8, (KeyCode)56 }, { Keys.D9, (KeyCode)57 }, { Keys.F1, (KeyCode)282 }, { Keys.F2, (KeyCode)283 }, { Keys.F3, (KeyCode)284 }, { Keys.F4, (KeyCode)285 }, { Keys.F5, (KeyCode)286 }, { Keys.F6, (KeyCode)287 }, { Keys.F7, (KeyCode)288 }, { Keys.F8, (KeyCode)289 }, { Keys.F9, (KeyCode)290 }, { Keys.F10, (KeyCode)291 }, { Keys.F11, (KeyCode)292 }, { Keys.F12, (KeyCode)293 }, { Keys.Control, (KeyCode)306 }, { Keys.Shift, (KeyCode)304 }, { Keys.Alt, (KeyCode)308 }, { Keys.Space, (KeyCode)32 }, { Keys.Enter, (KeyCode)13 }, { Keys.Back, (KeyCode)8 }, { Keys.Escape, (KeyCode)27 }, { Keys.Tab, (KeyCode)9 }, { Keys.Capital, (KeyCode)301 }, { Keys.Delete, (KeyCode)127 }, { Keys.Insert, (KeyCode)277 }, { Keys.Home, (KeyCode)278 }, { Keys.End, (KeyCode)279 }, { Keys.PageUp, (KeyCode)280 }, { Keys.PageDown, (KeyCode)281 }, { Keys.Up, (KeyCode)273 }, { Keys.Down, (KeyCode)274 }, { Keys.Left, (KeyCode)276 }, { Keys.Right, (KeyCode)275 }, { Keys.OemSemicolon, (KeyCode)59 }, { Keys.OemQuestion, (KeyCode)47 }, { Keys.OemPipe, (KeyCode)92 }, { Keys.OemOpenBrackets, (KeyCode)91 }, { Keys.OemCloseBrackets, (KeyCode)93 }, { Keys.OemQuotes, (KeyCode)39 }, { Keys.Oemtilde, (KeyCode)96 }, { Keys.OemMinus, (KeyCode)45 }, { Keys.Oemplus, (KeyCode)61 }, { Keys.Oemcomma, (KeyCode)44 }, { Keys.OemPeriod, (KeyCode)46 }, { Keys.NumPad0, (KeyCode)256 }, { Keys.NumPad1, (KeyCode)257 }, { Keys.NumPad2, (KeyCode)258 }, { Keys.NumPad3, (KeyCode)259 }, { Keys.NumPad4, (KeyCode)260 }, { Keys.NumPad5, (KeyCode)261 }, { Keys.NumPad6, (KeyCode)262 }, { Keys.NumPad7, (KeyCode)263 }, { Keys.NumPad8, (KeyCode)264 }, { Keys.NumPad9, (KeyCode)265 }, { Keys.Divide, (KeyCode)267 }, { Keys.Multiply, (KeyCode)268 }, { Keys.Subtract, (KeyCode)269 }, { Keys.Add, (KeyCode)270 }, { Keys.Decimal, (KeyCode)266 }, { Keys.PrintScreen, (KeyCode)316 }, { Keys.Scroll, (KeyCode)302 }, { Keys.Pause, (KeyCode)19 } }; } public class OptionsManager { public enum BraveOptionsOptionType { PLAYER_ONE_KEYBOARD_PORT = 256, PLAYER_ONE_MOUSE_PORT, SHARE_ONE_KEYBOARD_MODE, PLAYER_ONE_MOUSE_SENSITIVITY, PLAYER_TWO_MOUSE_SENSITIVITY } internal static bool isInitializingOptions = false; internal static GameObject masterControlsOptionsScrollablePanelObject; private static GameObject optionsMenuPanelDaveObject; private static GameObject editKeyboardBindingsButtonPanelCopyObject; private static GameObject playerOneKeyboardPortArrowSelectorPanelObject; private static GameObject playerOneMousePortArrowSelectorPanelObject; private static GameObject shareOneKeyboardPanelObject; internal static GameObject playerOneMouseSensitivityPanelObject; internal static GameObject playerTwoMouseSensitivityPanelObject; private static GameObject systemMouseLabelPanelTipPanelObject; private static GameObject shareOneKeyBoardWarningPanelObject; public static bool restrictKeyboardInputPort = true; public static bool restrictMouseInputPort = true; public static bool isShareOneKeyboardMode = false; public static int currentPlayerOneKeyboardPort = 0; public static int currentPlayerOneMousePort = 0; public static float normalizedPlayerOneMouseSensitivity = 0.4f; public static float normalizedPlayerTwoMouseSensitivity = 0.4f; public static bool isPrimaryPlayerOnMainCamera; internal static FullOptionsMenuController fullOptionsMenuController; internal static string sharingBindingData = string.Empty; internal static string nonSharingBindingData = string.Empty; internal static void OnStart() { try { CoopKBnMPreferences.LoadPreferences(); } catch (Exception ex) { Debug.LogError((object)("Failed to load Coop View Preferences." + ex)); } RawInputHandler.playerOneMouseSensitivity = Mathf.Clamp(4f * normalizedPlayerOneMouseSensitivity + 0.4f, 0.4f, 4.4f); RawInputHandler.playerTwoMouseSensitivity = Mathf.Clamp(4f * normalizedPlayerTwoMouseSensitivity + 0.4f, 0.4f, 4.4f); } internal static IEnumerator InitializeOptions() { isInitializingOptions = true; while (true) { if ((Object)(object)optionsMenuPanelDaveObject == (Object)null) { optionsMenuPanelDaveObject = GameObject.Find("OptionsMenuPanelDave"); } if ((Object)(object)optionsMenuPanelDaveObject == (Object)null) { yield return null; continue; } FullOptionsMenuController fullOptionsMenuController = optionsMenuPanelDaveObject.GetComponent<FullOptionsMenuController>(); if ((Object)(object)fullOptionsMenuController == (Object)null) { yield return null; continue; } if (!fullOptionsMenuController.IsVisible) { yield return null; continue; } if ((Object)(object)masterControlsOptionsScrollablePanelObject == (Object)null) { masterControlsOptionsScrollablePanelObject = GameObject.Find("MasterControlsOptionsScrollablePanel"); } if ((Object)(object)masterControlsOptionsScrollablePanelObject != (Object)null) { break; } yield return null; } while ((Object)(object)editKeyboardBindingsButtonPanelCopyObject == (Object)null) { GameObject editKeyboardBindingsButtonPanelObject = GameObject.Find("EditKeyboardBindingsButtonPanel"); if ((Object)(object)editKeyboardBindingsButtonPanelObject != (Object)null) { GameObject origEditKeyboardBindingsButtonObject = ((Component)editKeyboardBindingsButtonPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/EditKeyboardBindingsButton")).gameObject; editKeyboardBindingsButtonPanelCopyObject = Object.Instantiate<GameObject>(editKeyboardBindingsButtonPanelObject, editKeyboardBindingsButtonPanelObject.transform.parent); ((Object)editKeyboardBindingsButtonPanelCopyObject).name = "EditKeyboardBindingsButtonPanelCopy"; GameObject editKeyboardBindingsButtonObject = ((Component)editKeyboardBindingsButtonPanelCopyObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/EditKeyboardBindingsButton")).gameObject; editKeyboardBindingsButtonObject.GetComponent<dfButton>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "2P Coop KB&M 编辑按键" : "2P Coop KB&M Edit Keyboard Bindings"); editKeyboardBindingsButtonObject.GetComponent<dfButton>().HoverTextColor = new Color32(byte.MaxValue, (byte)163, (byte)52, byte.MaxValue); origEditKeyboardBindingsButtonObject.GetComponent<dfButton>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 编辑按键" : "1P Coop KB&M Edit Keyboard Bindings"); origEditKeyboardBindingsButtonObject.GetComponent<dfButton>().HoverTextColor = new Color32(byte.MaxValue, (byte)163, (byte)52, byte.MaxValue); ((dfControl)editKeyboardBindingsButtonPanelObject.GetComponent<dfPanel>()).ZOrder = 4; ((dfControl)editKeyboardBindingsButtonPanelCopyObject.GetComponent<dfPanel>()).ZOrder = 10; } if ((Object)(object)editKeyboardBindingsButtonPanelCopyObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneKeyboardPortArrowSelectorPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject = GameObject.Find("ControllerTypeArrowSelectorPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject != (Object)null) { playerOneKeyboardPortArrowSelectorPanelObject = Object.Instantiate<GameObject>(controllerTypeArrowSelectorPanelObject, controllerTypeArrowSelectorPanelObject.transform.parent); ((Object)playerOneKeyboardPortArrowSelectorPanelObject).name = "PlayerOneKeyboardPortArrowSelectorPanel"; GameObject optionsArrowSelectorLabelObject = ((Component)playerOneKeyboardPortArrowSelectorPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/OptionsArrowSelectorLabel")).gameObject; optionsArrowSelectorLabelObject.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 键盘接口" : "1P Coop KB&M Keyboard Port"); playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)256; playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().DetermineAvailableOptions(); playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = currentPlayerOneKeyboardPort; playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneKeyboardPortArrowSelectorPanelObject.GetComponent<dfPanel>()).ZOrder = 4; } if ((Object)(object)playerOneKeyboardPortArrowSelectorPanelObject == (Object)null) { yield return null; } } while ((Object)(object)shareOneKeyboardPanelObject == (Object)null) { GameObject allowUnknownControllersObject = ((Component)masterControlsOptionsScrollablePanelObject.transform.Find("AllowUnknownControllers")).gameObject; if ((Object)(object)allowUnknownControllersObject != (Object)null) { shareOneKeyboardPanelObject = Object.Instantiate<GameObject>(allowUnknownControllersObject, allowUnknownControllersObject.transform.parent); ((Object)shareOneKeyboardPanelObject).name = "ShareOneKeyboard"; GameObject checkboxLabelObject = ((Component)shareOneKeyboardPanelObject.transform.Find("Panel/CheckboxLabel")).gameObject; shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = (isShareOneKeyboardMode ? 1 : 0); shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)258; shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); dfLabel label = checkboxLabelObject.GetComponent<dfLabel>(); Vector2 origSize = label.obtainRenderer().MeasureString(label.Text); label.Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "Coop KB&M 共享一个键盘" : "Coop KB&M Share One Keyboard"); Vector2 size = label.obtainRenderer().MeasureString(label.Text); GameObject panelObject = ((Component)shareOneKeyboardPanelObject.transform.Find("Panel")).gameObject; dfPanel panel = panelObject.GetComponent<dfPanel>(); Vector2 panelSize = ((dfControl)panel).Size; ((dfControl)panel).SuspendLayout(); ((dfControl)panel).Size = new Vector2(panelSize.x + size.x - origSize.x, panelSize.y); ((dfControl)panel).ResumeLayout(); ((dfControl)shareOneKeyboardPanelObject.GetComponent<dfPanel>()).ZOrder = 2; } if ((Object)(object)shareOneKeyboardPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneMousePortArrowSelectorPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject3 = GameObject.Find("ControllerTypeArrowSelectorPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject3 != (Object)null) { playerOneMousePortArrowSelectorPanelObject = Object.Instantiate<GameObject>(controllerTypeArrowSelectorPanelObject3, controllerTypeArrowSelectorPanelObject3.transform.parent); ((Object)playerOneMousePortArrowSelectorPanelObject).name = "PlayerOneMousePortArrowSelectorPanel"; GameObject optionsArrowSelectorLabelObject2 = ((Component)playerOneMousePortArrowSelectorPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/OptionsArrowSelectorLabel")).gameObject; optionsArrowSelectorLabelObject2.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 鼠标接口" : "1P Coop KB&M Mouse Port"); playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)257; playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().DetermineAvailableOptions(); playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().m_selectedIndex = currentPlayerOneMousePort; playerOneMousePortArrowSelectorPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneMousePortArrowSelectorPanelObject.GetComponent<dfPanel>()).ZOrder = 5; } if ((Object)(object)playerOneMousePortArrowSelectorPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerOneMouseSensitivityPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject4 = GameObject.Find("ControllerTypeArrowSelectorPanel"); GameObject screenShakeOptionPanelObject2 = GameObject.Find("ScreenShakeOptionPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject4 != (Object)null && (Object)(object)screenShakeOptionPanelObject2 != (Object)null) { playerOneMouseSensitivityPanelObject = Object.Instantiate<GameObject>(screenShakeOptionPanelObject2, controllerTypeArrowSelectorPanelObject4.transform.parent); ((Object)playerOneMouseSensitivityPanelObject).name = "PlayerOneMouseSensitivityPanel"; GameObject musicVolumeLabelObject2 = ((Component)playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeLabel")).gameObject; musicVolumeLabelObject2.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "1P Coop KB&M 鼠标灵敏度" : "1P Coop KB&M Mouse Sensitivity"); playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)259; ((Component)playerOneMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = normalizedPlayerOneMouseSensitivity; playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().m_actualFillbarValue = normalizedPlayerOneMouseSensitivity; playerOneMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerOneMouseSensitivityPanelObject.GetComponent<dfPanel>()).ZOrder = 7; } if ((Object)(object)playerOneMouseSensitivityPanelObject == (Object)null) { yield return null; } } while ((Object)(object)playerTwoMouseSensitivityPanelObject == (Object)null) { GameObject controllerTypeArrowSelectorPanelObject2 = GameObject.Find("ControllerTypeArrowSelectorPanel"); GameObject screenShakeOptionPanelObject = GameObject.Find("ScreenShakeOptionPanel"); if ((Object)(object)controllerTypeArrowSelectorPanelObject2 != (Object)null && (Object)(object)screenShakeOptionPanelObject != (Object)null) { playerTwoMouseSensitivityPanelObject = Object.Instantiate<GameObject>(screenShakeOptionPanelObject, controllerTypeArrowSelectorPanelObject2.transform.parent); ((Object)playerTwoMouseSensitivityPanelObject).name = "PlayerTwoMouseSensitivityPanel"; GameObject musicVolumeLabelObject = ((Component)playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeLabel")).gameObject; musicVolumeLabelObject.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "2P Coop KB&M 鼠标灵敏度" : "2P Coop KB&M Mouse Sensitivity"); playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().optionType = (BraveOptionsOptionType)260; ((Component)playerTwoMouseSensitivityPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/MusicVolumeProgressBar")).GetComponent<dfProgressBar>().Value = normalizedPlayerTwoMouseSensitivity; playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().m_actualFillbarValue = normalizedPlayerTwoMouseSensitivity; playerTwoMouseSensitivityPanelObject.GetComponent<BraveOptionsMenuItem>().HandleValueChanged(); ((dfControl)playerTwoMouseSensitivityPanelObject.GetComponent<dfPanel>()).ZOrder = 15; } if ((Object)(object)playerTwoMouseSensitivityPanelObject == (Object)null) { yield return null; } } while ((Object)(object)systemMouseLabelPanelTipPanelObject == (Object)null) { GameObject playerOneLabelPanelObject2 = GameObject.Find("PlayerOneLabelPanel"); if ((Object)(object)playerOneLabelPanelObject2 != (Object)null) { systemMouseLabelPanelTipPanelObject = Object.Instantiate<GameObject>(playerOneLabelPanelObject2, playerOneLabelPanelObject2.transform.parent); ((Object)systemMouseLabelPanelTipPanelObject).name = "SystemMouseLabelPanelTipPanel"; GameObject labelObject2 = ((Component)systemMouseLabelPanelTipPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/Label")).gameObject; labelObject2.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? ("提示:使用快捷键 " + RawInputHandler.shortcutKeyString + " \n来暂时启用系统光标") : ("Tip: Use shortcut key " + RawInputHandler.shortcutKeyString + " \nto temporarily enable the system cursor")); ((dfControl)labelObject2.GetComponent<dfLabel>()).Color = new Color32((byte)0, byte.MaxValue, (byte)0, byte.MaxValue); GameObject panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject2 = ((Component)systemMouseLabelPanelTipPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy")).gameObject; Vector3 position2 = panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject2.transform.localPosition; panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject2.transform.localPosition = new Vector3(position2.x, position2.y + 0.12f * (float)Camera.main.pixelWidth / 1920f, position2.z); ((dfControl)systemMouseLabelPanelTipPanelObject.GetComponent<dfPanel>()).ZOrder = 0; } if ((Object)(object)systemMouseLabelPanelTipPanelObject == (Object)null) { yield return null; } } while ((Object)(object)shareOneKeyBoardWarningPanelObject == (Object)null) { GameObject playerOneLabelPanelObject = GameObject.Find("PlayerOneLabelPanel"); if ((Object)(object)playerOneLabelPanelObject != (Object)null) { shareOneKeyBoardWarningPanelObject = Object.Instantiate<GameObject>(playerOneLabelPanelObject, playerOneLabelPanelObject.transform.parent); ((Object)shareOneKeyBoardWarningPanelObject).name = "ShareOneKeyBoardWarningPanel"; GameObject labelObject = ((Component)shareOneKeyBoardWarningPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy/Label")).gameObject; labelObject.GetComponent<dfLabel>().Text = (((int)GameManager.Options.CurrentLanguage == 11) ? "警告:开启“共享一个键盘”会让2P中与1P相同\n的按键绑定删除" : "Warning: Enabling 'Share One Keyboard' will cause \nthe same key binding as 1P to be deleted in 2P"); ((dfControl)labelObject.GetComponent<dfLabel>()).Color = new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue); GameObject panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject = ((Component)shareOneKeyBoardWarningPanelObject.transform.Find("PanelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasy")).gameObject; Vector3 position = panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject.transform.localPosition; panelEnsmallenerThatmakesDavesLifeHardandBrentsLifeEasyObject.transform.localPosition = new Vector3(position.x, position.y + 0.12f * (float)Camera.main.pixelWidth / 1920f, position.z); ((dfControl)shareOneKeyBoardWarningPanelObject.GetComponent<dfPanel>()).ZOrder = 3; } if ((Object)(object)shareOneKeyBoardWarningPanelObject == (Object)null) { yield return null; } } dfList<dfControl> controls = ((dfControl)GameObject.Find("MasterControlsOptionsScrollablePanel").GetComponent<dfScrollPanel>()).controls; int i = 0; while (i < controls.Count - 1) { int num; if (((dfControl)((Component)controls[i]).gameObject.GetComponent<dfPanel>()).CanFocus) { int l = i + 1; while (l < controls.Count - 1 && !((dfControl)((Component)controls[l]).gameObject.GetComponent<dfPanel>()).CanFocus) { num = l + 1; l = num; } if (l < controls.Count - 1) { ((Component)controls[i]).gameObject.GetComponent<BraveOptionsMenuItem>().down = controls[l]; } } num = i + 1; i = num; } int j = controls.Count - 1; while (j > 0) { int num; if (((dfControl)((Component)controls[j]).gameObject.GetComponent<dfPanel>()).CanFocus) { int k = j - 1; while (k > 0 && !((dfControl)((Component)controls[k]).gameObject.GetComponent<dfPanel>()).CanFocus) { num = k - 1; k = num; } if (k > 0) { ((Component)controls[j]).gameObject.GetComponent<BraveOptionsMenuItem>().up = controls[k]; } } num = j - 1; j = num; } int indexCanSelect = 0; while (indexCanSelect < controls.Count && !controls[indexCanSelect].CanFocus) { int num = indexCanSelect + 1; indexCanSelect = num; } if (controls.Count > 0 && indexCanSelect < controls.Count && ((dfControl)optionsMenuPanelDaveObject.GetComponent<FullOptionsMenuController>().TabControls).IsVisible) { GameObject.Find("ConfirmButton").GetComponent<UIKeyControls>().down = controls[indexCanSelect]; GameObject.Find("CancelButton").GetComponent<UIKeyControls>().down = controls[indexCanSelect]; GameObject.Find("ResetDefaultsButton").GetComponent<UIKeyControls>().down = controls[indexCanSelect]; ((Component)controls[indexCanSelect]).gameObject.GetComponent<BraveOptionsMenuItem>().up = (dfControl)(object)GameObject.Find("ConfirmButton").GetComponent<dfButton>(); controls[indexCanSelect].Focus(true); } BraveInput.GetInstanceForPlayer(1); yield return null; if ((Object)(object)shareOneKeyboardPanelObject != (Object)null) { shareOneKeyboardPanelObject.GetComponent<BraveOptionsMenuItem>().HandleCheckboxValueChanged(); } isInitializingOptions = false; } internal static void SaveBindingInfoToCachedOptions() { if ((Object)(object)fullOptionsMenuController == (Object)null || fullOptionsMenuController.cloneOptions == null || (Object)(object)GameManager.Instance.PrimaryPlayer == (Object)null) { return; } Debug.Log((object)"Saving Binding Info To Cached Options"); for (int i = 0; i < BraveInput.m_instances.Count; i++) { if (BraveInput.m_instances[i].m_playerID == GameManager.Instance.PrimaryPlayer.PlayerIDX) { fullOptionsMenuController.cloneOptions.playerOneBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } else { fullOptionsMenuController.cloneOptions.playerTwoBindingDataV2 = ((PlayerActionSet)BraveInput.m_instances[i].ActiveActions).Save(); } } } public static void RemoveDuplicateBindings() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 if (!isShareOneKeyboardMode || BraveInput.m_instances.Count <= 1) { return; } foreach (PlayerAction action in ((PlayerActionSet)BraveInput.GetInstanceForPlayer(0).ActiveActions).Actions) { foreach (BindingSource binding in action.Bindings) { if ((int)binding.DeviceClass != 1) { continue; } foreach (PlayerAction action2 in ((PlayerActionSet)BraveInput.GetInstanceForPlayer(1).ActiveActions).Actions) { action2.HardRemoveBinding(binding); } } } } internal static IEnumerator ReassignKeyboardAndMouseCrt() { yield return null; yield return null; yield return null; ReassignKeyboardAndMouse(); } internal static IEnumerator DelayedRemoveDuplicateBindingsCrt() { yield return null; yield return null; yield return null; if (isShareOneKeyboardMode) { RemoveDuplicateBindings(); } } internal static void ReassignKeyboardAndMouse() { Dictionary<int, int> playerIDtoDeviceIndexMap = GameManager.Options.PlayerIDtoDeviceIndexMap; if (playerIDtoDeviceIndexMap.Count <= 1 || BraveInput.m_instances.Count <= 1) { restrictKeyboardInputPort = false; restrictMouseInputPort = false; return; } if (InputManager.Devices.Count > 0 && (playerIDtoDeviceIndexMap[0] != InputManager.Devices.Count || playerIDtoDeviceIndexMap[1] != InputManager.Devices.Count)) { restrictKeyboardInputPort = false; restrictMouseInputPort = false; return; } restrictKeyboardInputPort = true; restrictMouseInputPort = true; if (isShareOneKeyboardMode) { restrictKeyboardInputPort = false; } BraveInput val = ((currentPlayerOneKeyboardPort != 0) ? BraveInput.m_instances[1] : BraveInput.m_instances[0]); BraveInput val2 = ((currentPlayerOneMousePort != 0) ? BraveInput.m_instances[1] : BraveInput.m_instances[0]); GungeonActions activeGungeonActions = val.m_activeGungeonActions; if (activeGungeonActions != RawInputHandler.firstKeyboardActionSet) { RawInputHandler.firstKeyboardActionSet = activeGungeonActions; } GungeonActions activeGungeonActions2 = val2.m_activeGungeonActions; if (activeGungeonActions2 != RawInputHandler.firstMouseActionSet) { RawInputHandler.firstMouseActionSet = activeGungeonActions2; } } internal static void SaveBindingData(bool saveSharingBindingData) { if (BraveInput.m_instances.Count > 1) { if (saveSharingBindingData) { sharingBindingData = ((PlayerActionSet)BraveInput.m_instances[1].ActiveActions).Save(); } else { nonSharingBindingData = ((PlayerActionSet)BraveInput.m_instances[1].ActiveActions).Save(); } } } internal static void LoadBindingData(bool saveSharingBindingData) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Invalid comparison between Unknown and I4 //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Invalid comparison between Unknown and I4 if (BraveInput.m_instances.Count <= 1) { return; } string text = (saveSharingBindingData ? sharingBindingData : nonSharingBindingData); if (text.Length <= 0) { return; } GungeonActions val = new GungeonActions(); GungeonActions activeActions = BraveInput.m_instances[1].ActiveActions; ((PlayerActionSet)val).Load(text, true); foreach (PlayerAction action in ((PlayerActionSet)activeActions).Actions) { List<BindingSource> list = new List<BindingSource>(); PlayerAction playerActionByName = ((PlayerActionSet)val).GetPlayerActionByName(action.Name); foreach (BindingSource binding in action.Bindings) { if ((int)binding.DeviceClass == 1 && !playerActionByName.HasBinding(binding)) { list.Add(binding); } } foreach (BindingSource item in list) { action.HardRemoveBinding(item); } foreach (BindingSource binding2 in playerActionByName.Bindings) { if ((int)binding2.DeviceClass == 1 && !action.HasBinding(binding2)) { binding2.BoundTo = null; action.AddBinding(binding2); } } } } } public class RawInputHandler : MonoBehaviour { public struct RAWINPUTHEADER { public uint dwType; public uint dwSize; public IntPtr hDevice; public IntPtr wParam; } public struct RAWMOUSE { public ushort usFlags; public ushort _; public ushort usButtonFlags; public short usButtonData; public uint ulRawButtons; public int lLastX; public int lLastY; public uint ulExtraInformation; } public struct RAWKEYBOARD { public ushort MakeCode; public ushort Flags; public ushort Reserved; public ushort VKey; public uint Message; public uint ExtraInformation; } public struct RAWINPUTDEVICE { public ushort usUsagePage; public ushort usUsage; public uint dwFlags; public IntPtr hwndTarget; } private struct WNDCLASS { public uint style; public WNDPROC lpfn; public int cbClsExtra; public int cbWndExtra; public IntPtr hInstance; public IntPtr hIcon; public IntPtr hCursor; public IntPtr hbrBackground; public IntPtr lpszMenuName; public string lpszClassName; } private delegate IntPtr WNDPROC(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); public class SmoothWheel { private float smoothScrollValue = 0f; private float gravity = 15f; private float sensitivity = 15f; public SmoothWheel(float gravity = 15f, float sensitivity = 15f) { this.gravity = gravity; this.sensitivity = sensitivity; } public float GetSmoothWheelValue(float rawScrollValue) { if (Mathf.Abs(rawScrollValue) > 10f) { smoothScrollValue = Mathf.Lerp(smoothScrollValue, rawScrollValue, Time.unscaledDeltaTime * sensitivity); } else { smoothScrollValue = Mathf.Lerp(smoothScrollValue, 0f, Time.unscaledDeltaTime * gravity); } if (Mathf.Abs(smoothScrollValue) < 3f) { smoothScrollValue = 0f; } smoothScrollValue = Mathf.Clamp(smoothScrollValue / 120f, -1f, 1f); return smoothScrollValue; } } public struct MouseStatus { public bool leftButtonDown; public bool leftButtonUp; public bool leftButton; public bool rightButtonDown; public bool rightButtonUp; public bool rightButton; public bool middleButtonDown; public bool middleButtonUp; public bool middleButton; public int rawX; public int rawY; public int wheel; } private const int WM_INPUT = 255; private const int RIM_INPUT = 268435459; priv