acdream/tests/AcDream.App.Tests/UI/UiItemListGridTests.cs
Erik b7dc91a053 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>
2026-07-03 09:18:43 +02:00

70 lines
2.1 KiB
C#

using AcDream.App.UI;
namespace AcDream.App.Tests.UI;
public class UiItemListGridTests
{
[Fact]
public void CellOffset_RowMajor()
{
Assert.Equal((0f, 0f), UiItemList.CellOffset(0, 3, 36, 36));
Assert.Equal((72f, 0f), UiItemList.CellOffset(2, 3, 36, 36));
Assert.Equal((36f, 36f), UiItemList.CellOffset(4, 3, 36, 36)); // col 1, row 1
}
[Fact]
public void CellOffset_ColumnMajor_UsesLogicalRows()
{
Assert.Equal((0f, 0f), UiItemList.CellOffset(0, 3, 7, UiItemListFlow.ColumnMajor, 36, 36));
Assert.Equal((0f, 36f), UiItemList.CellOffset(1, 3, 7, UiItemListFlow.ColumnMajor, 36, 36));
Assert.Equal((36f, 0f), UiItemList.CellOffset(3, 3, 7, UiItemListFlow.ColumnMajor, 36, 36));
}
[Fact]
public void GridMode_PositionsCellsInColumns()
{
var list = new UiItemList { Columns = 3, CellWidth = 36, CellHeight = 36 };
list.Flush(); // drop the ctor's default cell
for (int i = 0; i < 7; i++) list.AddItem(new UiItemSlot());
var c4 = list.GetItem(4)!;
Assert.Equal(36f, c4.Left);
Assert.Equal(36f, c4.Top);
Assert.Equal(36f, c4.Width);
Assert.Equal(36f, c4.Height);
}
[Fact]
public void GridMode_ColumnMajor_PositionsCellsDownRowsFirst()
{
var list = new UiItemList
{
Columns = 3,
Flow = UiItemListFlow.ColumnMajor,
CellWidth = 36,
CellHeight = 36,
};
list.Flush();
for (int i = 0; i < 7; i++) list.AddItem(new UiItemSlot());
var c3 = list.GetItem(3)!;
Assert.Equal(36f, c3.Left);
Assert.Equal(0f, c3.Top);
}
[Fact]
public void FillMode_SizesSingleCellToList()
{
// CellWidth defaults to 0 = "fill the list" (single-cell toolbar legacy).
var list = new UiItemList { Width = 36, Height = 36 };
list.Flush();
list.AddItem(new UiItemSlot());
var c = list.Cell;
Assert.Equal(0f, c.Left);
Assert.Equal(0f, c.Top);
Assert.Equal(36f, c.Width);
Assert.Equal(36f, c.Height);
}
}