feat(D.2b): IUiRegistry plugin UI surface + buffered drain into UiHost
Adds the plugin-facing UI registration surface (Task 9, final D.2b task). Plugins call host.Ui.AddMarkupPanel(path, binding) from Enable(); calls are buffered in BufferedUiRegistry before the GL window opens, then drained into UiHost.Root in GameWindow.OnLoad inside the RetailUi block after the first- party vitals panel. Faulty plugin markup is isolated (try/catch per panel, logged + skipped). IPluginHost.Ui added; AppPluginHost wired; StubHost in Core.Tests updated; BufferedUiRegistryTests confirms drain-once semantics. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
07bf6cbf60
commit
019350fa31
8 changed files with 102 additions and 4 deletions
21
tests/AcDream.App.Tests/Plugins/BufferedUiRegistryTests.cs
Normal file
21
tests/AcDream.App.Tests/Plugins/BufferedUiRegistryTests.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using AcDream.App.Plugins;
|
||||
|
||||
namespace AcDream.App.Tests.Plugins;
|
||||
|
||||
public class BufferedUiRegistryTests
|
||||
{
|
||||
[Fact]
|
||||
public void Drain_YieldsBufferedRegistrationsOnceThenEmpty()
|
||||
{
|
||||
var reg = new BufferedUiRegistry();
|
||||
reg.AddMarkupPanel("a.xml", new object());
|
||||
reg.AddMarkupPanel("b.xml", new object());
|
||||
|
||||
var drained = reg.Drain();
|
||||
Assert.Equal(2, drained.Count);
|
||||
Assert.Equal("a.xml", drained[0].MarkupPath);
|
||||
Assert.Equal("b.xml", drained[1].MarkupPath);
|
||||
|
||||
Assert.Empty(reg.Drain()); // consumed
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,12 @@ public class PluginLoaderTests
|
|||
public IPluginLogger Log { get; } = new StubLogger();
|
||||
public IGameState State { get; } = new StubState();
|
||||
public IEvents Events { get; } = new StubEvents();
|
||||
public IUiRegistry Ui { get; } = new StubUiRegistry();
|
||||
}
|
||||
|
||||
private sealed class StubUiRegistry : IUiRegistry
|
||||
{
|
||||
public void AddMarkupPanel(string markupPath, object binding) { }
|
||||
}
|
||||
|
||||
private sealed class StubLogger : IPluginLogger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue