Clean up logging

This commit is contained in:
Michal Pikulski
2025-11-10 13:03:36 +01:00
parent c99aad49f3
commit 3ebbecc277
38 changed files with 234 additions and 300 deletions

View File

@@ -76,11 +76,11 @@ namespace UI.CardSystem
if (book != null)
{
book.OnFlip.AddListener(OnPageFlipped);
Debug.Log("[AlbumViewPage] Subscribed to book.OnFlip event");
Logging.Debug("[AlbumViewPage] Subscribed to book.OnFlip event");
}
else
{
Debug.LogWarning("[AlbumViewPage] Book reference is null, cannot subscribe to OnFlip event!");
Logging.Warning("[AlbumViewPage] Book reference is null, cannot subscribe to OnFlip event!");
}
// Subscribe to CardSystemManager events (managers are guaranteed to be initialized)
@@ -116,15 +116,15 @@ namespace UI.CardSystem
if (zoneTabs == null || zoneTabs.Length == 0)
{
Debug.LogWarning($"[AlbumViewPage] No BookTabButton components found in tab container '{tabContainer.name}'!");
Logging.Warning($"[AlbumViewPage] No BookTabButton components found in tab container '{tabContainer.name}'!");
zoneTabs = new BookTabButton[0];
}
else
{
Debug.Log($"[AlbumViewPage] Discovered {zoneTabs.Length} zone tabs from container '{tabContainer.name}'");
Logging.Debug($"[AlbumViewPage] Discovered {zoneTabs.Length} zone tabs from container '{tabContainer.name}'");
foreach (var tab in zoneTabs)
{
Debug.Log($" - Tab: {tab.name}, Zone: {tab.Zone}, TargetPage: {tab.TargetPage}");
Logging.Debug($" - Tab: {tab.name}, Zone: {tab.Zone}, TargetPage: {tab.TargetPage}");
}
}
}
@@ -209,7 +209,7 @@ namespace UI.CardSystem
if (Input.InputManager.Instance != null)
{
Input.InputManager.Instance.SetInputMode(_previousInputMode);
Debug.Log($"[AlbumViewPage] Restored input mode to {_previousInputMode} on exit");
Logging.Debug($"[AlbumViewPage] Restored input mode to {_previousInputMode} on exit");
}
if (UIPageController.Instance != null)
@@ -260,7 +260,7 @@ namespace UI.CardSystem
// Store the current input mode before switching
_previousInputMode = Input.InputMode.GameAndUI;
Input.InputManager.Instance.SetInputMode(Input.InputMode.UI);
Debug.Log("[AlbumViewPage] Switched to UI-only input mode on first entry");
Logging.Debug("[AlbumViewPage] Switched to UI-only input mode on first entry");
}
// Subscribe to pending card events while page is active
@@ -272,12 +272,12 @@ namespace UI.CardSystem
// Only spawn pending cards if we're already on an album page (not the menu)
if (IsInAlbumProper())
{
Debug.Log("[AlbumViewPage] Opening directly to album page - spawning cards immediately");
Logging.Debug("[AlbumViewPage] Opening directly to album page - spawning cards immediately");
SpawnPendingCards();
}
else
{
Debug.Log("[AlbumViewPage] Opening to menu page - cards will spawn when entering album");
Logging.Debug("[AlbumViewPage] Opening to menu page - cards will spawn when entering album");
}
base.TransitionIn();
@@ -374,13 +374,12 @@ namespace UI.CardSystem
{
if (book == null)
{
Debug.LogWarning("[AlbumViewPage] Book reference is null in IsInAlbumProper check");
Logging.Warning("[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;
}
@@ -390,24 +389,21 @@ namespace UI.CardSystem
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");
Logging.Debug("[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");
Logging.Debug("[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)");
Logging.Debug($"[AlbumViewPage] Page flipped but no card state change needed (already in correct state)");
}
}
@@ -434,7 +430,7 @@ namespace UI.CardSystem
int spawnCount = Mathf.Min(uniquePending.Count, MAX_VISIBLE_CARDS);
Debug.Log($"[AlbumViewPage] Spawning {spawnCount} unique pending cards (total pending: {pending.Count})");
Logging.Debug($"[AlbumViewPage] Spawning {spawnCount} unique pending cards (total pending: {pending.Count})");
for (int i = 0; i < spawnCount; i++)
{
@@ -450,14 +446,14 @@ namespace UI.CardSystem
// Guard: Don't spawn cards with zero copies
if (cardData.CopiesOwned <= 0)
{
Debug.LogWarning($"[AlbumViewPage] Skipping spawn of card '{cardData.Name}' with {cardData.CopiesOwned} copies");
Logging.Warning($"[AlbumViewPage] Skipping spawn of card '{cardData.Name}' with {cardData.CopiesOwned} copies");
return;
}
DraggableSlot slot = FindSlotByIndex(slotIndex);
if (slot == null)
{
Debug.LogWarning($"[AlbumViewPage] Could not find slot with SlotIndex {slotIndex}");
Logging.Warning($"[AlbumViewPage] Could not find slot with SlotIndex {slotIndex}");
return;
}
@@ -484,11 +480,11 @@ namespace UI.CardSystem
// Track it
_activeCards.Add(cardPlacement);
Debug.Log($"[AlbumViewPage] Spawned card '{cardData.Name}' (CopiesOwned: {cardData.CopiesOwned}) in slot {slotIndex}");
Logging.Debug($"[AlbumViewPage] Spawned card '{cardData.Name}' (CopiesOwned: {cardData.CopiesOwned}) in slot {slotIndex}");
}
else
{
Debug.LogWarning($"[AlbumViewPage] Spawned card has no AlbumCardDraggable component!");
Logging.Warning($"[AlbumViewPage] Spawned card has no AlbumCardDraggable component!");
Destroy(cardObj);
}
}
@@ -502,7 +498,7 @@ namespace UI.CardSystem
// Guard: Don't spawn cards with zero copies
if (card.CopiesOwned <= 0)
{
Debug.LogWarning($"[AlbumViewPage] Ignoring pending card '{card.Name}' with {card.CopiesOwned} copies");
Logging.Warning($"[AlbumViewPage] Ignoring pending card '{card.Name}' with {card.CopiesOwned} copies");
return;
}
@@ -513,7 +509,7 @@ namespace UI.CardSystem
if (alreadySpawned)
{
Debug.Log($"[AlbumViewPage] Card '{card.Name}' already spawned, skipping duplicate spawn");
Logging.Debug($"[AlbumViewPage] Card '{card.Name}' already spawned, skipping duplicate spawn");
return; // Don't spawn duplicates
}
@@ -530,14 +526,13 @@ namespace UI.CardSystem
/// </summary>
private void OnCardRevealed(AlbumCardPlacementDraggable cardPlacement, CardData cardData)
{
Debug.Log($"[AlbumViewPage] Card revealed: {cardData.Name} (Zone: {cardData.Zone}, CopiesOwned: {cardData.CopiesOwned})");
Debug.Log($"[PAGE-NAV-DEBUG] OnCardRevealed - Card: {cardData.Name}, CardZone: {cardData.Zone}");
Logging.Debug($"[AlbumViewPage] Card revealed: {cardData.Name} (Zone: {cardData.Zone}, CopiesOwned: {cardData.CopiesOwned})");
// IMMEDIATELY move card from pending to inventory upon reveal
if (CardSystemManager.Instance != null)
{
CardSystemManager.Instance.MarkCardAsPlaced(cardData);
Debug.Log($"[AlbumViewPage] Moved card '{cardData.Name}' from pending to inventory on reveal");
Logging.Debug($"[AlbumViewPage] Moved card '{cardData.Name}' from pending to inventory on reveal");
}
// Remove this card from active cards list
@@ -546,19 +541,15 @@ namespace UI.CardSystem
// Check if we're currently viewing the correct zone for this card
CardZone currentZone = GetCurrentZone();
Debug.Log($"[PAGE-NAV-DEBUG] Zone comparison - CurrentZone: {currentZone}, CardZone: {cardData.Zone}, Match: {currentZone == cardData.Zone}");
if (currentZone != cardData.Zone)
{
// Card is from a different zone - navigate to its zone
Debug.Log($"[AlbumViewPage] Card zone ({cardData.Zone}) doesn't match current zone ({currentZone}). Navigating to card's zone...");
Debug.Log($"[PAGE-NAV-DEBUG] ZONE MISMATCH - Calling NavigateToZone({cardData.Zone})");
Logging.Debug($"[AlbumViewPage] Card zone ({cardData.Zone}) doesn't match current zone ({currentZone}). Navigating to card's zone...");
NavigateToZone(cardData.Zone);
}
else
{
Debug.Log($"[AlbumViewPage] Card zone ({cardData.Zone}) matches current zone - no navigation needed.");
Debug.Log($"[PAGE-NAV-DEBUG] Zones match - skipping navigation");
Logging.Debug($"[AlbumViewPage] Card zone ({cardData.Zone}) matches current zone - no navigation needed.");
}
// Shuffle remaining cards to front and spawn next unique card
@@ -573,7 +564,7 @@ namespace UI.CardSystem
/// </summary>
private void OnCardPlacedInAlbum(AlbumCardPlacementDraggable cardPlacement, CardData cardData)
{
Debug.Log($"[AlbumViewPage] Card placed in album slot: {cardData.Name}");
Logging.Debug($"[AlbumViewPage] Card placed in album slot: {cardData.Name}");
// Unsubscribe from events (card is now static in album)
cardPlacement.OnCardRevealed -= OnCardRevealed;
@@ -656,30 +647,22 @@ namespace UI.CardSystem
/// </summary>
public CardZone GetCurrentZone()
{
Debug.Log($"[PAGE-NAV-DEBUG] GetCurrentZone() called");
if (book == null || zoneTabs == null || zoneTabs.Length == 0)
{
Debug.LogWarning($"[PAGE-NAV-DEBUG] GetCurrentZone - Missing references! book: {(book != null)}, zoneTabs: {(zoneTabs != null)}, zoneTabs.Length: {(zoneTabs != null ? zoneTabs.Length : 0)}");
return CardZone.AppleHills; // Default
}
int currentPage = book.CurrentPaper;
Debug.Log($"[PAGE-NAV-DEBUG] Current book page: {currentPage}");
// Find tab with matching target page
foreach (var tab in zoneTabs)
{
Debug.Log($"[PAGE-NAV-DEBUG] Checking tab - Zone: {tab.Zone}, TargetPage: {tab.TargetPage}");
if (tab.TargetPage == currentPage)
{
Debug.Log($"[PAGE-NAV-DEBUG] Found matching tab! Zone: {tab.Zone}");
return tab.Zone;
}
}
// Fallback to first zone
Debug.LogWarning($"[PAGE-NAV-DEBUG] No tab matched current page {currentPage}, falling back to first zone: {CardZone.NotApplicable}");
return CardZone.NotApplicable;
}
@@ -688,27 +671,20 @@ namespace UI.CardSystem
/// </summary>
public BookTabButton GetTabForZone(CardZone zone)
{
Debug.Log($"[PAGE-NAV-DEBUG] GetTabForZone({zone}) called");
if (zoneTabs == null)
{
Debug.LogError($"[PAGE-NAV-DEBUG] zoneTabs is NULL! Cannot find tab for zone {zone}");
return null;
}
Debug.Log($"[PAGE-NAV-DEBUG] Searching through {zoneTabs.Length} tabs for zone {zone}");
foreach (var tab in zoneTabs)
{
Debug.Log($"[PAGE-NAV-DEBUG] Checking tab - Zone: {tab.Zone}, TargetPage: {tab.TargetPage}, Match: {tab.Zone == zone}");
{
if (tab.Zone == zone)
{
Debug.Log($"[PAGE-NAV-DEBUG] FOUND matching tab for zone {zone}! TargetPage: {tab.TargetPage}");
return tab;
}
}
Debug.LogError($"[PAGE-NAV-DEBUG] NO TAB FOUND for zone {zone}! Navigation will fail.");
return null;
}
@@ -717,18 +693,11 @@ namespace UI.CardSystem
/// </summary>
public void NavigateToZone(CardZone zone)
{
Debug.Log($"[PAGE-NAV-DEBUG] NavigateToZone({zone}) called");
BookTabButton tab = GetTabForZone(zone);
if (tab != null)
{
Debug.Log($"[PAGE-NAV-DEBUG] Tab found! Calling ActivateTab() on {tab.name}");
tab.ActivateTab();
}
else
{
Debug.LogError($"[PAGE-NAV-DEBUG] NAVIGATION FAILED - No tab found for zone {zone}!");
}
}
/// <summary>
@@ -782,7 +751,7 @@ namespace UI.CardSystem
{
if (card == null) return;
Debug.Log($"[AlbumViewPage] OnCardEnlargeRequested called for card: {card.name}, current parent: {card.transform.parent.name}");
Logging.Debug($"[AlbumViewPage] OnCardEnlargeRequested called for card: {card.name}, current parent: {card.transform.parent.name}");
// IMPORTANT: Call EnlargeCard FIRST to store original parent (the slot)
// BEFORE reparenting to the enlarged container
@@ -792,7 +761,7 @@ namespace UI.CardSystem
if (cardEnlargedBackdrop != null)
{
cardEnlargedBackdrop.SetActive(true);
Debug.Log($"[AlbumViewPage] Backdrop shown");
Logging.Debug($"[AlbumViewPage] Backdrop shown");
}
// NOW reparent card to enlarged container (above backdrop)
@@ -800,10 +769,10 @@ namespace UI.CardSystem
{
card.transform.SetParent(cardEnlargedContainer, true);
card.transform.SetAsLastSibling(); // Ensure on top
Debug.Log($"[AlbumViewPage] Card reparented to enlarged container");
Logging.Debug($"[AlbumViewPage] Card reparented to enlarged container");
}
Debug.Log($"[AlbumViewPage] Card enlarged: {card.GetCardData()?.Name}");
Logging.Debug($"[AlbumViewPage] Card enlarged: {card.GetCardData()?.Name}");
}
/// <summary>
@@ -831,7 +800,7 @@ namespace UI.CardSystem
card.transform.localRotation = card.GetOriginalLocalRotation();
}
Debug.Log($"[AlbumViewPage] Card shrunk: {card.GetCardData()?.Name}");
Logging.Debug($"[AlbumViewPage] Card shrunk: {card.GetCardData()?.Name}");
}
/// <summary>
@@ -842,7 +811,7 @@ namespace UI.CardSystem
if (previewCardTransform == null)
return;
Debug.Log($"[AlbumViewPage] ShowSlotPreview called for slot: {slot.name}");
Logging.Debug($"[AlbumViewPage] ShowSlotPreview called for slot: {slot.name}");
// Show backdrop
if (cardEnlargedBackdrop != null)
@@ -866,7 +835,7 @@ namespace UI.CardSystem
if (previewCardTransform == null)
return;
Debug.Log($"[AlbumViewPage] HideSlotPreview called for slot: {slot.name}");
Logging.Debug($"[AlbumViewPage] HideSlotPreview called for slot: {slot.name}");
// Hide backdrop
if (cardEnlargedBackdrop != null)