fix(D.5.3a): selected-object meter visual-gate fixes (name, gate, flash, magenta)
Visual gate against retail surfaced several fidelity gaps in the selected-object strip; all fixed and user-confirmed. Faithful to gmToolbarUI::HandleSelectionChanged (acclient_2013_pseudo_c.txt:198635) + RecvNotice_UpdateObjectHealth (:196213). - UiMeter.DrawHBar: guard each slice on `id != 0` BEFORE resolve. resolve(0) returns the 1x1 magenta placeholder with a non-zero GL handle, so the single- image meter (caps id=0) was drawing 1px magenta caps at the bar's ends. The 3-slice vitals meter (all ids set) was unaffected. (the magenta-lines bug) - SelectedObjectController: meter visibility is now UpdateHealth-driven (shown when health is known for the selected guid — HasHealth at select or HealthChanged), not shown-on-select; brief green selection flash via Tick revert; overlay floated above the meter so the flash isn't hidden by the bar; name top-aligned into the bar sprite's black band (NameBandHeight) with the bar below. - GameWindow.IsHealthBarTarget: gate the health bar on the server PWD bits BF_ATTACKABLE (0x10) | BF_PLAYER (0x8) — friendly/vendor NPCs and attackable Doors (Misc type) are name-only; players/monsters get the bar. Replaces the too-loose IsLiveCreatureTarget. Wired SelectedObjectController.Tick in OnUpdate. - CombatState.HasHealth(guid): distinguishes a known health value from the 1.0 default, so a re-selected already-assessed target shows its bar immediately. - TextureCache.GetOrUploadRenderSurface: resolve the surface's DefaultPaletteId so paletted (P8/INDEX16) UI sprites decode instead of falling to magenta. - ToolbarController.HiddenIds: also hide 0x100001A3 (stack-entry box) — retail hides it in HandleSelectionChanged; it was rendering as a stray black box. Divergence register: AP-47 (meter-visible timing) retired (now faithful); AP-46 rewritten to the BF_ATTACKABLE/BF_PLAYER gate approximation. Full suite green (2,688 passed / 4 skipped). User-confirmed: name on top, NPC name-only, monster bar on assess, green flash, no magenta. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6636e50c2a
commit
8f627cce0e
8 changed files with 438 additions and 368 deletions
|
|
@ -2026,9 +2026,11 @@ public sealed class GameWindow : IDisposable
|
|||
_selectedObjectController = AcDream.App.UI.Layout.SelectedObjectController.Bind(
|
||||
toolbarLayout,
|
||||
subscribeSelectionChanged: h => SelectionChanged += h,
|
||||
isHealthTarget: IsLiveCreatureTarget,
|
||||
subscribeHealthChanged: h => Combat.HealthChanged += h,
|
||||
isHealthTarget: IsHealthBarTarget,
|
||||
name: g => Objects.Get(g)?.Name,
|
||||
healthPercent: g => Combat.GetHealthPercent(g),
|
||||
hasHealth: g => Combat.HasHealth(g),
|
||||
stackSize: g => (uint)(Objects.Get(g)?.StackSize ?? 0),
|
||||
sendQueryHealth: g => _liveSession?.SendQueryHealth(g),
|
||||
datFont: vitalsDatFont);
|
||||
|
|
@ -7410,6 +7412,10 @@ public sealed class GameWindow : IDisposable
|
|||
// that actually consume the events.
|
||||
_inputDispatcher?.Tick();
|
||||
|
||||
// Phase D.5.3a — advance the selected-object overlay flash (0.25s green pulse
|
||||
// on selection, then revert). No-op when nothing is flashing.
|
||||
_selectedObjectController?.Tick(dt);
|
||||
|
||||
// Phase K.2 — re-evaluate WantCaptureMouse for the MMB
|
||||
// mouse-look state machine. Detect rising/falling edges so the
|
||||
// state suspends correctly when ImGui claims the cursor while
|
||||
|
|
@ -12016,6 +12022,40 @@ public sealed class GameWindow : IDisposable
|
|||
return (LiveItemType(guid) & AcDream.Core.Items.ItemType.Creature) != 0;
|
||||
}
|
||||
|
||||
// PublicWeenieDesc _bitfield flags (acclient.h:6431-6463) — same bitfield RadarBlipColors reads.
|
||||
private const uint BfPlayer = 0x8u; // BF_PLAYER (acclient.h:6434)
|
||||
private const uint BfAttackable = 0x10u; // BF_ATTACKABLE (acclient.h:6437)
|
||||
|
||||
/// <summary>
|
||||
/// True if the selected-object strip should show a Health meter for <paramref name="guid"/>.
|
||||
/// Approximates retail's <c>IsPlayer() || pet_owner || ClientCombatSystem::ObjectIsAttackable()</c>
|
||||
/// gate (gmToolbarUI::HandleSelectionChanged :198754) using the server-provided PWD flags:
|
||||
/// the <c>BF_ATTACKABLE</c> bit (monsters) or the <c>BF_PLAYER</c> bit (other players).
|
||||
/// A friendly NPC (e.g. a vendor) has neither bit set → name-only, matching retail.
|
||||
/// The full PK/faction logic of ObjectIsAttackable + the pet case are not ported (divergence AP-46).
|
||||
/// </summary>
|
||||
private bool IsHealthBarTarget(uint guid)
|
||||
{
|
||||
if (guid == _playerServerGuid)
|
||||
return false;
|
||||
if (!_entitiesByServerGuid.ContainsKey(guid))
|
||||
return false;
|
||||
|
||||
uint pwd = _lastSpawnByGuid.TryGetValue(guid, out var spawn)
|
||||
&& spawn.ObjectDescriptionFlags is { } odf ? odf : 0u;
|
||||
|
||||
// Another player → health bar (retail IsPlayer branch).
|
||||
if ((pwd & BfPlayer) != 0)
|
||||
return true;
|
||||
|
||||
// Attackable branch: retail ObjectIsAttackable requires the object to be a CREATURE
|
||||
// first (InqType() & 0x10, acclient_2013_pseudo_c.txt:375406), THEN attackable. A Door
|
||||
// carries the BF_ATTACKABLE bit but is ItemType Misc, so it is never a health-bar target —
|
||||
// require the Creature flag here too (matches retail; excludes attackable doors/objects).
|
||||
bool isCreature = (LiveItemType(guid) & AcDream.Core.Items.ItemType.Creature) != 0;
|
||||
return isCreature && (pwd & BfAttackable) != 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 2026-05-16 — retail-faithful port of
|
||||
|
|
|
|||
|
|
@ -121,9 +121,11 @@ public sealed unsafe class TextureCache : Wb.ITextureCachePerInstance, IDisposab
|
|||
/// Surface→SurfaceTexture chain that <see cref="GetOrUpload(uint)"/> uses
|
||||
/// for world-geometry materials. This is the correct path for retail UI
|
||||
/// chrome + font glyph sheets, which reference RenderSurface directly.
|
||||
/// Palette is null for now (a paletted INDEX16/P8 UI sprite would return
|
||||
/// Magenta — wire a UI palette when one is actually encountered). Returns a
|
||||
/// 1x1 magenta handle on miss.
|
||||
/// Paletted (PFID_P8 / PFID_INDEX16) UI sprites — e.g. the selected-object
|
||||
/// health-bar track 0x0600193E — are decoded against the RenderSurface's own
|
||||
/// <c>DefaultPaletteId</c> (same starting palette <see cref="DecodeFromDats"/>
|
||||
/// uses); non-paletted formats have DefaultPaletteId==0 → palette null. Returns
|
||||
/// a 1x1 magenta handle on miss.
|
||||
/// </summary>
|
||||
public uint GetOrUploadRenderSurface(uint renderSurfaceId, out int width, out int height, bool nearest = false)
|
||||
{
|
||||
|
|
@ -138,7 +140,14 @@ public sealed unsafe class TextureCache : Wb.ITextureCachePerInstance, IDisposab
|
|||
if (_dats.Portal.TryGet<RenderSurface>(renderSurfaceId, out var rs)
|
||||
|| _dats.HighRes.TryGet<RenderSurface>(renderSurfaceId, out rs))
|
||||
{
|
||||
decoded = SurfaceDecoder.DecodeRenderSurface(rs, palette: null);
|
||||
// Resolve the surface's own default palette so paletted UI sprites decode
|
||||
// correctly instead of the magenta fallback (the back-track 0x0600193E behind
|
||||
// the selected-object health bar is PFID_P8/INDEX16). Non-paletted formats
|
||||
// (DefaultPaletteId==0) keep the previous null-palette behaviour unchanged.
|
||||
Palette? palette = rs.DefaultPaletteId != 0
|
||||
? _dats.Get<Palette>(rs.DefaultPaletteId)
|
||||
: null;
|
||||
decoded = SurfaceDecoder.DecodeRenderSurface(rs, palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue