fix(ui): share retail tab state binding

Replace the character window's synthesized tab sprites, labels, colors, and hit panels with the same DAT-authored Open/Closed state path used by Spellbook/Components. Preserve controller-owned page selection while letting UIElement state propagation own tab chrome and typography.

Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-15 17:21:16 +02:00
parent 1249ad03de
commit 15bb61e05d
5 changed files with 179 additions and 285 deletions

View file

@ -127,8 +127,8 @@ public sealed class SpellbookWindowController : IRetainedPanelController
_rowStyle = rowStyle;
_rowFont = rowFont;
SetClick(spellTab, () => ShowPage(SpellbookWindowPage.Spells));
SetClick(componentTab, () => ShowPage(SpellbookWindowPage.Components));
RetailTabBinding.SetClick(spellTab, () => ShowPage(SpellbookWindowPage.Spells));
RetailTabBinding.SetClick(componentTab, () => ShowPage(SpellbookWindowPage.Components));
closeButton.OnClick = close;
deleteButton.OnClick = RequestDeleteSelected;
foreach ((uint id, uint mask) in FilterButtons)
@ -213,8 +213,8 @@ public sealed class SpellbookWindowController : IRetainedPanelController
CurrentPage = page;
_spellPage.Visible = page == SpellbookWindowPage.Spells;
_componentPage.Visible = page == SpellbookWindowPage.Components;
SetTabOpen(_spellTab, page == SpellbookWindowPage.Spells);
SetTabOpen(_componentTab, page == SpellbookWindowPage.Components);
RetailTabBinding.SetOpen(_spellTab, page == SpellbookWindowPage.Spells);
RetailTabBinding.SetOpen(_componentTab, page == SpellbookWindowPage.Components);
}
private void ConfigureSpellList(ImportedLayout layout)
@ -520,30 +520,11 @@ public sealed class SpellbookWindowController : IRetainedPanelController
_objects.ObjectRemoved -= OnObjectRemoved;
_objects.ObjectMoved -= OnObjectMoved;
_objects.ContainerContentsReplaced -= OnContainerContentsReplaced;
SetClick(_spellTab, null);
SetClick(_componentTab, null);
RetailTabBinding.SetClick(_spellTab, null);
RetailTabBinding.SetClick(_componentTab, null);
_closeButton.OnClick = null;
_deleteButton.OnClick = null;
foreach ((UiButton button, _) in _filters) button.OnClick = null;
}
private static void SetClick(UiElement element, Action? action)
{
element.ClickThrough = action is null;
switch (element)
{
case UiButton button: button.OnClick = action; break;
case UiText text: text.OnClick = action; break;
case UiDatElement dat: dat.OnClick = action; break;
}
}
private static void SetTabOpen(UiElement element, bool open)
{
if (element is IUiDatStateful stateful
&& stateful.TrySetRetailState(open ? RetailUiStateIds.Open : RetailUiStateIds.Closed))
return;
if (element is UiButton button)
button.Selected = open;
}
}