2025-11-06 01:25:13 +01:00
|
|
|
|
using UI.Core;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace UI.CardSystem
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Opens the card album view when the button is pressed.
|
|
|
|
|
|
/// Attach this to a top-level GameObject in the scene.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class CardAlbumOpener : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
[Header("References")]
|
|
|
|
|
|
[SerializeField] private Button openAlbumButton;
|
|
|
|
|
|
[SerializeField] private AlbumViewPage albumViewPage;
|
2025-11-06 23:51:57 +01:00
|
|
|
|
[SerializeField] private BoosterOpeningPage boosterOpeningPage;
|
2025-11-06 01:25:13 +01:00
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (openAlbumButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
openAlbumButton.onClick.AddListener(OnOpenAlbumClicked);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (UIPageController.Instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIPageController.Instance.OnPageChanged += OnPageChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (UIPageController.Instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIPageController.Instance.OnPageChanged -= OnPageChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (openAlbumButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
openAlbumButton.onClick.RemoveListener(OnOpenAlbumClicked);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnOpenAlbumClicked()
|
|
|
|
|
|
{
|
2025-11-06 23:51:57 +01:00
|
|
|
|
if (UIPageController.Instance == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Check if we're currently on the booster opening page
|
|
|
|
|
|
if (UIPageController.Instance.CurrentPage == boosterOpeningPage)
|
2025-11-06 01:25:13 +01:00
|
|
|
|
{
|
2025-11-06 23:51:57 +01:00
|
|
|
|
// We're in booster opening page, pop back to album main page
|
|
|
|
|
|
UIPageController.Instance.PopPage();
|
2025-11-06 01:25:13 +01:00
|
|
|
|
}
|
2025-11-06 23:51:57 +01:00
|
|
|
|
else if (UIPageController.Instance.CurrentPage != albumViewPage)
|
2025-11-06 01:25:13 +01:00
|
|
|
|
{
|
2025-11-06 23:51:57 +01:00
|
|
|
|
// We're not in the album at all, open it
|
|
|
|
|
|
if (openAlbumButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
openAlbumButton.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (albumViewPage != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIPageController.Instance.PushPage(albumViewPage);
|
2025-11-08 22:16:43 +01:00
|
|
|
|
PlayerHudManager.Instance.appSwitcher.SetActive(false);
|
2025-11-06 23:51:57 +01:00
|
|
|
|
}
|
2025-11-06 01:25:13 +01:00
|
|
|
|
}
|
2025-11-06 23:51:57 +01:00
|
|
|
|
// If we're already on the album main page, do nothing
|
2025-11-06 01:25:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPageChanged(UIPage currentPage)
|
|
|
|
|
|
{
|
2025-11-06 23:51:57 +01:00
|
|
|
|
if (openAlbumButton == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Show the button when:
|
|
|
|
|
|
// 1. We're on the booster opening page (acts as "back to album" button)
|
|
|
|
|
|
// 2. We're NOT on the album main page (acts as "open album" button)
|
|
|
|
|
|
// Hide the button only when we're on the album main page
|
|
|
|
|
|
|
|
|
|
|
|
bool shouldShowButton = currentPage == boosterOpeningPage || currentPage != albumViewPage;
|
|
|
|
|
|
openAlbumButton.gameObject.SetActive(shouldShowButton);
|
2025-11-06 01:25:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|