RynthDreamWeave: web links in the bar icon's dropdown; card buttons only on older engines
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4afb8f3ac3
commit
1d7605db23
3 changed files with 97 additions and 0 deletions
|
|
@ -2,6 +2,8 @@
|
|||
// (the site's registry: dreamweave-market Source/ACE.Market/Site/SiteTools.cs and HostRouting.cs);
|
||||
// nothing here is ever read from chat. Pure, so RynthServerPack.Tests compiles it directly.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
|
||||
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||
|
||||
|
|
@ -24,6 +26,30 @@ internal static class DreamWeaveWeb
|
|||
new("abilities", "Ability Planner", "/tools/abilities", "Plan a class ability build."),
|
||||
};
|
||||
|
||||
/// <summary>The first engine API that draws a plugin window's bar-icon dropdown from the manifest's barMenu.</summary>
|
||||
internal const uint BarMenuEngineApi = 94;
|
||||
|
||||
/// <summary>Whether an engine of this API version draws the bar menu (so the card's buttons are redundant).</summary>
|
||||
internal static bool EngineDrawsBarMenu(uint engineVersion) => engineVersion >= BarMenuEngineApi;
|
||||
|
||||
/// <summary>The Phosphor glyph (private-use character) for a destination's menu item; "" when it has none.</summary>
|
||||
internal static string Icon(string id) => id switch
|
||||
{
|
||||
"market" => ((char)0xE470).ToString(), // Storefront
|
||||
"suit" => ((char)0xE40A).ToString(), // Shield
|
||||
"abilities" => ((char)0xE6A2).ToString(), // Sparkle
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
/// <summary>One bar-menu item per destination: id, label as tooltip, glyph, and the /rserver verb.</summary>
|
||||
internal static List<ServerBarMenuItem> BarMenu()
|
||||
{
|
||||
var items = new List<ServerBarMenuItem>(Destinations.Length);
|
||||
foreach (WebDestination d in Destinations)
|
||||
items.Add(new ServerBarMenuItem(d.Id, d.Label, Icon(d.Id), "/rserver " + d.Id));
|
||||
return items;
|
||||
}
|
||||
|
||||
public static WebDestination? ById(string? id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return null;
|
||||
|
|
|
|||
|
|
@ -59,10 +59,25 @@ public sealed partial class ServerPackPlugin
|
|||
}
|
||||
}
|
||||
|
||||
partial void ServerBarMenu(List<ServerBarMenuItem> items)
|
||||
{
|
||||
try
|
||||
{
|
||||
items.AddRange(DreamWeaveWeb.BarMenu());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// The constructor has no Host to log to yet; the destinations are constants.
|
||||
}
|
||||
}
|
||||
|
||||
partial void ServerCardActions()
|
||||
{
|
||||
try
|
||||
{
|
||||
// An engine that draws the bar icon's dropdown carries the links; the card keeps its buttons
|
||||
// (and the status line) only for older engines, so no one loses them.
|
||||
if (DreamWeaveWeb.EngineDrawsBarMenu(Host.Version)) return;
|
||||
WebButtons.Draw(_web, Active, _webClick ??= d => RunOnTick(() => StartLaunch(d)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
Loading…
Reference in a new issue