acdream/src/AcDream.App/UI/Layout/CharacterSheet.cs
Erik defbde1f86 feat(studio): Attributes tab Pass 2 — click-to-select (highlight + footer B + raise triangles) + tab states
- UiClickablePanel: new UiPanel subclass with OnClick action + HandlesClick=true
  so row clicks survive whole-window-Draggable ancestor frames.

- CharacterStatController overhaul (Pass 2):
  - Tab bar button states: SetButtonStateRecursive walks each tab group container
    (0x10000228/229/538) setting UiButton.ActiveState="Open" (Attributes) or
    "Closed" (Skills/Titles) via UIStateId enum string names from DatReaderWriter.
  - Row click: 9 rows become UiClickablePanel; sel[] mutable box drives footer/highlight.
  - Toggle: clicking the same row deselects (→ footer State A); click a new row
    updates title="Attrib: value", line-1 label="Experience To Raise:", line-1
    value=cost, line-2="Unassigned Experience:" in both states.
  - Row highlight: BackgroundColor=HighlightBg (semi-translucent gold) on selected row.
  - Raise buttons (0x10000246 ×1 + 0x100005EB ×10): hidden initially; shown on
    selection with ActiveState="Normal" (affordable) or "Ghosted" (cost=0 or unaffordable).
    CollectButtonsById tree-walk finds ALL copies of the button across tab-page mounts
    (not just the last-registered _byId copy) so all instances are controlled.

- CharacterSheet: AttributeRaiseCosts long[] (Strength…Mana raise costs in retail
  display order; cost=0 → max/disabled row demos the Ghosted button state).
- SampleData.SampleCharacter: fills AttributeRaiseCosts[9] — Strength/Quickness=0
  (maxed), Focus@10→110 matching the retail screenshot (spec §4).

- 35 new tests (total 673 pass) covering: row click→footer B title/line1/line2,
  toggle deselect→footer A, switch row, highlight set/clear, raise button
  hidden/Normal/Ghosted/deselect, tab Open/Closed states, GetRaiseCost helper,
  GetRowName helper, SampleData fixture sanity.

Console.WriteLine("[CharacterStat] Row click: index=N → selected=N (Name)") fires
on every click for the user's live verification in the studio.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 21:48:16 +02:00

