fix(ui): port source-aware toolbar drops
Plan retail shortcut drops from a complete post-lift snapshot so fresh inventory items use cyclic-right displacement while toolbar aliases restore to their vacated slot. Apply local mutations atomically, preserve raw shortcut fields, emit exact Remove/Add ordering, and retire AP-102 after the live ACE gate. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
b5b230c860
commit
3281e0acb4
8 changed files with 462 additions and 23 deletions
|
|
@ -865,6 +865,67 @@ public class ToolbarControllerTests
|
|||
Assert.DoesNotContain(adds, a => a.Index == 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandleDropRelease_freshInventoryToOccupied_usesCyclicRightSlotNotInventoryIndex()
|
||||
{
|
||||
var (layout, slots, _) = FakeToolbar();
|
||||
var repo = new ClientObjectTable();
|
||||
repo.AddOrUpdate(new ClientObject { ObjectId = 0x5001u, IconId = 1u });
|
||||
repo.AddOrUpdate(new ClientObject { ObjectId = 0x5002u, IconId = 2u });
|
||||
var shortcuts = new[]
|
||||
{
|
||||
new ShortcutEntry(5, 0x5002u, 0xA5C31234u),
|
||||
};
|
||||
var wire = new List<string>();
|
||||
var ctrl = ToolbarController.Bind(layout, repo, () => shortcuts,
|
||||
iconIds: (_, _, _, _, _) => 1u,
|
||||
useItem: _ => { },
|
||||
sendAddShortcut: entry => wire.Add($"add:{entry.Index}:{entry.ObjectId:X8}:{entry.SpellId:X8}"),
|
||||
sendRemoveShortcut: slot => wire.Add($"remove:{slot}"));
|
||||
|
||||
var payload = new ItemDragPayload(
|
||||
0x5001u, ItemDragSource.Inventory, SourceSlot: 12, new UiItemSlot());
|
||||
ctrl.HandleDropRelease(slots[Row1[5]], slots[Row1[5]].Cell, payload);
|
||||
|
||||
Assert.Equal(0x5001u, slots[Row1[5]].Cell.ItemId);
|
||||
Assert.Equal(0x5002u, slots[Row1[6]].Cell.ItemId);
|
||||
Assert.Equal(0u, slots[Row2[3]].Cell.ItemId); // inventory grid index 12 is irrelevant
|
||||
Assert.Equal(new[]
|
||||
{
|
||||
"remove:5",
|
||||
"add:5:00005001:00000000",
|
||||
"add:6:00005002:A5C31234",
|
||||
}, wire);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceFullyMergedShortcut_rekeysEntryAndPreservesRawFields()
|
||||
{
|
||||
var (layout, slots, _) = FakeToolbar();
|
||||
var repo = new ClientObjectTable();
|
||||
repo.AddOrUpdate(new ClientObject { ObjectId = 0x5001u, IconId = 1u });
|
||||
repo.AddOrUpdate(new ClientObject { ObjectId = 0x5002u, IconId = 2u });
|
||||
var shortcuts = new[]
|
||||
{
|
||||
new ShortcutEntry(4, 0x5001u, 0x11223344u),
|
||||
};
|
||||
var wire = new List<string>();
|
||||
var ctrl = ToolbarController.Bind(layout, repo, () => shortcuts,
|
||||
iconIds: (_, _, _, _, _) => 1u,
|
||||
useItem: _ => { },
|
||||
sendAddShortcut: entry => wire.Add($"add:{entry.Index}:{entry.ObjectId:X8}:{entry.SpellId:X8}"),
|
||||
sendRemoveShortcut: slot => wire.Add($"remove:{slot}"));
|
||||
|
||||
ctrl.ReplaceFullyMergedShortcut(0x5001u, 0x5002u);
|
||||
|
||||
Assert.Equal(0x5002u, slots[Row1[4]].Cell.ItemId);
|
||||
Assert.Equal(new[]
|
||||
{
|
||||
"remove:4",
|
||||
"add:4:00005002:11223344",
|
||||
}, wire);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandleDropRelease_ontoSelf_reAddsToSource()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue