- **Refactored Card Placement Flow** - Separated card presentation from orchestration logic - Extracted `CornerCardManager` for pending card lifecycle (spawn, shuffle, rebuild) - Extracted `AlbumNavigationService` for book page navigation and zone mapping - Extracted `CardEnlargeController` for backdrop management and card reparenting - Implemented controller pattern (non-MonoBehaviour) for complex logic - Cards now unparent from slots before rebuild to prevent premature destruction - **Improved Corner Card Display** - Fixed cards spawning on top of each other during rebuild - Implemented shuffle-to-front logic (remaining cards occupy slots 0→1→2) - Added smart card selection (prioritizes cards matching current album page) - Pending cards now removed from queue immediately on drag start - Corner cards rebuild after each placement with proper slot reassignment - **Enhanced Album Card Viewing** - Added dramatic scale increase when viewing cards from album slots - Implemented shrink animation when dismissing enlarged cards - Cards transition: `PlacedInSlotState` → `AlbumEnlargedState` → `PlacedInSlotState` - Backdrop shows/hides with card enlarge/shrink cycle - Cards reparent to enlarged container while viewing, return to slot after - **State Machine Improvements** - Added `CardStateNames` constants for type-safe state transitions - Implemented `ICardClickHandler` and `ICardStateDragHandler` interfaces - State transitions now use cached property indices - `BoosterCardContext` separated from `CardContext` for single responsibility - **Code Cleanup** - Identified unused `SlotContainerHelper.cs` (superseded by `CornerCardManager`) - Identified unused `BoosterPackDraggable.canOpenOnDrop` field - Identified unused `AlbumViewPage._previousInputMode` (hardcoded value) - Identified unused `Card.OnPlacedInAlbumSlot` event (no subscribers) Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Reviewed-on: #59
93 lines
2.8 KiB
C#
93 lines
2.8 KiB
C#
using Core;
|
|
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;
|
|
[SerializeField] private BoosterOpeningPage boosterOpeningPage;
|
|
|
|
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);
|
|
}
|
|
|
|
Logging.Debug("ALBUM: CardAlbumDestroyed");
|
|
}
|
|
|
|
private void OnOpenAlbumClicked()
|
|
{
|
|
if (UIPageController.Instance == null) return;
|
|
|
|
// Check if we're currently on the booster opening page
|
|
if (UIPageController.Instance.CurrentPage == boosterOpeningPage)
|
|
{
|
|
// We're in booster opening page, pop back to album main page
|
|
UIPageController.Instance.PopPage();
|
|
}
|
|
else if (UIPageController.Instance.CurrentPage != albumViewPage)
|
|
{
|
|
// We're not in the album at all, open it
|
|
if (openAlbumButton != null)
|
|
{
|
|
openAlbumButton.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (albumViewPage != null)
|
|
{
|
|
UIPageController.Instance.PushPage(albumViewPage);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnPageChanged(UIPage currentPage)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|