Restructured for new direction.

This commit is contained in:
2026-05-12 12:01:09 +01:00
parent 0439b6c1d2
commit c203f836b1
1134 changed files with 125569 additions and 213519 deletions

View File

@@ -1,19 +1,14 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace BriarQueen.UI.Menus.Components
{
/// <summary>
/// Save Slot UI:
/// - No Load button.
/// - Slot itself is clickable:
/// - Filled => click loads
/// - Empty => click creates (via SelectSaveWindow opening NewSaveWindow)
/// - Delete button remains for filled saves.
/// </summary>
public class SaveSlotUI : MonoBehaviour
public class SaveSlotUI : MonoBehaviour,
IPointerEnterHandler,
IPointerExitHandler
{
[Header("Clickable Root")]
[SerializeField]
@@ -30,17 +25,21 @@ namespace BriarQueen.UI.Menus.Components
[SerializeField]
private Button _deleteButton;
[Header("Empty Visual")]
[Header("Empty Text")]
[SerializeField]
private Image _emptyImage;
private TextMeshProUGUI _emptyImage;
[Header("Highlight")]
[SerializeField]
private SaveSlotHighlight _highlight;
private Action<SaveFileInfo> _onDeleteClick;
private Action _onEmptyClick;
private Action _onEmptyClick;
private Action<SaveFileInfo> _onFilledClick;
public SaveFileInfo SaveInfo { get; private set; }
public bool IsEmpty { get; private set; }
public SaveFileInfo SaveInfo { get; private set; }
public bool IsEmpty { get; private set; }
public bool IsSelected { get; private set; }
private void Awake()
{
@@ -59,28 +58,52 @@ namespace BriarQueen.UI.Menus.Components
private void OnDestroy()
{
if (_slotButton != null) _slotButton.onClick.RemoveAllListeners();
if (_slotButton != null) _slotButton.onClick.RemoveAllListeners();
if (_deleteButton != null) _deleteButton.onClick.RemoveAllListeners();
}
// ── Pointer events ────────────────────────────────────────────
public void OnPointerEnter(PointerEventData eventData)
{
_highlight?.SetHovered(true);
}
public void OnPointerExit(PointerEventData eventData)
{
_highlight?.SetHovered(false);
}
// ── Public API ────────────────────────────────────────────────
public GameObject GetSelectableGameObject()
{
return _slotButton != null ? _slotButton.gameObject : gameObject;
}
public void SetSelected(bool selected, bool immediate = false)
{
IsSelected = selected;
if (immediate)
_highlight?.SetSelectedImmediate(selected);
else
_highlight?.SetSelected(selected);
}
public void SetFilled(
SaveFileInfo saveInfo,
Action<SaveFileInfo> onClickFilled,
Action<SaveFileInfo> onDelete)
{
SaveInfo = saveInfo;
IsEmpty = false;
IsEmpty = false;
_onFilledClick = onClickFilled;
_onEmptyClick = null;
_onEmptyClick = null;
_onDeleteClick = onDelete;
if (_emptyImage != null) _emptyImage.gameObject.SetActive(false);
if (_emptyImage != null) _emptyImage.gameObject.SetActive(false);
if (_saveNameText != null)
{
@@ -107,16 +130,16 @@ namespace BriarQueen.UI.Menus.Components
public void SetEmpty(Action onClickEmpty)
{
SaveInfo = default;
IsEmpty = true;
IsEmpty = true;
_onFilledClick = null;
_onEmptyClick = onClickEmpty;
_onEmptyClick = onClickEmpty;
_onDeleteClick = null;
if (_saveNameText != null) _saveNameText.text = string.Empty;
if (_saveDateText != null) _saveDateText.text = string.Empty;
if (_emptyImage != null) _emptyImage.gameObject.SetActive(true);
if (_emptyImage != null) _emptyImage.gameObject.SetActive(true);
if (_deleteButton != null)
{
@@ -125,20 +148,20 @@ namespace BriarQueen.UI.Menus.Components
}
if (_slotButton != null)
_slotButton.interactable = true; // empty slot is still clickable
_slotButton.interactable = true;
}
public void SetInteractable(bool interactable)
{
// Slot click should still work even when empty; we fully disable during "busy" only.
if (_slotButton != null)
_slotButton.interactable = interactable;
// Delete only for filled saves.
if (_deleteButton != null)
_deleteButton.interactable = interactable && !IsEmpty;
}
// ── Internal ──────────────────────────────────────────────────
private void HandleSlotClicked()
{
if (IsEmpty)
@@ -149,8 +172,7 @@ namespace BriarQueen.UI.Menus.Components
private void HandleDeleteClicked()
{
if (IsEmpty)
return;
if (IsEmpty) return;
if (!string.IsNullOrWhiteSpace(SaveInfo.FileName))
_onDeleteClick?.Invoke(SaveInfo);
@@ -159,12 +181,12 @@ namespace BriarQueen.UI.Menus.Components
public struct SaveFileInfo
{
public readonly string FileName;
public readonly string FileName;
public readonly DateTime LastModified;
public SaveFileInfo(string fileName, DateTime lastModified)
{
FileName = fileName;
FileName = fileName;
LastModified = lastModified;
}
}