Decompiled source of MoreInputs v1.0.5

moreinputs.dll

Decompiled 3 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LLGUI;
using LLHandlers;
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("more inputs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("more inputs")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5c20c053-f176-4014-ae15-bc82b0e60192")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
namespace moreinputs;

[BepInPlugin("us.wallace.plugins.llb.moreinputs", "more inputs Plug-In", "1.0.5.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<bool> controllerMode;

	private void Awake()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Patching effects settings...");
		controllerMode = ((BaseUnityPlugin)this).Config.Bind<bool>("moreInputs", "setControllerMode", false, (ConfigDescription)null);
		Harmony val = new Harmony("us.wallace.plugins.llb.moreinputs");
		val.PatchAll(typeof(EConfigurablesPatch));
		val.PatchAll(typeof(GetInputActionNamePatch));
		val.PatchAll(typeof(PCBBCFNFDJLPatch));
		val.PatchAll(typeof(SetMovementKeysPatch));
	}

	private void Start()
	{
	}
}
internal class EConfigurablesPatch
{
	[HarmonyPatch(typeof(InputAction), "EConfigurables")]
	[HarmonyPostfix]
	private static void EConfigurables_Postfix(ref IEnumerable<int> __result)
	{
		if (Plugin.controllerMode.Value)
		{
			__result = new List<int>
			{
				InputAction.SWING,
				InputAction.JUMP,
				InputAction.BUNT,
				InputAction.GRAB,
				InputAction.TAUNT,
				InputAction.EXPRESS_UP,
				InputAction.EXPRESS_DOWN,
				InputAction.EXPRESS_LEFT,
				InputAction.EXPRESS_RIGHT,
				InputAction.PAUSE,
				InputAction.OK,
				InputAction.MENU,
				InputAction.BACK,
				InputAction.MENU_UP,
				InputAction.MENU_DOWN,
				InputAction.MENU_LEFT,
				InputAction.MENU_RIGHT,
				InputAction.SHLEFT,
				InputAction.SHRIGHT
			};
		}
		else
		{
			__result = new List<int>
			{
				InputAction.UP,
				InputAction.DOWN,
				InputAction.LEFT,
				InputAction.RIGHT,
				InputAction.SWING,
				InputAction.JUMP,
				InputAction.BUNT,
				InputAction.GRAB,
				InputAction.TAUNT,
				InputAction.EXPRESS_UP,
				InputAction.EXPRESS_DOWN,
				InputAction.EXPRESS_LEFT,
				InputAction.EXPRESS_RIGHT,
				InputAction.PAUSE,
				InputAction.OK,
				InputAction.MENU,
				InputAction.BACK,
				InputAction.MENU_UP,
				InputAction.MENU_DOWN,
				InputAction.MENU_LEFT,
				InputAction.MENU_RIGHT,
				InputAction.SHLEFT,
				InputAction.SHRIGHT
			};
		}
	}
}
internal class GetInputActionNamePatch
{
	[HarmonyPrefix]
	[HarmonyPatch(typeof(TextHandler), "GetInputActionName")]
	public static bool GetInputActionName_Prefix(ref string __result, int inputAction)
	{
		string text = string.Empty;
		if (inputAction == InputAction.UP)
		{
			text = "Up";
		}
		if (inputAction == InputAction.DOWN)
		{
			text = "Down";
		}
		if (inputAction == InputAction.LEFT)
		{
			text = "Left";
		}
		if (inputAction == InputAction.RIGHT)
		{
			text = "Right";
		}
		if (inputAction == InputAction.SWING)
		{
			text = "Swing";
		}
		if (inputAction == InputAction.JUMP)
		{
			text = "Jump";
		}
		if (inputAction == InputAction.BUNT)
		{
			text = "Bunt";
		}
		if (inputAction == InputAction.GRAB)
		{
			text = "Grab";
		}
		if (inputAction == InputAction.TAUNT)
		{
			text = "Taunt";
		}
		if (inputAction == InputAction.PAUSE)
		{
			text = "Pause";
		}
		if (inputAction == InputAction.MENU)
		{
			text = "Ready";
		}
		if (inputAction == InputAction.OK)
		{
			text = "Ok";
		}
		if (inputAction == InputAction.BACK)
		{
			text = "Back";
		}
		if (inputAction == InputAction.SHLEFT)
		{
			text = "Skin L";
		}
		if (inputAction == InputAction.SHRIGHT)
		{
			text = "Skin R";
		}
		if (inputAction == InputAction.EXPRESS_UP)
		{
			text = "Nice";
		}
		if (inputAction == InputAction.EXPRESS_DOWN)
		{
			text = "Bring It";
		}
		if (inputAction == InputAction.EXPRESS_LEFT)
		{
			text = "Oops";
		}
		if (inputAction == InputAction.EXPRESS_RIGHT)
		{
			text = "Wow";
		}
		if (inputAction == InputAction.MENU_UP)
		{
			text = "M Up";
		}
		if (inputAction == InputAction.MENU_DOWN)
		{
			text = "M Down";
		}
		if (inputAction == InputAction.MENU_LEFT)
		{
			text = "M Left";
		}
		if (inputAction == InputAction.MENU_RIGHT)
		{
			text = "M Right";
		}
		if (text == string.Empty)
		{
			__result = "???";
			return true;
		}
		__result = TextHandler.Get(text.ToUpperInvariant() ?? "", new string[0]);
		return false;
	}
}
internal class PCBBCFNFDJLPatch
{
	[HarmonyPatch(typeof(HGFCCNMEEEF), "PCBBCFNFDJL")]
	[HarmonyPrefix]
	private static bool PCBBCFNFDJL_Prefix(HGFCCNMEEEF __instance)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		__instance.CNINOFJOLNP.posBarNext = new Vector3(-150f, 110f, -30f);
		__instance.CNINOFJOLNP.offsetBars = new Vector3(-5f, -20f, -30f);
		OptionsBar obj = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, string.Empty, (HNEDEAGADKO)0, (List<string>)null);
		((OptionsBarInputConfig)((obj is OptionsBarInputConfig) ? obj : null)).inputConfigBarType = (InputConfigBarType)1;
		foreach (int item in InputAction.EConfigurables())
		{
			string inputActionName = TextHandler.GetInputActionName(item);
			OptionsBar obj2 = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, inputActionName, (HNEDEAGADKO)400, (List<string>)null);
			((OptionsBarInputConfig)((obj2 is OptionsBarInputConfig) ? obj2 : null)).inputAction = item;
			if (item == InputAction.BUNT || item == InputAction.GRAB || item == InputAction.JUMP || item == InputAction.TAUNT || item == InputAction.SWING)
			{
				OptionsBar obj3 = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, string.Empty, (HNEDEAGADKO)400, (List<string>)null);
				OptionsBarInputConfig val = (OptionsBarInputConfig)(object)((obj3 is OptionsBarInputConfig) ? obj3 : null);
				val.inputAction = item;
				val.altInput = true;
			}
			if (item == InputAction.UP || item == InputAction.DOWN || item == InputAction.LEFT || item == InputAction.RIGHT)
			{
				OptionsBar obj4 = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, string.Empty, (HNEDEAGADKO)400, (List<string>)null);
				OptionsBarInputConfig val2 = (OptionsBarInputConfig)(object)((obj4 is OptionsBarInputConfig) ? obj4 : null);
				val2.inputAction = item;
				val2.altInput = true;
			}
		}
		OptionsBar obj5 = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, string.Empty, (HNEDEAGADKO)0, (List<string>)null);
		((OptionsBarInputConfig)((obj5 is OptionsBarInputConfig) ? obj5 : null)).inputConfigBarType = (InputConfigBarType)2;
		OptionsBar obj6 = __instance.CNINOFJOLNP.AddBar((OptionsBarType)4, string.Empty, (HNEDEAGADKO)0, (List<string>)null);
		((OptionsBarInputConfig)((obj6 is OptionsBarInputConfig) ? obj6 : null)).inputConfigBarType = (InputConfigBarType)3;
		return false;
	}
}
internal class SetMovementKeysPatch
{
	[HarmonyPatch(typeof(InputHandler), "SetMovementKeys")]
	[HarmonyPrefix]
	public static bool SetMovementKeys_Prefix(MovementKeys mk)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		KeyCode[] movementKeys = InputHandler.GetMovementKeys(mk);
		if (movementKeys == null)
		{
			return true;
		}
		int[] array = new int[4]
		{
			InputAction.LEFT,
			InputAction.RIGHT,
			InputAction.UP,
			InputAction.DOWN
		};
		return false;
	}
}
internal class UpdateLooksPatch
{
	[HarmonyPatch(typeof(InputConfigElement), "UpdateLooks")]
	[HarmonyPrefix]
	public static bool UpdateLooks_Prefix(InputConfigElement __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_0028: Expected I4, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Invalid comparison between Unknown and I4
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		InputConfigBarType inputConfigBarType = __instance.inputConfigBarType;
		InputConfigBarType val = inputConfigBarType;
		switch ((int)val)
		{
		case 0:
		{
			int inputAction = __instance.inputAction;
			__instance.SetText(InputHandler.GetControlName(__instance.inputConfigController, inputAction, __instance.altInput));
			if (((LLClickable)__instance.button).CanClick() != __instance.inputConfigController.DJFKIGINECC)
			{
				((LLClickable)__instance.button).SetActive(__instance.inputConfigController.DJFKIGINECC);
				((LLClickable)__instance.button).OnHoverOut(-1);
			}
			break;
		}
		case 1:
			__instance.SetText(__instance.inputConfigController.KMBILNDIDKK);
			__instance.button.colDisabled = OptionsBarInputConfig.HEADER_COLOR;
			((LLClickable)__instance.button).SetActive(false);
			break;
		case 2:
			if (__instance.inputConfigController.DJFKIGINECC)
			{
				__instance.SetTextCode("OPTIONS_BT_SAVE");
			}
			else
			{
				__instance.SetTextCode("OPTIONS_BT_CHANGE");
			}
			break;
		case 3:
			if (__instance.inputConfigController.DJFKIGINECC)
			{
				__instance.SetTextCode("OPTIONS_BT_CANCEL");
			}
			else
			{
				__instance.SetTextCode("BT_USE_DEFAULTS");
			}
			break;
		case 4:
			if ((int)__instance.inputConfigController.NNGJKLIIDNI > 0)
			{
				((LLClickable)__instance.button).SetActive(false);
				((LLControl)__instance.button).visible = false;
			}
			else
			{
				MovementKeys movementKeys = InputHandler.movementKeys;
				__instance.SetTextCode("OPTIONS_MOVEMENT_" + ((object)(MovementKeys)(ref movementKeys)).ToString());
				((LLClickable)__instance.button).SetActive(__instance.inputConfigController.DJFKIGINECC);
			}
			break;
		case 5:
			__instance.SetText(string.Empty);
			((LLClickable)__instance.button).SetActive(false);
			break;
		}
		return false;
	}
}
internal class OptionsBarInputConfigAddControllerPatch
{
	[HarmonyPatch(typeof(OptionsBarInputConfig), "AddController")]
	[HarmonyPrefix]
	public static bool AddController_Prefix(OptionsBarInputConfig __instance, JBKFDDKLDDG inputConfigController)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Invalid comparison between Unknown and I4
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Invalid comparison between Unknown and I4
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		if (__instance.inputElements.Count >= 5)
		{
			return false;
		}
		Transform transform = Object.Instantiate<GameObject>(__instance.pfOptionsBarInputConfigButton).transform;
		transform.SetParent(((Component)((OptionsBar)__instance).imBar).transform, false);
		transform.localScale = Vector3.one;
		LLButton component = ((Component)transform).GetComponent<LLButton>();
		((LLControl)component).Init();
		component.SetFontSize(TextHandler.GetFontSize("MENU_SETTING"));
		((LLClickable)component).ignoreMouseHover = !((Controller)(ref inputConfigController.GDEMBCKIDMA)).IncludesMouse();
		if ((int)__instance.inputConfigBarType == 4 && (int)inputConfigController.NNGJKLIIDNI > 0)
		{
			((LLClickable)component).SetActive(false);
		}
		__instance.inputElements.Add(new InputConfigElement(component, inputConfigController, __instance.inputAction, __instance.altInput, __instance.inputConfigBarType));
		__instance.UpdateBar();
		__instance.UpdateButton(inputConfigController);
		return false;
	}
}