feat(D.5.3a): selected-object meter — Health bar + name on the action bar
Port of gmToolbarUI::HandleSelectionChanged (acclient_2013_pseudo_c.txt:198635). When the player selects a world object the action bar's bottom strip shows the object name + (for player/pet/attackable targets) a live Health meter; deselect clears it. Mana (#140) + stack slider deferred. - SelectedObjectController (new): clear-then-populate on selection change; sets name (UiText child, VitalsController pattern), overlay state (ObjectSelected / StackedItemSelected via UiDatElement.ActiveState), shows the health meter and sends QueryHealth for health targets. Subscribes via a delegate seam (no GameWindow coupling). - GameWindow: _selectedGuid field -> SelectedGuid property + SelectionChanged event (fires on actual change only); 3 write sites converted, reads untouched. All selection-write paths (LMB pick, Tab/Q, despawn-clear via Tick()) run on the render thread, so the event-driven UI mutation is single-threaded. - WorldSession.SendQueryHealth (0x01BF) — wraps SocialActions.BuildQueryHealth. - DatWidgetFactory.BuildMeter: handle the single-image toolbar meter shape (back-track on the element's own DirectState, fill on one Type-3 child). The sprites go in the TILE slot (DrawMode=Normal tiles to full bar geometry per UIElement_Meter::DrawChildren) — a left-cap assignment would gap/clamp a sub-140px sprite. Vitals 3-slice path unchanged. - ToolbarController.HiddenIds: A1 (health) now owned by SelectedObjectController; A2 (mana) + A4 (stack) stay hidden (deferred) so their dat back-tracks don't render as stray empty bars. Adversarial Opus review found + fixed: the mana-meter orphan (A2 left unhidden) and the meter tile-vs-cap render bug (C1). Divergence rows AP-46 (health gate approximation: IsLiveCreatureTarget vs IsPlayer||pet||attackable) + AP-47 (meter shown on select vs on UpdateHealth reply). Spec §5 corrected. Build + full test suite green (2,684 passed / 4 skipped). Health meter render fidelity (full-width fill + fraction mapping) pending the user's visual gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e8562fc4e2
commit
6636e50c2a
11 changed files with 851 additions and 30 deletions
|
|
@ -48,7 +48,7 @@ Copy this block when adding a new issue:
|
||||||
|
|
||||||
## #140 — Toolbar interactivity — selected-object display
|
## #140 — Toolbar interactivity — selected-object display
|
||||||
|
|
||||||
**Status:** OPEN
|
**Status:** IN PROGRESS (D.5.3a — health + name landed, pending visual gate; mana + stack slider still deferred)
|
||||||
**Severity:** MEDIUM
|
**Severity:** MEDIUM
|
||||||
**Filed:** 2026-06-17
|
**Filed:** 2026-06-17
|
||||||
**Component:** ui — D.5 toolbar / selection
|
**Component:** ui — D.5 toolbar / selection
|
||||||
|
|
@ -56,6 +56,7 @@ Copy this block when adding a new issue:
|
||||||
**Description:** The action bar (D.5.1) is the retail "selected object" display. Wire the B.4 WorldPicker/selection state to the toolbar's currently-hidden elements: the two meters 0x100001A1 (selected-object Health) / 0x100001A2 (selected-object Mana) + the stack slider 0x100001A4 + the object-name line, so the bar shows what the player has selected in the world. Click-to-use + the peace/war stance indicator already shipped in D.5.1. Promote to roadmap D.5.3 (already listed there).
|
**Description:** The action bar (D.5.1) is the retail "selected object" display. Wire the B.4 WorldPicker/selection state to the toolbar's currently-hidden elements: the two meters 0x100001A1 (selected-object Health) / 0x100001A2 (selected-object Mana) + the stack slider 0x100001A4 + the object-name line, so the bar shows what the player has selected in the world. Click-to-use + the peace/war stance indicator already shipped in D.5.1. Promote to roadmap D.5.3 (already listed there).
|
||||||
|
|
||||||
**Root cause / status:** The selection-state wire was deferred out of D.5.1 scope; the meter/slider elements are present in LayoutDesc 0x21000016 but hidden (no backing data). D.5.3 is the planned port.
|
**Root cause / status:** The selection-state wire was deferred out of D.5.1 scope; the meter/slider elements are present in LayoutDesc 0x21000016 but hidden (no backing data). D.5.3 is the planned port.
|
||||||
|
- **D.5.3a (2026-06-18):** the Health meter (0x100001A1) + the object-name line (0x1000019F) + the overlay state (0x100001A0) are wired via `SelectedObjectController` (port of `gmToolbarUI::HandleSelectionChanged`); `SelectionChanged` event on `GameWindow`; `QueryHealth (0x01BF)` sent on select. Spec/plan: `docs/superpowers/specs|plans/2026-06-18-d53a-*`. **Still deferred:** the Mana meter (0x100001A2 — owned-item-only; no remote-target mana path yet) and the stack entry/slider (0x100001A3/A4 — stack-split UI). Divergence rows AP-46/AP-47. Awaiting the visual gate before closing the health half.
|
||||||
|
|
||||||
**Files:** `src/AcDream.App/UI/Layout/ToolbarController.cs` + the selection/WorldPicker state (see `claude-memory/project_interaction_pipeline.md`).
|
**Files:** `src/AcDream.App/UI/Layout/ToolbarController.cs` + the selection/WorldPicker state (see `claude-memory/project_interaction_pipeline.md`).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,8 @@ accepted-divergence entries (#96, #49, #50).
|
||||||
| AP-41 | Scrollbar thumb 3-slice cap fallback only: single-tile draw (`0x06004C63`) used only when `ThumbTopSprite`/`ThumbBotSprite` are unset; the chat controller passes all three cap ids so the 3-slice path is drawn in practice | `src/AcDream.App/UI/UiScrollbar.cs:35` | The fallback single-tile path is unreachable when caps are bound (chat controller always sets them); the 3-slice path is the active code path | Only if a future caller omits the cap ids will the fallback fire — no visual regression in the chat window | `UIElement_Scrollbar::UpdateLayout @0x4710d0`; cap sprites `0x06004C60` (top) + `0x06004C66` (bottom) from base layout `0x2100003E` |
|
| AP-41 | Scrollbar thumb 3-slice cap fallback only: single-tile draw (`0x06004C63`) used only when `ThumbTopSprite`/`ThumbBotSprite` are unset; the chat controller passes all three cap ids so the 3-slice path is drawn in practice | `src/AcDream.App/UI/UiScrollbar.cs:35` | The fallback single-tile path is unreachable when caps are bound (chat controller always sets them); the 3-slice path is the active code path | Only if a future caller omits the cap ids will the fallback fire — no visual regression in the chat window | `UIElement_Scrollbar::UpdateLayout @0x4710d0`; cap sprites `0x06004C60` (top) + `0x06004C66` (bottom) from base layout `0x2100003E` |
|
||||||
| AP-42 | `UiMenu` item model is flat (label + opaque payload, single-level popup); retail `UIElement_Menu::MakePopup @0x46d310` supports hierarchical nested submenus via recursive popup chain | `src/AcDream.App/UI/UiMenu.cs` | The chat talk-focus menu is single-level (14 rows, 2 columns, no submenu); hierarchy is latent and unreachable through the chat window — no behavioral difference in the current usage | A future menu with nested submenus would render flat (only the top-level items drawn, no drill-down) | `UIElement_Menu::MakePopup` @0x46d310 |
|
| AP-42 | `UiMenu` item model is flat (label + opaque payload, single-level popup); retail `UIElement_Menu::MakePopup @0x46d310` supports hierarchical nested submenus via recursive popup chain | `src/AcDream.App/UI/UiMenu.cs` | The chat talk-focus menu is single-level (14 rows, 2 columns, no submenu); hierarchy is latent and unreachable through the chat window — no behavioral difference in the current usage | A future menu with nested submenus would render flat (only the top-level items drawn, no drill-down) | `UIElement_Menu::MakePopup` @0x46d310 |
|
||||||
| AP-45 | `PublicUpdatePropertyInt (0x02CE)` sequence byte parsed-past but not honored; last update wins (no freshness check against sequence number) | `src/AcDream.Core.Net/Messages/PublicUpdatePropertyInt.cs` | Loopback ACE rarely reorders; latest-wins matches `PrivateUpdateVital`/`UpdatePosition`'s existing non-sequence behavior. Sequence tracking added when needed alongside TS-26. | A reordered 0x02CE on a real network could apply a stale UiEffects value — item icon temporarily shows the wrong effect state, corrected on next update | `PublicUpdatePropertyInt` sequence byte (ACE GameMessagePublicUpdatePropertyInt) |
|
| AP-45 | `PublicUpdatePropertyInt (0x02CE)` sequence byte parsed-past but not honored; last update wins (no freshness check against sequence number) | `src/AcDream.Core.Net/Messages/PublicUpdatePropertyInt.cs` | Loopback ACE rarely reorders; latest-wins matches `PrivateUpdateVital`/`UpdatePosition`'s existing non-sequence behavior. Sequence tracking added when needed alongside TS-26. | A reordered 0x02CE on a real network could apply a stale UiEffects value — item icon temporarily shows the wrong effect state, corrected on next update | `PublicUpdatePropertyInt` sequence byte (ACE GameMessagePublicUpdatePropertyInt) |
|
||||||
|
| AP-46 | Health-meter gate approximation: retail shows the health meter for `IsPlayer() || pet_owner || ObjectIsAttackable()`; acdream uses `IsLiveCreatureTarget` (the `ItemType.Creature` flag) | `src/AcDream.App/UI/Layout/SelectedObjectController.cs` (`HandleSelectionChanged` analogue) | `IsLiveCreatureTarget` is already wired for Tab/Q combat-target gating and is the correct proxy for M1.5 scope (no pet system, no PK); the only practical gap is a friendly non-attackable NPC, which is rare in the ACE dev loop | A friendly (non-attackable) NPC shows a health meter where retail would show name+overlay only — false meter on non-combat NPCs | `gmToolbarUI::HandleSelectionChanged` acclient_2013_pseudo_c.txt:198754 |
|
||||||
|
| AP-47 | Meter-visible timing: acdream shows the health meter immediately on select; retail shows it from `RecvNotice_UpdateObjectHealth` when the queried value arrives | `src/AcDream.App/UI/Layout/SelectedObjectController.cs` (`OnSelectionChanged`) | Avoids a one-round-trip blank-then-pop; the fill polls `GetHealthPercent` which returns 1.0 until the reply — visually indistinguishable for a full-HP target and self-corrects within one RTT for a damaged target | A freshly-selected off-screen-damaged target reads full for one server round-trip before the `QueryHealth` reply lands | `gmToolbarUI::HandleSelectionChanged` acclient_2013_pseudo_c.txt:198757 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,12 @@ AcDream.App.UI.Layout.SelectedObjectController.Bind(
|
||||||
datFont: vitalsDatFont);
|
datFont: vitalsDatFont);
|
||||||
```
|
```
|
||||||
|
|
||||||
Also: remove `0x100001A1` and `0x100001A2` from `ToolbarController.HiddenIds` (single-owner: the
|
Also: remove **only** `0x100001A1` from `ToolbarController.HiddenIds` — the health meter is now owned
|
||||||
selected-object meters are now owned by `SelectedObjectController`); `0x100001A4` (stack slider) stays
|
by `SelectedObjectController` (it hides A1 at bind, shows on a health-target select). `0x100001A2`
|
||||||
in `HiddenIds` (deferred). Convert the `_selectedGuid` field → the `SelectedGuid` property (unit 1).
|
(mana, deferred #140) and `0x100001A4` (stack slider, deferred) **stay** in `HiddenIds`: they have no
|
||||||
|
controller yet, so they must stay hidden or their dat back-track sprites render as stray empty bars.
|
||||||
|
(`HiddenIds = { 0x100001A2, 0x100001A4 }`.) Convert the `_selectedGuid` field → the `SelectedGuid`
|
||||||
|
property (unit 1).
|
||||||
|
|
||||||
## Data flow
|
## Data flow
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,8 @@ public sealed class GameWindow : IDisposable
|
||||||
private AcDream.App.UI.UiHost? _uiHost;
|
private AcDream.App.UI.UiHost? _uiHost;
|
||||||
// Phase D.5.1 — toolbar controller (kept for lifetime clarity; mirrors _chatWindowController pattern).
|
// Phase D.5.1 — toolbar controller (kept for lifetime clarity; mirrors _chatWindowController pattern).
|
||||||
private AcDream.App.UI.Layout.ToolbarController? _toolbarController;
|
private AcDream.App.UI.Layout.ToolbarController? _toolbarController;
|
||||||
|
// Phase D.5.3a — selected-object strip controller (name, overlay state, health meter).
|
||||||
|
private AcDream.App.UI.Layout.SelectedObjectController? _selectedObjectController;
|
||||||
// Phase D.2b Task 9 — plugin UI registrations buffered before OnLoad; drained in OnLoad.
|
// Phase D.2b Task 9 — plugin UI registrations buffered before OnLoad; drained in OnLoad.
|
||||||
private readonly AcDream.App.Plugins.BufferedUiRegistry? _uiRegistry;
|
private readonly AcDream.App.Plugins.BufferedUiRegistry? _uiRegistry;
|
||||||
// Phase I.2: ImGui debug panel ViewModel. Lives for as long as
|
// Phase I.2: ImGui debug panel ViewModel. Lives for as long as
|
||||||
|
|
@ -846,6 +848,21 @@ public sealed class GameWindow : IDisposable
|
||||||
private readonly Dictionary<uint, AcDream.Core.Net.WorldSession.EntitySpawn> _lastSpawnByGuid = new();
|
private readonly Dictionary<uint, AcDream.Core.Net.WorldSession.EntitySpawn> _lastSpawnByGuid = new();
|
||||||
// Current selection: written by Q-cycle (combat) and LMB click (interact); cleared on entity despawn.
|
// Current selection: written by Q-cycle (combat) and LMB click (interact); cleared on entity despawn.
|
||||||
private uint? _selectedGuid;
|
private uint? _selectedGuid;
|
||||||
|
/// <summary>Fires when the selected world object changes (retail gmToolbarUI selection-change event,
|
||||||
|
/// acclient_2013_pseudo_c.txt:198635). Private: only the internal SelectedObjectController subscribes.</summary>
|
||||||
|
private event Action<uint?>? SelectionChanged;
|
||||||
|
/// <summary>Currently-selected world object guid. The setter fires <see cref="SelectionChanged"/> only on
|
||||||
|
/// an actual change (dedup), so all writes go through here; reads may use the field directly.</summary>
|
||||||
|
private uint? SelectedGuid
|
||||||
|
{
|
||||||
|
get => _selectedGuid;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_selectedGuid == value) return;
|
||||||
|
_selectedGuid = value;
|
||||||
|
SelectionChanged?.Invoke(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// B.6/B.7 (2026-05-16): pending close-range action that will be fired
|
// B.6/B.7 (2026-05-16): pending close-range action that will be fired
|
||||||
// once the local auto-walk overlay reports arrival (body has finished
|
// once the local auto-walk overlay reports arrival (body has finished
|
||||||
|
|
@ -2003,6 +2020,19 @@ public sealed class GameWindow : IDisposable
|
||||||
warDigits: toolbarWarDigits,
|
warDigits: toolbarWarDigits,
|
||||||
emptyDigits: toolbarEmptyDigits);
|
emptyDigits: toolbarEmptyDigits);
|
||||||
|
|
||||||
|
// Phase D.5.3a — selected-object strip (name, overlay state, health meter).
|
||||||
|
// Analogue of retail gmToolbarUI::HandleSelectionChanged
|
||||||
|
// (acclient_2013_pseudo_c.txt:198635).
|
||||||
|
_selectedObjectController = AcDream.App.UI.Layout.SelectedObjectController.Bind(
|
||||||
|
toolbarLayout,
|
||||||
|
subscribeSelectionChanged: h => SelectionChanged += h,
|
||||||
|
isHealthTarget: IsLiveCreatureTarget,
|
||||||
|
name: g => Objects.Get(g)?.Name,
|
||||||
|
healthPercent: g => Combat.GetHealthPercent(g),
|
||||||
|
stackSize: g => (uint)(Objects.Get(g)?.StackSize ?? 0),
|
||||||
|
sendQueryHealth: g => _liveSession?.SendQueryHealth(g),
|
||||||
|
datFont: vitalsDatFont);
|
||||||
|
|
||||||
var toolbarRoot = toolbarLayout.Root;
|
var toolbarRoot = toolbarLayout.Root;
|
||||||
// Wrap the dat content in the universal 8-piece beveled window chrome —
|
// Wrap the dat content in the universal 8-piece beveled window chrome —
|
||||||
// the SAME UiNineSlicePanel used by the vitals and chat windows. The
|
// the SAME UiNineSlicePanel used by the vitals and chat windows. The
|
||||||
|
|
@ -3708,7 +3738,7 @@ public sealed class GameWindow : IDisposable
|
||||||
_entitiesByServerGuid.Remove(serverGuid);
|
_entitiesByServerGuid.Remove(serverGuid);
|
||||||
_lastSpawnByGuid.Remove(serverGuid);
|
_lastSpawnByGuid.Remove(serverGuid);
|
||||||
if (_selectedGuid == serverGuid)
|
if (_selectedGuid == serverGuid)
|
||||||
_selectedGuid = null;
|
SelectedGuid = null;
|
||||||
|
|
||||||
if (logDelete)
|
if (logDelete)
|
||||||
_lightingSink?.UnregisterOwner(existingEntity.Id);
|
_lightingSink?.UnregisterOwner(existingEntity.Id);
|
||||||
|
|
@ -11568,7 +11598,7 @@ public sealed class GameWindow : IDisposable
|
||||||
|
|
||||||
if (picked is uint guid)
|
if (picked is uint guid)
|
||||||
{
|
{
|
||||||
_selectedGuid = guid;
|
SelectedGuid = guid;
|
||||||
string label = DescribeLiveEntity(guid);
|
string label = DescribeLiveEntity(guid);
|
||||||
Console.WriteLine($"[B.4b] pick guid=0x{guid:X8} name={label}");
|
Console.WriteLine($"[B.4b] pick guid=0x{guid:X8} name={label}");
|
||||||
// B.7 (2026-05-15): one-shot per-pick diagnostic so we can
|
// B.7 (2026-05-15): one-shot per-pick diagnostic so we can
|
||||||
|
|
@ -11958,7 +11988,7 @@ public sealed class GameWindow : IDisposable
|
||||||
bestGuid = guid;
|
bestGuid = guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedGuid = bestGuid;
|
SelectedGuid = bestGuid;
|
||||||
if (bestGuid is { } selected)
|
if (bestGuid is { } selected)
|
||||||
{
|
{
|
||||||
string label = DescribeLiveEntity(selected);
|
string label = DescribeLiveEntity(selected);
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,11 @@ public static class DatWidgetFactory
|
||||||
// ── Meter ────────────────────────────────────────────────────────────────
|
// ── Meter ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds a <see cref="UiMeter"/> and populates its six 3-slice sprite ids by
|
/// Builds a <see cref="UiMeter"/> and populates its sprite ids from the meter's
|
||||||
/// reading the meter's grandchild image elements (format doc §11).
|
/// child/grandchild elements (format doc §11). Two shapes are handled:
|
||||||
///
|
///
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Structure the importer produces for each meter (UIElement_Meter):
|
/// <b>3-slice shape</b> (vitals meters — 2 Type-3 containers, each with 3 image grandchildren):
|
||||||
/// <code>
|
/// <code>
|
||||||
/// meter (Type 7)
|
/// meter (Type 7)
|
||||||
/// ├── back-layer container (Type 3, lower ReadOrder — drawn first / behind)
|
/// ├── back-layer container (Type 3, lower ReadOrder — drawn first / behind)
|
||||||
|
|
@ -106,13 +106,27 @@ public static class DatWidgetFactory
|
||||||
/// │ ├── center image (→ front-tile sprite)
|
/// │ ├── center image (→ front-tile sprite)
|
||||||
/// │ ├── right-cap image (→ front-right sprite)
|
/// │ ├── right-cap image (→ front-right sprite)
|
||||||
/// │ └── expand overlay (named "ShowDetail"/"HideDetail" only — NO DirectState — IGNORED)
|
/// │ └── expand overlay (named "ShowDetail"/"HideDetail" only — NO DirectState — IGNORED)
|
||||||
/// └── text label (Type 0) (IGNORED — Fill/Label providers bound by VitalsController in Task 6)
|
/// └── text label (Type 0) (IGNORED — Fill/Label providers bound by VitalsController)
|
||||||
|
/// </code>
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// <b>Single-image shape</b> (toolbar selected-object meters 0x100001A1/0x100001A2 — 1 Type-3
|
||||||
|
/// child, no grandchildren): the back-track sprite is on the meter element's own DirectState;
|
||||||
|
/// the fill sprite is on the single Type-3 child's own DirectState. Both are placed in the
|
||||||
|
/// TILE slot (Back/FrontTile) with left/right caps 0, so <see cref="UiMeter.DrawHBar"/> tiles
|
||||||
|
/// them across the full bar geometry (DrawMode=Normal) and clips the fill to the fraction.
|
||||||
|
/// (retail: gmToolbarUI::HandleSelectionChanged :198635, UIElement_Meter::Initialize :123328)
|
||||||
|
/// <code>
|
||||||
|
/// meter (Type 7) [DirectState "" → back-track sprite, e.g. 0x0600193E]
|
||||||
|
/// └── fill container (Type 3) [DirectState "" → fill sprite, e.g. 0x0600193F]
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </para>
|
/// </para>
|
||||||
///
|
///
|
||||||
/// <para>
|
/// <para>
|
||||||
/// <see cref="UiMeter.Fill"/> and <see cref="UiMeter.Label"/> are NOT set here.
|
/// <see cref="UiMeter.Fill"/> and <see cref="UiMeter.Label"/> are NOT set here.
|
||||||
/// They are bound to the live stat providers in Task 6 (VitalsController).
|
/// They are bound to the live stat providers by the controller (VitalsController /
|
||||||
|
/// SelectedObjectController).
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static UiMeter BuildMeter(ElementInfo info,
|
private static UiMeter BuildMeter(ElementInfo info,
|
||||||
|
|
@ -132,23 +146,53 @@ public static class DatWidgetFactory
|
||||||
.OrderBy(c => c.ReadOrder)
|
.OrderBy(c => c.ReadOrder)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (containers.Count != 2)
|
|
||||||
Console.WriteLine($"[D.2b] meter 0x{info.Id:X8}: {containers.Count} Type-3 slice containers (expected 2) — bars may render as solid-color fallback.");
|
|
||||||
|
|
||||||
if (containers.Count >= 1)
|
|
||||||
{
|
|
||||||
var (l, t, r) = SliceIds(containers[0]);
|
|
||||||
m.BackLeft = l;
|
|
||||||
m.BackTile = t;
|
|
||||||
m.BackRight = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (containers.Count >= 2)
|
if (containers.Count >= 2)
|
||||||
{
|
{
|
||||||
var (l, t, r) = SliceIds(containers[1]);
|
// Vitals 3-slice shape: two Type-3 containers each holding 3 grandchild images
|
||||||
m.FrontLeft = l;
|
// (left-cap / center-tile / right-cap). Back is the lower ReadOrder; front is higher.
|
||||||
m.FrontTile = t;
|
var (bl, bt, br) = SliceIds(containers[0]);
|
||||||
m.FrontRight = r;
|
m.BackLeft = bl;
|
||||||
|
m.BackTile = bt;
|
||||||
|
m.BackRight = br;
|
||||||
|
|
||||||
|
var (fl, ft, fr) = SliceIds(containers[1]);
|
||||||
|
m.FrontLeft = fl;
|
||||||
|
m.FrontTile = ft;
|
||||||
|
m.FrontRight = fr;
|
||||||
|
}
|
||||||
|
else if (containers.Count == 1)
|
||||||
|
{
|
||||||
|
// Single-image shape used by the toolbar selected-object meters
|
||||||
|
// (health 0x100001A1, mana 0x100001A2).
|
||||||
|
// - The back-track sprite lives on the meter ELEMENT's own DirectState ("" key of
|
||||||
|
// info.StateMedia) — not on any grandchild image. e.g. health back = 0x0600193E.
|
||||||
|
// - The fill sprite lives on the single Type-3 child's own DirectState ("" key of
|
||||||
|
// containers[0].StateMedia). e.g. health fill = 0x0600193F.
|
||||||
|
// The fill child has NO image grandchildren, so SliceIds would return all-zero —
|
||||||
|
// read the container's StateMedia directly instead.
|
||||||
|
//
|
||||||
|
// These go in the TILE slot (not the left-cap slot): the sprites are DrawMode=Normal,
|
||||||
|
// which retail renders as "tile at native width to fill the full element geometry"
|
||||||
|
// (format doc §6; the generic UiDatElement.OnDraw Normal path; UIElement_Meter::
|
||||||
|
// DrawChildren :123574 clips the child's FULL 140px geometry box to the fill fraction).
|
||||||
|
// With the sprite on BackLeft instead, UiMeter.DrawHBar would clamp the cap to the
|
||||||
|
// sprite's NATIVE width (capL = min(nativeW, 140)) — leaving a right-side gap and
|
||||||
|
// mapping the fill fraction to native width when nativeW < 140. The tile slot makes
|
||||||
|
// midW = full bar width, so the back tiles across all 140px and the front clips to
|
||||||
|
// 140*fraction correctly for any native sprite width (left/right caps unused = 0).
|
||||||
|
// (retail: gmToolbarUI::HandleSelectionChanged :198635 / UIElement_Meter::DrawChildren :123574)
|
||||||
|
m.BackLeft = 0;
|
||||||
|
m.BackTile = info.StateMedia.TryGetValue("", out var bm) ? bm.File : 0u;
|
||||||
|
m.BackRight = 0;
|
||||||
|
|
||||||
|
m.FrontLeft = 0;
|
||||||
|
m.FrontTile = containers[0].StateMedia.TryGetValue("", out var fm) ? fm.File : 0u;
|
||||||
|
m.FrontRight = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Count == 0: no Type-3 containers at all — genuinely malformed meter dat.
|
||||||
|
Console.WriteLine($"[D.2b] meter 0x{info.Id:X8}: {containers.Count} Type-3 slice containers (expected 1 or 2) — bars may render as solid-color fallback.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
|
|
||||||
208
src/AcDream.App/UI/Layout/SelectedObjectController.cs
Normal file
208
src/AcDream.App/UI/Layout/SelectedObjectController.cs
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using AcDream.App.UI;
|
||||||
|
|
||||||
|
namespace AcDream.App.UI.Layout;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controller for the action bar's selected-object strip (ids 0x1000019F–0x100001A1).
|
||||||
|
/// Analogue of retail <c>gmToolbarUI::HandleSelectionChanged</c>
|
||||||
|
/// (<c>docs/research/named-retail/acclient_2013_pseudo_c.txt:198635</c>).
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// On selection change: clears the strip (name, overlay state, health meter), then
|
||||||
|
/// if a guid is provided it sets the name, puts the overlay field into the appropriate
|
||||||
|
/// state ("ObjectSelected" or "StackedItemSelected"), and for health-bearing targets
|
||||||
|
/// shows the health meter and sends a <c>QueryHealth (0x01BF)</c> request.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// <strong>Divergence — meter-visible timing.</strong>
|
||||||
|
/// Retail makes the health meter visible from <c>RecvNotice_UpdateObjectHealth</c>
|
||||||
|
/// (when the queried value arrives, cite HandleSelectionChanged:198757).
|
||||||
|
/// acdream shows it immediately on select (fill polls <see cref="CombatState.GetHealthPercent"/>
|
||||||
|
/// which returns 1.0 until the reply lands). Recorded in the divergence register.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// <strong>Divergence — health-target gate approximation.</strong>
|
||||||
|
/// Retail gates on <c>IsPlayer() || pet_owner || ObjectIsAttackable()</c>
|
||||||
|
/// (cite HandleSelectionChanged:198754). acdream uses <c>IsLiveCreatureTarget</c>
|
||||||
|
/// (the <c>ItemType.Creature</c> flag). Recorded in the divergence register.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
public sealed class SelectedObjectController
|
||||||
|
{
|
||||||
|
// ── Element ids (toolbar LayoutDesc 0x21000016) ─────────────────────────
|
||||||
|
/// <summary>Selected-object name element id.</summary>
|
||||||
|
public const uint NameId = 0x1000019F;
|
||||||
|
/// <summary>Selected-object overlay field element id (states: ObjectSelected / StackedItemSelected).</summary>
|
||||||
|
public const uint OverlayId = 0x100001A0;
|
||||||
|
/// <summary>Selected-object health meter element id.</summary>
|
||||||
|
public const uint HealthMeterId = 0x100001A1;
|
||||||
|
|
||||||
|
// ── Found elements (any may be null for partial/test layouts) ───────────
|
||||||
|
private readonly UiElement? _name;
|
||||||
|
private readonly UiDatElement? _overlay;
|
||||||
|
private readonly UiMeter? _healthMeter;
|
||||||
|
|
||||||
|
// ── Captured delegates ───────────────────────────────────────────────────
|
||||||
|
private readonly Func<uint, bool> _isHealthTarget;
|
||||||
|
private readonly Func<uint, string?> _name_;
|
||||||
|
private readonly Func<uint, float> _healthPercent;
|
||||||
|
private readonly Func<uint, uint> _stackSize;
|
||||||
|
private readonly Action<uint> _sendQueryHealth;
|
||||||
|
|
||||||
|
// ── Live state (read by closures on the per-frame draw path) ────────────
|
||||||
|
private uint? _current;
|
||||||
|
private string? _currentName;
|
||||||
|
|
||||||
|
/// <summary>White label color for the name line.</summary>
|
||||||
|
private static readonly Vector4 NameColor = new(1f, 1f, 1f, 1f);
|
||||||
|
|
||||||
|
private SelectedObjectController(
|
||||||
|
ImportedLayout layout,
|
||||||
|
Action<Action<uint?>> subscribeSelectionChanged,
|
||||||
|
Func<uint, bool> isHealthTarget,
|
||||||
|
Func<uint, string?> name,
|
||||||
|
Func<uint, float> healthPercent,
|
||||||
|
Func<uint, uint> stackSize,
|
||||||
|
Action<uint> sendQueryHealth,
|
||||||
|
UiDatFont? datFont)
|
||||||
|
{
|
||||||
|
_isHealthTarget = isHealthTarget;
|
||||||
|
_name_ = name;
|
||||||
|
_healthPercent = healthPercent;
|
||||||
|
_stackSize = stackSize;
|
||||||
|
_sendQueryHealth = sendQueryHealth;
|
||||||
|
|
||||||
|
// Find elements — silently skip absent ones (partial/test layouts).
|
||||||
|
_name = layout.FindElement(NameId);
|
||||||
|
_overlay = layout.FindElement(OverlayId) as UiDatElement;
|
||||||
|
_healthMeter = layout.FindElement(HealthMeterId) as UiMeter;
|
||||||
|
|
||||||
|
// This controller owns the health meter's initial-hidden state.
|
||||||
|
if (_healthMeter is not null)
|
||||||
|
{
|
||||||
|
_healthMeter.Visible = false;
|
||||||
|
// Fill polls live: _current holds the currently-selected guid (or null).
|
||||||
|
// Returns 0f when nothing is selected (empty bar), healthPercent(g) otherwise.
|
||||||
|
_healthMeter.Fill = () => _current is uint g ? _healthPercent(g) : (float?)0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach a centered UiText child to the name element for the object name display.
|
||||||
|
// Mirrors VitalsController.BindMeter's number attach (same decoration style).
|
||||||
|
if (_name is not null)
|
||||||
|
{
|
||||||
|
var label = new UiText
|
||||||
|
{
|
||||||
|
Left = 0f,
|
||||||
|
Top = 0f,
|
||||||
|
Width = _name.Width,
|
||||||
|
Height = _name.Height,
|
||||||
|
Anchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Right | AnchorEdges.Bottom,
|
||||||
|
Centered = true,
|
||||||
|
DatFont = datFont,
|
||||||
|
ClickThrough = true,
|
||||||
|
AcceptsFocus = false,
|
||||||
|
IsEditControl = false,
|
||||||
|
CapturesPointerDrag = false,
|
||||||
|
LinesProvider = () =>
|
||||||
|
{
|
||||||
|
// Returns a single white line when a name is available; empty otherwise.
|
||||||
|
var n = _currentName;
|
||||||
|
return string.IsNullOrEmpty(n)
|
||||||
|
? Array.Empty<UiText.Line>()
|
||||||
|
: new[] { new UiText.Line(n, NameColor) };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
_name.AddChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the handler LAST so the initial state is fully set up first.
|
||||||
|
subscribeSelectionChanged(OnSelectionChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create and bind a <see cref="SelectedObjectController"/> to <paramref name="layout"/>.
|
||||||
|
/// Port of retail <c>gmToolbarUI::HandleSelectionChanged</c>
|
||||||
|
/// (<c>acclient_2013_pseudo_c.txt:198635</c>).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="layout">Imported toolbar layout (LayoutDesc 0x21000016).</param>
|
||||||
|
/// <param name="subscribeSelectionChanged">
|
||||||
|
/// Called once with the controller's <see cref="OnSelectionChanged"/> handler.
|
||||||
|
/// Typical host: <c>h => SelectionChanged += h</c> — keeps the controller
|
||||||
|
/// decoupled from <c>GameWindow</c>.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="isHealthTarget">
|
||||||
|
/// Returns true for guids that should show a health meter (proxy for retail's
|
||||||
|
/// <c>IsPlayer() || pet_owner || ObjectIsAttackable()</c>).
|
||||||
|
/// </param>
|
||||||
|
/// <param name="name">Returns the display name for a given guid (or null if unknown).</param>
|
||||||
|
/// <param name="healthPercent">Returns the health fill fraction [0..1] for a given guid.</param>
|
||||||
|
/// <param name="stackSize">Returns the stack size for a given guid (0 or 1 = non-stacked).</param>
|
||||||
|
/// <param name="sendQueryHealth">
|
||||||
|
/// Sends retail <c>QueryHealth (0x01BF)</c>; server replies with <c>UpdateHealth (0x01C0)</c>.
|
||||||
|
/// May be a no-op when offline.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="datFont">Dat font for the name label; null = debug bitmap font fallback.</param>
|
||||||
|
public static SelectedObjectController Bind(
|
||||||
|
ImportedLayout layout,
|
||||||
|
Action<Action<uint?>> subscribeSelectionChanged,
|
||||||
|
Func<uint, bool> isHealthTarget,
|
||||||
|
Func<uint, string?> name,
|
||||||
|
Func<uint, float> healthPercent,
|
||||||
|
Func<uint, uint> stackSize,
|
||||||
|
Action<uint> sendQueryHealth,
|
||||||
|
UiDatFont? datFont)
|
||||||
|
{
|
||||||
|
return new SelectedObjectController(
|
||||||
|
layout, subscribeSelectionChanged,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port of <c>gmToolbarUI::HandleSelectionChanged</c>
|
||||||
|
/// (<c>acclient_2013_pseudo_c.txt:198635</c>):
|
||||||
|
/// clear-then-populate the selected-object strip on any selection change.
|
||||||
|
/// Registered via <c>subscribeSelectionChanged</c> at bind time; called by
|
||||||
|
/// <c>GameWindow.SelectionChanged</c> and by the despawn-clear path.
|
||||||
|
/// </summary>
|
||||||
|
public void OnSelectionChanged(uint? guid)
|
||||||
|
{
|
||||||
|
// ── 1. Clear first (retail: UIElement_Text::SetText + m_pSelObjectField->SetState(0)
|
||||||
|
// + SetVisible(0) on the health meter). ──────────────────────────────────────
|
||||||
|
if (_healthMeter is not null) _healthMeter.Visible = false;
|
||||||
|
if (_overlay is not null) _overlay.ActiveState = "";
|
||||||
|
_currentName = null;
|
||||||
|
|
||||||
|
// Update the backing current guid so the Fill closure reflects the new state.
|
||||||
|
_current = guid;
|
||||||
|
|
||||||
|
// ── 2. Selection == null → strip stays cleared, done. ───────────────────────────
|
||||||
|
if (guid is null) return;
|
||||||
|
|
||||||
|
uint g = guid.Value;
|
||||||
|
|
||||||
|
// ── 3. Selection != null — populate the strip. ──────────────────────────────────
|
||||||
|
|
||||||
|
// Name (displayed via the UiText child's LinesProvider reading _currentName).
|
||||||
|
_currentName = _name_(g);
|
||||||
|
|
||||||
|
// Overlay state: "StackedItemSelected" for stacked items, "ObjectSelected" otherwise.
|
||||||
|
// Retail ref: m_pSelObjectField->SetState(0x1000000b) = "ObjectSelected"
|
||||||
|
// (acclient_2013_pseudo_c.txt:198754). Stack sprite id 0x06004CF4 confirmed in toolbar dump.
|
||||||
|
if (_overlay is not null)
|
||||||
|
_overlay.ActiveState = _stackSize(g) > 1u ? "StackedItemSelected" : "ObjectSelected";
|
||||||
|
|
||||||
|
// Health meter: visible + QueryHealth for health-bearing targets.
|
||||||
|
// Divergence: retail shows the meter only when RecvNotice_UpdateObjectHealth arrives;
|
||||||
|
// acdream shows it immediately (fill reads GetHealthPercent = 1.0 until the reply).
|
||||||
|
// Retail ref: CM_Combat::Event_QueryHealth (acclient_2013_pseudo_c.txt:198757).
|
||||||
|
if (_isHealthTarget(g))
|
||||||
|
{
|
||||||
|
if (_healthMeter is not null) _healthMeter.Visible = true;
|
||||||
|
_sendQueryHealth(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,10 +35,15 @@ public sealed class ToolbarController
|
||||||
0x100006BC, 0x100006BD, 0x100006BE, 0x100006BF,
|
0x100006BC, 0x100006BD, 0x100006BE, 0x100006BF,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Elements hidden by default in retail gmToolbarUI::PostInit: the selected-object
|
// Elements hidden by default in retail gmToolbarUI::PostInit.
|
||||||
// vitals meters (health/stamina/mana bars that track your target) and the stack slider.
|
|
||||||
// Ids confirmed from the toolbar LayoutDesc dump.
|
// Ids confirmed from the toolbar LayoutDesc dump.
|
||||||
private static readonly uint[] HiddenIds = { 0x100001A1, 0x100001A2, 0x100001A4 };
|
// 0x100001A1 (health meter) is now OWNED by SelectedObjectController (D.5.3a) —
|
||||||
|
// it hides A1 at bind and shows it on a health-target selection, so A1 is removed
|
||||||
|
// from here to avoid double-ownership. 0x100001A2 (mana meter) and 0x100001A4
|
||||||
|
// (stack slider) are DEFERRED features (mana #140, stack-split UI) with no controller
|
||||||
|
// yet, so they stay hidden here — otherwise their dat back-track sprites render as
|
||||||
|
// stray empty bars on the toolbar.
|
||||||
|
private static readonly uint[] HiddenIds = { 0x100001A2, 0x100001A4 };
|
||||||
|
|
||||||
// Four mutually-exclusive combat-mode indicator elements — exactly one visible at a time.
|
// Four mutually-exclusive combat-mode indicator elements — exactly one visible at a time.
|
||||||
// Index 0 = NonCombat (peace), 1 = Melee, 2 = Missile, 3 = Magic.
|
// Index 0 = NonCombat (peace), 1 = Melee, 2 = Missile, 3 = Magic.
|
||||||
|
|
|
||||||
|
|
@ -1140,6 +1140,18 @@ public sealed class WorldSession : IDisposable
|
||||||
SendGameAction(body);
|
SendGameAction(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Send retail QueryHealth (0x01BF). Server replies UpdateHealth (0x01C0).</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Retail anchor: <c>CM_Combat::Event_QueryHealth</c> / <c>gmToolbarUI::HandleSelectionChanged:198635</c>
|
||||||
|
/// (docs/research/named-retail/acclient_2013_pseudo_c.txt).
|
||||||
|
/// </remarks>
|
||||||
|
public void SendQueryHealth(uint targetGuid)
|
||||||
|
{
|
||||||
|
uint seq = NextGameActionSequence();
|
||||||
|
byte[] body = SocialActions.BuildQueryHealth(seq, targetGuid);
|
||||||
|
SendGameAction(body);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Send retail TargetedMeleeAttack (0x0008).</summary>
|
/// <summary>Send retail TargetedMeleeAttack (0x0008).</summary>
|
||||||
public void SendMeleeAttack(uint targetGuid, AttackHeight attackHeight, float powerLevel)
|
public void SendMeleeAttack(uint targetGuid, AttackHeight attackHeight, float powerLevel)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,47 @@ public class DatWidgetFactoryTests
|
||||||
Assert.IsType<AcDream.App.UI.UiItemList>(w);
|
Assert.IsType<AcDream.App.UI.UiItemList>(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Test M1: Single-image meter (toolbar selected-object meters) ────────
|
||||||
|
//
|
||||||
|
// The toolbar health/mana meters (0x100001A1 / 0x100001A2) use a DIFFERENT
|
||||||
|
// shape from the vitals 3-slice meters: the back-track sprite lives on the
|
||||||
|
// meter ELEMENT's own DirectState ("" key), and there is exactly ONE Type-3
|
||||||
|
// child whose own DirectState ("" key) carries the fill sprite. That child
|
||||||
|
// has no image grandchildren, so SliceIds would return all-zero — the new
|
||||||
|
// Count==1 branch reads the StateMedia entries directly instead.
|
||||||
|
// The sprites go in the TILE slot (Back/FrontTile), NOT the cap slot: DrawMode=Normal
|
||||||
|
// tiles at native width across the full bar geometry (UIElement_Meter::DrawChildren),
|
||||||
|
// so the back spans all 140px and the fill clips to 140*fraction for any native width.
|
||||||
|
// Back/FrontLeft + Back/FrontRight must be 0 (no caps on a single-image bar).
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void BuildMeter_SingleImageShape_ReadsDirectStateFromElementAndFillChild()
|
||||||
|
{
|
||||||
|
const uint BackFile = 0x0600193Eu; // health back-track (from toolbar dump)
|
||||||
|
const uint FillFile = 0x0600193Fu; // health fill (from toolbar dump)
|
||||||
|
|
||||||
|
// Meter element: Type 7, own DirectState = back-track sprite.
|
||||||
|
var meter = new ElementInfo { Type = 7, Id = 0x100001A1u, Width = 140, Height = 31 };
|
||||||
|
meter.StateMedia[""] = (BackFile, 1);
|
||||||
|
|
||||||
|
// Single Type-3 fill container: own DirectState = fill sprite, no grandchildren.
|
||||||
|
var fillContainer = new ElementInfo { Type = 3, ReadOrder = 1 };
|
||||||
|
fillContainer.StateMedia[""] = (FillFile, 1);
|
||||||
|
meter.Children.Add(fillContainer);
|
||||||
|
|
||||||
|
var e = DatWidgetFactory.Create(meter, NoTex, null);
|
||||||
|
|
||||||
|
var m = Assert.IsType<UiMeter>(e);
|
||||||
|
// Back-track on the meter element's own DirectState, fill on the single child —
|
||||||
|
// both in the TILE slot so they tile across the full 140px bar (DrawMode=Normal).
|
||||||
|
Assert.Equal(BackFile, m.BackTile);
|
||||||
|
Assert.Equal(0u, m.BackLeft);
|
||||||
|
Assert.Equal(0u, m.BackRight);
|
||||||
|
Assert.Equal(FillFile, m.FrontTile);
|
||||||
|
Assert.Equal(0u, m.FrontLeft);
|
||||||
|
Assert.Equal(0u, m.FrontRight);
|
||||||
|
}
|
||||||
|
|
||||||
// ── Test 6: Meter slice extraction (the important one) ───────────────────
|
// ── Test 6: Meter slice extraction (the important one) ───────────────────
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,461 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using AcDream.App.UI;
|
||||||
|
using AcDream.App.UI.Layout;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace AcDream.App.Tests.UI.Layout;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unit tests for <see cref="SelectedObjectController"/> — the
|
||||||
|
/// <c>gmToolbarUI::HandleSelectionChanged</c> analogue
|
||||||
|
/// (<c>acclient_2013_pseudo_c.txt:198635</c>).
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Layout construction mirrors <see cref="ToolbarControllerTests"/>: build a minimal
|
||||||
|
/// <see cref="ImportedLayout"/> from a root <see cref="UiPanel"/> + a
|
||||||
|
/// <see cref="Dictionary{TKey,TValue}"/> keyed by element id. Elements are constructed
|
||||||
|
/// directly (no importer / no dat / no GL) so tests are pure in-process.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
public class SelectedObjectControllerTests
|
||||||
|
{
|
||||||
|
// ── Shared layout ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Build a minimal toolbar layout containing the three selected-object elements:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item>0x1000019F → a <see cref="UiPanel"/> name container (100×20).</item>
|
||||||
|
/// <item>0x100001A0 → a <see cref="UiDatElement"/> overlay with "ObjectSelected"
|
||||||
|
/// and "StackedItemSelected" states wired to distinct file ids.</item>
|
||||||
|
/// <item>0x100001A1 → a <see cref="UiMeter"/> health meter.</item>
|
||||||
|
/// </list>
|
||||||
|
/// Additional element ids can be added by the caller for edge-case tests.
|
||||||
|
/// </summary>
|
||||||
|
private static (
|
||||||
|
ImportedLayout layout,
|
||||||
|
UiPanel nameEl,
|
||||||
|
UiDatElement overlayEl,
|
||||||
|
UiMeter healthMeterEl)
|
||||||
|
FakeLayout()
|
||||||
|
{
|
||||||
|
var dict = new Dictionary<uint, UiElement>();
|
||||||
|
var root = new UiPanel();
|
||||||
|
|
||||||
|
// Name element: a plain panel that will have a UiText child attached by the controller.
|
||||||
|
var nameEl = new UiPanel { Width = 100, Height = 20 };
|
||||||
|
dict[SelectedObjectController.NameId] = nameEl;
|
||||||
|
root.AddChild(nameEl);
|
||||||
|
|
||||||
|
// Overlay element: a UiDatElement with the two named states the controller switches between.
|
||||||
|
var overlayInfo = new ElementInfo
|
||||||
|
{
|
||||||
|
Id = SelectedObjectController.OverlayId,
|
||||||
|
Type = 3, // Type 3 = container/chrome — the overlay field's dat type
|
||||||
|
StateMedia =
|
||||||
|
{
|
||||||
|
[""] = (0x06000001u, 3), // DirectState (blank)
|
||||||
|
["ObjectSelected"] = (0x06001937u, 3), // ObjectSelected sprite id from toolbar dump
|
||||||
|
["StackedItemSelected"] = (0x06004CF4u, 3), // StackedItemSelected sprite id
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var overlayEl = new UiDatElement(overlayInfo, _ => (0u, 0, 0));
|
||||||
|
dict[SelectedObjectController.OverlayId] = overlayEl;
|
||||||
|
root.AddChild(overlayEl);
|
||||||
|
|
||||||
|
// Health meter element.
|
||||||
|
var healthMeterEl = new UiMeter { Width = 100, Height = 10, Visible = true };
|
||||||
|
dict[SelectedObjectController.HealthMeterId] = healthMeterEl;
|
||||||
|
root.AddChild(healthMeterEl);
|
||||||
|
|
||||||
|
return (new ImportedLayout(root, dict), nameEl, overlayEl, healthMeterEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Recording delegates ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Build a recording set of delegates. Name, health, stack are keyed by guid;
|
||||||
|
/// <paramref name="queryHealthCalls"/> accumulates every guid passed to sendQueryHealth.
|
||||||
|
/// </summary>
|
||||||
|
private static (
|
||||||
|
Action<Action<uint?>> subscribe,
|
||||||
|
Action<uint?> fireSelection,
|
||||||
|
Func<uint, bool> isHealthTarget,
|
||||||
|
Func<uint, string?> name,
|
||||||
|
Func<uint, float> healthPercent,
|
||||||
|
Func<uint, uint> stackSize,
|
||||||
|
Action<uint> sendQueryHealth,
|
||||||
|
List<uint> queryHealthCalls)
|
||||||
|
MakeDelegates(
|
||||||
|
Dictionary<uint, bool> healthTargetMap,
|
||||||
|
Dictionary<uint, string> nameMap,
|
||||||
|
Dictionary<uint, float> healthMap,
|
||||||
|
Dictionary<uint, uint> stackMap)
|
||||||
|
{
|
||||||
|
Action<uint?>? registeredHandler = null;
|
||||||
|
var queryHealthCalls = new List<uint>();
|
||||||
|
|
||||||
|
Action<Action<uint?>> subscribe = h => registeredHandler = h;
|
||||||
|
Action<uint?> fireSelection = guid => registeredHandler?.Invoke(guid);
|
||||||
|
|
||||||
|
Func<uint, bool> isHealthTarget = g => healthTargetMap.TryGetValue(g, out var v) && v;
|
||||||
|
Func<uint, string?> name = g => nameMap.TryGetValue(g, out var v) ? v : null;
|
||||||
|
Func<uint, float> healthPercent = g => healthMap.TryGetValue(g, out var v) ? v : 1f;
|
||||||
|
Func<uint, uint> stackSize = g => stackMap.TryGetValue(g, out var v) ? v : 0u;
|
||||||
|
Action<uint> sendQueryHealth = g => queryHealthCalls.Add(g);
|
||||||
|
|
||||||
|
return (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, queryHealthCalls);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── B1: Bind initialisation ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After Bind:
|
||||||
|
/// - the health meter is hidden (controller owns initial-hidden state).
|
||||||
|
/// - the name element has exactly one UiText child (the name label).
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void Bind_healthMeterHidden_andNameTextChildAttached()
|
||||||
|
{
|
||||||
|
var (layout, nameEl, _, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, _, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new(),
|
||||||
|
nameMap: new(),
|
||||||
|
healthMap: new(),
|
||||||
|
stackMap: new());
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
// Health meter must start hidden.
|
||||||
|
Assert.False(healthMeterEl.Visible,
|
||||||
|
"health meter must be Visible=false immediately after Bind");
|
||||||
|
|
||||||
|
// A UiText child should have been attached to the name element.
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().SingleOrDefault();
|
||||||
|
Assert.NotNull(textChild);
|
||||||
|
Assert.True(textChild!.Centered, "name UiText must be Centered");
|
||||||
|
Assert.True(textChild.ClickThrough, "name UiText must be ClickThrough (non-interactive decoration)");
|
||||||
|
Assert.False(textChild.AcceptsFocus, "AcceptsFocus must be false on name label");
|
||||||
|
Assert.False(textChild.IsEditControl, "IsEditControl must be false on name label");
|
||||||
|
Assert.False(textChild.CapturesPointerDrag, "CapturesPointerDrag must be false on name label");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After Bind, the attached UiText's LinesProvider yields no lines (nothing selected yet).
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void Bind_nameLinesProvider_yieldsEmpty_whenNothingSelected()
|
||||||
|
{
|
||||||
|
var (layout, nameEl, _, _) = FakeLayout();
|
||||||
|
var (subscribe, _, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(new(), new(), new(), new());
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().Single();
|
||||||
|
var lines = textChild.LinesProvider();
|
||||||
|
Assert.Empty(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H1: Select a health target (creature) ───────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selecting a health target (stackSize=1, isHealthTarget=true):
|
||||||
|
/// - overlay ActiveState == "ObjectSelected"
|
||||||
|
/// - meter Visible == true
|
||||||
|
/// - sendQueryHealth invoked exactly once with the guid
|
||||||
|
/// - name LinesProvider yields a single white line with the expected name
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void SelectHealthTarget_meterVisible_overlayObjectSelected_queryHealthFired()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xAA01u;
|
||||||
|
const string ExpectedName = "Drudge Prowler";
|
||||||
|
|
||||||
|
var (layout, nameEl, overlayEl, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, queryHealthCalls) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = true },
|
||||||
|
nameMap: new() { [Guid] = ExpectedName },
|
||||||
|
healthMap: new() { [Guid] = 0.75f },
|
||||||
|
stackMap: new() { [Guid] = 1u }); // stackSize=1 → ObjectSelected
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
// Fire the selection.
|
||||||
|
fireSelection(Guid);
|
||||||
|
|
||||||
|
Assert.True(healthMeterEl.Visible,
|
||||||
|
"health meter must become Visible after selecting a health target");
|
||||||
|
Assert.Equal("ObjectSelected", overlayEl.ActiveState);
|
||||||
|
Assert.Single(queryHealthCalls);
|
||||||
|
Assert.Equal(Guid, queryHealthCalls[0]);
|
||||||
|
|
||||||
|
// Name label: the LinesProvider should yield the creature's name as a white line.
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().Single();
|
||||||
|
var lines = textChild.LinesProvider();
|
||||||
|
Assert.Single(lines);
|
||||||
|
Assert.Equal(ExpectedName, lines[0].Text);
|
||||||
|
Assert.Equal(new Vector4(1f, 1f, 1f, 1f), lines[0].Color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H2: Select a stacked item ────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selecting a stacked item (stackSize > 1): overlay ActiveState == "StackedItemSelected".
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void SelectStackedItem_overlayStackedItemSelected()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xBB02u;
|
||||||
|
|
||||||
|
var (layout, _, overlayEl, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = false },
|
||||||
|
nameMap: new() { [Guid] = "Heal Kits" },
|
||||||
|
healthMap: new(),
|
||||||
|
stackMap: new() { [Guid] = 5u }); // stackSize > 1
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
fireSelection(Guid);
|
||||||
|
|
||||||
|
Assert.Equal("StackedItemSelected", overlayEl.ActiveState);
|
||||||
|
// Not a health target → meter stays hidden.
|
||||||
|
Assert.False(healthMeterEl.Visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H3: Select a non-health target (friendly NPC / scenery) ─────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selecting a non-health target (isHealthTarget=false):
|
||||||
|
/// - meter stays hidden
|
||||||
|
/// - sendQueryHealth NOT invoked
|
||||||
|
/// - name and overlay are still set
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void SelectNonHealthTarget_meterHidden_noQueryHealth_nameSet()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xCC03u;
|
||||||
|
const string ExpectedName = "Town Crier";
|
||||||
|
|
||||||
|
var (layout, nameEl, overlayEl, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, queryHealthCalls) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = false },
|
||||||
|
nameMap: new() { [Guid] = ExpectedName },
|
||||||
|
healthMap: new(),
|
||||||
|
stackMap: new() { [Guid] = 0u }); // non-stack → ObjectSelected
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
fireSelection(Guid);
|
||||||
|
|
||||||
|
Assert.False(healthMeterEl.Visible, "meter must stay hidden for a non-health target");
|
||||||
|
Assert.Empty(queryHealthCalls); // sendQueryHealth must NOT be invoked for a non-health target
|
||||||
|
|
||||||
|
// Overlay and name are still populated.
|
||||||
|
Assert.Equal("ObjectSelected", overlayEl.ActiveState);
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().Single();
|
||||||
|
var lines = textChild.LinesProvider();
|
||||||
|
Assert.Single(lines);
|
||||||
|
Assert.Equal(ExpectedName, lines[0].Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H4: Deselect (null) ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selecting null clears the strip:
|
||||||
|
/// - meter Visible == false
|
||||||
|
/// - overlay ActiveState == ""
|
||||||
|
/// - name LinesProvider yields empty
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void SelectNull_clearsStrip()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xDD04u;
|
||||||
|
|
||||||
|
var (layout, nameEl, overlayEl, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = true },
|
||||||
|
nameMap: new() { [Guid] = "Wolf" },
|
||||||
|
healthMap: new() { [Guid] = 0.5f },
|
||||||
|
stackMap: new() { [Guid] = 0u });
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
// First select something...
|
||||||
|
fireSelection(Guid);
|
||||||
|
Assert.True(healthMeterEl.Visible);
|
||||||
|
|
||||||
|
// ...then deselect.
|
||||||
|
fireSelection(null);
|
||||||
|
|
||||||
|
Assert.False(healthMeterEl.Visible, "meter must be hidden after deselect");
|
||||||
|
Assert.Equal("", overlayEl.ActiveState);
|
||||||
|
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().Single();
|
||||||
|
var lines = textChild.LinesProvider();
|
||||||
|
Assert.Empty(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H5: Clear → new selection (re-select) ────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selecting one target then another should clear the first and apply the second.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ReSelect_differentGuid_clearsFirstThenAppliesSecond()
|
||||||
|
{
|
||||||
|
const uint GuidA = 0xEE05u;
|
||||||
|
const uint GuidB = 0xFF06u;
|
||||||
|
|
||||||
|
var (layout, nameEl, overlayEl, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, queryHealthCalls) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [GuidA] = true, [GuidB] = false },
|
||||||
|
nameMap: new() { [GuidA] = "Bandit", [GuidB] = "Chest" },
|
||||||
|
healthMap: new() { [GuidA] = 1.0f },
|
||||||
|
stackMap: new() { [GuidA] = 0u, [GuidB] = 0u });
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
// Select A (health target).
|
||||||
|
fireSelection(GuidA);
|
||||||
|
Assert.True(healthMeterEl.Visible);
|
||||||
|
Assert.Single(queryHealthCalls);
|
||||||
|
|
||||||
|
// Select B (non-health target) — must clear A's state and apply B.
|
||||||
|
fireSelection(GuidB);
|
||||||
|
|
||||||
|
Assert.False(healthMeterEl.Visible, "health meter must be cleared when switching to non-health target");
|
||||||
|
Assert.Equal("ObjectSelected", overlayEl.ActiveState);
|
||||||
|
// sendQueryHealth must NOT be called again (B is not a health target).
|
||||||
|
Assert.Single(queryHealthCalls);
|
||||||
|
|
||||||
|
// Name should reflect B.
|
||||||
|
var textChild = nameEl.Children.OfType<UiText>().Single();
|
||||||
|
var lines = textChild.LinesProvider();
|
||||||
|
Assert.Single(lines);
|
||||||
|
Assert.Equal("Chest", lines[0].Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H6: Partial layout (missing elements) ────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When elements are absent (partial layout), Bind does not throw and
|
||||||
|
/// OnSelectionChanged does not throw for any combination.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void PartialLayout_noElements_doesNotThrow()
|
||||||
|
{
|
||||||
|
// Empty layout — none of the three ids are present.
|
||||||
|
var root = new UiPanel();
|
||||||
|
var layout = new ImportedLayout(root, new Dictionary<uint, UiElement>());
|
||||||
|
|
||||||
|
Action<uint?>? registeredHandler = null;
|
||||||
|
var queryHealthCalls = new List<uint>();
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(
|
||||||
|
layout,
|
||||||
|
subscribeSelectionChanged: h => registeredHandler = h,
|
||||||
|
isHealthTarget: _ => true,
|
||||||
|
name: _ => "Something",
|
||||||
|
healthPercent: _ => 1f,
|
||||||
|
stackSize: _ => 0u,
|
||||||
|
sendQueryHealth: g => queryHealthCalls.Add(g),
|
||||||
|
datFont: null);
|
||||||
|
|
||||||
|
Assert.NotNull(registeredHandler);
|
||||||
|
|
||||||
|
// Firing selection / deselection on a partial layout must not throw.
|
||||||
|
var ex = Record.Exception(() => registeredHandler!.Invoke(0x12345678u));
|
||||||
|
Assert.Null(ex);
|
||||||
|
|
||||||
|
ex = Record.Exception(() => registeredHandler!.Invoke(null));
|
||||||
|
Assert.Null(ex);
|
||||||
|
|
||||||
|
// QueryHealth must still be called (the delegate doesn't depend on the meter element).
|
||||||
|
Assert.Single(queryHealthCalls);
|
||||||
|
Assert.Equal(0x12345678u, queryHealthCalls[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H7: Fill closure reflects live healthPercent ─────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The meter's Fill closure reads the current guid's health percent from the
|
||||||
|
/// <c>healthPercent</c> delegate on every poll — so if the server updates the
|
||||||
|
/// health between polls the fill reflects the new value without re-selecting.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void HealthMeterFill_reflectsLiveHealthPercent()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xAA07u;
|
||||||
|
float currentHealth = 0.5f;
|
||||||
|
|
||||||
|
var (layout, _, _, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, _, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = true },
|
||||||
|
nameMap: new() { [Guid] = "Arwic Banderling" },
|
||||||
|
healthMap: new(), // not used here
|
||||||
|
stackMap: new() { [Guid] = 0u });
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name,
|
||||||
|
healthPercent: _ => currentHealth, // reads the captured variable
|
||||||
|
stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
fireSelection(Guid);
|
||||||
|
|
||||||
|
// Fill should return the current health value.
|
||||||
|
Assert.Equal(0.5f, healthMeterEl.Fill());
|
||||||
|
|
||||||
|
// Simulate server updating health (as if UpdateHealth 0x01C0 arrived).
|
||||||
|
currentHealth = 0.25f;
|
||||||
|
Assert.Equal(0.25f, healthMeterEl.Fill());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── H8: Fill returns 0 when nothing is selected ──────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After deselect, the meter Fill returns 0f (empty bar) rather than
|
||||||
|
/// the last selected target's health value.
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void HealthMeterFill_returnsZero_whenNothingSelected()
|
||||||
|
{
|
||||||
|
const uint Guid = 0xAA08u;
|
||||||
|
|
||||||
|
var (layout, _, _, healthMeterEl) = FakeLayout();
|
||||||
|
var (subscribe, fireSelection, isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, _) =
|
||||||
|
MakeDelegates(
|
||||||
|
healthTargetMap: new() { [Guid] = true },
|
||||||
|
nameMap: new() { [Guid] = "Spider" },
|
||||||
|
healthMap: new() { [Guid] = 0.8f },
|
||||||
|
stackMap: new() { [Guid] = 0u });
|
||||||
|
|
||||||
|
SelectedObjectController.Bind(layout, subscribe,
|
||||||
|
isHealthTarget, name, healthPercent, stackSize, sendQueryHealth, datFont: null);
|
||||||
|
|
||||||
|
fireSelection(Guid);
|
||||||
|
Assert.Equal(0.8f, healthMeterEl.Fill()); // sanity check
|
||||||
|
|
||||||
|
fireSelection(null);
|
||||||
|
// After deselect, Fill() must return 0f (or null coerced to 0f).
|
||||||
|
var fill = healthMeterEl.Fill();
|
||||||
|
Assert.Equal(0f, fill ?? 0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -74,4 +74,18 @@ public sealed class WorldSessionCombatTests
|
||||||
Assert.NotNull(captured);
|
Assert.NotNull(captured);
|
||||||
Assert.Equal(AttackTargetRequest.BuildCancel(1), captured);
|
Assert.Equal(AttackTargetRequest.BuildCancel(1), captured);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void SendQueryHealth_UsesRetailQueryHealthBuilder()
|
||||||
|
{
|
||||||
|
// Retail anchor: CM_Combat::Event_QueryHealth / gmToolbarUI::HandleSelectionChanged:198635
|
||||||
|
using var session = NewSession();
|
||||||
|
byte[]? captured = null;
|
||||||
|
session.GameActionCapture = body => captured = body;
|
||||||
|
|
||||||
|
session.SendQueryHealth(0x50000007u);
|
||||||
|
|
||||||
|
Assert.NotNull(captured);
|
||||||
|
Assert.Equal(SocialActions.BuildQueryHealth(1, 0x50000007u), captured);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue