Add seeing mr Cement photos in the album
This commit is contained in:
@@ -0,0 +1,312 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CardSystem.UI.Component;
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Controllers;
|
||||
using Minigames.StatueDressup.PhotoGallery;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
namespace CardSystem.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller for managing photo slots across album pages.
|
||||
/// Discovers all AlbumPhotoSlot prefabs in scene, groups by CaptureType,
|
||||
/// and populates with latest photos from PhotoManager.
|
||||
/// </summary>
|
||||
public class AlbumPhotoPageController
|
||||
{
|
||||
private readonly GameObject _backdrop;
|
||||
private readonly Transform _enlargedContainer;
|
||||
private readonly float _animationDuration;
|
||||
|
||||
private Dictionary<CaptureType, List<AlbumPhotoSlot>> _slotsByType;
|
||||
private Dictionary<AlbumPhotoSlot, string> _photoAssignments; // Maps each slot to its assigned photoId
|
||||
private PhotoEnlargeController _enlargeController;
|
||||
private bool _isInitialized;
|
||||
|
||||
public bool IsInitialized => _isInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="backdrop">Backdrop for photo enlargement</param>
|
||||
/// <param name="enlargedContainer">Container for enlarged photos</param>
|
||||
/// <param name="animationDuration">Duration for enlarge/shrink animations</param>
|
||||
public AlbumPhotoPageController(GameObject backdrop, Transform enlargedContainer, float animationDuration = 0.3f)
|
||||
{
|
||||
_backdrop = backdrop;
|
||||
_enlargedContainer = enlargedContainer;
|
||||
_animationDuration = animationDuration;
|
||||
|
||||
// Initialize data structures
|
||||
_photoAssignments = new Dictionary<AlbumPhotoSlot, string>();
|
||||
|
||||
// Initialize enlarge controller
|
||||
_enlargeController = new PhotoEnlargeController(backdrop, enlargedContainer, animationDuration);
|
||||
|
||||
Logging.Debug("[AlbumPhotoPageController] Controller created");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Discover all photo slots in scene and populate them with latest photos
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
Logging.Debug("[AlbumPhotoPageController] Initialize() called");
|
||||
|
||||
if (_isInitialized)
|
||||
{
|
||||
Logging.Warning("[AlbumPhotoPageController] Already initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find all photo slots in scene
|
||||
AlbumPhotoSlot[] allSlots = Object.FindObjectsByType<AlbumPhotoSlot>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Found {(allSlots != null ? allSlots.Length : 0)} AlbumPhotoSlot components in scene");
|
||||
|
||||
if (allSlots == null || allSlots.Length == 0)
|
||||
{
|
||||
Logging.Warning("[AlbumPhotoPageController] No AlbumPhotoSlot components found in scene");
|
||||
_isInitialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Group slots by CaptureType
|
||||
_slotsByType = new Dictionary<CaptureType, List<AlbumPhotoSlot>>();
|
||||
|
||||
foreach (var slot in allSlots)
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoPageController] Processing slot: {slot.name}, CaptureType: {slot.CaptureType}");
|
||||
|
||||
if (!_slotsByType.ContainsKey(slot.CaptureType))
|
||||
{
|
||||
_slotsByType[slot.CaptureType] = new List<AlbumPhotoSlot>();
|
||||
}
|
||||
|
||||
_slotsByType[slot.CaptureType].Add(slot);
|
||||
|
||||
// Initialize the slot with this controller
|
||||
slot.Initialize(this);
|
||||
}
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Found {allSlots.Length} photo slots across {_slotsByType.Count} capture types");
|
||||
|
||||
// Log slot counts per type
|
||||
foreach (var kvp in _slotsByType)
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoPageController] {kvp.Key}: {kvp.Value.Count} slots");
|
||||
}
|
||||
|
||||
// Prepare photo assignments (but don't populate yet - slots will request when they become active)
|
||||
Logging.Debug("[AlbumPhotoPageController] Starting PreparePhotoAssignments()");
|
||||
PreparePhotoAssignments();
|
||||
|
||||
_isInitialized = true;
|
||||
Logging.Debug("[AlbumPhotoPageController] Initialize() complete");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare photo assignments for all discovered slots.
|
||||
/// Slots will request their assigned photo when they become active.
|
||||
/// </summary>
|
||||
private void PreparePhotoAssignments()
|
||||
{
|
||||
_photoAssignments.Clear();
|
||||
|
||||
foreach (var kvp in _slotsByType)
|
||||
{
|
||||
CaptureType captureType = kvp.Key;
|
||||
List<AlbumPhotoSlot> slots = kvp.Value;
|
||||
|
||||
// Get latest photos for this capture type
|
||||
int slotCount = slots.Count;
|
||||
List<string> photoIds = PhotoManager.GetPhotoIds(captureType, slotCount);
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Preparing assignments for {slotCount} slots of {captureType} with {photoIds.Count} photos");
|
||||
|
||||
// Build assignment map
|
||||
for (int i = 0; i < slots.Count; i++)
|
||||
{
|
||||
string photoId = (i < photoIds.Count) ? photoIds[i] : null;
|
||||
_photoAssignments[slots[i]] = photoId;
|
||||
|
||||
if (photoId != null)
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoPageController] Slot {i} ({slots[i].name}) -> {photoId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoPageController] Slot {i} ({slots[i].name}) -> (no photo)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Prepared {_photoAssignments.Count} photo assignments");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the assigned photo ID for a specific slot.
|
||||
/// Called by slots when they become active.
|
||||
/// </summary>
|
||||
public string GetAssignedPhotoId(AlbumPhotoSlot slot)
|
||||
{
|
||||
if (slot == null || _photoAssignments == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_photoAssignments.TryGetValue(slot, out string photoId))
|
||||
{
|
||||
return photoId;
|
||||
}
|
||||
|
||||
Logging.Warning($"[AlbumPhotoPageController] Slot {slot.name} not found in assignments");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh photos for a specific capture type (call after new photo is taken)
|
||||
/// </summary>
|
||||
public void RefreshPhotosForType(CaptureType captureType)
|
||||
{
|
||||
if (!_isInitialized || !_slotsByType.ContainsKey(captureType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<AlbumPhotoSlot> slots = _slotsByType[captureType];
|
||||
|
||||
// Clear existing slots
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
slot.Clear();
|
||||
}
|
||||
|
||||
// Get latest photos and rebuild assignments
|
||||
int slotCount = slots.Count;
|
||||
List<string> photoIds = PhotoManager.GetPhotoIds(captureType, slotCount);
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Refreshing assignments for {slotCount} slots of {captureType} with {photoIds.Count} photos");
|
||||
|
||||
// Update assignments
|
||||
for (int i = 0; i < slots.Count; i++)
|
||||
{
|
||||
string photoId = (i < photoIds.Count) ? photoIds[i] : null;
|
||||
_photoAssignments[slots[i]] = photoId;
|
||||
}
|
||||
|
||||
// Trigger slots to reload (they will request their new assignment when they become active)
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
if (slot.gameObject.activeInHierarchy)
|
||||
{
|
||||
// If slot is currently active, immediately populate with new assignment
|
||||
slot.PopulateWithPhoto(GetAssignedPhotoId(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh all photo slots (call after album is opened to show latest photos)
|
||||
/// </summary>
|
||||
public void RefreshAllPhotos()
|
||||
{
|
||||
if (!_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var captureType in _slotsByType.Keys.ToList())
|
||||
{
|
||||
RefreshPhotosForType(captureType);
|
||||
}
|
||||
|
||||
Logging.Debug("[AlbumPhotoPageController] All photos refreshed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enlarge a photo (called by AlbumPhotoSlot)
|
||||
/// </summary>
|
||||
public void EnlargePhoto(AlbumPhotoSlot slot, Texture2D fullSizeTexture)
|
||||
{
|
||||
if (_enlargeController == null)
|
||||
{
|
||||
Logging.Error("[AlbumPhotoPageController] Enlarge controller not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
// If already enlarged, shrink it
|
||||
if (_enlargeController.IsPhotoEnlarged)
|
||||
{
|
||||
_enlargeController.ShrinkPhoto();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fullSizeTexture == null)
|
||||
{
|
||||
Logging.Error($"[AlbumPhotoPageController] Cannot enlarge null texture for slot {slot.PhotoId}");
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.Debug($"[AlbumPhotoPageController] Enlarging photo: {slot.PhotoId} from {slot.CaptureType}");
|
||||
|
||||
// Default enlarged scale (can be made configurable)
|
||||
float enlargedScale = 2.5f;
|
||||
|
||||
// Enlarge using the controller
|
||||
_enlargeController.EnlargePhoto(slot, slot.gameObject, fullSizeTexture, enlargedScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get photo count for a specific capture type
|
||||
/// </summary>
|
||||
public int GetPhotoCount(CaptureType captureType)
|
||||
{
|
||||
return PhotoManager.GetPhotoCount(captureType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get slot count for a specific capture type
|
||||
/// </summary>
|
||||
public int GetSlotCount(CaptureType captureType)
|
||||
{
|
||||
if (!_isInitialized || !_slotsByType.ContainsKey(captureType))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _slotsByType[captureType].Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup when album is closed
|
||||
/// </summary>
|
||||
public void Cleanup()
|
||||
{
|
||||
if (_enlargeController != null)
|
||||
{
|
||||
_enlargeController.Cleanup();
|
||||
}
|
||||
|
||||
// Clear all slots
|
||||
if (_slotsByType != null)
|
||||
{
|
||||
foreach (var slots in _slotsByType.Values)
|
||||
{
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
if (slot != null)
|
||||
{
|
||||
slot.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logging.Debug("[AlbumPhotoPageController] Cleanup complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 607fe563cc4a4d48976d845145bc0d57
|
||||
timeCreated: 1765801157
|
||||
257
Assets/Scripts/CardSystem/UI/Component/AlbumPhotoSlot.cs
Normal file
257
Assets/Scripts/CardSystem/UI/Component/AlbumPhotoSlot.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
using System.Collections;
|
||||
using CardSystem.Controllers;
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Utils;
|
||||
|
||||
namespace CardSystem.UI.Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Photo display slot for the album book pages.
|
||||
/// Pre-placed prefab that displays photos from a specific minigame category.
|
||||
/// Supports click-to-enlarge functionality.
|
||||
/// </summary>
|
||||
public class AlbumPhotoSlot : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
[Header("Configuration")]
|
||||
[Tooltip("Which minigame category this slot displays photos from")]
|
||||
[SerializeField] private CaptureType captureType = CaptureType.StatueMinigame;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Image photoImage;
|
||||
[SerializeField] private GameObject loadingIndicator;
|
||||
[SerializeField] private GameObject emptyPlaceholder;
|
||||
|
||||
[Header("Visual Settings")]
|
||||
[SerializeField] private int thumbnailSize = 256;
|
||||
|
||||
private string _photoId;
|
||||
private Texture2D _currentTexture;
|
||||
private Texture2D _fullSizeTexture;
|
||||
private AlbumPhotoPageController _controller;
|
||||
private bool _isPopulated;
|
||||
|
||||
public CaptureType CaptureType => captureType;
|
||||
public bool IsPopulated => _isPopulated;
|
||||
public string PhotoId => _photoId;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the slot with controller reference
|
||||
/// </summary>
|
||||
public void Initialize(AlbumPhotoPageController controller)
|
||||
{
|
||||
_controller = controller;
|
||||
Logging.Debug($"[AlbumPhotoSlot] {gameObject.name} initialized with controller");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When slot becomes active, request and load assigned photo from controller
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
// Only auto-load if we have a controller and haven't already populated
|
||||
if (_controller != null && !_isPopulated && string.IsNullOrEmpty(_photoId))
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoSlot] {gameObject.name} became active, requesting assigned photo");
|
||||
|
||||
// Request our assigned photo ID from controller
|
||||
string assignedPhotoId = _controller.GetAssignedPhotoId(this);
|
||||
|
||||
if (!string.IsNullOrEmpty(assignedPhotoId))
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoSlot] {gameObject.name} assigned photoId: {assignedPhotoId}");
|
||||
PopulateWithPhoto(assignedPhotoId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoSlot] {gameObject.name} has no assigned photo, showing empty state");
|
||||
ShowEmptyState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate this slot with a photo from the minigame
|
||||
/// </summary>
|
||||
/// <param name="photoId">Photo ID to load</param>
|
||||
public void PopulateWithPhoto(string photoId)
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoSlot] PopulateWithPhoto called: photoId='{photoId}', captureType={captureType}");
|
||||
|
||||
if (string.IsNullOrEmpty(photoId))
|
||||
{
|
||||
Logging.Debug($"[AlbumPhotoSlot] Photo ID is null or empty, showing empty state");
|
||||
ShowEmptyState();
|
||||
return;
|
||||
}
|
||||
|
||||
_photoId = photoId;
|
||||
StartCoroutine(LoadPhotoAsync(photoId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load photo asynchronously to avoid frame hitches
|
||||
/// </summary>
|
||||
private IEnumerator LoadPhotoAsync(string photoId)
|
||||
{
|
||||
ShowLoadingState();
|
||||
|
||||
Logging.Debug($"[AlbumPhotoSlot] LoadPhotoAsync started for photoId: {photoId}, captureType: {captureType}");
|
||||
|
||||
// Yield to avoid loading all photos in one frame
|
||||
yield return null;
|
||||
|
||||
// Load full photo
|
||||
Logging.Debug($"[AlbumPhotoSlot] Calling PhotoManager.LoadPhoto({captureType}, {photoId})");
|
||||
Texture2D fullPhoto = PhotoManager.LoadPhoto(captureType, photoId);
|
||||
|
||||
if (fullPhoto == null)
|
||||
{
|
||||
Logging.Warning($"[AlbumPhotoSlot] Failed to load photo: {photoId} for {captureType}");
|
||||
ShowEmptyState();
|
||||
yield break;
|
||||
}
|
||||
|
||||
Logging.Debug($"[AlbumPhotoSlot] Photo loaded successfully! Size: {fullPhoto.width}x{fullPhoto.height}");
|
||||
|
||||
// Create thumbnail for display
|
||||
Texture2D thumbnail = PhotoManager.CreateThumbnail(fullPhoto, thumbnailSize);
|
||||
Logging.Debug($"[AlbumPhotoSlot] Thumbnail created: {thumbnail.width}x{thumbnail.height}");
|
||||
|
||||
// Store full size for enlargement
|
||||
_fullSizeTexture = fullPhoto;
|
||||
_currentTexture = thumbnail;
|
||||
|
||||
// Display thumbnail
|
||||
DisplayPhoto(thumbnail);
|
||||
|
||||
_isPopulated = true;
|
||||
Logging.Debug($"[AlbumPhotoSlot] Photo display complete for {photoId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display photo texture on the image component
|
||||
/// </summary>
|
||||
private void DisplayPhoto(Texture2D texture)
|
||||
{
|
||||
if (texture == null || photoImage == null) return;
|
||||
|
||||
// Create sprite from texture
|
||||
Sprite photoSprite = Sprite.Create(
|
||||
texture,
|
||||
new Rect(0, 0, texture.width, texture.height),
|
||||
new Vector2(0.5f, 0.5f)
|
||||
);
|
||||
|
||||
photoImage.sprite = photoSprite;
|
||||
photoImage.enabled = true;
|
||||
|
||||
HideLoadingState();
|
||||
HideEmptyState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle click to enlarge photo
|
||||
/// </summary>
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (!_isPopulated || string.IsNullOrEmpty(_photoId) || _controller == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.Debug($"[AlbumPhotoSlot] Clicked photo: {_photoId} from {captureType}");
|
||||
|
||||
// Request enlargement from controller
|
||||
_controller.EnlargePhoto(this, _fullSizeTexture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the slot
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
_photoId = null;
|
||||
_isPopulated = false;
|
||||
|
||||
if (_currentTexture != null)
|
||||
{
|
||||
Destroy(_currentTexture);
|
||||
_currentTexture = null;
|
||||
}
|
||||
|
||||
if (_fullSizeTexture != null)
|
||||
{
|
||||
Destroy(_fullSizeTexture);
|
||||
_fullSizeTexture = null;
|
||||
}
|
||||
|
||||
if (photoImage != null)
|
||||
{
|
||||
photoImage.sprite = null;
|
||||
photoImage.enabled = false;
|
||||
}
|
||||
|
||||
ShowEmptyState();
|
||||
}
|
||||
|
||||
#region Visual States
|
||||
|
||||
private void ShowLoadingState()
|
||||
{
|
||||
if (loadingIndicator != null)
|
||||
loadingIndicator.SetActive(true);
|
||||
|
||||
if (photoImage != null)
|
||||
photoImage.enabled = false;
|
||||
|
||||
if (emptyPlaceholder != null)
|
||||
emptyPlaceholder.SetActive(false);
|
||||
}
|
||||
|
||||
private void HideLoadingState()
|
||||
{
|
||||
if (loadingIndicator != null)
|
||||
loadingIndicator.SetActive(false);
|
||||
}
|
||||
|
||||
private void ShowEmptyState()
|
||||
{
|
||||
if (emptyPlaceholder != null)
|
||||
emptyPlaceholder.SetActive(true);
|
||||
|
||||
if (loadingIndicator != null)
|
||||
loadingIndicator.SetActive(false);
|
||||
|
||||
if (photoImage != null)
|
||||
photoImage.enabled = false;
|
||||
|
||||
_isPopulated = false;
|
||||
}
|
||||
|
||||
private void HideEmptyState()
|
||||
{
|
||||
if (emptyPlaceholder != null)
|
||||
emptyPlaceholder.SetActive(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// Cleanup textures
|
||||
if (_currentTexture != null)
|
||||
{
|
||||
Destroy(_currentTexture);
|
||||
}
|
||||
|
||||
if (_fullSizeTexture != null)
|
||||
{
|
||||
Destroy(_fullSizeTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb3200565b9f4a14b27f74ff9ec083c6
|
||||
timeCreated: 1765801126
|
||||
@@ -20,6 +20,7 @@ namespace UI.CardSystem
|
||||
|
||||
[Header("Tab Configuration")]
|
||||
[SerializeField] private int targetPage;
|
||||
[Tooltip("Optional: Set this for card collection zone tabs. Leave unassigned for other tabs (e.g., photo pages).")]
|
||||
[SerializeField] private CardZone zone;
|
||||
|
||||
[Header("Visual Settings")]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using AppleHills.Data.CardSystem;
|
||||
using CardSystem.Controllers;
|
||||
using Core;
|
||||
using Data.CardSystem;
|
||||
using Pixelplacement;
|
||||
@@ -8,6 +9,7 @@ using UI.DragAndDrop.Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Serialization;
|
||||
using Utils;
|
||||
|
||||
namespace UI.CardSystem
|
||||
{
|
||||
@@ -35,6 +37,11 @@ namespace UI.CardSystem
|
||||
[SerializeField] private GameObject cardEnlargedBackdrop; // Backdrop to block interactions
|
||||
[SerializeField] private Transform cardEnlargedContainer; // Container for enlarged cards (sits above backdrop)
|
||||
|
||||
[Header("Photo Gallery System")]
|
||||
[SerializeField] private GameObject photoEnlargedBackdrop; // Backdrop for photo enlargement
|
||||
[SerializeField] private Transform photoEnlargedContainer; // Container for enlarged photos
|
||||
[SerializeField] private float photoAnimationDuration = 0.3f;
|
||||
|
||||
[Header("Booster Pack UI")]
|
||||
[SerializeField] private GameObject[] boosterPackButtons;
|
||||
[SerializeField] private BoosterOpeningPage boosterOpeningPage;
|
||||
@@ -61,6 +68,13 @@ namespace UI.CardSystem
|
||||
cardEnlargedContainer
|
||||
);
|
||||
|
||||
private AlbumPhotoPageController _photoController;
|
||||
private AlbumPhotoPageController PhotoController => _photoController ??= new AlbumPhotoPageController(
|
||||
photoEnlargedBackdrop,
|
||||
photoEnlargedContainer,
|
||||
photoAnimationDuration
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query method: Check if the book is currently flipping to a page.
|
||||
/// Used by card states to know if they should wait before placing.
|
||||
@@ -84,6 +98,12 @@ namespace UI.CardSystem
|
||||
cardEnlargedBackdrop.SetActive(false);
|
||||
}
|
||||
|
||||
// Hide photo backdrop initially
|
||||
if (photoEnlargedBackdrop != null)
|
||||
{
|
||||
photoEnlargedBackdrop.SetActive(false);
|
||||
}
|
||||
|
||||
// Set up exit button
|
||||
if (exitButton != null)
|
||||
{
|
||||
@@ -283,6 +303,13 @@ namespace UI.CardSystem
|
||||
Logging.Debug("[AlbumViewPage] Switched to UI-only input mode on first entry");
|
||||
}
|
||||
|
||||
// Initialize photo controller if not already done
|
||||
if (!PhotoController.IsInitialized)
|
||||
{
|
||||
PhotoController.Initialize();
|
||||
Logging.Debug("[AlbumViewPage] Photo controller initialized");
|
||||
}
|
||||
|
||||
// Only spawn pending cards if we're already on an album page (not the menu)
|
||||
if (IsInAlbumProper())
|
||||
{
|
||||
@@ -305,6 +332,12 @@ namespace UI.CardSystem
|
||||
// Clean up active pending cards to prevent duplicates on next opening
|
||||
CleanupPendingCornerCards();
|
||||
|
||||
// Clean up photo controller
|
||||
if (_photoController != null)
|
||||
{
|
||||
_photoController.Cleanup();
|
||||
}
|
||||
|
||||
// Don't restore input mode here - only restore when actually exiting (in OnExitButtonClicked)
|
||||
base.TransitionOut();
|
||||
}
|
||||
@@ -329,6 +362,12 @@ namespace UI.CardSystem
|
||||
// Clean up any enlarged card state before closing
|
||||
CleanupEnlargedCardState();
|
||||
|
||||
// Clean up photo controller
|
||||
if (_photoController != null)
|
||||
{
|
||||
_photoController.Cleanup();
|
||||
}
|
||||
|
||||
// Simple fade out animation
|
||||
if (canvasGroup != null)
|
||||
{
|
||||
@@ -401,6 +440,34 @@ namespace UI.CardSystem
|
||||
Enlarge.UnregisterCard(card);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Photo Gallery System
|
||||
|
||||
/// <summary>
|
||||
/// Refresh photos for a specific capture type after a new photo is taken
|
||||
/// </summary>
|
||||
public void RefreshPhotosForType(CaptureType captureType)
|
||||
{
|
||||
if (_photoController != null && _photoController.IsInitialized)
|
||||
{
|
||||
_photoController.RefreshPhotosForType(captureType);
|
||||
Logging.Debug($"[AlbumViewPage] Refreshed photos for {captureType}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get photo count for a specific capture type
|
||||
/// </summary>
|
||||
public int GetPhotoCount(CaptureType captureType)
|
||||
{
|
||||
if (_photoController != null && _photoController.IsInitialized)
|
||||
{
|
||||
return _photoController.GetPhotoCount(captureType);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user