137 lines
6.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
namespace AcDream.App.UI.Layout;
/// <summary>
/// Snapshot of all character data the Character window report uses.
/// Passed to <see cref="CharacterController.Bind"/> as a provider delegate
/// so the window can be rebound to live data in GameWindow or a static
/// fixture in the UI Studio.
///
/// <para>Field names and retail property ids confirmed from
/// <c>gmCharacterInfoUI::UpdatePlayerBirthAgeDeaths</c> (0x004b8cb0),
/// <c>UpdateEnduranceInfo</c> (0x004b8eb0),
/// <c>UpdateInnateAttributeInfo</c> (0x004b87e0),
/// <c>UpdateFakeSkills</c> (0x004b8930),
/// <c>UpdateAugmentations</c> (0x004b9000), and
/// <c>UpdateLoad</c> (0x004b8a20).</para>
/// </summary>
public sealed class CharacterSheet
{
// ── Identity ──────────────────────────────────────────────────────────────
/// <summary>Character name (first line of the report).</summary>
public string Name { get; init; } = string.Empty;
/// <summary>Character level.</summary>
public int Level { get; init; }
/// <summary>Race string, e.g. "Aluvian". Null = omit.</summary>
public string? Race { get; init; }
/// <summary>Heritage string, e.g. "Aluvian Heritage". Null = omit.</summary>
public string? Heritage { get; init; }
/// <summary>Title string, e.g. "the Adventurer". Null = omit.</summary>
public string? Title { get; init; }
// ── Experience / PK (gmStatManagementUI::UpdateExperience 0x004f0a70,
// UpdatePKStatus 0x004f00a0) — the Attributes-tab header strip ──────────
/// <summary>Total accrued experience (retail PropertyInt64 1). Header value
/// element 0x10000235 (m_pTotalXPText).</summary>
public long TotalXp { get; init; }
/// <summary>Experience remaining to the next level. Header value element
/// 0x10000238 (m_pXPToLevelText).</summary>
public long XpToNextLevel { get; init; }
/// <summary>XP-to-next-level meter fill, 0..1 (retail (curbase)/(capbase)).
/// Drives the header meter 0x10000236 (m_pXPToLevelMeter).</summary>
public float XpFraction { get; init; }
/// <summary>PK status display string, e.g. "Non-Player Killer". Header element
/// 0x10000233 (m_pPKStatusText). Null = omit.</summary>
public string? PkStatus { get; init; }
// ── Birth / age / deaths (UpdatePlayerBirthAgeDeaths 0x004b8cb0) ─────────
/// <summary>Formatted birth date string (retail InqInt(0x62) → strftime).
/// Null = omit the birth line.</summary>
public string? BirthDate { get; init; }
/// <summary>Formatted play-time duration (retail InqInt(0x7d) → QueryDuration).
/// Null = omit the age line.</summary>
public string? PlayTime { get; init; }
/// <summary>Total deaths (retail InqInt(0x2b) = NumDeaths).</summary>
public int Deaths { get; init; }
// ── Vitals (UpdateEnduranceInfo 0x004b8eb0) ─────────────────────────────
public int HealthCurrent { get; init; }
public int HealthMax { get; init; }
public int StaminaCurrent { get; init; }
public int StaminaMax { get; init; }
public int ManaCurrent { get; init; }
public int ManaMax { get; init; }
// ── Innate attributes (UpdateInnateAttributeInfo 0x004b87e0) ────────────
// InqAttribute order: 1,2,4,3,5,6 = Strength, Endurance, Quickness, Coordination, Focus, Self.
public int Strength { get; init; }
public int Endurance { get; init; }
public int Quickness { get; init; }
public int Coordination { get; init; }
public int Focus { get; init; }
public int Self { get; init; }
// ── Skills (UpdateFakeSkills 0x004b8930) ────────────────────────────────
// Retail InqInt(0xb5) = SkillCredits; InqInt(0xc0) = AvailableSkillCredits.
// InqInt(0x18) = available skill credits — footer 0x10000245 in the Attributes tab.
public int UnspentSkillCredits { get; init; }
public int SpecializedSkillCredits { get; init; }
/// <summary>
/// Available (unspent) skill credits shown in the Attributes tab footer State-A.
/// Retail InqInt(0x18) — gmStatManagementUI::DisplayDefaultFooter (0x0049cde0).
/// Element 0x10000243 (footer line-1 value in the studio's 3-line layout).
/// </summary>
public int SkillCredits { get; init; }
/// <summary>
/// Unassigned (banked) experience points.
/// Retail InqInt64(2) — shown in footer line-2 in State-A display.
/// Element 0x10000245 (footer line-2 value).
/// </summary>
public long UnassignedXp { get; init; }
// ── Attribute raise costs (ExperienceToAttributeLevel, gmAttributeUI::PostInit) ──
// Retail formula: ExperienceToAttributeLevel(value + 1) ExperienceToAttributeLevel(value).
// We store pre-computed per-attribute costs for the fixture; cost == 0 → attribute is
// at max or not trainable (raise button ghosted/hidden). Ordered to match AttrRows
// (Strength, Endurance, Coordination, Quickness, Focus, Self, Health, Stamina, Mana).
// Source: gmAttributeUI::AttributeInfoRegion::Update (0x004f1910) + CM_Train::Event_TrainAttribute.
/// <summary>
/// XP cost to raise each of the 9 attributes/vitals by 1, in retail display order:
/// [0]=Strength, [1]=Endurance, [2]=Coordination, [3]=Quickness, [4]=Focus, [5]=Self,
/// [6]=Health, [7]=Stamina, [8]=Mana.
/// Cost 0 means the attribute is at max (raise button ghosted).
/// </summary>
public long[] AttributeRaiseCosts { get; init; } = Array.Empty<long>();
// ── Augmentations (UpdateAugmentations 0x004b9000) ─────────────────────
// Retail InqInt(0x162) = AugmentationStat; string-switch 1..0xb.
/// <summary>Augmentation name from the switch in UpdateAugmentations (0x004b9000),
/// e.g. "Swords", "Two Handed Weapons". Null = "None".</summary>
public string? AugmentationName { get; init; }
// ── Burden / load (UpdateLoad 0x004b8a20) ───────────────────────────────
// Retail InqLoad + EncumbranceCapacity(Strength, AugEncumbrance).
public int BurdenCurrent { get; init; }
public int BurdenMax { get; init; }
}