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:
parent
1249ad03de
commit
15bb61e05d
5 changed files with 179 additions and 285 deletions
39
src/AcDream.App/UI/Layout/RetailTabBinding.cs
Normal file
39
src/AcDream.App/UI/Layout/RetailTabBinding.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
namespace AcDream.App.UI.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// Shared controller seam for retail DAT-authored tabs. The LayoutDesc owns the
|
||||
/// tab's font, colors, and child chrome; controllers only bind activation and
|
||||
/// select the retail <c>Open</c>/<c>Closed</c> state.
|
||||
/// </summary>
|
||||
internal static class RetailTabBinding
|
||||
{
|
||||
public static void SetClick(UiElement? element, Action? action)
|
||||
{
|
||||
if (element is null) return;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SetOpen(UiElement? element, bool open)
|
||||
{
|
||||
if (element is IUiDatStateful stateful
|
||||
&& stateful.TrySetRetailState(open ? RetailUiStateIds.Open : RetailUiStateIds.Closed))
|
||||
return true;
|
||||
|
||||
if (element is UiButton button)
|
||||
{
|
||||
button.Selected = open;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue