Port of UIElement_UIItem::SetShortcutNum (acclient_2013_pseudo_c.txt:229465) and
gmToolbarUI::RecvNotice_SetCombatMode (196610-196621). The 9 top-row toolbar slots
show digit labels 1-9 at all times (even when empty — confirmed from the user''s
retail screenshot). The digit sprites are real 32x32 PFID_A8R8G8B8 RenderSurfaces
with glyphs baked into the top-left corner (rest alpha=0), drawn Alphablend over
the slot icon/empty sprite.
Digit DID arrays (peace: property 0x10000042, war: 0x10000043) are read at startup
from LayoutDesc 0x21000037 element 0x1000034A under composite 0x10000346 using the
same ArrayBaseProperty{DataIdBaseProperty} pattern as LayoutImporter.ReadState.
A cited-constant fallback (same confirmed dat ids) is used if the dat navigation
fails. The war glyph set (darker/golden glyphs) switches on any combat stance;
peace glyphs (lighter) restore on NonCombat — re-stamped by RestampShortcutNumbers()
called from both Populate() and SetCombatMode().
Changes:
- UiItemSlot: ShortcutNum/ShortcutPeace/PeaceDigits/WarDigits state; SetShortcutNum/
ClearShortcutNum; OnDraw restructured (no early return) so digit draws after icon.
- ToolbarController: _peaceDigits/_warDigits/_peace fields; Bind() gains peaceDigits/
warDigits optional params; RestampShortcutNumbers() helper; Populate() and
SetCombatMode() both call RestampShortcutNumbers().
- GameWindow: reads digit arrays under _datLock from LayoutDesc 0x21000037, passes to
Bind(); cited constants as fallback.
- Tests: 5 new UiItemSlotTests (SetShortcutNum/ClearShortcutNum state); 4 new
ToolbarControllerTests (top-row/bottom-row labels, peace/war switch, array injection).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
using AcDream.App.UI;
|
|
|
|
namespace AcDream.App.Tests.UI;
|
|
|
|
public class UiItemSlotTests
|
|
{
|
|
[Fact]
|
|
public void IsLeafWidget()
|
|
=> Assert.True(new UiItemSlot().ConsumesDatChildren);
|
|
|
|
[Fact]
|
|
public void DefaultEmptySprite_isToolbarBorder()
|
|
=> Assert.Equal(0x060074CFu, new UiItemSlot().EmptySprite);
|
|
|
|
[Fact]
|
|
public void Empty_whenNoItem()
|
|
{
|
|
var s = new UiItemSlot();
|
|
Assert.Equal(0u, s.ItemId);
|
|
Assert.Equal(0u, s.IconTexture);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetItem_setsIdAndTexture()
|
|
{
|
|
var s = new UiItemSlot();
|
|
s.SetItem(0x5001u, 0x99u);
|
|
Assert.Equal(0x5001u, s.ItemId);
|
|
Assert.Equal(0x99u, s.IconTexture);
|
|
}
|
|
|
|
[Fact]
|
|
public void Clear_afterSetItem_resetsToEmpty()
|
|
{
|
|
var s = new UiItemSlot();
|
|
s.SetItem(0x5001u, 0x99u);
|
|
s.Clear();
|
|
Assert.Equal(0u, s.ItemId);
|
|
Assert.Equal(0u, s.IconTexture);
|
|
}
|
|
|
|
// ── Shortcut number tests ────────────────────────────────────────────────
|
|
// Port of UIElement_UIItem::SetShortcutNum (acclient_2013_pseudo_c.txt:229465).
|
|
|
|
[Fact]
|
|
public void ShortcutNum_defaultIsMinusOne()
|
|
{
|
|
var s = new UiItemSlot();
|
|
Assert.Equal(-1, s.ShortcutNum);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShortcutPeace_defaultIsTrue()
|
|
{
|
|
var s = new UiItemSlot();
|
|
Assert.True(s.ShortcutPeace);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetShortcutNum_setsIndexAndPeace()
|
|
{
|
|
var s = new UiItemSlot();
|
|
s.SetShortcutNum(3, peace: false);
|
|
Assert.Equal(3, s.ShortcutNum);
|
|
Assert.False(s.ShortcutPeace);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetShortcutNum_peaceTrue()
|
|
{
|
|
var s = new UiItemSlot();
|
|
s.SetShortcutNum(0, peace: true);
|
|
Assert.Equal(0, s.ShortcutNum);
|
|
Assert.True(s.ShortcutPeace);
|
|
}
|
|
|
|
[Fact]
|
|
public void ClearShortcutNum_setsMinusOne()
|
|
{
|
|
var s = new UiItemSlot();
|
|
s.SetShortcutNum(5, peace: true);
|
|
s.ClearShortcutNum();
|
|
Assert.Equal(-1, s.ShortcutNum);
|
|
}
|
|
}
|