fix(ui): keep spellbook tab captions above chrome

This commit is contained in:
Erik 2026-07-15 17:02:14 +02:00
parent c918ccea06
commit 16eb4844c1
4 changed files with 91 additions and 1 deletions

View file

@ -29,4 +29,36 @@ public sealed class SpellbookRowStyleTests
Assert.Equal(0x06001396u, style.BackgroundSprite);
Assert.Equal(0x06001397u, style.SelectedSprite);
}
[Fact]
public void InstalledDat_ResolvesAuthoredSpellbookTabCaptions()
{
string datDir = System.Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
?? Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile),
"Documents", "Asheron's Call");
if (!Directory.Exists(datDir)) return;
using var dats = new DatCollection(datDir, DatAccessType.Read);
ElementInfo root = Assert.IsType<ElementInfo>(LayoutImporter.ImportInfos(
dats, SpellbookWindowController.LayoutId, SpellbookWindowController.RootId));
var strings = new DatStringResolver(dats);
Assert.Equal("Spellbook", ResolveCaption(SpellbookWindowController.SpellTabId));
Assert.Equal("Components", ResolveCaption(SpellbookWindowController.ComponentTabId));
string? ResolveCaption(uint id)
{
ElementInfo node = Assert.IsType<ElementInfo>(Find(root, id));
Assert.True(node.TryGetEffectiveProperty(0x17u, out UiPropertyValue label));
return strings.Resolve(label.StringInfoValue);
}
}
private static ElementInfo? Find(ElementInfo root, uint id)
{
if (root.Id == id) return root;
foreach (ElementInfo child in root.Children)
if (Find(child, id) is { } found) return found;
return null;
}
}

View file

@ -26,7 +26,16 @@ public sealed class SpellbookWindowControllerTests
[Fact]
public void RetailFixture_BindsTextTabs_AndPropagatesOpenClosedState()
{
ImportedLayout layout = FixtureLoader.LoadSpellbook();
ImportedLayout layout = LayoutImporter.Build(
FixtureLoader.LoadSpellbookInfos(),
_ => (0u, 0, 0),
datFont: null,
stringResolve: value => value.StringId switch
{
49867858u => "Spellbook",
79360818u => "Components",
_ => null,
});
var closed = new List<uint>();
using SpellbookWindowController? controller = Bind(
layout, new Spellbook(), close: () => closed.Add(1u));
@ -37,6 +46,11 @@ public sealed class SpellbookWindowControllerTests
UiElement spellPage = Assert.IsAssignableFrom<UiElement>(layout.FindElement(SpellbookWindowController.SpellPageId));
UiElement componentPage = Assert.IsAssignableFrom<UiElement>(layout.FindElement(SpellbookWindowController.ComponentPageId));
Assert.Equal("Spellbook", Assert.Single(spellTab.LinesProvider()).Text);
Assert.Equal("Components", Assert.Single(componentTab.LinesProvider()).Text);
Assert.True(spellTab.DrawTextAfterChildren);
Assert.True(componentTab.DrawTextAfterChildren);
Assert.Equal(RetailUiStateIds.Open, spellTab.ActiveRetailStateId);
Assert.Equal(RetailUiStateIds.Closed, componentTab.ActiveRetailStateId);
Assert.True(spellPage.Visible);