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:
parent
e3fc7ac5ba
commit
b7dc91a053
74 changed files with 6669 additions and 238 deletions
|
|
@ -9,6 +9,12 @@ namespace AcDream.App.UI;
|
|||
[System.Flags]
|
||||
public enum AnchorEdges { None = 0, Left = 1, Top = 2, Right = 4, Bottom = 8 }
|
||||
|
||||
/// <summary>Retail dat cursor media attached to a UI state.</summary>
|
||||
public readonly record struct UiCursorMedia(uint File, int HotspotX, int HotspotY)
|
||||
{
|
||||
public bool IsValid => File != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for every UI widget in the retained-mode tree.
|
||||
///
|
||||
|
|
@ -40,9 +46,56 @@ public abstract class UiElement
|
|||
/// </summary>
|
||||
public uint EventId { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dat LayoutDesc element id for widgets imported from retail UI data.
|
||||
/// Zero for runtime-created helper widgets. This is intentionally separate
|
||||
/// from <see cref="EventId"/>: event ids are runtime-local, while this id is
|
||||
/// stable across retail layout dumps, decomp references, and UI probes.
|
||||
/// </summary>
|
||||
public uint DatElementId { get; internal set; }
|
||||
|
||||
/// <summary>Human-readable name for debugging / FindByName.</summary>
|
||||
public string? Name { get; init; }
|
||||
|
||||
private readonly Dictionary<string, UiCursorMedia> _stateCursors = new();
|
||||
|
||||
/// <summary>Retail MediaDescCursor entries keyed by UIStateId.ToString(), or "" for DirectState.</summary>
|
||||
public IReadOnlyDictionary<string, UiCursorMedia> StateCursors => _stateCursors;
|
||||
|
||||
/// <summary>Active state name used for cursor media. Stateful dat widgets override this.</summary>
|
||||
public virtual string ActiveCursorStateName => "";
|
||||
|
||||
public void SetStateCursors(IReadOnlyDictionary<string, UiCursorMedia> cursors)
|
||||
{
|
||||
_stateCursors.Clear();
|
||||
foreach (var kv in cursors)
|
||||
{
|
||||
if (kv.Value.IsValid)
|
||||
_stateCursors[kv.Key] = kv.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public UiCursorMedia ActiveCursor()
|
||||
=> CursorForState(ActiveCursorStateName, allowFallback: true);
|
||||
|
||||
public UiCursorMedia CursorForState(string stateName, bool allowFallback = true)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(stateName)
|
||||
&& _stateCursors.TryGetValue(stateName, out var named)
|
||||
&& named.IsValid)
|
||||
return named;
|
||||
|
||||
if (!allowFallback)
|
||||
return default;
|
||||
|
||||
if (_stateCursors.TryGetValue("", out var direct) && direct.IsValid)
|
||||
return direct;
|
||||
if (_stateCursors.TryGetValue("Normal", out var normal) && normal.IsValid)
|
||||
return normal;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
// ── Geometry ────────────────────────────────────────────────────────
|
||||
/// <summary>X in the parent's local pixel space.</summary>
|
||||
public float Left { get; set; }
|
||||
|
|
@ -130,6 +183,14 @@ public abstract class UiElement
|
|||
/// self-driven interior drag such as text selection). Default false.</summary>
|
||||
public virtual bool HandlesClick => false;
|
||||
|
||||
/// <summary>
|
||||
/// Optional game-object target used by item-use cursor/target mode when this UI
|
||||
/// element represents a target that is not its visible item icon. Example:
|
||||
/// the status-bar backpack button and paperdoll both mean "self" for a
|
||||
/// health-kit-style use-with-target action.
|
||||
/// </summary>
|
||||
public Func<uint>? UseTargetGuidProvider { get; set; }
|
||||
|
||||
/// <summary>Minimum size enforced while resizing.</summary>
|
||||
public float MinWidth { get; set; } = 40f;
|
||||
public float MinHeight { get; set; } = 40f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue