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>
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|