fix(ui): restore retail vitals and window interactions
All checks were successful
CI / linux-portable (push) Successful in 3m16s
CI / windows-gate (push) Successful in 5m41s
CI / release (push) Successful in 2m5s

This commit is contained in:
Erik 2026-08-20 13:26:35 +02:00
parent 4d84456c21
commit 1bd2b30291
36 changed files with 1462 additions and 86 deletions

View file

@ -465,6 +465,73 @@ public class ToolbarControllerTests
Assert.Equal("Normal", characterButton.ActiveState);
}
[Fact]
public void RetailFixture_inventoryButtonPressKeepsClosedFaceThenOpensDirectly()
{
ImportedLayout layout = LayoutImporter.Build(
FixtureLoader.LoadToolbarInfos(),
static file => (file, 8, 8),
null);
var controller = ToolbarController.Bind(
layout,
new ClientObjectTable(),
new ShortcutStore(),
iconIds: (_, _, _, _, _) => 0u,
useItem: _ => { });
controller.BindPanelButtons(
_ => true,
panelId => controller.SetPanelOpen(panelId, open: true));
var inventory = Assert.IsType<UiButton>(layout.FindElement(InventoryButtonId));
Assert.Equal("Normal", inventory.ActiveState);
Assert.Equal(0x06004CF7u, DrawnFaceFile(inventory));
inventory.OnEvent(new UiEvent(
inventory.EventId,
inventory,
UiEventType.MouseDown,
Data1: 31,
Data2: 29));
Assert.Equal("Normal_pressed", inventory.ActiveState);
Assert.Equal(0x06004CF7u, DrawnFaceFile(inventory));
inventory.OnEvent(new UiEvent(
inventory.EventId,
inventory,
UiEventType.MouseUp,
Data1: 31,
Data2: 29));
Assert.Equal("Highlight", inventory.ActiveState);
Assert.Equal(0x06004CF8u, DrawnFaceFile(inventory));
}
[InstalledDatFact]
[Trait("Lane", "InstalledDat")]
public void InstalledDat_inventoryButtonPressStateKeepsTheCurrentFace()
{
string datDirectory = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
?? Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Documents",
"Asheron's Call");
using var dats = new AcDream.App.Tests.BoundedTestDatCollection(
datDirectory,
DatReaderWriter.Options.DatAccessType.Read);
ElementInfo root = Assert.IsType<ElementInfo>(
LayoutImporter.ImportInfos(dats, 0x21000016u));
ElementInfo inventory = FindInfo(root, InventoryButtonId);
Assert.Equal(1, inventory.States[UiButtonStateMachine.Normal].MediaCount);
Assert.Equal(1, inventory.States[UiButtonStateMachine.Normal].ImageMediaCount);
Assert.Equal(1, inventory.States[UiButtonStateMachine.NormalPressed].MediaCount);
Assert.Equal(0, inventory.States[UiButtonStateMachine.NormalPressed].ImageMediaCount);
Assert.Equal(1, inventory.States[UiButtonStateMachine.Highlight].MediaCount);
Assert.Equal(1, inventory.States[UiButtonStateMachine.Highlight].ImageMediaCount);
Assert.DoesNotContain("Normal_pressed", inventory.StateMedia.Keys);
}
[Fact]
public void RetailFixture_panelButtonsExposeExactDatPanelIds()
{
@ -1526,4 +1593,39 @@ public class ToolbarControllerTests
iconIds: (_,_,_,_,_) => 0u, useItem: _ => { });
Assert.Equal(0x060011FAu, slots[Row1[0]].Cell.DragAcceptSprite); // green cross, not the ring F9
}
private static uint DrawnFaceFile(UiButton button)
{
var renderer = new AcDream.App.Rendering.TextRenderer(
new AcDream.App.Tests.Rendering.Gpu.RecordingGpuDevice(),
new NullGpuFrameSource(),
"unused");
renderer.Begin(new System.Numerics.Vector2(200f, 200f));
button.DrawSelfAndChildren(new UiRenderContext(
renderer,
new System.Numerics.Vector2(200f, 200f)));
return Assert.Single(renderer.DebugSpriteSegments).Texture;
}
private sealed class NullGpuFrameSource
: AcDream.App.Rendering.ICurrentGpuFrameSource
{
public AcDream.App.Rendering.Gpu.IGpuFrame? CurrentFrame => null;
}
private static ElementInfo FindInfo(ElementInfo root, uint id)
=> TryFindInfo(root, id)
?? throw new InvalidOperationException($"Element 0x{id:X8} was not found.");
private static ElementInfo? TryFindInfo(ElementInfo root, uint id)
{
if (root.Id == id)
return root;
foreach (ElementInfo child in root.Children)
{
if (TryFindInfo(child, id) is { } found)
return found;
}
return null;
}
}