Only show cards when in actual album
This commit is contained in:
@@ -56,7 +56,7 @@ namespace UI.CardSystem
|
|||||||
canvasGroup = GetComponent<CanvasGroup>();
|
canvasGroup = GetComponent<CanvasGroup>();
|
||||||
if (canvasGroup == null)
|
if (canvasGroup == null)
|
||||||
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
||||||
|
|
||||||
// Hide backdrop initially
|
// Hide backdrop initially
|
||||||
if (cardEnlargedBackdrop != null)
|
if (cardEnlargedBackdrop != null)
|
||||||
{
|
{
|
||||||
@@ -72,6 +72,17 @@ namespace UI.CardSystem
|
|||||||
// Set up booster pack button listeners
|
// Set up booster pack button listeners
|
||||||
SetupBoosterButtonListeners();
|
SetupBoosterButtonListeners();
|
||||||
|
|
||||||
|
// Subscribe to book page flip events
|
||||||
|
if (book != null)
|
||||||
|
{
|
||||||
|
book.OnFlip.AddListener(OnPageFlipped);
|
||||||
|
Debug.Log("[AlbumViewPage] Subscribed to book.OnFlip event");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[AlbumViewPage] Book reference is null, cannot subscribe to OnFlip event!");
|
||||||
|
}
|
||||||
|
|
||||||
// Subscribe to CardSystemManager events (managers are guaranteed to be initialized)
|
// Subscribe to CardSystemManager events (managers are guaranteed to be initialized)
|
||||||
if (CardSystemManager.Instance != null)
|
if (CardSystemManager.Instance != null)
|
||||||
{
|
{
|
||||||
@@ -125,6 +136,12 @@ namespace UI.CardSystem
|
|||||||
for (int i = 0; i < boosterPackButtons.Length; i++)
|
for (int i = 0; i < boosterPackButtons.Length; i++)
|
||||||
{
|
{
|
||||||
if (boosterPackButtons[i] == null) continue;
|
if (boosterPackButtons[i] == null) continue;
|
||||||
|
// Unsubscribe from book events
|
||||||
|
if (book != null)
|
||||||
|
{
|
||||||
|
book.OnFlip.RemoveListener(OnPageFlipped);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Button button = boosterPackButtons[i].GetComponent<Button>();
|
Button button = boosterPackButtons[i].GetComponent<Button>();
|
||||||
if (button != null)
|
if (button != null)
|
||||||
@@ -252,8 +269,16 @@ namespace UI.CardSystem
|
|||||||
CardSystemManager.Instance.OnPendingCardAdded += OnPendingCardAdded;
|
CardSystemManager.Instance.OnPendingCardAdded += OnPendingCardAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn pending cards when opening album
|
// Only spawn pending cards if we're already on an album page (not the menu)
|
||||||
SpawnPendingCards();
|
if (IsInAlbumProper())
|
||||||
|
{
|
||||||
|
Debug.Log("[AlbumViewPage] Opening directly to album page - spawning cards immediately");
|
||||||
|
SpawnPendingCards();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("[AlbumViewPage] Opening to menu page - cards will spawn when entering album");
|
||||||
|
}
|
||||||
|
|
||||||
base.TransitionIn();
|
base.TransitionIn();
|
||||||
}
|
}
|
||||||
@@ -342,6 +367,50 @@ namespace UI.CardSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if we're currently viewing the album proper (not the menu page)
|
||||||
|
/// </summary>
|
||||||
|
private bool IsInAlbumProper()
|
||||||
|
{
|
||||||
|
if (book == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[AlbumViewPage] Book reference is null in IsInAlbumProper check");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page 1 is the menu/cover, page 2+ are album pages with card slots
|
||||||
|
bool inAlbum = book.CurrentPaper > 1;
|
||||||
|
Debug.Log($"[PAGE-NAV-DEBUG] IsInAlbumProper check - CurrentPage: {book.CurrentPaper}, InAlbum: {inAlbum}");
|
||||||
|
return inAlbum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when book page flips - show/hide pending cards based on whether we're in the album proper
|
||||||
|
/// </summary>
|
||||||
|
private void OnPageFlipped()
|
||||||
|
{
|
||||||
|
bool isInAlbum = IsInAlbumProper();
|
||||||
|
|
||||||
|
Debug.Log($"[PAGE-NAV-DEBUG] OnPageFlipped - CurrentPage: {book.CurrentPaper}, IsInAlbum: {isInAlbum}, CardsCurrentlySpawned: {_activeCards.Count}");
|
||||||
|
|
||||||
|
if (isInAlbum && _activeCards.Count == 0)
|
||||||
|
{
|
||||||
|
// Entering album proper and no cards spawned yet - spawn them with animation
|
||||||
|
Debug.Log("[AlbumViewPage] Entering album proper - spawning pending cards with animation");
|
||||||
|
SpawnPendingCards();
|
||||||
|
}
|
||||||
|
else if (!isInAlbum && _activeCards.Count > 0)
|
||||||
|
{
|
||||||
|
// Returning to menu page - cleanup cards
|
||||||
|
Debug.Log("[AlbumViewPage] Returning to menu page - cleaning up pending cards");
|
||||||
|
CleanupActiveCards();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log($"[AlbumViewPage] Page flipped but no card state change needed (already in correct state)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Album Card Reveal System
|
#region Album Card Reveal System
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user