feat(ui): D.2b item interaction + retail cursors + live character sheet

Lands the codex-worktree D.2b stream plus the extraction the 2026-07-02
UI architecture review mandated before commit:

- ItemInteractionController: single owner of double-click use/equip/
  container-open, targeted-use mode (health kits), drag-out drop;
  toolbar shortcut drags don't drop the real item. ItemEquipRules for
  multi-slot (coat) coverage via equip masks.
- Cursor phase: CursorFeedbackController (semantic priority chain:
  drag > resize > window-move > target-mode > text) + RetailCursorCatalog
  (enums 0x27/0x28/0x29, hotspot 14,14; ClientUISystem::UpdateCursorState
  0x00564630) resolved through the portal EnumIDMap chain by
  RetailCursorResolver; RetailCursorManager applies dat cursor art to the
  OS cursor. Register row AP-72 covers the OS standard-cursor fallback.
- Character window goes live: CharacterSheetProvider owns sheet assembly,
  XP-curve/raise-cost math and the raise flow — extracted out of
  GameWindow per Code Structure Rule 1 instead of committing the ~430-line
  feature body there. Optimistic XP/credit debits go through eventful
  store APIs (new ClientObjectTable.UpdateInt64Property +
  LocalPlayerState.DebitIntProperty/DebitInt64Property) instead of raw
  property-dictionary writes; register row AP-73 covers the still-missing
  raise ledger (#163).
- RetailWindowFrame: the shared nine-slice window mount recipe; the
  character window uses it, remaining windows migrate via #164.
- Status-bar buttons toggle inventory/character windows; retail row-major
  backpack ordering; WorldSession.SendUseWithTarget + raise/train sends.

GameWindow shrinks 14,214 -> 13,877 lines despite the new features; the
sheet/raise logic is unit-tested in CharacterSheetProviderTests instead
of trapped in the god object. Build green; full suite 3,286 tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-03 09:18:43 +02:00
parent e3fc7ac5ba
commit b7dc91a053
74 changed files with 6669 additions and 238 deletions

View file

@ -0,0 +1,76 @@
using AcDream.App.UI;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
namespace AcDream.App.Rendering;
/// <summary>Resolves retail global cursor enum IDs through the portal EnumIDMap chain.</summary>
internal sealed class RetailCursorResolver
{
private readonly DatCollection _dats;
private readonly object _datLock;
private readonly Dictionary<uint, uint> _didByEnum = new();
private readonly HashSet<uint> _missingEnums = new();
public RetailCursorResolver(DatCollection dats, object datLock)
{
_dats = dats;
_datLock = datLock;
}
public bool TryResolve(CursorFeedbackKind kind, out UiCursorMedia cursor)
{
cursor = default;
if (!RetailCursorCatalog.TryGetGlobalCursor(kind, out var spec))
return false;
return TryResolve(spec, out cursor);
}
internal bool TryResolve(RetailCursorSpec spec, out UiCursorMedia cursor)
{
cursor = default;
if (!spec.IsValid)
return false;
if (_didByEnum.TryGetValue(spec.EnumId, out uint cachedDid))
{
cursor = new UiCursorMedia(cachedDid, spec.HotspotX, spec.HotspotY);
return true;
}
if (_missingEnums.Contains(spec.EnumId))
return false;
uint did = ResolveDidByEnum(spec.EnumId);
if (did == 0)
{
_missingEnums.Add(spec.EnumId);
return false;
}
cursor = new UiCursorMedia(did, spec.HotspotX, spec.HotspotY);
_didByEnum[spec.EnumId] = did;
return true;
}
private uint ResolveDidByEnum(uint cursorEnum)
{
lock (_datLock)
{
uint masterDid = (uint)_dats.Portal.Header.MasterMapId;
if (masterDid == 0)
return 0;
if (!_dats.Portal.TryGet<EnumIDMap>(masterDid, out var master) || master is null)
return 0;
if (!master.ClientEnumToID.TryGetValue(RetailCursorCatalog.CursorEnumTable, out uint cursorMapDid))
return 0;
if (!_dats.Portal.TryGet<EnumIDMap>(cursorMapDid, out var cursorMap) || cursorMap is null)
return 0;
return cursorMap.ClientEnumToID.TryGetValue(cursorEnum, out uint did) ? did : 0;
}
}
}