Fix up the UI + game flow in minigame, should function correctly now

This commit is contained in:
Michal Pikulski
2025-10-24 13:01:19 +02:00
parent 1003c3f6ac
commit 04737ab01b
11 changed files with 919 additions and 1203 deletions

View File

@@ -2,7 +2,6 @@
using Bootstrap;
using Core;
using Data.CardSystem;
using Input;
using Pixelplacement;
using UI.Core;
using UnityEngine;
@@ -33,8 +32,7 @@ namespace UI.CardSystem
public GameObject BackpackIcon => backpackIcon;
private UIPageController PageController => UIPageController.Instance;
private CardSystemManager _cardManager;
private bool _isInitialized = false;
private bool _hasUnseenCards = false;
private bool _hasUnseenCards;
private void Awake()
{
@@ -59,6 +57,13 @@ namespace UI.CardSystem
// Initialize pages and hide them
InitializePages();
// React to global UI hide/show events (top-page only) by toggling this GameObject
if (UIPageController.Instance != null)
{
UIPageController.Instance.OnAllUIHidden += HandleAllUIHidden;
UIPageController.Instance.OnAllUIShown += HandleAllUIShown;
}
}
private void Start()
@@ -77,8 +82,6 @@ namespace UI.CardSystem
// Initialize UI with current values
UpdateBoosterCount(_cardManager.GetBoosterPackCount());
}
_isInitialized = true;
}
private void OnDestroy()
@@ -103,6 +106,13 @@ namespace UI.CardSystem
{
PageController.OnPageChanged -= OnPageChanged;
}
// Unsubscribe from global UI hide/show events
if (UIPageController.Instance != null)
{
UIPageController.Instance.OnAllUIHidden -= HandleAllUIHidden;
UIPageController.Instance.OnAllUIShown -= HandleAllUIShown;
}
}
/// <summary>
@@ -168,6 +178,7 @@ namespace UI.CardSystem
if (newPage == null)
{
ShowOnlyBackpackIcon();
GameManager.Instance.ReleasePause(this);
}
else
{
@@ -221,8 +232,6 @@ namespace UI.CardSystem
boosterNotificationDot.gameObject.SetActive(hasBooters || _hasUnseenCards);
}
}
GameManager.Instance.ReleasePause(this);
}
/// <summary>
@@ -313,5 +322,19 @@ namespace UI.CardSystem
// Just log the upgrade event without showing a notification
Logging.Debug($"[CardAlbumUI] Card upgraded: {card.Name} to {card.Rarity}");
}
// Handlers for UI controller hide/show events — toggle this GameObject active state
private void HandleAllUIHidden()
{
// Ensure UI returns to backpack-only state before deactivating so we don't leave the game paused
ShowOnlyBackpackIcon();
backpackButton.gameObject.SetActive(false);
}
private void HandleAllUIShown()
{
backpackButton.gameObject.SetActive(true);
}
}
}