MVP implemented with: - placing, removing etc. decorations - saving the state, displaying it on the map, restoring when game restarts - saving screenshots to folder on device Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #65
80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
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 newPhotoId, StatuePhotoGalleryController controller)
|
|
{
|
|
this.photoId = newPhotoId;
|
|
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 enlarge/shrink photo
|
|
/// </summary>
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (galleryController != null && !string.IsNullOrEmpty(photoId))
|
|
{
|
|
Logging.Debug($"[PhotoGridItem] Clicked: {photoId}");
|
|
galleryController.OnGridItemClicked(this, photoId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|