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
155
tests/AcDream.App.Tests/UI/CursorFeedbackControllerTests.cs
Normal file
155
tests/AcDream.App.Tests/UI/CursorFeedbackControllerTests.cs
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
using AcDream.App.UI;
|
||||
using AcDream.Core.Items;
|
||||
|
||||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
public sealed class CursorFeedbackControllerTests
|
||||
{
|
||||
private const uint Player = 0x50000001u;
|
||||
private const uint Pack = 0x50000010u;
|
||||
private const uint Source = 0x50000020u;
|
||||
private const uint Target = 0x50000021u;
|
||||
private const uint HealthKitUseability = 0x000A0008u;
|
||||
|
||||
[Fact]
|
||||
public void DragState_winsOverResizeAndUsesAcceptRejectCursors()
|
||||
{
|
||||
var c = new CursorFeedbackController();
|
||||
|
||||
var accept = c.Resolve(new CursorFeedbackSnapshot(
|
||||
DragPayload: new object(),
|
||||
DragAccept: UiItemSlot.DragAcceptState.Accept,
|
||||
HoverResizeEdges: ResizeEdges.Right));
|
||||
var reject = c.Resolve(new CursorFeedbackSnapshot(
|
||||
DragPayload: new object(),
|
||||
DragAccept: UiItemSlot.DragAcceptState.Reject,
|
||||
HoverResizeEdges: ResizeEdges.Right));
|
||||
|
||||
Assert.Equal(CursorFeedbackKind.DragAccept, accept.Kind);
|
||||
Assert.Equal(CursorFeedbackKind.DragReject, reject.Kind);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ResizeEdges.Right, CursorFeedbackKind.ResizeHorizontal)]
|
||||
[InlineData(ResizeEdges.Bottom, CursorFeedbackKind.ResizeVertical)]
|
||||
[InlineData(ResizeEdges.Right | ResizeEdges.Bottom, CursorFeedbackKind.ResizeDiagonalNwse)]
|
||||
[InlineData(ResizeEdges.Left | ResizeEdges.Bottom, CursorFeedbackKind.ResizeDiagonalNesw)]
|
||||
public void ResizeEdges_chooseExpectedCursor(ResizeEdges edges, CursorFeedbackKind expected)
|
||||
{
|
||||
var c = new CursorFeedbackController();
|
||||
|
||||
var feedback = c.Resolve(new CursorFeedbackSnapshot(HoverResizeEdges: edges));
|
||||
|
||||
Assert.Equal(expected, feedback.Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveAndTextHover_useDedicatedCursorsWhenNoHigherPriorityState()
|
||||
{
|
||||
var c = new CursorFeedbackController();
|
||||
|
||||
Assert.Equal(CursorFeedbackKind.WindowMove,
|
||||
c.Resolve(new CursorFeedbackSnapshot(HoverWindowMove: true)).Kind);
|
||||
Assert.Equal(CursorFeedbackKind.Text,
|
||||
c.Resolve(new CursorFeedbackSnapshot(HoverTextEdit: true)).Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TargetMode_reportsValidInvalidAndPendingTargets()
|
||||
{
|
||||
var objects = SeedTargetObjects();
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
sendUseWithTarget: null,
|
||||
sendWield: null,
|
||||
sendDrop: null,
|
||||
nowMs: () => 1_000);
|
||||
var c = new CursorFeedbackController(interaction);
|
||||
|
||||
Assert.True(interaction.ActivateItem(Source));
|
||||
|
||||
Assert.Equal(CursorFeedbackKind.TargetValid,
|
||||
c.Resolve(new CursorFeedbackSnapshot(HoverUi: true, HoverTargetGuid: Player)).Kind);
|
||||
Assert.Equal(CursorFeedbackKind.TargetInvalid,
|
||||
c.Resolve(new CursorFeedbackSnapshot(HoverUi: true, HoverTargetGuid: 0x5000BADu)).Kind);
|
||||
Assert.Equal(CursorFeedbackKind.TargetInvalid,
|
||||
c.Resolve(new CursorFeedbackSnapshot(HoverUi: true)).Kind);
|
||||
Assert.Equal(CursorFeedbackKind.TargetPending,
|
||||
c.Resolve(new CursorFeedbackSnapshot()).Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateFromRoot_usesUseTargetGuidProviderBeforeSlotItem()
|
||||
{
|
||||
var objects = SeedTargetObjects();
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
sendUseWithTarget: null,
|
||||
sendWield: null,
|
||||
sendDrop: null,
|
||||
nowMs: () => 1_000);
|
||||
var root = new UiRoot { Width = 800, Height = 600 };
|
||||
var slot = new UiItemSlot
|
||||
{
|
||||
Left = 10,
|
||||
Top = 10,
|
||||
Width = 32,
|
||||
Height = 32,
|
||||
UseTargetGuidProvider = () => Player,
|
||||
};
|
||||
var acceptCursor = new UiCursorMedia(0x06009999u, 11, 12);
|
||||
slot.SetStateCursors(new Dictionary<string, UiCursorMedia>
|
||||
{
|
||||
["Drag_rollover_accept"] = acceptCursor,
|
||||
});
|
||||
slot.SetItem(Target, iconTexture: 1u);
|
||||
root.AddChild(slot);
|
||||
root.OnMouseMove(20, 20);
|
||||
var c = new CursorFeedbackController(interaction);
|
||||
|
||||
Assert.True(interaction.ActivateItem(Source));
|
||||
|
||||
var feedback = c.Update(root);
|
||||
Assert.Equal(CursorFeedbackKind.TargetValid, feedback.Kind);
|
||||
Assert.Equal(acceptCursor, feedback.Cursor);
|
||||
}
|
||||
|
||||
private static ClientObjectTable SeedTargetObjects()
|
||||
{
|
||||
var objects = new ClientObjectTable();
|
||||
objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = Player,
|
||||
Name = "Player",
|
||||
Type = ItemType.Creature,
|
||||
});
|
||||
objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = Pack,
|
||||
Name = "Backpack",
|
||||
Type = ItemType.Container,
|
||||
ItemsCapacity = 24,
|
||||
});
|
||||
objects.MoveItem(Pack, Player, 0);
|
||||
objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = Source,
|
||||
Name = "Health Kit",
|
||||
Type = ItemType.Misc,
|
||||
Useability = HealthKitUseability,
|
||||
});
|
||||
objects.MoveItem(Source, Pack, 0);
|
||||
objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = Target,
|
||||
Name = "Target",
|
||||
Type = ItemType.Misc,
|
||||
});
|
||||
objects.MoveItem(Target, Pack, 1);
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue