Decompiled source of InputNameFinder v1.1.1

InputNameFinder.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI.Phone;
using InputNameFinder.Phone;
using Reptile;
using Reptile.Phone;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("InputNameFinder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InputNameFinder")]
[assembly: AssemblyTitle("InputNameFinder")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace InputNameFinder
{
	public class InputDisplayMonitor : MonoBehaviour
	{
		private static readonly KeyCode[] _allKeyCodes = (KeyCode[])Enum.GetValues(typeof(KeyCode));

		private GameObject _canvasGo;

		private TextMeshProUGUI _label;

		public static InputDisplayMonitor Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void EnsureCreated()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_canvasGo != (Object)null))
			{
				Core instance = Core.Instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					UIManager uIManager = instance.UIManager;
					obj = ((uIManager != null) ? ((Component)uIManager).transform : null);
				}
				Transform val = (Transform)obj;
				if (!((Object)(object)val == (Object)null))
				{
					_canvasGo = new GameObject("InputNameFinder_Display");
					_canvasGo.transform.SetParent(val, false);
					Canvas obj2 = _canvasGo.AddComponent<Canvas>();
					obj2.renderMode = (RenderMode)0;
					obj2.sortingOrder = 201;
					_canvasGo.AddComponent<CanvasScaler>();
					_canvasGo.AddComponent<GraphicRaycaster>();
					GameObject val2 = new GameObject("InputLabel");
					val2.transform.SetParent(_canvasGo.transform, false);
					_label = val2.AddComponent<TextMeshProUGUI>();
					((TMP_Text)_label).text = "";
					((TMP_Text)_label).fontSize = 22f;
					((Graphic)_label).color = new Color(1f, 1f, 0f);
					((TMP_Text)_label).alignment = (TextAlignmentOptions)260;
					((TMP_Text)_label).enableWordWrapping = false;
					RectTransform component = val2.GetComponent<RectTransform>();
					component.anchorMin = new Vector2(1f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(1f, 1f);
					component.sizeDelta = new Vector2(400f, 60f);
					component.anchoredPosition = new Vector2(-16f, -140f);
				}
			}
		}

		private void Update()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<bool> displayInputs = InputNameFinderPlugin.DisplayInputs;
			if (displayInputs == null || !displayInputs.Value)
			{
				if ((Object)(object)_canvasGo != (Object)null && _canvasGo.activeSelf)
				{
					_canvasGo.SetActive(false);
				}
				return;
			}
			EnsureCreated();
			if ((Object)(object)_canvasGo == (Object)null || (Object)(object)_label == (Object)null || !Input.anyKeyDown)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			KeyCode[] allKeyCodes = _allKeyCodes;
			for (int i = 0; i < allKeyCodes.Length; i++)
			{
				KeyCode val = allKeyCodes[i];
				if (Input.GetKeyDown(val))
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(", ");
					}
					stringBuilder.Append(((object)(KeyCode)(ref val)).ToString());
				}
			}
			if (stringBuilder.Length != 0)
			{
				((TMP_Text)_label).text = "Input: " + stringBuilder;
				_canvasGo.SetActive(true);
			}
		}
	}
	[BepInPlugin("com.inputnamefinder", "Input Name Finder", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class InputNameFinderPlugin : BaseUnityPlugin
	{
		private static string _pluginFolder;

		public static ConfigEntry<bool> DisplayInputs { get; private set; }

		private void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			_pluginFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			DisplayInputs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisplayInputs", true, "When true, displays input names on screen.");
			AppInputNameFinder.Initialize();
			GameObject val = new GameObject("InputNameFinder_Monitor");
			val.AddComponent<InputDisplayMonitor>();
			Object.DontDestroyOnLoad((Object)val);
		}

		public static string GetAppIconPath(string filename)
		{
			if (!string.IsNullOrEmpty(_pluginFolder))
			{
				return Path.Combine(_pluginFolder, filename);
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.inputnamefinder";

		public const string PLUGIN_NAME = "Input Name Finder";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "InputNameFinder";

		public const string PLUGIN_NAME = "InputNameFinder";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace InputNameFinder.Phone
{
	public class AppInputNameFinder : CustomApp
	{
		public static void Initialize()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = null;
			string appIconPath = InputNameFinderPlugin.GetAppIconPath("AppIcon.png");
			if (!string.IsNullOrEmpty(appIconPath) && File.Exists(appIconPath))
			{
				try
				{
					byte[] array = File.ReadAllBytes(appIconPath);
					Texture2D val2 = new Texture2D(2, 2);
					if (ImageConversion.LoadImage(val2, array))
					{
						((Texture)val2).wrapMode = (TextureWrapMode)1;
						((Texture)val2).filterMode = (FilterMode)1;
						val2.Apply();
						val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
					}
				}
				catch
				{
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				PhoneAPI.RegisterApp<AppInputNameFinder>("Input Name Finder", val);
			}
			else
			{
				PhoneAPI.RegisterApp<AppInputNameFinder>("Input Name Finder", (Sprite)null);
			}
		}

		public override void OnAppInit()
		{
			((CustomApp)this).OnAppInit();
			((CustomApp)this).CreateIconlessTitleBar("Input Name Finder", 80f);
			base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
			PopulateButtons();
		}

		public override void OnAppEnable()
		{
			((App)this).OnAppEnable();
			PopulateButtons();
		}

		private void PopulateButtons()
		{
			base.ScrollView.RemoveAllButtons();
			ShowMainMenu();
		}

		private void ShowMainMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = InputNameFinderPlugin.DisplayInputs?.Value ?? false;
			SimplePhoneButton displayInputsBtn = PhoneUIUtility.CreateSimpleButton("Display Inputs: " + (flag ? "On" : "Off"));
			SimplePhoneButton obj = displayInputsBtn;
			((PhoneButton)obj).OnConfirm = (Action)Delegate.Combine(((PhoneButton)obj).OnConfirm, (Action)delegate
			{
				if (InputNameFinderPlugin.DisplayInputs != null)
				{
					InputNameFinderPlugin.DisplayInputs.Value = !InputNameFinderPlugin.DisplayInputs.Value;
					((TMP_Text)displayInputsBtn.Label).text = "Display Inputs: " + (InputNameFinderPlugin.DisplayInputs.Value ? "On" : "Off");
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)displayInputsBtn);
		}
	}
}