using System;
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.Logging;
using HarmonyLib;
using PEAKLib.UI;
using PEAKLib.UI.Elements;
using UnityEngine;
using UnityEngine.Events;
using Zorro.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PEAK_PocketPassport\u200b")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PEAK_PocketPassport\u200b")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77d850cd-e943-4d4b-9a01-a02cdd35b827")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Peak_PocketPassport;
[BepInPlugin("com.Xiaohai.PocketPassport", "PocketPassport\u200b", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
private static class Patch
{
private static bool setParent;
private static PauseMenuMainPage back;
[HarmonyPatch(typeof(PauseMenuMainPage), "OnEnable")]
[HarmonyPostfix]
private static void PauseMenuMainPage_OnEnablePatch(PauseMenuMainPage __instance)
{
if ((Object)(object)back == (Object)null)
{
setParent = false;
}
if (!setParent)
{
Instance.closePage = delegate
{
__instance.OnResumeClicked();
};
try
{
__instance.OnSettingsClicked();
}
catch
{
}
back = __instance;
}
}
[HarmonyPatch(typeof(PauseMenuSettingsMenuPage), "Start")]
[HarmonyPostfix]
private static void PauseMenuSettingsMenuPage_StartPatch(PauseMenuSettingsMenuPage __instance)
{
if (setParent)
{
return;
}
Transform val = ((Component)__instance).gameObject.transform.Find("UI_MainMenuButton_PASSEPORT");
if ((Object)(object)val != (Object)null)
{
logger.LogInfo((object)"已经成功找到UI_MainMenuButton_PASSEPORT!");
Transform val2 = ((Component)__instance).gameObject.transform.parent.Find("MainPage/MainPage/Options");
if ((Object)(object)val2 != (Object)null)
{
val.SetParent(val2);
Transform val3 = val.parent.Find("UI_MainMenuButton_LeaveGame");
int siblingIndex = val.GetSiblingIndex();
int siblingIndex2 = val3.GetSiblingIndex();
val.SetSiblingIndex(siblingIndex2);
val3.SetSiblingIndex(siblingIndex);
logger.LogInfo((object)"已经成功设置父对象!");
setParent = true;
__instance.BackClicked();
}
else
{
logger.LogError((object)"没有找到Options!!!");
}
}
else
{
logger.LogError((object)"没有找到UI_MainMenuButton_PASSEPORT!");
}
}
}
public const string PLUGIN_GUID = "com.Xiaohai.PocketPassport";
public const string PLUGIN_NAME = "PocketPassport\u200b";
public const string PLUGIN_VERSION = "1.0.0";
public Action closePage;
public static Plugin Instance { get; private set; }
public static ManualLogSource logger => ((BaseUnityPlugin)Instance).Logger;
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"已加载 PocketPassport\u200b v1.0.0");
new Harmony("com.Xiaohai.PocketPassport").PatchAll();
}
private void Start()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
MenuAPI.AddToSettingsMenu(new BuilderDelegate(CreateButton));
}
private void CreateButton(Transform parent)
{
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: 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_0170: Expected O, but got Unknown
try
{
MainMenuPageHandler componentInParent = ((Component)parent).GetComponentInParent<MainMenuPageHandler>();
PauseMenuHandler componentInParent2 = ((Component)parent).GetComponentInParent<PauseMenuHandler>();
if ((Object)(object)componentInParent == (Object)null && (Object)(object)componentInParent2 == (Object)null)
{
throw new Exception("Failed to get a UIPageHandler");
}
UIPage val = ((componentInParent != null) ? ((UIPageHandler)componentInParent).GetPage<MainMenuSettingsPage>() : null) ?? ((componentInParent2 != null) ? ((UIPageHandler)componentInParent2).GetPage<PauseMenuSettingsMenuPage>() : null);
if ((Object)(object)val == (Object)null)
{
throw new Exception("Failed to get the parent settings page");
}
TranslationKey val2 = MenuAPI.CreateLocalization("PASSEPORT").AddLocalization("PASSEPORT", (Language)0).AddLocalization("PASSEPORT", (Language)1)
.AddLocalization("PASSAPORTO", (Language)2)
.AddLocalization("PASS", (Language)3)
.AddLocalization("PASAPORTE", (Language)4)
.AddLocalization("PASAPORTE", (Language)5)
.AddLocalization("PASSAPORTE", (Language)6)
.AddLocalization("ПАСПОРТ", (Language)7)
.AddLocalization("ПАСПОРТ", (Language)8)
.AddLocalization("护照", (Language)9)
.AddLocalization("護照", (Language)10)
.AddLocalization("パスポート", (Language)11)
.AddLocalization("여권", (Language)12);
PeakMenuButton val3 = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(ElementExtensions.SetLocalizationIndex<PeakMenuButton>(MenuAPI.CreatePauseMenuButton("PASSEPORT"), val2).SetColor(new Color(0.2f, 0.7f, 0.3f), true), parent), new Vector2(960f, 258f)).SetWidth(277f);
if (val3 != null)
{
val3.OnClick((UnityAction)delegate
{
closePage();
PassportManager.instance.ToggleOpen();
});
}
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to create button: {arg}");
}
}
}