2025-11-06 01:25:13 +01:00
|
|
|
|
using Pixelplacement;
|
2025-10-21 12:10:16 +02:00
|
|
|
|
using UI.Core;
|
2025-10-10 14:31:51 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
2025-10-21 12:10:16 +02:00
|
|
|
|
namespace UI.CardSystem
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2025-10-20 08:32:57 +02:00
|
|
|
|
/// UI page for viewing the player's card collection in an album.
|
2025-10-10 14:31:51 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class AlbumViewPage : UIPage
|
|
|
|
|
|
{
|
2025-10-15 09:22:13 +02:00
|
|
|
|
[SerializeField] private CanvasGroup canvasGroup;
|
2025-11-06 01:25:13 +01:00
|
|
|
|
[SerializeField] private Button exitButton;
|
|
|
|
|
|
[SerializeField] private BookCurlPro.BookPro book;
|
2025-10-10 14:31:51 +02:00
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
2025-10-15 09:22:13 +02:00
|
|
|
|
// Make sure we have a CanvasGroup for transitions
|
|
|
|
|
|
if (canvasGroup == null)
|
|
|
|
|
|
canvasGroup = GetComponent<CanvasGroup>();
|
|
|
|
|
|
if (canvasGroup == null)
|
|
|
|
|
|
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
2025-10-20 10:29:22 +02:00
|
|
|
|
|
2025-11-06 01:25:13 +01:00
|
|
|
|
// Set up exit button
|
|
|
|
|
|
if (exitButton != null)
|
2025-10-20 10:29:22 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
exitButton.onClick.AddListener(OnExitButtonClicked);
|
2025-10-20 10:29:22 +02:00
|
|
|
|
}
|
2025-10-15 09:22:13 +02:00
|
|
|
|
|
2025-11-06 01:25:13 +01:00
|
|
|
|
// UI pages should start disabled
|
|
|
|
|
|
gameObject.SetActive(false);
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 01:25:13 +01:00
|
|
|
|
private void OnDestroy()
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
if (exitButton != null)
|
2025-10-15 09:22:13 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
exitButton.onClick.RemoveListener(OnExitButtonClicked);
|
2025-10-15 09:22:13 +02:00
|
|
|
|
}
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
2025-10-20 13:45:56 +02:00
|
|
|
|
|
2025-11-06 01:25:13 +01:00
|
|
|
|
private void OnExitButtonClicked()
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
if (book != null && book.CurrentPaper != 1)
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
// Not on page 0, flip to page 0 first
|
|
|
|
|
|
BookCurlPro.AutoFlip autoFlip = book.GetComponent<BookCurlPro.AutoFlip>();
|
|
|
|
|
|
if (autoFlip == null)
|
2025-10-15 09:22:13 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
autoFlip = book.gameObject.AddComponent<BookCurlPro.AutoFlip>();
|
2025-10-15 09:22:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 01:25:13 +01:00
|
|
|
|
autoFlip.enabled = true;
|
|
|
|
|
|
autoFlip.StartFlipping(1);
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
2025-11-06 01:25:13 +01:00
|
|
|
|
else
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
// Already on page 0 or no book reference, exit
|
|
|
|
|
|
if (UIPageController.Instance != null)
|
2025-10-15 09:22:13 +02:00
|
|
|
|
{
|
2025-11-06 01:25:13 +01:00
|
|
|
|
UIPageController.Instance.PopPage();
|
2025-10-15 09:22:13 +02:00
|
|
|
|
}
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
2025-10-15 09:22:13 +02:00
|
|
|
|
}
|
2025-11-06 01:25:13 +01:00
|
|
|
|
|
2025-10-10 14:31:51 +02:00
|
|
|
|
protected override void DoTransitionIn(System.Action onComplete)
|
|
|
|
|
|
{
|
2025-10-20 13:45:56 +02:00
|
|
|
|
// Simple fade in animation
|
2025-10-15 09:22:13 +02:00
|
|
|
|
if (canvasGroup != null)
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-10-15 09:22:13 +02:00
|
|
|
|
canvasGroup.alpha = 0f;
|
2025-10-27 15:21:23 +01:00
|
|
|
|
Tween.Value(0f, 1f, (value) => canvasGroup.alpha = value, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, onComplete, obeyTimescale: false);
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-10-20 13:45:56 +02:00
|
|
|
|
// Fallback if no CanvasGroup
|
|
|
|
|
|
onComplete?.Invoke();
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-06 01:25:13 +01:00
|
|
|
|
|
2025-10-10 14:31:51 +02:00
|
|
|
|
protected override void DoTransitionOut(System.Action onComplete)
|
|
|
|
|
|
{
|
2025-10-20 13:45:56 +02:00
|
|
|
|
// Simple fade out animation
|
2025-10-15 09:22:13 +02:00
|
|
|
|
if (canvasGroup != null)
|
2025-10-10 14:31:51 +02:00
|
|
|
|
{
|
2025-10-27 15:21:23 +01:00
|
|
|
|
Tween.Value(canvasGroup.alpha, 0f, (value) => canvasGroup.alpha = value, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, onComplete, obeyTimescale: false);
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-10-20 13:45:56 +02:00
|
|
|
|
// Fallback if no CanvasGroup
|
|
|
|
|
|
onComplete?.Invoke();
|
2025-10-15 09:22:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-10 14:31:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|