Decompiled source of PassporPagination v1.0.1

PassportPagination.dll

Decompiled 3 weeks ago
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PassportPagination")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("PassportPagination")]
[assembly: AssemblyTitle("PassportPagination")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace PassportPagination;

[BepInPlugin("radsi.pagination", "PassportPagination", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private class Patcher
	{
		private static void ConfigureModButton(GameObject button, string name, Action onClick)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			((Object)button).name = name;
			Button component = button.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
		}

		[HarmonyPatch(typeof(PassportManager), "Awake")]
		[HarmonyPostfix]
		private static void PassportManagerAwakePostfix(PassportManager __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			passportManager = __instance;
			GameObject val = GameObject.Find("GAME/PassportManager/PassportUI/Canvas/Panel/Panel/BG/Options/Grid/UI_PassportGridButton");
			Transform parent = val.transform.parent.parent.parent;
			buttonRight = Object.Instantiate<GameObject>(val);
			buttonLeft = Object.Instantiate<GameObject>(buttonRight);
			buttonRight.transform.SetParent(parent, false);
			buttonLeft.transform.SetParent(parent, false);
			buttonRight.transform.localScale = new Vector3(1f, 0.4f, 1f);
			buttonLeft.transform.localScale = new Vector3(-1f, 0.4f, 1f);
			((Component)buttonRight.transform.GetChild(1).GetChild(0)).GetComponent<RawImage>().texture = (Texture)(object)arrowImage;
			((Component)buttonLeft.transform.GetChild(1).GetChild(0)).GetComponent<RawImage>().texture = (Texture)(object)arrowImage;
			buttonRight.transform.localPosition = new Vector3(276.6f, -196.6f, 0f);
			buttonLeft.transform.localPosition = new Vector3(-56.6f, -196.6f, 0f);
			Object.Destroy((Object)(object)buttonRight.GetComponent<PassportButton>());
			Object.Destroy((Object)(object)buttonLeft.GetComponent<PassportButton>());
			buttonRight.SetActive(false);
			buttonLeft.SetActive(false);
			ConfigureModButton(buttonRight, "right_mod", delegate
			{
				currentPage = Mathf.Min(currentPage + 1, GetMaxPage());
				UpdatePage();
			});
			ConfigureModButton(buttonLeft, "left_mod", delegate
			{
				currentPage = Mathf.Max(currentPage - 1, 0);
				UpdatePage();
			});
		}

		[HarmonyPatch(typeof(PassportManager), "OpenTab")]
		[HarmonyPostfix]
		private static void PassportManagerOpenTabPostfix()
		{
			currentPage = 0;
			UpdatePage();
		}

		private static void UpdatePage()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			CustomizationOption[] list = Singleton<Customization>.Instance.GetList(passportManager.activeType);
			int num = currentPage * 28;
			for (int i = 0; i < passportManager.buttons.Length; i++)
			{
				int num2 = num + i;
				if (num2 < list.Length)
				{
					passportManager.buttons[i].SetButton(list[num2], num2);
				}
				else
				{
					passportManager.buttons[i].SetButton((CustomizationOption)null, -1);
				}
			}
			typeof(PassportManager).GetMethod("SetActiveButton", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(passportManager, null);
			int maxPage = GetMaxPage();
			buttonLeft.SetActive(currentPage > 0);
			buttonRight.SetActive(currentPage < maxPage);
		}

		private static int GetMaxPage()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			int num = Singleton<Customization>.Instance.GetList(passportManager.activeType).Length;
			return Mathf.Max((num - 1) / 28, 0);
		}
	}

	private static PassportManager passportManager;

	private static Texture2D arrowImage;

	private static int currentPage;

	private static GameObject buttonRight;

	private static GameObject buttonLeft;

	private void Awake()
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		arrowImage = new Texture2D(2, 2);
		ImageConversion.LoadImage(arrowImage, Resource1.arrow);
		new Harmony("radsi.pagination").PatchAll(typeof(Patcher));
	}
}
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resource1
{
	private static ResourceManager resourceMan;

	private static CultureInfo resourceCulture;

	[EditorBrowsable(EditorBrowsableState.Advanced)]
	internal static ResourceManager ResourceManager
	{
		get
		{
			if (resourceMan == null)
			{
				ResourceManager resourceManager = new ResourceManager("PassportPagination.Resource1", typeof(Resource1).Assembly);
				resourceMan = resourceManager;
			}
			return resourceMan;
		}
	}

	[EditorBrowsable(EditorBrowsableState.Advanced)]
	internal static CultureInfo Culture
	{
		get
		{
			return resourceCulture;
		}
		set
		{
			resourceCulture = value;
		}
	}

	internal static byte[] arrow
	{
		get
		{
			object @object = ResourceManager.GetObject("arrow", resourceCulture);
			return (byte[])@object;
		}
	}

	internal Resource1()
	{
	}
}