Snapshot for release 2026.10.27.1 (internal bf8b2f3)
This commit is contained in:
parent
6fe5630e8c
commit
c68e251cd6
9 changed files with 116 additions and 101 deletions
|
|
@ -99,7 +99,9 @@ public static unsafe class ServerPackExports
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthCore's Mini Remote sections: "section:server-<id>" (":popout" added in a popped-out
|
||||
/// "window:server" (":popout" added popped out): the server's window on RynthCore's bar, everything
|
||||
/// the server has (ServerPackModel.BuildSectionsJson's "windows").
|
||||
/// RynthCore's Mini Remote sections (no longer declared): "section:server-<id>" (":popout" added in a popped-out
|
||||
/// window) draws the server card into the engine's current window, "section:server-<id>.<page>"
|
||||
/// one of the server's own pages (ServerPackPages). 1 = drawn, 0 = not ready or not ours.
|
||||
/// </summary>
|
||||
|
|
@ -114,7 +116,11 @@ public static unsafe class ServerPackExports
|
|||
var plugin = Runtime.Plugin;
|
||||
if (plugin == null) return 0;
|
||||
float wantH;
|
||||
if (name.Equals(ServerPackPlugin.SettingsSurface, StringComparison.Ordinal))
|
||||
if (name.Equals(ServerPackModel.WindowSurface, StringComparison.Ordinal))
|
||||
{
|
||||
if (!plugin.RenderEmbeddedWindow(out wantH)) return 0;
|
||||
}
|
||||
else if (name.Equals(ServerPackPlugin.SettingsSurface, StringComparison.Ordinal))
|
||||
{
|
||||
if (!plugin.RenderEmbeddedCard(out wantH)) return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,24 +148,26 @@ internal sealed class ServerPackModel
|
|||
|
||||
// ── RynthPluginGetSectionsJson ────────────────────────────────────────
|
||||
|
||||
/// <summary>The Mini Remote surface of the server card.</summary>
|
||||
/// <summary>The Mini Remote surface of the server card (the Mini Remote no longer asks for it since 2026-10-24).</summary>
|
||||
public static string SurfaceFor(string serverId) => "section:server-" + serverId;
|
||||
|
||||
/// <summary>
|
||||
/// The Mini Remote section the server cards share: right after Session Stats (core order 0) and
|
||||
/// before Map (100). Every server plugin declares it the same way; the first declaration wins.
|
||||
/// The server's window on RynthCore's bar (plugin windows, API v89): its surface. Every server
|
||||
/// plugin uses the same one; only the active server's plugin declares its window.
|
||||
/// </summary>
|
||||
public const string SectionId = "server";
|
||||
public const string SectionLabel = "Server";
|
||||
public const int SectionOrder = 50;
|
||||
public const string WindowSurface = "window:server";
|
||||
public const string WindowId = "server";
|
||||
/// <summary>Phosphor's castle turret: the server's bar button.</summary>
|
||||
public const string WindowIcon = "";
|
||||
|
||||
/// <summary>
|
||||
/// The plugin's sections manifest (schema 1): its server, for RynthCore to detect, and the server
|
||||
/// card in the shared "Server" section, shown only while that server is active (detected or
|
||||
/// forced in RynthCore Options > Diagnostics). The card left the Char section on 2026-10-13: that
|
||||
/// section is Session Stats now, session stats only.
|
||||
/// <paramref name="pages"/> (ServerPackPages, already validated) are the server's own views:
|
||||
/// primary views of the same section, so each gets a sub-tab there, also only on that server.
|
||||
/// The plugin's sections manifest (schema 1): its server, for RynthCore to detect, and the server's
|
||||
/// own window on RynthCore's bar, named for the server ("Aelrynth", "Conquest"), only while that
|
||||
/// server is active (detected or forced in RynthCore Options > Diagnostics). The window holds
|
||||
/// everything the server has: the card first, then <paramref name="pages"/> as tabs
|
||||
/// (ServerPackUi.RenderTabs). Tom, 2026-10-24: every server its own spot on the bar, where everything
|
||||
/// is easy to find, not mixed in with the rest; until then the card and pages were sub-tabs of a
|
||||
/// shared "Server" section of the Mini Remote.
|
||||
/// </summary>
|
||||
public static string BuildSectionsJson(ServerPackInfo info, string pluginName, IReadOnlyList<ServerPage>? pages = null)
|
||||
{
|
||||
|
|
@ -175,33 +177,23 @@ internal sealed class ServerPackModel
|
|||
AppendList(sb, info.WorldNames);
|
||||
sb.Append("],\"hosts\":[");
|
||||
AppendList(sb, info.Hosts);
|
||||
sb.Append("]}],\"sections\":[{\"id\":").Append(Q(SectionId)).Append(",\"label\":").Append(Q(SectionLabel));
|
||||
sb.Append(",\"order\":").Append(SectionOrder).Append("}],\"contributions\":[{\"section\":").Append(Q(SectionId));
|
||||
sb.Append(",\"server\":").Append(Q(info.Id));
|
||||
sb.Append(",\"label\":").Append(Q(info.Name + " server (" + pluginName + ")"));
|
||||
sb.Append(",\"surface\":").Append(Q(SurfaceFor(info.Id)));
|
||||
sb.Append(",\"primary\":false,\"height\":320,\"enabled\":true,\"tooltip\":");
|
||||
sb.Append(Q("What is known about " + info.Name + ": rules, account limits, botting policy, links and setup ("
|
||||
+ pluginName + "; also /rserver)."));
|
||||
sb.Append(",\"order\":130}");
|
||||
if (pages != null)
|
||||
{
|
||||
for (int i = 0; i < pages.Count; i++)
|
||||
{
|
||||
ServerPage p = pages[i];
|
||||
sb.Append(",{\"section\":").Append(Q(SectionId));
|
||||
sb.Append(",\"server\":").Append(Q(info.Id));
|
||||
sb.Append(",\"label\":").Append(Q(p.Label));
|
||||
sb.Append(",\"surface\":").Append(Q(ServerPackPages.SurfaceFor(info.Id, p.Id)));
|
||||
sb.Append(",\"primary\":true,\"width\":").Append(ServerPackPages.Width).Append(",\"height\":").Append(ServerPackPages.Height);
|
||||
sb.Append(",\"enabled\":true,\"tooltip\":").Append(Q(p.Tooltip.Length > 0 ? p.Tooltip : p.Label + " (" + pluginName + ")"));
|
||||
sb.Append(",\"order\":").Append(100 + i).Append('}');
|
||||
}
|
||||
}
|
||||
sb.Append("]}");
|
||||
bool tabs = pages != null && pages.Count > 0;
|
||||
sb.Append("]}],\"windows\":[{\"id\":").Append(Q(WindowId));
|
||||
sb.Append(",\"title\":").Append(Q(WindowTitle(info)));
|
||||
sb.Append(",\"surface\":").Append(Q(WindowSurface));
|
||||
sb.Append(",\"icon\":").Append(Q(WindowIcon));
|
||||
sb.Append(",\"width\":").Append(tabs ? ServerPackPages.Width : 460).Append(",\"height\":").Append(ServerPackPages.Height);
|
||||
sb.Append(",\"minWidth\":320,\"minHeight\":200,\"bar\":true,\"server\":").Append(Q(info.Id));
|
||||
sb.Append("}]}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The window's title, which is also its panel key (saved place, /rc commands, the bar button's
|
||||
/// tooltip): the server's name, so each server is its own spot.
|
||||
/// </summary>
|
||||
public static string WindowTitle(ServerPackInfo info) => info.Name.Trim().Length > 0 ? info.Name.Trim() : info.Id;
|
||||
|
||||
private static void AppendList(StringBuilder sb, string[] values)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++) sb.Append(i == 0 ? "" : ",").Append(Q(values[i]));
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
// Leaderboards pages, RynthAelrynth's Leaderboards, ...).
|
||||
//
|
||||
// A server's own features need somewhere to show. The ServerPackPlugin.ServerPages hook lists them
|
||||
// once, at construction; the shared code then
|
||||
// * declares each one in the sections manifest as a primary view of the shared "Server" section,
|
||||
// shown only while this plugin's server is active (contribution "server": <id>), so RynthCore's
|
||||
// Mini Remote gives it a sub-tab next to the server card;
|
||||
// * draws it through RynthPluginRenderEmbed under the surface "section:server-<id>.<page>"
|
||||
// (":popout" added in a popped-out window), into the engine's current window and context;
|
||||
// * shows the same pages as tabs of the standalone "/rserver" window, after the card.
|
||||
// once, at construction; the shared code then shows them as tabs after the card in the server's own
|
||||
// window on RynthCore's bar (named for the server, only while it is active: ServerPackModel's
|
||||
// "windows", 2026-10-24), and in the standalone "/rserver" window on engines without plugin windows.
|
||||
// Until 2026-10-24 each was also a sub-tab of the Mini Remote's shared "Server" section, drawn under
|
||||
// the surface "section:server-<id>.<page>" (RynthPluginRenderEmbed still answers it).
|
||||
// Draw runs on the render thread: a page reads its state under its own lock and queues anything it
|
||||
// sends for the plugin tick (ServerPackPlugin.RunOnTick).
|
||||
// Pure (no ImGui, no host calls): RynthServerPack.Tests covers it.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ using System.Collections.Generic;
|
|||
using System.Runtime.InteropServices;
|
||||
using ImGuiNET;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
|
|
@ -269,6 +270,28 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
|||
/// </summary>
|
||||
internal bool RenderEmbeddedCard(out float wantHeight) => RenderEmbedded(_ui.RenderBody, "Server card", out wantHeight);
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "window:server": the server's window on RynthCore's bar, the card and the
|
||||
/// server's pages as tabs. Render thread.
|
||||
/// </summary>
|
||||
internal bool RenderEmbeddedWindow(out float wantHeight) => RenderEmbedded(_ui.RenderTabs, "Server window", out wantHeight);
|
||||
|
||||
/// <summary>
|
||||
/// /rserver show|hide|toggle: the server's window on RynthCore's bar when the engine hosts it (plugin
|
||||
/// windows, v89), else the standalone window this plugin draws itself (older engines).
|
||||
/// </summary>
|
||||
private void SetWindow(RynthPanelOpen mode)
|
||||
{
|
||||
string title = ServerPackModel.WindowTitle(Info);
|
||||
if (Host.HasSetPanelOpen && Host.SetPanelOpen(title, RynthPanelOpen.Ask) >= 0)
|
||||
{
|
||||
_ui.WindowOpen = false;
|
||||
Host.SetPanelOpen(title, mode);
|
||||
return;
|
||||
}
|
||||
_ui.WindowOpen = mode switch { RynthPanelOpen.Open => true, RynthPanelOpen.Close => false, _ => !_ui.WindowOpen };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "section:server-<id>.<page>": one of the server's pages
|
||||
/// (ServerPages) in RynthCore's Mini Remote. False for a page this plugin doesn't have, or before login.
|
||||
|
|
@ -354,13 +377,13 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
|||
switch (verb)
|
||||
{
|
||||
case "show":
|
||||
_ui.WindowOpen = true;
|
||||
SetWindow(RynthPanelOpen.Open);
|
||||
return;
|
||||
case "hide":
|
||||
_ui.WindowOpen = false;
|
||||
SetWindow(RynthPanelOpen.Close);
|
||||
return;
|
||||
case "toggle":
|
||||
_ui.WindowOpen = !_ui.WindowOpen;
|
||||
SetWindow(RynthPanelOpen.Toggle);
|
||||
return;
|
||||
case "auto":
|
||||
case "on":
|
||||
|
|
|
|||
|
|
@ -49,30 +49,34 @@ internal sealed class ServerPackUi
|
|||
if (!WindowOpen) return;
|
||||
ImGui.SetNextWindowSize(new Vector2(_pages.Count > 0 ? 560 : 460, 520), ImGuiCond.FirstUseEver);
|
||||
bool open = WindowOpen;
|
||||
if (ImGui.Begin(_windowTitle, ref open))
|
||||
{
|
||||
if (_pages.Count == 0) RenderBody();
|
||||
else if (ImGui.BeginTabBar("##server_tabs_" + _model.Info.Id))
|
||||
{
|
||||
if (ImGui.BeginTabItem("Server##card"))
|
||||
{
|
||||
RenderBody();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
foreach (ServerPage page in _pages)
|
||||
{
|
||||
if (!ImGui.BeginTabItem(page.Label + "##page_" + page.Id)) continue;
|
||||
if (ImGui.BeginChild("##page_body_" + page.Id)) page.Draw();
|
||||
ImGui.EndChild();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
}
|
||||
if (ImGui.Begin(_windowTitle, ref open)) RenderTabs();
|
||||
ImGui.End();
|
||||
WindowOpen = open;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Everything the server has, into the current window: the card, then its pages as tabs when it has
|
||||
/// some. The server's window on RynthCore's bar (ServerPackModel's "windows") and the standalone one.
|
||||
/// </summary>
|
||||
public void RenderTabs()
|
||||
{
|
||||
if (_pages.Count == 0) { RenderBody(); return; }
|
||||
if (!ImGui.BeginTabBar("##server_tabs_" + _model.Info.Id)) return;
|
||||
if (ImGui.BeginTabItem("Server##card"))
|
||||
{
|
||||
RenderBody();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
foreach (ServerPage page in _pages)
|
||||
{
|
||||
if (!ImGui.BeginTabItem(page.Label + "##page_" + page.Id)) continue;
|
||||
if (ImGui.BeginChild("##page_body_" + page.Id)) page.Draw();
|
||||
ImGui.EndChild();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
|
||||
/// <summary>The card's content, into the current window.</summary>
|
||||
public void RenderBody()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,9 +113,10 @@ internal static class AelrynthTests
|
|||
ServerPackInfo info = new("aelrynth", "Aelrynth", new[] { "aelrynth.com" }, new[] { "Aelrynth*", "Aeshnidae*" });
|
||||
SectionManifest m = SectionManifestParser.Parse("RynthAelrynth", ServerPackModel.BuildSectionsJson(info, "RynthAelrynth", pages), out string error);
|
||||
Check.Eq(error, "", "RynthCore parses the manifest");
|
||||
SectionContribution view = m.Contributions.Single(c => c.Primary);
|
||||
Check.True(view.Server == "aelrynth" && view.Label == "Leaderboards" && view.Surface == "section:server-aelrynth.boards",
|
||||
"Leaderboards, only while Aelrynth is active");
|
||||
SectionWindowDecl window = m.Windows.Single();
|
||||
Check.True(window.Title == "Aelrynth" && window.Bar && window.Server == "aelrynth" && window.Surface == "window:server",
|
||||
"the Aelrynth window on the bar (its Leaderboards a tab in it), only while Aelrynth is active");
|
||||
Check.Eq(m.Contributions.Length, 0, "nothing in the Mini Remote");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -208,9 +208,9 @@ internal static class ConquestTests
|
|||
ServerPackInfo info = new("conquest", "Conquest", new[] { "acconquest.ddns.net" }, new[] { "Conquest", "ConquestAC" });
|
||||
SectionManifest m = SectionManifestParser.Parse("RynthConquest", ServerPackModel.BuildSectionsJson(info, "RynthConquest", pages), out string error);
|
||||
Check.Eq(error, "", "RynthCore parses the manifest");
|
||||
SectionContribution[] views = m.Contributions.Where(c => c.Primary).ToArray();
|
||||
Check.Eq(views.Length, 2, "two pages in the Mini Remote");
|
||||
Check.True(views.All(c => c.Server == "conquest"), "shown only while Conquest is active");
|
||||
Check.True(views.Select(c => c.Surface).SequenceEqual(new[] { "section:server-conquest.main", "section:server-conquest.boards" }), "their surfaces");
|
||||
SectionWindowDecl window = m.Windows.Single();
|
||||
Check.True(window.Title == "Conquest" && window.Bar && window.Server == "conquest",
|
||||
"the Conquest window on the bar (Conquest and Leaderboards are tabs in it), only while Conquest is active");
|
||||
Check.Eq(m.Contributions.Length, 0, "nothing in the Mini Remote");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,24 +81,16 @@ internal static class ServerPackHooksTests
|
|||
string json = ServerPackModel.BuildSectionsJson(info, "RynthConquest", pages);
|
||||
SectionManifest m = SectionManifestParser.Parse("RynthConquest", json, out string error);
|
||||
Check.Eq(error, "", "RynthCore parses it");
|
||||
Check.Eq(m.Contributions.Length, 3, "the card and two pages");
|
||||
SectionContribution card = m.Contributions.Single(c => !c.Primary);
|
||||
Check.Eq(card.Surface, "section:server-conquest", "the card keeps its surface");
|
||||
SectionContribution[] views = m.Contributions.Where(c => c.Primary).ToArray();
|
||||
Check.True(views.All(c => c.Section == ServerPackModel.SectionId && c.Server == "conquest" && c.IsSurface),
|
||||
"pages: primary views of the Server section, only on Conquest");
|
||||
Check.Eq(views[0].Surface, "section:server-conquest.main", "page surface");
|
||||
Check.Eq(views[0].Label, "Conquest", "page label");
|
||||
Check.Eq(views[0].Tooltip, "Bank, augs and more", "page tooltip");
|
||||
Check.Eq(views[1].Tooltip, "Leaderboards (RynthConquest)", "a default tooltip");
|
||||
Check.True(views[0].Order < views[1].Order, "pages keep their order");
|
||||
Check.True(views[0].Width > 0 && views[0].Height > 0, "pages say their size");
|
||||
// Tom 10-24: the card and the pages are one window on RynthCore's bar (pages are its tabs), not Mini Remote sub-tabs.
|
||||
Check.Eq(m.Contributions.Length, 0, "nothing in the Mini Remote");
|
||||
SectionWindowDecl window = m.Windows.Single();
|
||||
Check.True(window.Title == "Conquest" && window.Bar && window.Server == "conquest" && window.Surface == ServerPackModel.WindowSurface,
|
||||
"one window named for the server, with a bar button, only on Conquest");
|
||||
Check.True(window.Icon == ServerPackModel.WindowIcon && window.Width >= ServerPackPages.Width && window.Height > 0, "its icon and a size that fits the tabs");
|
||||
|
||||
// Without pages the manifest is byte for byte what it was.
|
||||
Check.Eq(ServerPackModel.BuildSectionsJson(info, "RynthConquest", null), ServerPackModel.BuildSectionsJson(info, "RynthConquest"),
|
||||
"no pages: the old manifest");
|
||||
Check.Eq(SectionManifestParser.Parse("x", ServerPackModel.BuildSectionsJson(info, "RynthConquest"), out _).Contributions.Length, 1,
|
||||
"no pages: only the card");
|
||||
// Without pages: the same window, narrower (the card alone).
|
||||
SectionWindowDecl alone = SectionManifestParser.Parse("x", ServerPackModel.BuildSectionsJson(info, "RynthConquest"), out _).Windows.Single();
|
||||
Check.True(alone.Title == "Conquest" && alone.Width < window.Width, "no pages: the card's window");
|
||||
}
|
||||
|
||||
private static void SettingsRoundTrip()
|
||||
|
|
|
|||
|
|
@ -204,14 +204,13 @@ internal static class ServerPackModelTests
|
|||
Check.Eq(server.GetProperty("id").GetString(), "coldeve", "server id lower-cased");
|
||||
Check.Eq(server.GetProperty("hosts")[0].GetString(), "play.coldeve.ac", "hosts");
|
||||
Check.Eq(server.GetProperty("worldNames")[0].GetString(), "Coldeve", "world names");
|
||||
JsonElement card = root.GetProperty("contributions")[0];
|
||||
Check.Eq(card.GetProperty("section").GetString(), "server", "in the Server section (not Session Stats)");
|
||||
JsonElement section = root.GetProperty("sections")[0];
|
||||
Check.Eq(section.GetProperty("id").GetString(), "server", "the Server section is declared");
|
||||
Check.Eq(section.GetProperty("label").GetString(), "Server", "its label");
|
||||
Check.Eq(section.GetProperty("order").GetInt32(), 50, "after Session Stats, before Map");
|
||||
Check.Eq(card.GetProperty("server").GetString(), "coldeve", "only while Coldeve is active");
|
||||
Check.Eq(card.GetProperty("surface").GetString(), "section:server-coldeve", "the card's surface");
|
||||
// Tom 10-24: every server its own spot on RynthCore's bar, not mixed in with the rest.
|
||||
Check.False(root.TryGetProperty("contributions", out _) || root.TryGetProperty("sections", out _), "nothing in the Mini Remote");
|
||||
JsonElement window = root.GetProperty("windows")[0];
|
||||
Check.Eq(window.GetProperty("title").GetString(), "Coldeve", "its own window, named for the server");
|
||||
Check.True(window.GetProperty("bar").GetBoolean(), "with a button on the bar");
|
||||
Check.Eq(window.GetProperty("server").GetString(), "coldeve", "only while Coldeve is active");
|
||||
Check.Eq(window.GetProperty("surface").GetString(), "window:server", "drawn by the plugin");
|
||||
|
||||
var quoted = new ServerPackInfo("odd", "Odd \"Name\"\n", new[] { "a\\b" }, Array.Empty<string>());
|
||||
using JsonDocument odd = JsonDocument.Parse(ServerPackModel.BuildSectionsJson(quoted, "RynthOdd"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue