Add docs, cleanup structure
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
@@ -40,9 +40,9 @@ namespace Minigames.StatueDressup.Controllers
|
||||
private bool isLoadingPage;
|
||||
private PhotoEnlargeController enlargeController;
|
||||
|
||||
internal override void OnManagedStart()
|
||||
internal override void OnManagedAwake()
|
||||
{
|
||||
base.OnManagedStart();
|
||||
base.OnManagedAwake();
|
||||
|
||||
// Singleton pattern
|
||||
if (Instance != null && Instance != this)
|
||||
@@ -53,11 +53,29 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
internal override void OnManagedStart()
|
||||
{
|
||||
base.OnManagedStart();
|
||||
|
||||
var settings = StatueDressupSettings.Instance?.Settings;
|
||||
// Wait for data manager to be ready before initializing
|
||||
DecorationDataManager.WhenReady(() =>
|
||||
{
|
||||
InitializeGallery();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize gallery once data manager is ready
|
||||
/// </summary>
|
||||
private void InitializeGallery()
|
||||
{
|
||||
var settings = DecorationDataManager.Instance?.Settings;
|
||||
|
||||
// Initialize enlarge controller
|
||||
enlargeController = new PhotoEnlargeController(backdrop, enlargedContainer, settings?.GalleryAnimationDuration ?? 0.3f);
|
||||
enlargeController = new PhotoEnlargeController(backdrop, enlargedContainer,
|
||||
settings?.GalleryAnimationDuration ?? StatueDressupConstants.DefaultAnimationDuration);
|
||||
|
||||
// Setup page navigation buttons
|
||||
if (previousPageButton != null)
|
||||
@@ -108,7 +126,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
ClearGrid();
|
||||
|
||||
// Get photos for current page
|
||||
int itemsPerPage = StatueDressupSettings.Instance?.Settings?.GalleryItemsPerPage ?? 20;
|
||||
int itemsPerPage = DecorationDataManager.Instance?.Settings?.GalleryItemsPerPage ?? StatueDressupConstants.DefaultGalleryItemsPerPage;
|
||||
List<string> pagePhotoIds = PhotoManager.GetPhotoIdsPage(CaptureType.StatueMinigame, currentPage, itemsPerPage);
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Displaying page {currentPage + 1}: {pagePhotoIds.Count} items");
|
||||
@@ -134,7 +152,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
/// </summary>
|
||||
private void UpdatePageButtons()
|
||||
{
|
||||
int itemsPerPage = StatueDressupSettings.Instance?.Settings?.GalleryItemsPerPage ?? 20;
|
||||
int itemsPerPage = DecorationDataManager.Instance?.Settings?.GalleryItemsPerPage ?? StatueDressupConstants.DefaultGalleryItemsPerPage;
|
||||
int totalPages = Mathf.CeilToInt((float)allPhotoIds.Count / itemsPerPage);
|
||||
|
||||
// Enable/disable previous button
|
||||
@@ -168,7 +186,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
/// </summary>
|
||||
private void OnNextPageClicked()
|
||||
{
|
||||
int itemsPerPage = StatueDressupSettings.Instance?.Settings?.GalleryItemsPerPage ?? 20;
|
||||
int itemsPerPage = DecorationDataManager.Instance?.Settings?.GalleryItemsPerPage ?? StatueDressupConstants.DefaultGalleryItemsPerPage;
|
||||
int totalPages = Mathf.CeilToInt((float)allPhotoIds.Count / itemsPerPage);
|
||||
|
||||
if (currentPage < totalPages - 1)
|
||||
@@ -224,7 +242,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
|
||||
// Create thumbnail
|
||||
int thumbSize = StatueDressupSettings.Instance?.Settings?.GalleryThumbnailSize ?? 256;
|
||||
int thumbSize = DecorationDataManager.Instance?.Settings?.GalleryThumbnailSize ?? StatueDressupConstants.DefaultThumbnailSize;
|
||||
Texture2D thumbnail = PhotoManager.CreateThumbnail(fullPhoto, thumbSize);
|
||||
|
||||
// Destroy full photo immediately (we only need thumbnail)
|
||||
@@ -250,7 +268,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
thumbnailCacheOrder.Enqueue(photoId);
|
||||
|
||||
// Evict oldest if over limit
|
||||
int maxCached = StatueDressupSettings.Instance?.Settings?.GalleryMaxCachedThumbnails ?? 50;
|
||||
int maxCached = DecorationDataManager.Instance?.Settings?.GalleryMaxCachedThumbnails ?? StatueDressupConstants.DefaultMaxCachedThumbnails;
|
||||
while (thumbnailCache.Count > maxCached && thumbnailCacheOrder.Count > 0)
|
||||
{
|
||||
string oldestId = thumbnailCacheOrder.Dequeue();
|
||||
@@ -284,7 +302,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
|
||||
Logging.Debug($"[StatuePhotoGalleryController] Enlarging photo: {photoId}");
|
||||
|
||||
float enlargedScale = StatueDressupSettings.Instance?.Settings?.GalleryEnlargedScale ?? 2.5f;
|
||||
float enlargedScale = DecorationDataManager.Instance?.Settings?.GalleryEnlargedScale ?? StatueDressupConstants.DefaultEnlargedScale;
|
||||
|
||||
// Check cache first
|
||||
if (fullPhotoCache.TryGetValue(photoId, out Texture2D fullPhoto))
|
||||
@@ -404,3 +422,4 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user