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>
108 lines
3.5 KiB
C#
108 lines
3.5 KiB
C#
// DreamWeavePlugin.cs - RynthDreamWeave's own features, through the shared server plugin's hooks
|
|
// (Plugins/Shared/ServerPack/ServerPackPlugin.cs): the every-minute bank check that gives Lum/hr its
|
|
// luminance on DreamWeave (DreamWeave/DreamWeaveBank.cs, 2026-11-02), published as the profile value
|
|
// "bankLuminance" for the session stats, and its Bank page (DreamWeave/DreamWeavePages.cs).
|
|
// The website buttons and verbs (DreamWeaveWebTools.cs) share these hooks: each one below hands off to
|
|
// its Web* method first, so a launch-code line is read whatever the world is and the bank's own gates
|
|
// stay as they were.
|
|
using System;
|
|
using RynthCore.Plugin.RynthDreamWeave;
|
|
|
|
namespace RynthCore.Plugin.ServerPack;
|
|
|
|
public sealed partial class ServerPackPlugin
|
|
{
|
|
private readonly DreamWeaveBank _bank = new();
|
|
|
|
partial void ServerPages(System.Collections.Generic.List<ServerPage> pages)
|
|
{
|
|
var bankPages = new DreamWeavePages(_bank, () => Active, RunOnTick, CheckBankNow, SaveDreamWeaveSettings);
|
|
pages.AddRange(bankPages.Pages());
|
|
AddCharacterPage(pages); // DreamWeaveSkills.cs: the Character panel's page
|
|
}
|
|
|
|
partial void ServerInitialize()
|
|
{
|
|
lock (_bank.Gate) _bank.LoadSettings(Settings);
|
|
}
|
|
|
|
private void SaveDreamWeaveSettings()
|
|
{
|
|
lock (_bank.Gate) _bank.SaveSettings(Settings);
|
|
}
|
|
|
|
partial void ServerLoginComplete()
|
|
{
|
|
WebLoginComplete();
|
|
lock (_bank.Gate) _bank.Login(Environment.TickCount64);
|
|
}
|
|
|
|
partial void ServerLogout()
|
|
{
|
|
WebLogout();
|
|
lock (_bank.Gate) _bank.Logout();
|
|
}
|
|
|
|
partial void ServerShutdown()
|
|
{
|
|
WebShutdown();
|
|
SaveDreamWeaveSettings();
|
|
}
|
|
|
|
partial void ServerChatText(string text, int chatType, ref bool eat)
|
|
{
|
|
WebChatText(text, chatType, ref eat);
|
|
if (!Active) return;
|
|
bool ours;
|
|
long? value;
|
|
lock (_bank.Gate)
|
|
{
|
|
ours = _bank.OnChatLine(text, Environment.TickCount64);
|
|
value = _bank.Published;
|
|
}
|
|
if (value is long v) SetProfileValue(DreamWeaveBank.LuminanceKey, v);
|
|
if (ours) eat = true;
|
|
}
|
|
|
|
partial void ServerChatBar(string text)
|
|
{
|
|
// The player's own /b: its reply shows (DreamWeaveBank tells it from RynthDreamWeave's).
|
|
if (DreamWeaveBank.IsBalanceCommand(text)) _bank.NoteTypedCommand();
|
|
}
|
|
|
|
partial void ServerTick(bool active)
|
|
{
|
|
WebTick();
|
|
if (!active) return;
|
|
string? check;
|
|
lock (_bank.Gate)
|
|
{
|
|
_bank.Tick();
|
|
check = _bank.CheckDue(Environment.TickCount64);
|
|
}
|
|
if (check != null && !Send(check)) lock (_bank.Gate) _bank.NotSent();
|
|
}
|
|
|
|
/// <summary>The page's Check now (on the tick).</summary>
|
|
private void CheckBankNow()
|
|
{
|
|
if (!Active) return;
|
|
string command;
|
|
lock (_bank.Gate) command = _bank.Request(Environment.TickCount64);
|
|
if (!Send(command))
|
|
{
|
|
lock (_bank.Gate) _bank.NotSent();
|
|
ChatFail($"[{RynthPluginInfo.Name}] Couldn't send {command}.");
|
|
}
|
|
}
|
|
|
|
partial void ServerInfoLines(Action<string> line)
|
|
{
|
|
lock (_bank.Gate)
|
|
{
|
|
string lum = _bank.Luminance is long l ? l.ToString("N0", System.Globalization.CultureInfo.InvariantCulture) : "not read yet";
|
|
line($"Bank check every minute {(_bank.CheckEveryMinute ? "on" : "off")}; banked luminance {lum}.");
|
|
}
|
|
WebInfoLines(line);
|
|
}
|
|
}
|