DreamWeaveWebTools.cs wires the launcher into the ServerPack hooks: the card buttons (render thread, draw only, a click queues StartLaunch with RunOnTick), the /rserver market|suit|abilities verbs, the /weblogin reply read off chat (Code, Refused and Stale eat the line; Stale does nothing else), the 10 s timeout polled every tick, and Reset at login, logout and shutdown. Every launcher call is under lock (Gate); Send, OpenWeb, Reply and the log are always outside it. OpenWeb's answer replaces the "Opening X..." status. WebButtons.cs draws the buttons and is the only ImGui code in the web tools. A source-scan test pins the thread rules. Rebased onto release 2026.11.8.1, which ships its own DreamWeavePlugin.cs (bank check, Bank page) and DreamWeaveSkills.cs (Skills and Character panels, /rserver skills). Those files keep the one implementation of each shared hook and call the web tools' Web* method first; the web code lives in DreamWeaveWebTools.cs. The ImGui scan covers the web tools' own files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2 KiB
C#
55 lines
2 KiB
C#
// The DreamWeave card's website buttons (Market, Suit Builder, Ability Planner). Render thread, inside
|
|
// the card hook only: this file draws and nothing else. It calls no host function, sends nothing and
|
|
// opens nothing; a click is handed to the caller, which queues the work for the tick (RunOnTick).
|
|
// It never switches the ImGui context (RenderEmbedded and OnRender own it), and it draws no
|
|
// Begin/End or Push/Pop pairs, so an exception part-way can't leave ImGui's stacks unbalanced.
|
|
using System;
|
|
using ImGuiNET;
|
|
using RynthCore.Plugin.Shared;
|
|
|
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
|
|
|
internal static class WebButtons
|
|
{
|
|
/// <summary>Shown on the card, and answered to a verb, when RynthCore doesn't see the world as DreamWeave.</summary>
|
|
public const string NotDreamWeave = "The web tools are DreamWeave's; RynthCore doesn't see this world as DreamWeave.";
|
|
|
|
/// <summary>
|
|
/// One small button per destination on one row, each with its tooltip; while a request is pending,
|
|
/// the status line instead. The launcher's state is copied out under its lock first, then drawn.
|
|
/// </summary>
|
|
public static void Draw(WebLauncher l, bool active, Action<WebDestination> click)
|
|
{
|
|
if (!active)
|
|
{
|
|
SafeImGui.TextWrapped(NotDreamWeave);
|
|
return;
|
|
}
|
|
|
|
bool pending;
|
|
string status;
|
|
lock (l.Gate)
|
|
{
|
|
pending = l.Pending != null;
|
|
status = l.Status;
|
|
}
|
|
|
|
if (pending)
|
|
{
|
|
SafeImGui.TextDisabled(status);
|
|
return;
|
|
}
|
|
|
|
WebDestination? clicked = null;
|
|
bool first = true;
|
|
foreach (WebDestination d in DreamWeaveWeb.Destinations)
|
|
{
|
|
if (!first) ImGui.SameLine();
|
|
first = false;
|
|
if (ImGui.SmallButton(d.Label + "##dw_web_" + d.Id)) clicked = d;
|
|
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(d.Tooltip);
|
|
}
|
|
if (status.Length > 0) SafeImGui.TextWrapped(status);
|
|
if (clicked != null) click(clicked);
|
|
}
|
|
}
|