using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using TMPro; 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("passportcustom")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0")] [assembly: AssemblyProduct("passportcustom")] [assembly: AssemblyTitle("passportcustom")] [assembly: AssemblyVersion("2.0.0.0")] namespace passportcustom; public static class PassportPaginationAPI { private static readonly Dictionary> _extraItems = new Dictionary>(); public static event Action OnPageChanged; public static void RegisterExtraItems(int typeKey, IEnumerable options) { if (options != null) { if (!_extraItems.ContainsKey(typeKey)) { _extraItems[typeKey] = new List(); } _extraItems[typeKey].AddRange(options); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[PassportPaginationAPI] Registered {_extraItems[typeKey].Count} extra item(s) for type key {typeKey}."); } } } public static void UnregisterExtraItems(int typeKey) { if (_extraItems.Remove(typeKey)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[PassportPaginationAPI] Unregistered extra items for type key {typeKey}."); } } } public static CustomizationOption[] GetMergedList(int typeKey, CustomizationOption[] nativeList) { if (!_extraItems.TryGetValue(typeKey, out var value) || value.Count == 0) { return nativeList; } CustomizationOption[] array = (CustomizationOption[])(object)new CustomizationOption[nativeList.Length + value.Count]; nativeList.CopyTo(array, 0); for (int i = 0; i < value.Count; i++) { array[nativeList.Length + i] = value[i]; } return array; } public static bool HasExtraItems(int typeKey) { return _extraItems.ContainsKey(typeKey) && _extraItems[typeKey].Count > 0; } internal static void RaisePageChanged(int typeKey, int page, int maxPage) { PassportPaginationAPI.OnPageChanged?.Invoke(typeKey, page, maxPage); } } [BepInPlugin("radsi.pagination", "passportcustom", "2.0.0")] public class Plugin : BaseUnityPlugin { private class Patcher { [HarmonyPatch(typeof(PassportManager), "Awake")] [HarmonyPostfix] private static void OnPassportManagerAwake(PassportManager __instance) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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) CurrentPassportManager = __instance; Log.LogInfo((object)"[passportcustom] PassportManager.Awake — instance capturée."); GameObject val = FindTemplateButton(); if ((Object)(object)val == (Object)null) { return; } Transform parent = val.transform.parent; object obj; if (parent == null) { obj = null; } else { Transform parent2 = parent.parent; obj = ((parent2 != null) ? parent2.parent : null); } Transform val2 = (Transform)obj; if ((Object)(object)val2 == (Object)null) { Log.LogError((object)"[passportcustom] Impossible de remonter au parent des boutons (parent.parent.parent == null)."); return; } DestroyModButtons(); ButtonRight = Object.Instantiate(val); ButtonLeft = Object.Instantiate(val); ButtonRight.transform.SetParent(val2, false); ButtonLeft.transform.SetParent(val2, false); ButtonRight.transform.localScale = new Vector3(1f, 0.4f, 1f); ButtonLeft.transform.localScale = new Vector3(-1f, 0.4f, 1f); TrySetArrowTexture(ButtonRight); TrySetArrowTexture(ButtonLeft); ButtonRight.transform.localPosition = new Vector3(276.6f, -196.6f, 0f); ButtonLeft.transform.localPosition = new Vector3(-56.6f, -196.6f, 0f); PassportButton component = ButtonRight.GetComponent(); PassportButton component2 = ButtonLeft.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } ((Object)ButtonRight).name = "passportcustom_right"; ((Object)ButtonLeft).name = "passportcustom_left"; ButtonRight.SetActive(false); ButtonLeft.SetActive(false); SetButtonAction(ButtonRight, "right_mod", delegate { int maxPage2 = GetMaxPage(CurrentPassportManager); CurrentPage = Mathf.Min(CurrentPage + 1, maxPage2); Log.LogInfo((object)$"[passportcustom] → Page {CurrentPage}/{maxPage2}"); UpdatePage(CurrentPassportManager); }); SetButtonAction(ButtonLeft, "left_mod", delegate { int maxPage = GetMaxPage(CurrentPassportManager); CurrentPage = Mathf.Max(CurrentPage - 1, 0); Log.LogInfo((object)$"[passportcustom] ← Page {CurrentPage}/{maxPage}"); UpdatePage(CurrentPassportManager); }); Log.LogInfo((object)"[passportcustom] Boutons de navigation créés avec succès."); } [HarmonyPatch(typeof(PassportManager), "OpenTab")] [HarmonyPostfix] private static void OnOpenTab(PassportManager __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) CurrentPassportManager = __instance; CurrentPage = 0; Log.LogInfo((object)$"[passportcustom] OpenTab — reset page 0 (type={__instance.activeType})"); UpdatePage(__instance); } [HarmonyPatch(typeof(PassportManager), "SetButtons")] [HarmonyPrefix] private static bool OnSetButtonsPrefix(PassportManager __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) int typeKey = Convert.ToInt32(__instance.activeType); bool flag = PassportPaginationAPI.HasExtraItems(typeKey); if (CurrentPage == 0 && !flag) { Log.LogDebug((object)"[passportcustom] SetButtons — page 0, pas d'extras, passage au natif."); return true; } Log.LogDebug((object)$"[passportcustom] SetButtons — bridge actif (page={CurrentPage}, extras={flag})"); UpdatePage(__instance); return false; } [HarmonyPatch(typeof(PassportManager), "SetButtons")] [HarmonyPostfix] private static void OnSetButtonsPostfix(PassportManager __instance) { RefreshNavButtons(__instance); } } internal static ManualLogSource Log; internal static PassportManager CurrentPassportManager; internal static Texture2D ArrowImage; internal static int CurrentPage; internal static GameObject ButtonRight; internal static GameObject ButtonLeft; private static MethodInfo _setActiveButtonMethod; private static FieldInfo _buttonsPerPageField; private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"[passportcustom] Initialisation du bridge de pagination..."); ArrowImage = new Texture2D(2, 2); ImageConversion.LoadImage(ArrowImage, Resource1.arrow); Type typeFromHandle = typeof(PassportManager); _setActiveButtonMethod = typeFromHandle.GetMethod("SetActiveButton", BindingFlags.Instance | BindingFlags.NonPublic); if (_setActiveButtonMethod == null) { Log.LogWarning((object)"[passportcustom] SetActiveButton introuvable — la sélection active ne sera pas mise à jour."); } _buttonsPerPageField = typeFromHandle.GetField("buttonsPerPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_buttonsPerPageField == null) { Log.LogWarning((object)"[passportcustom] buttonsPerPage introuvable — fallback sur buttons.Length."); } Harmony val = new Harmony("radsi.pagination"); val.PatchAll(typeof(Patcher)); val.PatchAll(typeof(ReportCardInjector)); Log.LogInfo((object)"[passportcustom] Harmony patches appliqués."); } internal static int GetButtonsPerPage(PassportManager pm) { if (_buttonsPerPageField != null && _buttonsPerPageField.GetValue(pm) is int num && num > 0) { return num; } PassportButton[] buttons = pm.buttons; return (buttons != null) ? buttons.Length : 28; } internal static void InvokeSetActiveButton(PassportManager pm) { _setActiveButtonMethod?.Invoke(pm, null); } internal static GameObject FindTemplateButton() { GameObject val = GameObject.Find("GAME/PassportManager/PassportUI/Canvas/Panel/Panel/BG/Options/Grid/UI_PassportGridButton"); if ((Object)(object)val != (Object)null) { Log.LogInfo((object)"[passportcustom] Bouton template trouvé via path complet."); return val; } PassportButton[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array != null && array.Length != 0) { Log.LogInfo((object)$"[passportcustom] Bouton template trouvé via FindObjectsOfType ({array.Length} bouton(s))."); return ((Component)array[0]).gameObject; } if ((Object)(object)CurrentPassportManager != (Object)null) { Transform val2 = FindChildRecursive(((Component)CurrentPassportManager).transform, "Grid"); if ((Object)(object)val2 != (Object)null && val2.childCount > 0) { Log.LogInfo((object)"[passportcustom] Bouton template trouvé via Grid child."); return ((Component)val2.GetChild(0)).gameObject; } } Log.LogError((object)"[passportcustom] IMPOSSIBLE de trouver le bouton template. Le nom de l'objet a probablement changé dans cette version de PEAK. Les boutons de navigation ne seront pas créés."); return null; } private static Transform FindChildRecursive(Transform parent, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; if (((Object)val).name.Contains(name)) { return val; } Transform val2 = FindChildRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } internal static void UpdatePage(PassportManager pm) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pm == (Object)null) { Log.LogError((object)"[passportcustom] UpdatePage appelé avec pm == null !"); return; } int typeKey = Convert.ToInt32(pm.activeType); int buttonsPerPage = GetButtonsPerPage(pm); CustomizationOption[] list = Singleton.Instance.GetList(pm.activeType); CustomizationOption[] mergedList = PassportPaginationAPI.GetMergedList(typeKey, list); int num = mergedList.Length; int num2 = CurrentPage * buttonsPerPage; int maxPage = GetMaxPage(pm, num, buttonsPerPage); Log.LogDebug((object)($"[passportcustom] UpdatePage — type={pm.activeType} page={CurrentPage}/{maxPage} " + $"total={num} perPage={buttonsPerPage} nativeItems={list.Length} mergedItems={num}")); for (int i = 0; i < pm.buttons.Length; i++) { int num3 = num2 + i; if (num3 < num) { pm.buttons[i].SetButton(mergedList[num3], num3); } else { pm.buttons[i].SetButton((CustomizationOption)null, -1); } } InvokeSetActiveButton(pm); RefreshNavButtons(pm, maxPage); PassportPaginationAPI.RaisePageChanged(typeKey, CurrentPage, maxPage); } internal static void RefreshNavButtons(PassportManager pm, int maxPage = -1) { if (!((Object)(object)ButtonLeft == (Object)null) && !((Object)(object)ButtonRight == (Object)null)) { if (maxPage < 0) { maxPage = GetMaxPage(pm); } ButtonLeft.SetActive(CurrentPage > 0); ButtonRight.SetActive(CurrentPage < maxPage); } } internal static int GetMaxPage(PassportManager pm) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) int typeKey = Convert.ToInt32(pm.activeType); CustomizationOption[] list = Singleton.Instance.GetList(pm.activeType); CustomizationOption[] mergedList = PassportPaginationAPI.GetMergedList(typeKey, list); return GetMaxPage(pm, mergedList.Length, GetButtonsPerPage(pm)); } private static int GetMaxPage(PassportManager pm, int total, int perPage) { return Mathf.Max((total - 1) / perPage, 0); } private static void TrySetArrowTexture(GameObject btn) { try { RawImage component = ((Component)btn.transform.GetChild(1).GetChild(0)).GetComponent(); if ((Object)(object)component != (Object)null) { component.texture = (Texture)(object)ArrowImage; return; } } catch { } RawImage componentInChildren = btn.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.texture = (Texture)(object)ArrowImage; } else { Log.LogWarning((object)"[passportcustom] Impossible de trouver le RawImage sur le bouton cloné."); } } private static void SetButtonAction(GameObject btn, string name, Action onClick) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown ((Object)btn).name = name; Button component = btn.GetComponent