Decompiled source of UIShortcuts v1.2.0

AtlyssItemTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using JetBrains.Annotations;
using Nessie.ATLYSS.EasySettings;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AtlyssItemTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AtlyssItemTweaks")]
[assembly: AssemblyCopyright("Copyright © crpz1 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("66fa1810-9987-4b06-aeee-7ed34abe5e0d")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyVersion("1.2.0.22")]
namespace AtlyssUIShortcuts;

[BepInPlugin("crpz.AtlyssUIShortcuts", "AtlyssUIShortcuts", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AtlyssUIShortcuts : BaseUnityPlugin
{
	internal static ConfigEntry<bool> UnlockCursorConfig;

	internal static ConfigEntry<bool> InviteConfig;

	internal static ConfigEntry<bool> WorldPortalScrollConfig;

	internal static ConfigEntry<KeyCode> UnlockCursorBind;

	internal static ConfigEntry<KeyCode> InviteAcceptBind;

	internal static ConfigEntry<KeyCode> InviteDeclineBind;

	public static bool unlockedByUs;

	private string[] delimiters = new string[1] { " (" };

	[CanBeNull]
	internal static AtlyssUIShortcuts instance;

	internal static ManualLogSource Logger { get; private set; }

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		InitConfig();
		instance = this;
		if (EasySettingsCompat.enabled)
		{
			EasySettingsCompat.SetupSettings();
		}
		Logger.Log((LogLevel)8, (object)"hii :3");
	}

	private void Update()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Invalid comparison between Unknown and I4
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player._mainPlayer == (Object)null || (int)Player._mainPlayer._currentGameCondition != 1 || (Object)(object)CameraFunction._current == (Object)null)
		{
			return;
		}
		if (UnlockCursorConfig.Value)
		{
			if (unlockedByUs && !CameraFunction._current._unlockedCamera)
			{
				Logger.Log((LogLevel)8, (object)"unlocking because we were forced to");
				unlockedByUs = false;
			}
			if (Input.GetKeyDown(UnlockCursorBind.Value) && !CameraFunction._current._unlockedCamera)
			{
				Logger.Log((LogLevel)8, (object)("KeyDownEvent: " + NameOfKey(UnlockCursorBind.Value)));
				CameraFunction._current._unlockedCamera = true;
				unlockedByUs = true;
			}
			else if (Input.GetKeyUp(UnlockCursorBind.Value) && unlockedByUs)
			{
				Logger.Log((LogLevel)8, (object)("KeyUpEvent: " + NameOfKey(UnlockCursorBind.Value)));
				CameraFunction._current._unlockedCamera = false;
				unlockedByUs = false;
			}
		}
		HandleWorldPortalScroll();
		if (!InviteConfig.Value || (Object)(object)AtlyssNetworkManager._current == (Object)null || (Object)(object)PartyUIManager._current == (Object)null || AtlyssNetworkManager._current._soloMode || (Object)(object)PartyUIManager._current._partyObject != (Object)null || !PartyUIManager._current._partyInviteElement.isEnabled)
		{
			return;
		}
		Text componentInChildren = ((Component)PartyUIManager._current._acceptInviteButton).GetComponentInChildren<Text>();
		Text componentInChildren2 = ((Component)PartyUIManager._current._declineInviteButton).GetComponentInChildren<Text>();
		if (!componentInChildren.text.Contains("(" + NameOfKey(InviteAcceptBind.Value) + ")"))
		{
			if (componentInChildren.text.Contains("("))
			{
				componentInChildren.text = componentInChildren.text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)[0];
				componentInChildren2.text = componentInChildren2.text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)[0];
			}
			componentInChildren.text = componentInChildren.text + " (" + NameOfKey(InviteAcceptBind.Value) + ")";
			componentInChildren2.text = componentInChildren2.text + " (" + NameOfKey(InviteDeclineBind.Value) + ")";
		}
		if (Input.GetKeyDown(InviteAcceptBind.Value))
		{
			Player._mainPlayer.Cmd_SetPartyInviteCondition((PartyInviteStatus)3);
		}
		if (Input.GetKeyDown(InviteDeclineBind.Value))
		{
			Player._mainPlayer.Cmd_SetPartyInviteCondition((PartyInviteStatus)4);
		}
	}

	private void HandleWorldPortalScroll()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		if (!WorldPortalScrollConfig.Value || (Object)(object)ZoneSelectionManager._current == (Object)null)
		{
			return;
		}
		ZoneSelectionManager zsm = ZoneSelectionManager._current;
		if (!zsm._isOpen)
		{
			return;
		}
		if (Input.mouseScrollDelta.y < 0f)
		{
			List<GameObject> list = zsm._zoneSelectPrefabs.FindAll((GameObject entry) => entry.activeSelf);
			if (list.Count == 1)
			{
				return;
			}
			bool flag = false;
			int num = list.FindIndex((GameObject entry) => entry.GetComponent<ZoneSelectionEntry>()._dataID == zsm._worldPortal._selectedPortalEntry);
			if (num + 1 < list.Count)
			{
				int dataID = list[num + 1].GetComponent<ZoneSelectionEntry>()._dataID;
				if (dataID <= zsm._worldPortal._worldPortalSlots.Length - 1 && Player._mainPlayer._waypointAttunements.Contains(zsm._worldPortal._worldPortalSlots[dataID]._mapLockID) && dataID / 8 <= zsm._worldPortal._selectedPortalEntry / 8)
				{
					zsm._zoneSelectPrefabs[dataID].GetComponent<ZoneSelectionEntry>().Select_Entry();
				}
			}
		}
		else
		{
			if (!(Input.mouseScrollDelta.y > 0f) || zsm._worldPortal._selectedPortalEntry == 0)
			{
				return;
			}
			List<GameObject> list2 = zsm._zoneSelectPrefabs.FindAll((GameObject entry) => entry.activeSelf);
			if (list2.Count == 1)
			{
				return;
			}
			int selectedPortalEntry = zsm._worldPortal._selectedPortalEntry;
			int num2 = list2.FindIndex((GameObject entry) => entry.GetComponent<ZoneSelectionEntry>()._dataID == zsm._worldPortal._selectedPortalEntry);
			if (num2 != 0)
			{
				selectedPortalEntry = list2[num2 - 1].GetComponent<ZoneSelectionEntry>()._dataID;
				if (selectedPortalEntry / 8 >= zsm._worldPortal._selectedPortalEntry / 8 && Player._mainPlayer._waypointAttunements.Contains(zsm._worldPortal._worldPortalSlots[selectedPortalEntry]._mapLockID))
				{
					zsm._zoneSelectPrefabs[selectedPortalEntry].GetComponent<ZoneSelectionEntry>().Select_Entry();
				}
			}
		}
	}

	private void InitConfig()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Expected O, but got Unknown
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Expected O, but got Unknown
		ConfigDefinition val = new ConfigDefinition("Features", "UnlockCursorEnabled");
		ConfigDescription val2 = new ConfigDescription("Decline Invite", (AcceptableValueBase)null, Array.Empty<object>());
		UnlockCursorConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(val, true, val2);
		ConfigDefinition val3 = new ConfigDefinition("Features", "InviteBindEnable");
		ConfigDescription val4 = new ConfigDescription("Decline Invite", (AcceptableValueBase)null, Array.Empty<object>());
		InviteConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(val3, true, val4);
		ConfigDefinition val5 = new ConfigDefinition("Features", "WorldPortalScrollEnabled");
		ConfigDescription val6 = new ConfigDescription("Decline Invite", (AcceptableValueBase)null, Array.Empty<object>());
		WorldPortalScrollConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(val5, true, val6);
		ConfigDefinition val7 = new ConfigDefinition("Keybinds", "UnlockCursorKeybind");
		ConfigDescription val8 = new ConfigDescription("Unlock Mouse", (AcceptableValueBase)null, Array.Empty<object>());
		UnlockCursorBind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(val7, (KeyCode)308, val8);
		ConfigDefinition val9 = new ConfigDefinition("Keybinds", "InviteAcceptKeybind");
		ConfigDescription val10 = new ConfigDescription("Accept Invite", (AcceptableValueBase)null, Array.Empty<object>());
		InviteAcceptBind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(val9, (KeyCode)121, val10);
		ConfigDefinition val11 = new ConfigDefinition("Keybinds", "InviteDeclineKeybind");
		ConfigDescription val12 = new ConfigDescription("Decline Invite", (AcceptableValueBase)null, Array.Empty<object>());
		InviteDeclineBind = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(val11, (KeyCode)110, val12);
	}

	private string NameOfKey(KeyCode key)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		return Enum.GetName(typeof(KeyCode), key);
	}
}
public static class EasySettingsCompat
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__3_0;

		internal void <SetupSettings>b__3_0()
		{
			((BaseUnityPlugin)AtlyssUIShortcuts.instance).Config.Save();
		}
	}

	private static bool? _enabled;

	public static bool enabled
	{
		get
		{
			if (!_enabled.HasValue)
			{
				_enabled = Chainloader.PluginInfos.ContainsKey("EasySettings");
			}
			return _enabled.Value;
		}
	}

	public static void SetupSettings()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		Settings.OnInitialized.AddListener(new UnityAction(AddSettings));
		UnityEvent onApplySettings = Settings.OnApplySettings;
		object obj = <>c.<>9__3_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
				((BaseUnityPlugin)AtlyssUIShortcuts.instance).Config.Save();
			};
			<>c.<>9__3_0 = val;
			obj = (object)val;
		}
		onApplySettings.AddListener((UnityAction)obj);
	}

	private static void AddSettings()
	{
		SettingsTab modTab = Settings.ModTab;
		modTab.AddHeader("UIShortcuts");
		modTab.AddToggle(AtlyssUIShortcuts.UnlockCursorConfig);
		modTab.AddToggle(AtlyssUIShortcuts.InviteConfig);
		modTab.AddToggle(AtlyssUIShortcuts.WorldPortalScrollConfig);
		modTab.AddSpace();
		modTab.AddKeyButton(AtlyssUIShortcuts.UnlockCursorBind);
		modTab.AddKeyButton(AtlyssUIShortcuts.InviteAcceptBind);
		modTab.AddKeyButton(AtlyssUIShortcuts.InviteDeclineBind);
	}
}