ServerPack: open pages in the engine's web panel #3
2 changed files with 9 additions and 4 deletions
ServerPack: card actions add no separator of their own
Hookless servers render exactly as before: call _cardActions?.Invoke() after RenderVerdict and let the existing separator close the block. Test now pins the RenderBody separator count and restores the trailing CRLF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
5c6af0bbe5
|
|
@ -85,7 +85,7 @@ internal sealed class ServerPackUi
|
||||||
{
|
{
|
||||||
ServerPackInfo info = _model.Info;
|
ServerPackInfo info = _model.Info;
|
||||||
RenderVerdict(info);
|
RenderVerdict(info);
|
||||||
if (_cardActions != null) { ImGui.Separator(); _cardActions(); }
|
_cardActions?.Invoke();
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
RenderFacts(info);
|
RenderFacts(info);
|
||||||
if (info.Commands.Length > 0)
|
if (info.Commands.Length > 0)
|
||||||
|
|
|
||||||
|
|
@ -228,12 +228,17 @@ internal static class ServerPackHooksTests
|
||||||
int verdict = ui.IndexOf("RenderVerdict(info);", body, StringComparison.Ordinal);
|
int verdict = ui.IndexOf("RenderVerdict(info);", body, StringComparison.Ordinal);
|
||||||
int facts = ui.IndexOf("RenderFacts(info);", body, StringComparison.Ordinal);
|
int facts = ui.IndexOf("RenderFacts(info);", body, StringComparison.Ordinal);
|
||||||
Check.True(verdict > body && facts > verdict, "RenderBody draws the verdict, then the facts");
|
Check.True(verdict > body && facts > verdict, "RenderBody draws the verdict, then the facts");
|
||||||
Check.Eq(CountOf(ui, "_cardActions()"), 1, "the card actions are invoked exactly once");
|
Check.Eq(CountOf(ui, "_cardActions?.Invoke()"), 1, "the card actions are invoked exactly once");
|
||||||
int call = ui.IndexOf("_cardActions()", StringComparison.Ordinal);
|
int call = ui.IndexOf("_cardActions?.Invoke()", StringComparison.Ordinal);
|
||||||
Check.True(call > verdict && call < facts, "the actions are drawn after the verdict and before the facts");
|
Check.True(call > verdict && call < facts, "the actions are drawn after the verdict and before the facts");
|
||||||
|
|
||||||
|
// Hookless servers must render exactly as before: no separator was added to the card (base RenderBody has 5).
|
||||||
|
int bodyEnd = ui.IndexOf("private void RenderVerdict", body, StringComparison.Ordinal);
|
||||||
|
Check.Eq(CountOf(ui.Substring(body, bodyEnd - body), "ImGui.Separator()"), 5, "RenderBody separator count is unchanged from base");
|
||||||
|
Check.False(ui.Substring(verdict, call - verdict).Contains("Separator", StringComparison.Ordinal), "no separator between the verdict and the actions");
|
||||||
|
|
||||||
Check.True(plugin.Contains("DrawCardActions", StringComparison.Ordinal) && plugin.Contains("partial void ServerCardActions();", StringComparison.Ordinal),
|
Check.True(plugin.Contains("DrawCardActions", StringComparison.Ordinal) && plugin.Contains("partial void ServerCardActions();", StringComparison.Ordinal),
|
||||||
"the plugin declares the ServerCardActions hook and DrawCardActions");
|
"the plugin declares the ServerCardActions hook and DrawCardActions");
|
||||||
Check.True(plugin.Contains("_pages, DrawCardActions)", StringComparison.Ordinal), "the plugin passes DrawCardActions to ServerPackUi");
|
Check.True(plugin.Contains("_pages, DrawCardActions)", StringComparison.Ordinal), "the plugin passes DrawCardActions to ServerPackUi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue