Resolve the authored spell shortcut row prototype so the spellbook presents the retail icon, name, separator, selected overlay, and scrollbar geometry. Port exact school and level filters, stable display ordering, selection exposure, and learned-spell drags into the open favorite bar. Route deletion through the shared retail confirmation dialog and send CM_Magic::Event_RemoveSpell only after an affirmative answer, leaving the inbound server notice authoritative for list state. Co-Authored-By: Codex <noreply@openai.com>
85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using AcDream.App.UI;
|
|
using Xunit;
|
|
|
|
namespace AcDream.App.Tests.UI;
|
|
|
|
public class UiItemListTests
|
|
{
|
|
[Fact]
|
|
public void IsLeafWidget() => Assert.True(new UiItemList().ConsumesDatChildren);
|
|
|
|
[Fact]
|
|
public void StartsWithOneCell_forSingleCellSlot()
|
|
{
|
|
var list = new UiItemList();
|
|
Assert.Equal(1, list.GetNumUIItems());
|
|
Assert.NotNull(list.GetItem(0));
|
|
}
|
|
|
|
[Fact]
|
|
public void Cell_returnsTheFirstSlot()
|
|
{
|
|
var list = new UiItemList();
|
|
Assert.Same(list.GetItem(0), list.Cell);
|
|
}
|
|
|
|
[Fact]
|
|
public void CellEmptySprite_stamps_existing_and_future_cells()
|
|
{
|
|
var list = new UiItemList(); // ctor adds one default cell
|
|
Assert.Equal(0x060074CFu, list.GetItem(0)!.EmptySprite); // UiItemSlot default before set
|
|
|
|
list.CellEmptySprite = 0x06004D20u; // a pack-slot sprite
|
|
Assert.Equal(0x06004D20u, list.GetItem(0)!.EmptySprite); // existing cell re-stamped
|
|
|
|
list.AddItem(new UiItemSlot());
|
|
Assert.Equal(0x06004D20u, list.GetItem(1)!.EmptySprite); // new cell stamped
|
|
}
|
|
|
|
[Fact]
|
|
public void CellEmptySprite_zero_leaves_the_UiItemSlot_default()
|
|
{
|
|
var list = new UiItemList();
|
|
list.CellEmptySprite = 0u;
|
|
Assert.Equal(0x060074CFu, list.GetItem(0)!.EmptySprite); // unchanged default
|
|
}
|
|
|
|
[Fact]
|
|
public void CatalogDrop_routes_payload_and_local_coordinates()
|
|
{
|
|
var list = new UiItemList();
|
|
object payload = new();
|
|
(object Payload, int X, int Y)? received = null;
|
|
list.CatalogDropped = (value, x, y) => received = (value, x, y);
|
|
|
|
bool handled = list.OnEvent(new UiEvent(
|
|
0, list, UiEventType.DropReleased, Data1: 17, Data2: 9, Payload: payload));
|
|
|
|
Assert.True(handled);
|
|
Assert.NotNull(received);
|
|
Assert.Same(payload, received.Value.Payload);
|
|
Assert.Equal((17, 9), (received.Value.X, received.Value.Y));
|
|
}
|
|
|
|
[Fact]
|
|
public void ScrollItemIntoView_moves_only_when_row_is_outside_viewport()
|
|
{
|
|
var list = new UiItemList
|
|
{
|
|
Width = 100f,
|
|
Height = 64f,
|
|
Columns = 1,
|
|
CellWidth = 100f,
|
|
CellHeight = 32f,
|
|
};
|
|
list.Flush();
|
|
for (int i = 0; i < 5; i++) list.AddItem(new UiItemSlot());
|
|
|
|
list.ScrollItemIntoView(3);
|
|
Assert.Equal(64, list.Scroll.ScrollY);
|
|
list.ScrollItemIntoView(2);
|
|
Assert.Equal(64, list.Scroll.ScrollY);
|
|
list.ScrollItemIntoView(0);
|
|
Assert.Equal(0, list.Scroll.ScrollY);
|
|
}
|
|
}
|