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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue