fix(ui): select and examine favorite spells like retail

This commit is contained in:
Erik 2026-07-24 06:47:54 +02:00
parent 043ab10b3c
commit 3e31b0ac70
23 changed files with 974 additions and 34 deletions

View file

@ -245,6 +245,30 @@ public class DragDropSpineTests
return (root, list, list.Cell);
}
private static (UiRoot root, UiItemList list, UiCatalogSlot cell)
RootWithCatalogSlot(uint entryId)
{
var root = new UiRoot { Width = 800, Height = 600 };
var list = new UiItemList(_ => (1u, 1, 1))
{
Left = 0,
Top = 0,
Width = 32,
Height = 32,
};
list.Flush();
var cell = new UiCatalogSlot
{
EntryId = entryId,
Width = 32,
Height = 32,
SpriteResolve = _ => (1u, 1, 1),
};
list.AddItem(cell);
root.AddChild(list);
return (root, list, cell);
}
[Fact]
public void BeginDrag_arms_whenPayloadNonNull()
{
@ -359,6 +383,32 @@ public class DragDropSpineTests
Assert.Null(root.DragSource);
}
[Fact]
public void CatalogEntryPress_selectsBeforeRelease_withoutForgingItemIdentity()
{
var (root, list, cell) = RootWithCatalogSlot(42u);
var selected = new List<uint>();
list.PrimaryCatalogEntryPressed = selected.Add;
root.OnMouseDown(UiMouseButton.Left, 10, 10);
Assert.Equal(new uint[] { 42u }, selected);
Assert.Equal(0u, cell.ItemId);
}
[Fact]
public void CatalogEntryRightClick_requestsLocalCatalogExamination()
{
var (root, list, _) = RootWithCatalogSlot(42u);
var examined = new List<uint>();
list.ExamineCatalogEntryRequested = examined.Add;
root.OnMouseDown(UiMouseButton.Right, 10, 10);
root.OnMouseUp(UiMouseButton.Right, 10, 10);
Assert.Equal(new uint[] { 42u }, examined);
}
[Fact]
public void CompletedDrag_doesNotFireUse()
{