fix(ui): select and examine favorite spells like retail
This commit is contained in:
parent
043ab10b3c
commit
3e31b0ac70
23 changed files with 974 additions and 34 deletions
|
|
@ -280,6 +280,45 @@ public sealed class SpellcastingUiControllerTests
|
|||
Assert.Empty(used);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FavoritePressSelectsImmediately_AndRightClickExaminesLocally()
|
||||
{
|
||||
ImportedLayout layout = LayoutImporter.Build(
|
||||
FixtureLoader.LoadCombatInfos(), NoTex, datFont: null);
|
||||
var spellbook = new Spellbook();
|
||||
spellbook.OnSpellLearned(42u, 1f);
|
||||
spellbook.OnSpellLearned(43u, 1f);
|
||||
spellbook.SetFavorite(0, 0, 42u);
|
||||
spellbook.SetFavorite(0, 1, 43u);
|
||||
var objects = new ClientObjectTable();
|
||||
objects.AddOrUpdate(new ClientObject { ObjectId = 1u, Name = "Player" });
|
||||
var selection = new SelectionState();
|
||||
var examined = new List<uint>();
|
||||
using SpellcastingUiController controller = Bind(
|
||||
layout,
|
||||
spellbook,
|
||||
objects,
|
||||
_ => { },
|
||||
selection: selection,
|
||||
examineSpell: examined.Add)!;
|
||||
UiElement group = layout.FindElement(0x100000AAu)!;
|
||||
UiItemList list = Descendants(group).OfType<UiItemList>().First();
|
||||
UiCatalogSlot first = Assert.IsType<UiCatalogSlot>(list.GetItem(0));
|
||||
UiCatalogSlot second = Assert.IsType<UiCatalogSlot>(list.GetItem(1));
|
||||
Assert.True(first.Selected);
|
||||
|
||||
second.OnEvent(new UiEvent(0u, second, UiEventType.MouseDown));
|
||||
|
||||
Assert.False(first.Selected);
|
||||
Assert.True(second.Selected);
|
||||
Assert.Null(selection.SelectedObjectId);
|
||||
|
||||
second.OnEvent(new UiEvent(0u, second, UiEventType.RightClick));
|
||||
|
||||
Assert.Equal(new uint[] { 43u }, examined);
|
||||
Assert.Null(selection.SelectedObjectId);
|
||||
}
|
||||
|
||||
private static SpellcastingUiController? Bind(
|
||||
ImportedLayout layout,
|
||||
Spellbook spellbook,
|
||||
|
|
@ -287,7 +326,9 @@ public sealed class SpellcastingUiControllerTests
|
|||
Action<uint> useItem,
|
||||
Action<int, int, uint>? addFavorite = null,
|
||||
UiShortcutDigitGraphics? shortcutDigits = null,
|
||||
uint emptySlotSprite = 0u)
|
||||
uint emptySlotSprite = 0u,
|
||||
SelectionState? selection = null,
|
||||
Action<uint>? examineSpell = null)
|
||||
{
|
||||
var casting = new SpellCastingController(
|
||||
spellbook, () => null, () => 1u, () => { }, _ => { }, (_, _) => { }, _ => { });
|
||||
|
|
@ -296,11 +337,12 @@ public sealed class SpellcastingUiControllerTests
|
|||
spellId => spellId,
|
||||
item => item.ObjectId,
|
||||
useItem,
|
||||
new SelectionState(),
|
||||
selection ?? new SelectionState(),
|
||||
addFavorite ?? ((_, _, _) => { }),
|
||||
(_, _) => { },
|
||||
shortcutDigits,
|
||||
emptySlotSprite);
|
||||
emptySlotSprite,
|
||||
examineSpell);
|
||||
}
|
||||
|
||||
private static void ApplyAnchors(UiElement parent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue