Fix method signatures for apple machines
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimal test for photo capture - just capture and save to disk
|
||||
/// </summary>
|
||||
public class PhotoCaptureTestController : MonoBehaviour
|
||||
{
|
||||
[Header("Required")]
|
||||
[SerializeField] private RectTransform captureArea;
|
||||
[SerializeField] private Button captureButton;
|
||||
|
||||
[Header("Optional - UI to hide during capture")]
|
||||
[SerializeField] private GameObject[] hideTheseObjects;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (captureButton != null)
|
||||
{
|
||||
captureButton.onClick.AddListener(OnCaptureClicked);
|
||||
}
|
||||
|
||||
Debug.Log($"[PhotoCaptureTest] Ready. Photo save path: {StatuePhotoManager.GetPhotoDirectory()}");
|
||||
}
|
||||
|
||||
private void OnCaptureClicked()
|
||||
{
|
||||
if (captureArea == null)
|
||||
{
|
||||
Debug.LogError("[PhotoCaptureTest] Capture Area not assigned!");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("[PhotoCaptureTest] Starting capture...");
|
||||
StartCoroutine(CaptureCoroutine());
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator CaptureCoroutine()
|
||||
{
|
||||
// Hide UI
|
||||
foreach (var obj in hideTheseObjects)
|
||||
if (obj != null) obj.SetActive(false);
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
// Capture
|
||||
bool done = false;
|
||||
Texture2D photo = null;
|
||||
|
||||
StatuePhotoManager.CaptureAreaPhoto(captureArea, (texture) => {
|
||||
photo = texture;
|
||||
done = true;
|
||||
});
|
||||
|
||||
yield return new WaitUntil(() => done);
|
||||
|
||||
// Restore UI
|
||||
foreach (var obj in hideTheseObjects)
|
||||
if (obj != null) obj.SetActive(true);
|
||||
|
||||
// Save
|
||||
if (photo != null)
|
||||
{
|
||||
string photoId = StatuePhotoManager.SavePhoto(photo, 0);
|
||||
|
||||
if (!string.IsNullOrEmpty(photoId))
|
||||
{
|
||||
string path = $"{StatuePhotoManager.GetPhotoDirectory()}/{photoId}.png";
|
||||
Debug.Log($"[PhotoCaptureTest] ✅ SUCCESS! Photo saved: {path}");
|
||||
Debug.Log($"[PhotoCaptureTest] Photo size: {photo.width}x{photo.height}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[PhotoCaptureTest] ❌ Failed to save photo");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[PhotoCaptureTest] ❌ Failed to capture photo");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (captureButton != null)
|
||||
captureButton.onClick.RemoveListener(OnCaptureClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deab1758ddef4bdea0e2c50554eaf568
|
||||
timeCreated: 1764077035
|
||||
@@ -0,0 +1,79 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Individual photo thumbnail in the gallery grid.
|
||||
/// Handles click to show enlarged view.
|
||||
/// </summary>
|
||||
public class PhotoGridItem : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Image thumbnailImage;
|
||||
[SerializeField] private GameObject loadingIndicator;
|
||||
|
||||
private string _photoId;
|
||||
private StatuePhotoGalleryController _galleryController;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize grid item with photo ID
|
||||
/// </summary>
|
||||
public void Initialize(string photoId, StatuePhotoGalleryController controller)
|
||||
{
|
||||
_photoId = photoId;
|
||||
_galleryController = controller;
|
||||
|
||||
// Show loading state
|
||||
if (loadingIndicator != null)
|
||||
loadingIndicator.SetActive(true);
|
||||
|
||||
if (thumbnailImage != null)
|
||||
thumbnailImage.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the thumbnail texture
|
||||
/// </summary>
|
||||
public void SetThumbnail(Texture2D thumbnail)
|
||||
{
|
||||
if (thumbnail == null)
|
||||
{
|
||||
Logging.Warning($"[PhotoGridItem] Null thumbnail for photo: {_photoId}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create sprite from thumbnail
|
||||
Sprite thumbnailSprite = Sprite.Create(
|
||||
thumbnail,
|
||||
new Rect(0, 0, thumbnail.width, thumbnail.height),
|
||||
new Vector2(0.5f, 0.5f)
|
||||
);
|
||||
|
||||
if (thumbnailImage != null)
|
||||
{
|
||||
thumbnailImage.sprite = thumbnailSprite;
|
||||
thumbnailImage.enabled = true;
|
||||
}
|
||||
|
||||
// Hide loading indicator
|
||||
if (loadingIndicator != null)
|
||||
loadingIndicator.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle click to show enlarged view
|
||||
/// </summary>
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (_galleryController != null && !string.IsNullOrEmpty(_photoId))
|
||||
{
|
||||
Logging.Debug($"[PhotoGridItem] Clicked: {_photoId}");
|
||||
_galleryController.ShowEnlargedView(_photoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acd8d97ee2f744d984a9507e75309be0
|
||||
timeCreated: 1764065014
|
||||
@@ -129,82 +129,61 @@ namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
// Capture the photo area
|
||||
Texture2D photo = CaptureScreenshotArea();
|
||||
// Capture using Screenshot Helper via StatuePhotoManager
|
||||
bool captureComplete = false;
|
||||
Texture2D capturedPhoto = null;
|
||||
|
||||
if (photo != null)
|
||||
Utils.StatuePhotoManager.CaptureAreaPhoto(
|
||||
photoArea,
|
||||
(Texture2D texture) =>
|
||||
{
|
||||
capturedPhoto = texture;
|
||||
captureComplete = true;
|
||||
},
|
||||
Camera.main
|
||||
);
|
||||
|
||||
// Wait for capture to complete
|
||||
yield return new WaitUntil(() => captureComplete);
|
||||
|
||||
if (capturedPhoto != null)
|
||||
{
|
||||
// Save photo to album
|
||||
SavePhotoToAlbum(photo);
|
||||
// Save photo with StatuePhotoManager
|
||||
int decorationCount = _placedDecorations.Count;
|
||||
string photoId = Utils.StatuePhotoManager.SavePhoto(capturedPhoto, decorationCount);
|
||||
|
||||
// Award cards
|
||||
AwardCards();
|
||||
|
||||
// Update town icon
|
||||
UpdateTownIcon(photo);
|
||||
|
||||
// Show completion feedback
|
||||
ShowCompletionFeedback();
|
||||
|
||||
_minigameCompleted = true;
|
||||
if (!string.IsNullOrEmpty(photoId))
|
||||
{
|
||||
Logging.Debug($"[StatueDecorationController] Photo saved: {photoId}");
|
||||
|
||||
// Award cards
|
||||
AwardCards();
|
||||
|
||||
// Update town icon
|
||||
UpdateTownIcon(capturedPhoto);
|
||||
|
||||
// Show completion feedback
|
||||
ShowCompletionFeedback();
|
||||
|
||||
_minigameCompleted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Error("[StatueDecorationController] Failed to save photo!");
|
||||
DebugUIMessage.Show("Failed to save photo!", Color.red);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Error("[StatueDecorationController] Failed to capture photo!");
|
||||
DebugUIMessage.Show("Failed to capture photo!", Color.red);
|
||||
}
|
||||
|
||||
// Restore UI
|
||||
HideUIForPhoto(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capture screenshot of specific area
|
||||
/// </summary>
|
||||
private Texture2D CaptureScreenshotArea()
|
||||
{
|
||||
if (photoArea == null)
|
||||
{
|
||||
Logging.Warning("[StatueDecorationController] No photo area specified, capturing full screen");
|
||||
|
||||
// Capture full screen
|
||||
Texture2D screenshot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
|
||||
screenshot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
screenshot.Apply();
|
||||
return screenshot;
|
||||
}
|
||||
|
||||
// Get world corners of the rect
|
||||
Vector3[] corners = new Vector3[4];
|
||||
photoArea.GetWorldCorners(corners);
|
||||
|
||||
// Convert to screen space
|
||||
Vector2 min = RectTransformUtility.WorldToScreenPoint(Camera.main, corners[0]);
|
||||
Vector2 max = RectTransformUtility.WorldToScreenPoint(Camera.main, corners[2]);
|
||||
|
||||
int width = (int)(max.x - min.x);
|
||||
int height = (int)(max.y - min.y);
|
||||
|
||||
Logging.Debug($"[StatueDecorationController] Capturing area: {width}x{height} at ({min.x}, {min.y})");
|
||||
|
||||
// Capture the specified area
|
||||
Texture2D areaScreenshot = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
areaScreenshot.ReadPixels(new Rect(min.x, min.y, width, height), 0, 0);
|
||||
areaScreenshot.Apply();
|
||||
|
||||
return areaScreenshot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save photo to card album
|
||||
/// </summary>
|
||||
private void SavePhotoToAlbum(Texture2D photo)
|
||||
{
|
||||
// TODO: Integrate with existing album save system
|
||||
// For now, save to PlayerPrefs as base64
|
||||
byte[] bytes = photo.EncodeToPNG();
|
||||
string base64 = System.Convert.ToBase64String(bytes);
|
||||
string saveKey = _settings?.PhotoSaveKey ?? photoSaveKey;
|
||||
PlayerPrefs.SetString(saveKey, base64);
|
||||
PlayerPrefs.Save();
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Photo saved to album");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Award Blokkemon cards to player
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
using Minigames.StatueDressup.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages photo gallery display with optimized memory usage.
|
||||
/// Loads photos in pages and caches thumbnails to avoid loading 1000+ photos at once.
|
||||
/// Supports grid view with thumbnail preview and enlarged view on selection.
|
||||
/// </summary>
|
||||
public class StatuePhotoGalleryController : ManagedBehaviour
|
||||
{
|
||||
[Header("Gallery UI")]
|
||||
[SerializeField] private Transform gridContainer;
|
||||
[SerializeField] private PhotoGridItem gridItemPrefab;
|
||||
[SerializeField] private ScrollRect scrollRect;
|
||||
|
||||
[Header("Enlarged View")]
|
||||
[SerializeField] private GameObject enlargedViewPanel;
|
||||
[SerializeField] private Image enlargedPhotoImage;
|
||||
[SerializeField] private Button closeEnlargedButton;
|
||||
[SerializeField] private Button deletePhotoButton;
|
||||
[SerializeField] private Text photoInfoText;
|
||||
|
||||
[Header("Pagination")]
|
||||
[SerializeField] private Button loadMoreButton;
|
||||
[SerializeField] private Text statusText;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private int itemsPerPage = 20;
|
||||
[SerializeField] private int thumbnailSize = 256;
|
||||
[SerializeField] private int maxCachedThumbnails = 50; // Keep recent thumbnails in memory
|
||||
|
||||
private int _currentPage = 0;
|
||||
private List<string> _allPhotoIds = new List<string>();
|
||||
private Dictionary<string, PhotoGridItem> _activeGridItems = new Dictionary<string, PhotoGridItem>();
|
||||
private Dictionary<string, Texture2D> _thumbnailCache = new Dictionary<string, Texture2D>();
|
||||
private Queue<string> _thumbnailCacheOrder = new Queue<string>();
|
||||
private string _currentEnlargedPhotoId = null;
|
||||
private Texture2D _currentEnlargedTexture = null;
|
||||
|
||||
internal override void OnManagedStart()
|
||||
{
|
||||
base.OnManagedStart();
|
||||
|
||||
// Setup buttons
|
||||
if (closeEnlargedButton != null)
|
||||
closeEnlargedButton.onClick.AddListener(CloseEnlargedView);
|
||||
|
||||
if (deletePhotoButton != null)
|
||||
deletePhotoButton.onClick.AddListener(DeleteCurrentPhoto);
|
||||
|
||||
if (loadMoreButton != null)
|
||||
loadMoreButton.onClick.AddListener(LoadNextPage);
|
||||
|
||||
// Hide enlarged view initially
|
||||
if (enlargedViewPanel != null)
|
||||
enlargedViewPanel.SetActive(false);
|
||||
|
||||
// Load first page
|
||||
RefreshGallery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the entire gallery from scratch
|
||||
/// </summary>
|
||||
public void RefreshGallery()
|
||||
{
|
||||
// Clear existing items
|
||||
ClearGallery();
|
||||
|
||||
// Get all photo IDs
|
||||
_allPhotoIds = StatuePhotoManager.GetAllPhotoIds();
|
||||
_currentPage = 0;
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Gallery refreshed: {_allPhotoIds.Count} photos");
|
||||
|
||||
// Load first page
|
||||
LoadNextPage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load next page of photos
|
||||
/// </summary>
|
||||
private void LoadNextPage()
|
||||
{
|
||||
List<string> pagePhotoIds = StatuePhotoManager.GetPhotoIdsPage(_currentPage, itemsPerPage);
|
||||
|
||||
if (pagePhotoIds.Count == 0)
|
||||
{
|
||||
if (loadMoreButton != null)
|
||||
loadMoreButton.gameObject.SetActive(false);
|
||||
|
||||
UpdateStatusText($"All photos loaded ({_allPhotoIds.Count} total)");
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Loading page {_currentPage}: {pagePhotoIds.Count} items");
|
||||
|
||||
// Spawn grid items for this page
|
||||
foreach (string photoId in pagePhotoIds)
|
||||
{
|
||||
SpawnGridItem(photoId);
|
||||
}
|
||||
|
||||
_currentPage++;
|
||||
|
||||
// Update UI state
|
||||
bool hasMore = _currentPage * itemsPerPage < _allPhotoIds.Count;
|
||||
if (loadMoreButton != null)
|
||||
loadMoreButton.gameObject.SetActive(hasMore);
|
||||
|
||||
UpdateStatusText($"Showing {_activeGridItems.Count} of {_allPhotoIds.Count} photos");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn a grid item for a photo
|
||||
/// </summary>
|
||||
private void SpawnGridItem(string photoId)
|
||||
{
|
||||
if (_activeGridItems.ContainsKey(photoId))
|
||||
{
|
||||
Logging.Warning($"[StatuePhotoGalleryController] Grid item already exists: {photoId}");
|
||||
return;
|
||||
}
|
||||
|
||||
PhotoGridItem gridItem = Instantiate(gridItemPrefab, gridContainer);
|
||||
gridItem.Initialize(photoId, this);
|
||||
|
||||
_activeGridItems[photoId] = gridItem;
|
||||
|
||||
// Load thumbnail asynchronously
|
||||
StartCoroutine(LoadThumbnailAsync(photoId, gridItem));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load thumbnail for grid item (async to avoid frame hitches)
|
||||
/// </summary>
|
||||
private IEnumerator LoadThumbnailAsync(string photoId, PhotoGridItem gridItem)
|
||||
{
|
||||
// Check cache first
|
||||
if (_thumbnailCache.TryGetValue(photoId, out Texture2D cachedThumbnail))
|
||||
{
|
||||
gridItem.SetThumbnail(cachedThumbnail);
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Yield to avoid loading all thumbnails in one frame
|
||||
yield return null;
|
||||
|
||||
// Load full photo
|
||||
Texture2D fullPhoto = StatuePhotoManager.LoadPhoto(photoId);
|
||||
|
||||
if (fullPhoto == null)
|
||||
{
|
||||
Logging.Warning($"[StatuePhotoGalleryController] Failed to load photo: {photoId}");
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Create thumbnail
|
||||
Texture2D thumbnail = StatuePhotoManager.CreateThumbnail(fullPhoto, thumbnailSize);
|
||||
|
||||
// Destroy full photo immediately (we only need thumbnail)
|
||||
Destroy(fullPhoto);
|
||||
|
||||
// Cache thumbnail
|
||||
CacheThumbnail(photoId, thumbnail);
|
||||
|
||||
// Set on grid item
|
||||
if (gridItem != null)
|
||||
{
|
||||
gridItem.SetThumbnail(thumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache thumbnail with LRU eviction
|
||||
/// </summary>
|
||||
private void CacheThumbnail(string photoId, Texture2D thumbnail)
|
||||
{
|
||||
// Add to cache
|
||||
_thumbnailCache[photoId] = thumbnail;
|
||||
_thumbnailCacheOrder.Enqueue(photoId);
|
||||
|
||||
// Evict oldest if over limit
|
||||
while (_thumbnailCache.Count > maxCachedThumbnails && _thumbnailCacheOrder.Count > 0)
|
||||
{
|
||||
string oldestId = _thumbnailCacheOrder.Dequeue();
|
||||
|
||||
if (_thumbnailCache.TryGetValue(oldestId, out Texture2D oldThumbnail))
|
||||
{
|
||||
Destroy(oldThumbnail);
|
||||
_thumbnailCache.Remove(oldestId);
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Evicted thumbnail from cache: {oldestId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show enlarged view of a photo (called by PhotoGridItem)
|
||||
/// </summary>
|
||||
public void ShowEnlargedView(string photoId)
|
||||
{
|
||||
if (enlargedViewPanel == null || enlargedPhotoImage == null)
|
||||
{
|
||||
Logging.Warning("[StatuePhotoGalleryController] Enlarged view UI not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Showing enlarged view: {photoId}");
|
||||
|
||||
// Clear previous enlarged texture
|
||||
if (_currentEnlargedTexture != null)
|
||||
{
|
||||
Destroy(_currentEnlargedTexture);
|
||||
_currentEnlargedTexture = null;
|
||||
}
|
||||
|
||||
// Load full-size photo
|
||||
_currentEnlargedTexture = StatuePhotoManager.LoadPhoto(photoId);
|
||||
|
||||
if (_currentEnlargedTexture == null)
|
||||
{
|
||||
Logging.Error($"[StatuePhotoGalleryController] Failed to load enlarged photo: {photoId}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create sprite from texture
|
||||
Sprite enlargedSprite = Sprite.Create(
|
||||
_currentEnlargedTexture,
|
||||
new Rect(0, 0, _currentEnlargedTexture.width, _currentEnlargedTexture.height),
|
||||
new Vector2(0.5f, 0.5f)
|
||||
);
|
||||
|
||||
enlargedPhotoImage.sprite = enlargedSprite;
|
||||
_currentEnlargedPhotoId = photoId;
|
||||
|
||||
// Update photo info
|
||||
UpdatePhotoInfo(photoId);
|
||||
|
||||
// Show panel
|
||||
enlargedViewPanel.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close enlarged view
|
||||
/// </summary>
|
||||
private void CloseEnlargedView()
|
||||
{
|
||||
if (enlargedViewPanel != null)
|
||||
enlargedViewPanel.SetActive(false);
|
||||
|
||||
// Clean up texture
|
||||
if (_currentEnlargedTexture != null)
|
||||
{
|
||||
Destroy(_currentEnlargedTexture);
|
||||
_currentEnlargedTexture = null;
|
||||
}
|
||||
|
||||
_currentEnlargedPhotoId = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete currently viewed photo
|
||||
/// </summary>
|
||||
private void DeleteCurrentPhoto()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_currentEnlargedPhotoId))
|
||||
{
|
||||
Logging.Warning("[StatuePhotoGalleryController] No photo selected for deletion");
|
||||
return;
|
||||
}
|
||||
|
||||
string photoIdToDelete = _currentEnlargedPhotoId;
|
||||
|
||||
// Close enlarged view first
|
||||
CloseEnlargedView();
|
||||
|
||||
// Delete photo
|
||||
bool deleted = StatuePhotoManager.DeletePhoto(photoIdToDelete);
|
||||
|
||||
if (deleted)
|
||||
{
|
||||
// Remove from grid
|
||||
if (_activeGridItems.TryGetValue(photoIdToDelete, out PhotoGridItem gridItem))
|
||||
{
|
||||
Destroy(gridItem.gameObject);
|
||||
_activeGridItems.Remove(photoIdToDelete);
|
||||
}
|
||||
|
||||
// Remove from cache
|
||||
if (_thumbnailCache.TryGetValue(photoIdToDelete, out Texture2D thumbnail))
|
||||
{
|
||||
Destroy(thumbnail);
|
||||
_thumbnailCache.Remove(photoIdToDelete);
|
||||
}
|
||||
|
||||
// Refresh photo list
|
||||
_allPhotoIds.Remove(photoIdToDelete);
|
||||
|
||||
UpdateStatusText($"Photo deleted. {_allPhotoIds.Count} photos remaining");
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Photo deleted: {photoIdToDelete}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update photo info text in enlarged view
|
||||
/// </summary>
|
||||
private void UpdatePhotoInfo(string photoId)
|
||||
{
|
||||
if (photoInfoText == null) return;
|
||||
|
||||
StatuePhotoManager.PhotoMetadata metadata = StatuePhotoManager.GetPhotoMetadata(photoId);
|
||||
|
||||
if (metadata != null)
|
||||
{
|
||||
System.DateTime timestamp = System.DateTime.Parse(metadata.timestamp);
|
||||
string dateStr = timestamp.ToString("MMM dd, yyyy hh:mm tt");
|
||||
|
||||
float fileSizeMB = metadata.fileSizeBytes / (1024f * 1024f);
|
||||
|
||||
photoInfoText.text = $"Date: {dateStr}\n" +
|
||||
$"Decorations: {metadata.decorationCount}\n" +
|
||||
$"Size: {fileSizeMB:F2} MB";
|
||||
}
|
||||
else
|
||||
{
|
||||
photoInfoText.text = "Photo information unavailable";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update status text
|
||||
/// </summary>
|
||||
private void UpdateStatusText(string message)
|
||||
{
|
||||
if (statusText != null)
|
||||
statusText.text = message;
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Status: {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all grid items and cached data
|
||||
/// </summary>
|
||||
private void ClearGallery()
|
||||
{
|
||||
// Destroy grid items
|
||||
foreach (var gridItem in _activeGridItems.Values)
|
||||
{
|
||||
if (gridItem != null)
|
||||
Destroy(gridItem.gameObject);
|
||||
}
|
||||
_activeGridItems.Clear();
|
||||
|
||||
// Clear thumbnail cache
|
||||
foreach (var thumbnail in _thumbnailCache.Values)
|
||||
{
|
||||
if (thumbnail != null)
|
||||
Destroy(thumbnail);
|
||||
}
|
||||
_thumbnailCache.Clear();
|
||||
_thumbnailCacheOrder.Clear();
|
||||
|
||||
Logging.Debug("[StatuePhotoGalleryController] Gallery cleared");
|
||||
}
|
||||
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnManagedDestroy();
|
||||
|
||||
// Cleanup
|
||||
ClearGallery();
|
||||
CloseEnlargedView();
|
||||
|
||||
// Unsubscribe buttons
|
||||
if (closeEnlargedButton != null)
|
||||
closeEnlargedButton.onClick.RemoveListener(CloseEnlargedView);
|
||||
|
||||
if (deletePhotoButton != null)
|
||||
deletePhotoButton.onClick.RemoveListener(DeleteCurrentPhoto);
|
||||
|
||||
if (loadMoreButton != null)
|
||||
loadMoreButton.onClick.RemoveListener(LoadNextPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7339274a0c54f8c9134942f84d47140
|
||||
timeCreated: 1764065004
|
||||
Reference in New Issue
Block a user