All working but codex.

This commit is contained in:
2026-05-13 14:20:25 +01:00
parent c203f836b1
commit 602e1ec0d3
49 changed files with 186784 additions and 62239 deletions

View File

@@ -10,6 +10,7 @@ using BriarQueen.Framework.Managers.Player.Data;
using BriarQueen.Framework.Managers.UI.Base;
using BriarQueen.Framework.Registries;
using BriarQueen.Framework.Services.Destruction;
using BriarQueen.UI.Components;
using BriarQueen.UI.Menus;
using BriarQueen.UI.Menus.Components;
using Cysharp.Threading.Tasks;
@@ -25,31 +26,29 @@ namespace BriarQueen.UI.Codex
{
public class CodexWindow : MonoBehaviour, IUIWindow, IUIBackHandler
{
// ── Root ──────────────────────────────────────────────────────
[Header("Root UI")]
[SerializeField] private CanvasGroup _canvasGroup;
[SerializeField] private RectTransform _windowRect;
// ── Left panel — header ───────────────────────────────────────
[Header("Content")]
[SerializeField] private CanvasGroup _backgroundGroup; // Direct child — faded instead of root
[Header("Left Panel — Header")]
[SerializeField] private TextMeshProUGUI _leftPanelTitleText;
[SerializeField] private CanvasGroup _leftPanelTitleGroup;
// ── Left panel — categories ───────────────────────────────────
[Header("Left Panel — Categories")]
[SerializeField] private CanvasGroup _categoriesGroup;
[SerializeField] private CodexCategoryButton _booksButton;
[SerializeField] private CodexCategoryButton _cluesButton;
[SerializeField] private CodexCategoryButton _photosButton;
[SerializeField] private UnderlineButton _booksButton;
[SerializeField] private UnderlineButton _cluesButton;
[SerializeField] private UnderlineButton _photosButton;
// ── Left panel — locations ────────────────────────────────────
[Header("Left Panel — Locations")]
[SerializeField] private CanvasGroup _locationListGroup;
[SerializeField] private RectTransform _locationListContainer;
[SerializeField] private VerticalScrollbar _locationScrollbar;
[SerializeField] private Button _backToCategoriesButton;
// ── Left panel — entries ──────────────────────────────────────
[Header("Left Panel — Entries")]
[SerializeField] private CanvasGroup _entryListGroup;
[SerializeField] private RectTransform _entryListContainer;
@@ -57,24 +56,20 @@ namespace BriarQueen.UI.Codex
[SerializeField] private Button _backToLocationsButton;
[SerializeField] private UnderlineButtonGroup _entryButtonGroup;
// ── Right panel — display ─────────────────────────────────────
[Header("Right Panel — Display")]
[SerializeField] private CanvasGroup _displayGroup;
[SerializeField] private RectTransform _displayLayoutRoot;
[SerializeField] private CanvasGroup _rightPanelGroup;
[SerializeField] private RectTransform _rightPanelRoot;
[SerializeField] private TextMeshProUGUI _titleText;
[SerializeField] private CanvasGroup _titleGroup;
[SerializeField] private CanvasGroup _contentGroup;
[SerializeField] private RectTransform _contentScrollContainer;
[SerializeField] private VerticalScrollbar _contentScrollbar;
[SerializeField] private TextMeshProUGUI _bodyText;
[SerializeField] private TextMeshProUGUI _photoDescription;
[SerializeField] private CanvasGroup _displayAreaGroup;
[SerializeField] private ScrollableTextBox _bodyText;
[SerializeField] private ScrollableTextBox _photoDescription;
[SerializeField] private TextMeshProUGUI _polaroidWriting;
[SerializeField] private Image _polaroid;
[SerializeField] private Image _displayImage;
[SerializeField] private GameObject _contentRoot;
[SerializeField] private GameObject _displayAreaRoot;
[SerializeField] private GameObject _emptyStateRoot;
// ── Tween settings ────────────────────────────────────────────
[Header("Tween Settings")]
[SerializeField] private TweenSettings _windowTweenSettings = new()
{
@@ -117,7 +112,6 @@ namespace BriarQueen.UI.Codex
[Header("Internal")]
[SerializeField] private GraphicRaycaster _graphicRaycaster;
// ── Runtime state ─────────────────────────────────────────────
private enum LeftPanelState { Categories, Locations, Entries }
private LeftPanelState _leftPanelState = LeftPanelState.Categories;
@@ -161,11 +155,59 @@ namespace BriarQueen.UI.Codex
public bool IsModal => true;
public WindowType WindowType => WindowType.CodexWindow;
// ── Raycaster ─────────────────────────────────────────────────
private void TryRegisterRaycaster()
{
Debug.Log($"[CodexWindow] TryRegisterRaycaster " +
$"registered={_raycasterRegistered} " +
$"interactManager={_interactManager != null} " +
$"raycaster={_graphicRaycaster != null}");
Debug.Log("[CodexWindow] Try register raycaster.");
if (_raycasterRegistered || _interactManager == null || _graphicRaycaster == null) return;
_interactManager.AddUIRaycaster(_graphicRaycaster);
_interactManager.SetExclusiveRaycaster(_graphicRaycaster);
_raycasterRegistered = true;
Debug.Log("[CodexWindow] Registered raycaster.");
}
private void TryUnregisterRaycaster()
{
Debug.Log("[CodexWindow] Try unregister raycaster.");
if (!_raycasterRegistered || _interactManager == null || _graphicRaycaster == null) return;
_interactManager.RemoveUIRaycaster(_graphicRaycaster);
_interactManager.ClearExclusiveRaycaster();
_raycasterRegistered = false;
Debug.Log("[CodexWindow] Raycaster unregistered.");
}
// ── Unity lifecycle ───────────────────────────────────────────
private void Awake()
{
SetCanvasGroupImmediate(_canvasGroup, 0f, false);
if (_canvasGroup != null)
{
_canvasGroup.alpha = 0f;
_canvasGroup.blocksRaycasts = false;
_canvasGroup.interactable = false;
}
// Background group controls visual fading
if (_backgroundGroup != null)
{
_backgroundGroup.alpha = 0f;
_backgroundGroup.blocksRaycasts = false;
_backgroundGroup.interactable = false;
}
if (_windowRect != null)
_windowRect.localScale = Vector3.one * _hiddenScale;
@@ -177,29 +219,26 @@ namespace BriarQueen.UI.Codex
SetLeftPanelTitleImmediate("Codex");
}
private void Start()
private async UniTaskVoid Start()
{
InitializeCategoryButtons();
_started = true;
CacheButtonReferences();
await EnsurePoolsReady();
}
private void OnEnable()
{
BindCategoryButtons();
BindNavButtons();
if (_started)
TryRegisterRaycaster();
}
private void OnDisable()
{
UnbindCategoryButtons();
UnbindNavButtons();
TryUnregisterRaycaster();
ReleaseAllLocationButtons();
ReleaseAllEntryButtons();
CancelAllOperations();
_interactManager?.ClearExclusiveRaycaster();
}
private void OnDestroy()
@@ -207,25 +246,31 @@ namespace BriarQueen.UI.Codex
CancelAllOperations();
_locationButtonPool?.Dispose();
_entryButtonPool?.Dispose();
TryUnregisterRaycaster();
}
// ── IUIWindow ─────────────────────────────────────────────────
public async UniTask Show()
{
CacheButtonReferences();
ResetOperationCts();
gameObject.SetActive(true);
TryRegisterRaycaster();
if (!_started)
await UniTask.WaitUntil(() => _started,
cancellationToken: this.GetCancellationTokenOnDestroy());
if (_canvasGroup != null)
{
_canvasGroup.blocksRaycasts = false;
_canvasGroup.interactable = false;
}
await EnsurePoolsReady();
if (_backgroundGroup != null)
{
_backgroundGroup.alpha = 0f;
_backgroundGroup.blocksRaycasts = false;
_backgroundGroup.interactable = false;
}
ResetOperationCts();
gameObject.SetActive(true);
SetCanvasGroupImmediate(_canvasGroup, 0f, false);
if (_windowRect != null)
_windowRect.localScale = Vector3.one * _hiddenScale;
@@ -236,7 +281,7 @@ namespace BriarQueen.UI.Codex
SetLeftPanelTitleImmediate("Codex");
_windowSequence = Sequence.Create(useUnscaledTime: true)
.Group(Tween.Alpha(_canvasGroup, new TweenSettings<float>
.Group(Tween.Alpha(_backgroundGroup, new TweenSettings<float>
{
startValue = 0f,
endValue = 1f,
@@ -251,26 +296,54 @@ namespace BriarQueen.UI.Codex
try
{
await _windowSequence.ToUniTask(cancellationToken: _operationCts.Token);
}
catch (OperationCanceledException) { return; }
finally { _windowSequence = default; }
var canvasTask = Tween.Alpha(_canvasGroup, new TweenSettings<float>
{
startValue = 0f,
endValue = 1f,
settings = _windowTweenSettings
}).ToUniTask();
var backgroundTask = _windowSequence.ToUniTask();
await UniTask.WhenAll(canvasTask, backgroundTask).AttachExternalCancellation(_operationCts.Token);
_backgroundGroup.blocksRaycasts = true;
_backgroundGroup.interactable = true;
}
catch (OperationCanceledException)
{
return;
}
finally
{
_windowSequence = default;
}
_canvasGroup.interactable = true;
_canvasGroup.blocksRaycasts = true;
_canvasGroup.alpha = 1f;
SetCanvasGroupImmediate(_canvasGroup, 1f, true);
await TransitionToCategories(instant: true);
Debug.Log($"[CodexWindow] Codex Window Show Complete.");
}
public async UniTask Hide()
{
TryUnregisterRaycaster();
Debug.Log($"[CodexWindow] Codex Window Hide Started.");
ResetOperationCts();
SetCanvasGroupInteractivity(_canvasGroup, false);
if (_canvasGroup != null)
{
_canvasGroup.blocksRaycasts = false;
_canvasGroup.interactable = false;
}
TryUnregisterRaycaster();
_windowSequence = Sequence.Create(useUnscaledTime: true)
.Group(Tween.Alpha(_canvasGroup, new TweenSettings<float>
.Group(Tween.Alpha(_backgroundGroup, new TweenSettings<float>
{
startValue = _canvasGroup.alpha,
startValue = _backgroundGroup != null ? _backgroundGroup.alpha : 1f,
endValue = 0f,
settings = _windowTweenSettings
}))
@@ -288,7 +361,15 @@ namespace BriarQueen.UI.Codex
catch (OperationCanceledException) { return; }
finally { _windowSequence = default; }
if (_canvasGroup != null)
{
_canvasGroup.alpha = 0f;
_canvasGroup.blocksRaycasts = false;
_canvasGroup.interactable = false;
}
gameObject.SetActive(false);
Debug.Log($"[CodexWindow] Codex Window Hide Complete.");
}
// ── IUIBackHandler ────────────────────────────────────────────
@@ -297,19 +378,10 @@ namespace BriarQueen.UI.Codex
{
switch (_leftPanelState)
{
case LeftPanelState.Entries:
NavigateBackToLocations().Forget();
return true;
case LeftPanelState.Locations:
NavigateBackToCategories().Forget();
return true;
case LeftPanelState.Categories:
return false;
default:
return false;
case LeftPanelState.Entries: NavigateBackToLocations().Forget(); return true;
case LeftPanelState.Locations: NavigateBackToCategories().Forget(); return true;
case LeftPanelState.Categories: return false;
default: return false;
}
}
@@ -415,7 +487,6 @@ namespace BriarQueen.UI.Codex
{
if (_entryButtonGroup != null)
_entryButtonGroup.RemoveButton(btn.UnderlineButton);
btn.OnEntryClicked -= OnEntryClicked;
btn.SetSelected(false);
btn.gameObject.SetActive(false);
@@ -432,30 +503,15 @@ namespace BriarQueen.UI.Codex
// ── Navigation ────────────────────────────────────────────────
private void OnCategoryClicked(CodexType category)
{
NavigateToLocations(category).Forget();
}
private void OnCluesClicked(UnderlineButton _) => NavigateToLocations(CodexType.PuzzleClue).Forget();
private void OnDocumentsClicked(UnderlineButton _) => NavigateToLocations(CodexType.DocumentEntry).Forget();
private void OnPhotosClicked(UnderlineButton _) => NavigateToLocations(CodexType.Photo).Forget();
private void OnLocationClicked(Location location)
{
NavigateToEntries(location).Forget();
}
private void OnEntryClicked(CodexEntrySo entry)
{
DisplayEntry(entry).Forget();
}
private void OnBackToCategoriesClicked()
{
NavigateBackToCategories().Forget();
}
private void OnBackToLocationsClicked()
{
NavigateBackToLocations().Forget();
}
private void OnLocationClicked(Location location) => NavigateToEntries(location).Forget();
private void OnEntryClicked(CodexEntrySo entry) => DisplayEntry(entry).Forget();
private void OnBackToCategoriesClicked() => NavigateBackToCategories().Forget();
private void OnBackToLocationsClicked() => NavigateBackToLocations().Forget();
// ── Left panel transitions ────────────────────────────────────
@@ -494,7 +550,6 @@ namespace BriarQueen.UI.Codex
await FadeLeftPanelTitle(GetCategoryDisplayName(category));
await FadeOutCurrentLeftPanel();
await BuildLocationButtons(token);
token.ThrowIfCancellationRequested();
_leftPanelState = LeftPanelState.Locations;
@@ -502,7 +557,6 @@ namespace BriarQueen.UI.Codex
await RefreshLayout(_locationListContainer);
RestoreLocationScroll();
await FadePanelIn(_locationListGroup);
await FadeOutDisplay();
ShowEmptyDisplay();
}
@@ -524,7 +578,6 @@ namespace BriarQueen.UI.Codex
await FadeLeftPanelTitle(GetLocationDisplayName(location));
await FadePanelOut(_locationListGroup);
await BuildEntryButtons(token);
token.ThrowIfCancellationRequested();
_leftPanelState = LeftPanelState.Entries;
@@ -532,7 +585,6 @@ namespace BriarQueen.UI.Codex
await RefreshLayout(_entryListContainer);
RestoreEntryScroll();
await FadePanelIn(_entryListGroup);
await FadeOutDisplay();
ShowEmptyDisplay();
}
@@ -542,7 +594,6 @@ namespace BriarQueen.UI.Codex
private async UniTask NavigateBackToCategories()
{
ResetOperationCts();
try
{
await FadeOutDisplay();
@@ -565,7 +616,6 @@ namespace BriarQueen.UI.Codex
await FadeLeftPanelTitle(GetCategoryDisplayName(_currentCategory));
await FadePanelOut(_entryListGroup);
ReleaseAllEntryButtons();
token.ThrowIfCancellationRequested();
_leftPanelState = LeftPanelState.Locations;
@@ -573,7 +623,6 @@ namespace BriarQueen.UI.Codex
await RefreshLayout(_locationListContainer);
RestoreLocationScroll();
await FadePanelIn(_locationListGroup);
await FadeOutDisplay();
ShowEmptyDisplay();
}
@@ -584,15 +633,9 @@ namespace BriarQueen.UI.Codex
{
switch (_leftPanelState)
{
case LeftPanelState.Categories:
await FadePanelOut(_categoriesGroup);
break;
case LeftPanelState.Locations:
await FadePanelOut(_locationListGroup);
break;
case LeftPanelState.Entries:
await FadePanelOut(_entryListGroup);
break;
case LeftPanelState.Categories: await FadePanelOut(_categoriesGroup); break;
case LeftPanelState.Locations: await FadePanelOut(_locationListGroup); break;
case LeftPanelState.Entries: await FadePanelOut(_entryListGroup); break;
}
}
@@ -600,11 +643,12 @@ namespace BriarQueen.UI.Codex
private void SetLeftPanelTitleImmediate(string title)
{
if (_leftPanelTitleText != null) _leftPanelTitleText.text = title;
if (_leftPanelTitleText != null) _leftPanelTitleText.text = title;
if (_leftPanelTitleGroup != null)
{
_leftPanelTitleGroup.alpha = 1f;
_leftPanelTitleGroup.gameObject.SetActive(true);
_leftPanelTitleGroup.alpha = 1f;
_leftPanelTitleGroup.interactable = true;
_leftPanelTitleGroup.blocksRaycasts = true;
}
}
@@ -617,7 +661,6 @@ namespace BriarQueen.UI.Codex
}
StopLeftPanelTitleTween();
var token = _operationCts?.Token ?? this.GetCancellationTokenOnDestroy();
_leftPanelTitleSequence = Sequence.Create(useUnscaledTime: true)
@@ -663,10 +706,8 @@ namespace BriarQueen.UI.Codex
_ => string.Empty
};
private static string GetLocationDisplayName(Location location)
{
return location.ToString().Replace("_", " ");
}
private static string GetLocationDisplayName(Location location) =>
location.ToString().Replace("_", " ");
// ── Display area ──────────────────────────────────────────────
@@ -679,7 +720,7 @@ namespace BriarQueen.UI.Codex
try
{
if (_currentEntry != null && _displayGroup.alpha > 0.001f)
if (_currentEntry != null && _rightPanelGroup.alpha > 0.001f)
await FadeOutDisplay();
token.ThrowIfCancellationRequested();
@@ -687,10 +728,9 @@ namespace BriarQueen.UI.Codex
_currentEntry = entry;
_lastEntryByCategory[_currentCategory] = entry.UniqueID;
UpdateEntryButtonSelection();
ApplyEntryToDisplay(entry);
await RefreshLayout(_displayLayoutRoot);
await RefreshLayout(_rightPanelRoot);
SetTitleVisible(false);
SetContentVisible(false);
@@ -718,9 +758,9 @@ namespace BriarQueen.UI.Codex
private async UniTask FadeInTitle(CancellationToken token)
{
if (_titleGroup == null) return;
_titleGroup.alpha = 0f;
_titleGroup.gameObject.SetActive(true);
_titleGroup.alpha = 0f;
_titleGroup.interactable = true;
_titleGroup.blocksRaycasts = true;
await Tween.Alpha(_titleGroup, new TweenSettings<float>
{
@@ -734,31 +774,31 @@ namespace BriarQueen.UI.Codex
private async UniTask FadeInContent(CancellationToken token)
{
if (_contentGroup == null) return;
if (_displayAreaGroup == null) return;
_displayAreaGroup.alpha = 0f;
_displayAreaGroup.interactable = true;
_displayAreaGroup.blocksRaycasts = true;
_contentGroup.alpha = 0f;
_contentGroup.gameObject.SetActive(true);
await Tween.Alpha(_contentGroup, new TweenSettings<float>
await Tween.Alpha(_displayAreaGroup, new TweenSettings<float>
{
startValue = 0f,
endValue = 1f,
settings = _contentFadeSettings
}).ToUniTask(cancellationToken: token);
_contentGroup.alpha = 1f;
_displayAreaGroup.alpha = 1f;
}
private async UniTask FadeOutDisplay()
{
if (_displayGroup == null || _displayGroup.alpha < 0.001f) return;
if (_rightPanelGroup == null || _rightPanelGroup.alpha < 0.001f) return;
StopDisplayTween();
_displaySequence = Sequence.Create(useUnscaledTime: true)
.Group(Tween.Alpha(_displayGroup, new TweenSettings<float>
.Group(Tween.Alpha(_rightPanelGroup, new TweenSettings<float>
{
startValue = _displayGroup.alpha,
startValue = _rightPanelGroup.alpha,
endValue = 0f,
settings = _contentFadeSettings
}));
@@ -777,15 +817,17 @@ namespace BriarQueen.UI.Codex
private void SetTitleVisible(bool visible)
{
if (_titleGroup == null) return;
_titleGroup.alpha = visible ? 1f : 0f;
_titleGroup.gameObject.SetActive(visible);
_titleGroup.alpha = visible ? 1f : 0f;
_titleGroup.interactable = visible;
_titleGroup.blocksRaycasts = visible;
}
private void SetContentVisible(bool visible)
{
if (_contentGroup == null) return;
_contentGroup.alpha = visible ? 1f : 0f;
_contentGroup.gameObject.SetActive(visible);
if (_displayAreaGroup == null) return;
_displayAreaGroup.alpha = visible ? 1f : 0f;
_displayAreaGroup.interactable = visible;
_displayAreaGroup.blocksRaycasts = visible;
}
// ── Panel fade helpers ────────────────────────────────────────
@@ -796,7 +838,6 @@ namespace BriarQueen.UI.Codex
StopLeftPanelTween();
group.alpha = 0f;
group.gameObject.SetActive(true);
group.blocksRaycasts = false;
group.interactable = false;
@@ -825,7 +866,12 @@ namespace BriarQueen.UI.Codex
{
if (group == null || group.alpha < 0.001f)
{
SetPanelImmediate(group, false);
if (group != null)
{
group.alpha = 0f;
group.interactable = false;
group.blocksRaycasts = false;
}
return;
}
@@ -849,7 +895,9 @@ namespace BriarQueen.UI.Codex
catch (OperationCanceledException) { return; }
finally { _leftPanelSequence = default; }
SetPanelImmediate(group, false);
group.alpha = 0f;
group.interactable = false;
group.blocksRaycasts = false;
}
// ── Button building ───────────────────────────────────────────
@@ -872,10 +920,8 @@ namespace BriarQueen.UI.Codex
foreach (var location in locations)
{
token.ThrowIfCancellationRequested();
var button = _locationButtonPool.Get();
if (button == null) continue;
button.Initialize(location);
button.OnLocationClicked += OnLocationClicked;
_activeLocationButtons.Add(button);
@@ -901,14 +947,11 @@ namespace BriarQueen.UI.Codex
foreach (var entry in entries)
{
token.ThrowIfCancellationRequested();
var button = _entryButtonPool.Get();
if (button == null) continue;
button.Initialize(entry);
button.OnEntryClicked += OnEntryClicked;
_activeEntryButtons.Add(button);
if (_entryButtonGroup != null && button.UnderlineButton != null)
_entryButtonGroup.AddButton(button.UnderlineButton);
}
@@ -923,14 +966,13 @@ namespace BriarQueen.UI.Codex
{
if (entry == null) { ClearDisplay(); return; }
if (_titleText != null)
_titleText.text = entry.Title;
if (_titleText != null) _titleText.text = entry.Title;
var isPhoto = entry.EntryType == CodexType.Photo || entry.IsPhotoOverride;
var showImage = isPhoto && entry.DisplayImage != null;
var showText = !string.IsNullOrWhiteSpace(entry.BodyText) || entry.IsBodyTextOverride;
var showPhotoDesc = isPhoto && !string.IsNullOrWhiteSpace(entry.PhotoDescription);
var showPolaroid = isPhoto && !string.IsNullOrWhiteSpace(entry.PolaroidWriting);
var showPhotoDesc = isPhoto && !string.IsNullOrWhiteSpace(entry.PhotoDescription);
if (_polaroid != null)
_polaroid.gameObject.SetActive(isPhoto);
@@ -942,36 +984,36 @@ namespace BriarQueen.UI.Codex
_displayImage.gameObject.SetActive(showImage);
}
if (_photoDescription != null)
{
_photoDescription.text = showPhotoDesc ? entry.PhotoDescription : string.Empty;
_photoDescription.gameObject.SetActive(showPhotoDesc);
}
if (_polaroidWriting != null)
{
_polaroidWriting.text = showPolaroid ? entry.PolaroidWriting : string.Empty;
_polaroidWriting.gameObject.SetActive(showPolaroid);
}
if (_photoDescription != null)
{
if (showPhotoDesc) { _photoDescription.gameObject.SetActive(true); _photoDescription.SetText(entry.PhotoDescription); }
else { _photoDescription.Clear(); _photoDescription.gameObject.SetActive(false); }
}
if (_bodyText != null)
{
_bodyText.text = showText ? entry.BodyText : string.Empty;
_bodyText.gameObject.SetActive(showText);
if (showText) { _bodyText.gameObject.SetActive(true); _bodyText.SetText(entry.BodyText); }
else { _bodyText.Clear(); _bodyText.gameObject.SetActive(false); }
}
SetEmptyStateVisible(false);
if (_contentRoot != null) _contentRoot.SetActive(true);
if (_displayAreaRoot != null) _displayAreaRoot.SetActive(true);
}
private void ClearDisplay()
{
if (_titleText != null) _titleText.text = string.Empty;
if (_bodyText != null) { _bodyText.text = string.Empty; _bodyText.gameObject.SetActive(false); }
if (_polaroid != null) _polaroid.gameObject.SetActive(false);
if (_displayImage != null) { _displayImage.sprite = null; _displayImage.enabled = false; _displayImage.gameObject.SetActive(false); }
if (_photoDescription != null) { _photoDescription.text = string.Empty; _photoDescription.gameObject.SetActive(false); }
if (_polaroidWriting != null) { _polaroidWriting.text = string.Empty; _polaroidWriting.gameObject.SetActive(false); }
if (_titleText != null) _titleText.text = string.Empty;
if (_bodyText != null) { _bodyText.Clear(); _bodyText.gameObject.SetActive(false); }
if (_photoDescription != null) { _photoDescription.Clear(); _photoDescription.gameObject.SetActive(false); }
if (_polaroid != null) _polaroid.gameObject.SetActive(false);
if (_displayImage != null) { _displayImage.sprite = null; _displayImage.enabled = false; _displayImage.gameObject.SetActive(false); }
if (_polaroidWriting != null) { _polaroidWriting.text = string.Empty; _polaroidWriting.gameObject.SetActive(false); }
}
// ── Selection state ───────────────────────────────────────────
@@ -981,13 +1023,10 @@ namespace BriarQueen.UI.Codex
foreach (var button in _activeEntryButtons)
{
if (button == null) continue;
var isSelected = _currentEntry != null &&
button.Entry != null &&
button.Entry.UniqueID == _currentEntry.UniqueID;
button.SetSelected(isSelected);
if (_entryButtonGroup != null && button.UnderlineButton != null && isSelected)
_entryButtonGroup.SelectButton(button.UnderlineButton);
}
@@ -1050,26 +1089,19 @@ namespace BriarQueen.UI.Codex
}
// ── Binding ───────────────────────────────────────────────────
private void InitializeCategoryButtons()
{
if (_booksButton != null) _booksButton.Initialize(CodexType.DocumentEntry);
if (_cluesButton != null) _cluesButton.Initialize(CodexType.PuzzleClue);
if (_photosButton != null) _photosButton.Initialize(CodexType.Photo);
}
private void BindCategoryButtons()
{
if (_booksButton != null) _booksButton.OnCategoryClicked += OnCategoryClicked;
if (_cluesButton != null) _cluesButton.OnCategoryClicked += OnCategoryClicked;
if (_photosButton != null) _photosButton.OnCategoryClicked += OnCategoryClicked;
if (_booksButton != null) _booksButton.SelectionRequested += OnDocumentsClicked;
if (_cluesButton != null) _cluesButton.SelectionRequested += OnCluesClicked;
if (_photosButton != null) _photosButton.SelectionRequested += OnPhotosClicked;
}
private void UnbindCategoryButtons()
{
if (_booksButton != null) _booksButton.OnCategoryClicked -= OnCategoryClicked;
if (_cluesButton != null) _cluesButton.OnCategoryClicked -= OnCategoryClicked;
if (_photosButton != null) _photosButton.OnCategoryClicked -= OnCategoryClicked;
if (_booksButton != null) _booksButton.SelectionRequested -= OnDocumentsClicked;
if (_cluesButton != null) _cluesButton.SelectionRequested -= OnCluesClicked;
if (_photosButton != null) _photosButton.SelectionRequested -= OnPhotosClicked;
}
private void BindNavButtons()
@@ -1088,24 +1120,6 @@ namespace BriarQueen.UI.Codex
_backToLocationsButton.onClick.RemoveListener(OnBackToLocationsClicked);
}
// ── Raycaster ─────────────────────────────────────────────────
private void TryRegisterRaycaster()
{
if (_raycasterRegistered || _interactManager == null || _graphicRaycaster == null) return;
_interactManager.AddUIRaycaster(_graphicRaycaster);
_interactManager.SetExclusiveRaycaster(_graphicRaycaster);
_raycasterRegistered = true;
}
private void TryUnregisterRaycaster()
{
if (!_raycasterRegistered || _interactManager == null || _graphicRaycaster == null) return;
_interactManager.RemoveUIRaycaster(_graphicRaycaster);
_interactManager.ClearExclusiveRaycaster();
_raycasterRegistered = false;
}
// ── Layout ────────────────────────────────────────────────────
private async UniTask RefreshLayout(RectTransform root)
@@ -1142,7 +1156,6 @@ namespace BriarQueen.UI.Codex
group.alpha = visible ? 1f : 0f;
group.interactable = visible;
group.blocksRaycasts = visible;
group.gameObject.SetActive(visible);
}
private static void SetCanvasGroupImmediate(CanvasGroup group, float alpha, bool interactable)
@@ -1162,17 +1175,16 @@ namespace BriarQueen.UI.Codex
private void SetDisplayImmediate(bool visible)
{
if (_displayGroup == null) return;
_displayGroup.alpha = visible ? 1f : 0f;
_displayGroup.interactable = visible;
_displayGroup.blocksRaycasts = visible;
_displayGroup.gameObject.SetActive(visible);
if (_rightPanelGroup == null) return;
_rightPanelGroup.alpha = visible ? 1f : 0f;
_rightPanelGroup.interactable = visible;
_rightPanelGroup.blocksRaycasts = visible;
}
private void SetEmptyStateVisible(bool visible)
{
if (_emptyStateRoot != null) _emptyStateRoot.SetActive(visible);
if (_contentRoot != null) _contentRoot.SetActive(!visible);
if (_emptyStateRoot != null) _emptyStateRoot.SetActive(visible);
if (_displayAreaRoot != null) _displayAreaRoot.SetActive(!visible);
}
// ── CTS helpers ───────────────────────────────────────────────