feat(ui): port retail spellbook interactions
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>
This commit is contained in:
parent
ad30c37a48
commit
ac2ca8f965
17 changed files with 727 additions and 47 deletions
|
|
@ -78,6 +78,35 @@ public sealed class SpellcastingUiControllerTests
|
|||
Assert.Equal([42u], spellbook.GetFavorites(0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SpellbookShortcutDrop_AddsToOpenTabWithoutRemovingLearnedSpell()
|
||||
{
|
||||
ImportedLayout layout = LayoutImporter.Build(
|
||||
FixtureLoader.LoadCombatInfos(), NoTex, datFont: null);
|
||||
var spellbook = new Spellbook();
|
||||
spellbook.OnSpellLearned(42u, 1f);
|
||||
var objects = new ClientObjectTable();
|
||||
objects.AddOrUpdate(new ClientObject { ObjectId = 1u, Name = "Player" });
|
||||
var added = new List<(int Tab, int Position, uint Spell)>();
|
||||
using SpellcastingUiController controller = Bind(
|
||||
layout, spellbook, objects, _ => { },
|
||||
(tab, position, spell) => added.Add((tab, position, spell)))!;
|
||||
UiElement group = Assert.IsAssignableFrom<UiElement>(layout.FindElement(0x100000AAu));
|
||||
UiItemList list = Descendants(group).OfType<UiItemList>().First();
|
||||
|
||||
bool handled = list.OnEvent(new UiEvent(
|
||||
0,
|
||||
list,
|
||||
UiEventType.DropReleased,
|
||||
Data1: 5,
|
||||
Payload: new SpellbookShortcutDragPayload(42u)));
|
||||
|
||||
Assert.True(handled);
|
||||
Assert.Equal([(0, 0, 42u)], added);
|
||||
Assert.Equal([42u], spellbook.GetFavorites(0));
|
||||
Assert.True(spellbook.Knows(42u));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnrelatedObjectUpdate_DoesNotRecreateFavoriteSlots()
|
||||
{
|
||||
|
|
@ -137,7 +166,8 @@ public sealed class SpellcastingUiControllerTests
|
|||
ImportedLayout layout,
|
||||
Spellbook spellbook,
|
||||
ClientObjectTable objects,
|
||||
Action<uint> useItem)
|
||||
Action<uint> useItem,
|
||||
Action<int, int, uint>? addFavorite = null)
|
||||
{
|
||||
var casting = new SpellCastingController(
|
||||
spellbook, () => null, () => 1u, () => { }, _ => { }, (_, _) => { }, _ => { });
|
||||
|
|
@ -147,7 +177,7 @@ public sealed class SpellcastingUiControllerTests
|
|||
item => item.ObjectId,
|
||||
useItem,
|
||||
new SelectionState(),
|
||||
(_, _, _) => { },
|
||||
addFavorite ?? ((_, _, _) => { }),
|
||||
(_, _) => { });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue