From 5c6af0bbe5545554fd092c9448945c0da354d3a4 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Sat, 7 Nov 2026 14:34:27 -0800 Subject: [PATCH] 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 --- Plugins/Shared/ServerPack/ServerPackUi.cs | 2 +- Tools/RynthServerPack.Tests/ServerPackHooksTests.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Plugins/Shared/ServerPack/ServerPackUi.cs b/Plugins/Shared/ServerPack/ServerPackUi.cs index e5fe52c..1df73e6 100644 --- a/Plugins/Shared/ServerPack/ServerPackUi.cs +++ b/Plugins/Shared/ServerPack/ServerPackUi.cs @@ -85,7 +85,7 @@ internal sealed class ServerPackUi { ServerPackInfo info = _model.Info; RenderVerdict(info); - if (_cardActions != null) { ImGui.Separator(); _cardActions(); } + _cardActions?.Invoke(); ImGui.Separator(); RenderFacts(info); if (info.Commands.Length > 0) diff --git a/Tools/RynthServerPack.Tests/ServerPackHooksTests.cs b/Tools/RynthServerPack.Tests/ServerPackHooksTests.cs index 68ce76b..0ef0c2a 100644 --- a/Tools/RynthServerPack.Tests/ServerPackHooksTests.cs +++ b/Tools/RynthServerPack.Tests/ServerPackHooksTests.cs @@ -228,12 +228,17 @@ internal static class ServerPackHooksTests int verdict = ui.IndexOf("RenderVerdict(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.Eq(CountOf(ui, "_cardActions()"), 1, "the card actions are invoked exactly once"); - int call = ui.IndexOf("_cardActions()", StringComparison.Ordinal); + Check.Eq(CountOf(ui, "_cardActions?.Invoke()"), 1, "the card actions are invoked exactly once"); + 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"); + // 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), "the plugin declares the ServerCardActions hook and DrawCardActions"); Check.True(plugin.Contains("_pages, DrawCardActions)", StringComparison.Ordinal), "the plugin passes DrawCardActions to ServerPackUi"); } -} \ No newline at end of file +}