Snapshot for release 2026.10.28.3 (internal 1eeafca)
This commit is contained in:
parent
f9ae10d692
commit
0bfe184288
19 changed files with 1510 additions and 454 deletions
|
|
@ -1130,12 +1130,16 @@ internal static class AcMainThreadQueue
|
|||
// Dispatch() itself (rather than at each caller) covers all three at once.
|
||||
// A full command line can't ride the uint Entry ring, so it gets its own
|
||||
// string queue, same shape as the WriteToChat slot above.
|
||||
private static readonly System.Collections.Generic.Queue<(string Text, long At, int Epoch)> _chatCommandQueue = new();
|
||||
private static readonly System.Collections.Generic.Queue<(string Text, long At, int Epoch, ChatCommandOrigin Origin)> _chatCommandQueue = new();
|
||||
private static readonly object _chatCommandLock = new();
|
||||
private const int MaxChatCommandQueue = 64;
|
||||
|
||||
// Off-thread enqueue. Drops (returns false) if the queue is full.
|
||||
public static bool EnqueueChatCommand(string text)
|
||||
public static bool EnqueueChatCommand(string text) => EnqueueChatCommand(text, ChatCommandOrigin.Script);
|
||||
|
||||
// The same, saying who sent the line (Player: a RynthCore hotkey), for the answer of an engine
|
||||
// /rc command (ChatCommandDispatcher.Dispatch, RynthCoreChatCommands).
|
||||
public static bool EnqueueChatCommand(string text, ChatCommandOrigin origin)
|
||||
{
|
||||
lock (_chatCommandLock)
|
||||
{
|
||||
|
|
@ -1144,7 +1148,7 @@ internal static class AcMainThreadQueue
|
|||
Interlocked.Increment(ref _dropped);
|
||||
return false;
|
||||
}
|
||||
_chatCommandQueue.Enqueue((text, NowMs, Volatile.Read(ref _loginEpoch)));
|
||||
_chatCommandQueue.Enqueue((text, NowMs, Volatile.Read(ref _loginEpoch), origin));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1162,7 +1166,7 @@ internal static class AcMainThreadQueue
|
|||
int epoch = Volatile.Read(ref _loginEpoch);
|
||||
while (budget-- > 0)
|
||||
{
|
||||
(string Text, long At, int Epoch) item;
|
||||
(string Text, long At, int Epoch, ChatCommandOrigin Origin) item;
|
||||
lock (_chatCommandLock)
|
||||
{
|
||||
if (_chatCommandQueue.Count == 0) return;
|
||||
|
|
@ -1173,7 +1177,7 @@ internal static class AcMainThreadQueue
|
|||
NoteStale("a chat command", now - item.At, dropped: true);
|
||||
continue;
|
||||
}
|
||||
try { ChatCommandDispatcher.Dispatch(item.Text); }
|
||||
try { ChatCommandDispatcher.Dispatch(item.Text, item.Origin); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -563,12 +563,18 @@ internal static class ChatCallbackHooks
|
|||
|
||||
// RynthCore engine commands (/rc ...) — consume before plugins or
|
||||
// AC see the line so the user never broadcasts "/rc resetbar" and
|
||||
// a hidden overlay bar stays recoverable.
|
||||
if (RynthCoreChatCommands.TryHandle(line))
|
||||
// a hidden overlay bar stays recoverable. Typed by the player: every
|
||||
// reply goes to chat.
|
||||
if (RynthCoreChatCommands.TryHandle(line, ChatCommandOrigin.Player))
|
||||
return 1;
|
||||
|
||||
if (PluginManager.DispatchChatBarEnter(line))
|
||||
return 1;
|
||||
// A /rc line a plugin runs while it handles this one (RynthAi's /ra videopatch) is the
|
||||
// player's too, so it answers in chat.
|
||||
using (RynthCoreChatCommands.PlayerLine())
|
||||
{
|
||||
if (PluginManager.DispatchChatBarEnter(line))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return _originalOutgoingChat!(thisPtr, text, commandSource);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,14 @@ internal static unsafe class ChatCommandDispatcher
|
|||
}
|
||||
}
|
||||
|
||||
public static bool Dispatch(string? text)
|
||||
/// <summary>A line from a plugin, a command file or the login commands (<see cref="ChatCommandOrigin.Script"/>).</summary>
|
||||
public static bool Dispatch(string? text) => Dispatch(text, ChatCommandOrigin.Script);
|
||||
|
||||
/// <summary>
|
||||
/// Runs a chat line as if typed. <paramref name="origin"/> says who sent it, for the answer of an
|
||||
/// engine /rc command (RynthCoreChatCommands): Player for a RynthCore hotkey, Script for the rest.
|
||||
/// </summary>
|
||||
public static bool Dispatch(string? text, ChatCommandOrigin origin)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return false;
|
||||
|
|
@ -128,7 +135,7 @@ internal static unsafe class ChatCommandDispatcher
|
|||
// from the drain, where IsOnMainThread is satisfied and the body
|
||||
// below runs directly — so there's only one code path to keep in sync.
|
||||
if (!MainThreadGuard.IsOnMainThread())
|
||||
return AcMainThreadQueue.EnqueueChatCommand(text);
|
||||
return AcMainThreadQueue.EnqueueChatCommand(text, origin);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -139,7 +146,7 @@ internal static unsafe class ChatCommandDispatcher
|
|||
// RynthCore engine commands (/rc ...) are handled before plugin
|
||||
// pre-dispatch and before any AC chat routing so they work even
|
||||
// when the overlay is hidden and no plugin can eat the line.
|
||||
if (RynthCoreChatCommands.TryHandle(trimmed))
|
||||
if (RynthCoreChatCommands.TryHandle(trimmed, origin))
|
||||
return true;
|
||||
|
||||
// Expand shorthand: /s → /say, /t → /tell, /e → /emote
|
||||
|
|
@ -161,7 +168,15 @@ internal static unsafe class ChatCommandDispatcher
|
|||
_inPluginPreDispatch = true;
|
||||
try
|
||||
{
|
||||
if (PluginManager.DispatchChatBarEnter(trimmed))
|
||||
// The player's line (a hotkey's /ra command): a /rc line a plugin runs while it
|
||||
// handles it is the player's too (RynthCoreChatCommands.PlayerLine).
|
||||
if (origin == ChatCommandOrigin.Player)
|
||||
{
|
||||
using (RynthCoreChatCommands.PlayerLine())
|
||||
if (PluginManager.DispatchChatBarEnter(trimmed))
|
||||
return true;
|
||||
}
|
||||
else if (PluginManager.DispatchChatBarEnter(trimmed))
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
376
src/RynthCore.Engine/Compatibility/ChatCommandReplies.cs
Normal file
376
src/RynthCore.Engine/Compatibility/ChatCommandReplies.cs
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/ChatCommandReplies.cs
|
||||
//
|
||||
// How the engine's chat commands (/rc ..., /rv plates) answer. Every command a
|
||||
// player types gets a clear line back: what changed and the value now, or why
|
||||
// not with the usage (2026-10-28: "It should tell you whether it worked for
|
||||
// every single command a player punches in").
|
||||
//
|
||||
// The pure part (no AC, no engine state), so tools\ChatCommandReplyTests can
|
||||
// compile it in: who a line came from and whether a reply goes to chat or only
|
||||
// to the log, the two reply colours, every verb with its usage, the argument
|
||||
// check made before a command runs, and the reply texts built from plain
|
||||
// values. Writing the reply (log + chat) is RynthCoreChatCommands.Reply.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
/// <summary>Who an engine command line came from (<see cref="RynthCoreChatCommands.TryHandle"/>).</summary>
|
||||
internal enum ChatCommandOrigin
|
||||
{
|
||||
/// <summary>
|
||||
/// A plugin (Host.InvokeChatParser: a meta, a window's button), the command files (dispatch.txt,
|
||||
/// RynthRemote's sendchat), the login commands, or one of the engine's own buttons and menus.
|
||||
/// A reply that says it worked goes to the log only; one that says it didn't still goes to chat.
|
||||
/// </summary>
|
||||
Script = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The player: typed in AC's chat bar or RynthChat's, a RynthCore hotkey, or a line a plugin passes
|
||||
/// on while it handles one the player typed (/ra videopatch runs /rc videopatch). Every reply goes
|
||||
/// to chat.
|
||||
/// </summary>
|
||||
Player = 1,
|
||||
}
|
||||
|
||||
/// <summary>What a reply says: it worked (or here is the state), or it didn't.</summary>
|
||||
internal enum ChatReplyKind
|
||||
{
|
||||
Ok = 0,
|
||||
Fail = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One engine verb: its name, other spellings, usage, and the argument check made before it runs
|
||||
/// (<see cref="Args"/> null: the command's own handler checks its arguments and answers with its usage).
|
||||
/// </summary>
|
||||
internal sealed record ChatVerb(string Name, string[] Aliases, string Usage, Func<string, bool>? Args);
|
||||
|
||||
/// <summary>What the check before a command runs found: the verb (null: unknown), its arguments, and
|
||||
/// the reply when the command can't run (null: run it).</summary>
|
||||
internal readonly record struct ChatVerbCheck(ChatVerb? Verb, string Args, string? Problem);
|
||||
|
||||
internal static class ChatCommandReplies
|
||||
{
|
||||
/// <summary>Every engine reply starts with this (the style since the first /rc command).</summary>
|
||||
public const string ReplyPrefix = "[RynthCore] ";
|
||||
|
||||
/// <summary>ChatMessageType 0x01, green in AC's chat: it worked, or the state.</summary>
|
||||
public const int OkChatType = 1;
|
||||
|
||||
/// <summary>ChatMessageType 0x1A, red: the type AC prints its own command notices in
|
||||
/// ("Someone must @tell you first!", ChatCommandDispatcher.ChatTypeNotice).</summary>
|
||||
public const int FailChatType = 0x1A;
|
||||
|
||||
// ── who sent it, where the reply goes ──────────────────────────────────
|
||||
|
||||
/// <summary>The origin a line is handled with: the player's when the caller says so, or when it
|
||||
/// arrives while a line the player typed is being handed on (RynthCoreChatCommands.PlayerLine).</summary>
|
||||
public static ChatCommandOrigin Effective(ChatCommandOrigin given, bool insidePlayerLine) =>
|
||||
given == ChatCommandOrigin.Player || insidePlayerLine ? ChatCommandOrigin.Player : ChatCommandOrigin.Script;
|
||||
|
||||
/// <summary>True when the reply goes to chat as well as the log: always for the player, and for
|
||||
/// anyone else only when it says the command didn't work.</summary>
|
||||
public static bool ToChat(ChatReplyKind kind, ChatCommandOrigin origin) =>
|
||||
kind == ChatReplyKind.Fail || origin == ChatCommandOrigin.Player;
|
||||
|
||||
/// <summary>The AC chat type (colour) a reply is written with.</summary>
|
||||
public static int ChatType(ChatReplyKind kind) => kind == ChatReplyKind.Fail ? FailChatType : OkChatType;
|
||||
|
||||
/// <summary>
|
||||
/// How the modules a command hands its arguments to (the video patch, flight recorder, report,
|
||||
/// AutoId, server messages, Discord relay, action gates) start a line that says the command
|
||||
/// didn't work. Their other lines are the state.
|
||||
/// </summary>
|
||||
private static readonly string[] FailOpenings =
|
||||
{
|
||||
"Usage", "Unknown", "Can't", "Not dumped", "Not capturing", "Capture failed", "Report not sent",
|
||||
"Log in first", "No route", "No hotkey on", "Which key", "Unlock skipped",
|
||||
"Video patch unavailable", "Video patch is switched off", "Flight recorder is off",
|
||||
"The server message stream is off", "The relay is off",
|
||||
};
|
||||
|
||||
/// <summary>Whether a line a module returned says the command didn't work.</summary>
|
||||
public static ChatReplyKind KindOfLine(string line)
|
||||
{
|
||||
string s = line.TrimStart();
|
||||
foreach (string f in FailOpenings)
|
||||
if (s.StartsWith(f, StringComparison.OrdinalIgnoreCase))
|
||||
return ChatReplyKind.Fail;
|
||||
return s.Contains("isn't available", StringComparison.OrdinalIgnoreCase) ? ChatReplyKind.Fail : ChatReplyKind.Ok;
|
||||
}
|
||||
|
||||
/// <summary>A module's reply lines as one answer: failed when any line says so.</summary>
|
||||
public static ChatReplyKind KindOfLines(IEnumerable<string> lines)
|
||||
{
|
||||
foreach (string l in lines)
|
||||
if (KindOfLine(l) == ChatReplyKind.Fail)
|
||||
return ChatReplyKind.Fail;
|
||||
return ChatReplyKind.Ok;
|
||||
}
|
||||
|
||||
// ── the verbs ──────────────────────────────────────────────────────────
|
||||
|
||||
public const string PlatesUsage =
|
||||
"Usage: /rv plates [on|off] | all on|off | self [numbers|name|firstperson|lock|debuffs] [on|off] | " +
|
||||
"self fixed|follow|unlock|reset | self debuffs size <50-200%> | " +
|
||||
"debuffs [on|off] | debuffs size <50-200%> | others [on|off] | numbers [dealt|taken|heals|kills] [on|off] | " +
|
||||
"gains [xp|lum|radiance] [on|off] | npcs [on|off] | npcs dist <yd>|max <n> | players [on|off] | portals [on|off] | portals dist <yd> | " +
|
||||
"all|engaged |dist <yd>|max <n>|scale <x>|opacity <x>|lift <m> | " +
|
||||
"names|hp|level|weak|distance|fade|click [on|off] | reset | status | test";
|
||||
|
||||
public const string ServerUsage =
|
||||
"Usage: /rc server [<server> auto|on|off] | pick <server>|auto | [aelrynth|other|auto] | names ilt [add|remove <pattern>]";
|
||||
|
||||
public const string HotkeyUsage =
|
||||
"Usage: /rc hotkey list | add <combo> <action or /command> | remove <combo> | enable|disable <combo> | actions | status | on|off";
|
||||
|
||||
/// <summary>The Classic dashboard look's tabs, in order (RynthAiDashboardState.SetClassicTab's index).</summary>
|
||||
public static readonly string[] ClassicTabNames = { "main", "monsters", "gear", "buffs", "route", "loot", "meta", "tuning" };
|
||||
|
||||
private static ChatVerb V(string name, string usage, Func<string, bool>? args, params string[] aliases) =>
|
||||
new(name, aliases, usage, args);
|
||||
|
||||
private static bool NoArgs(string a) => a.Length == 0;
|
||||
|
||||
private static Func<string, bool> Words(params string[] allowed) =>
|
||||
a => Array.Exists(allowed, w => w.Equals(a, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private static bool PanelArgs(string a) => TryPanelMode(a, out _);
|
||||
|
||||
/// <summary>
|
||||
/// Every /rc verb RynthCoreChatCommands answers. Keep it in step with TryHandle: a verb missing
|
||||
/// here is answered as unknown before its handler runs (tools\ChatCommandReplyTests reads TryHandle
|
||||
/// and checks both ways).
|
||||
/// </summary>
|
||||
public static readonly ChatVerb[] Verbs =
|
||||
{
|
||||
V("vendor", "Usage: /rc vendor list | info | status | buy <id|sel> [n] | sell <id|sel> [id ...]", null),
|
||||
V("imgui", "Usage: /rc imgui on|off|fonttest|diag", Words("", "on", "off", "fonttest", "diag")),
|
||||
V("ui", "Usage: /rc ui list | open|close|popout|redock|snap <Panel> | channels | retailvitals [on|off] | retailtoolbar [on|off] | barsize [0-10|+|-|status] | barrows [1-6|+|-] | baricons [2-30|none|+|-]", null),
|
||||
V("chathold", "Usage: /rc chathold [on|off|status]", Words("", "on", "off", "status")),
|
||||
V("discord", "Usage: /rc discord [on|off|status|window|test [route]|resume [route]]", null),
|
||||
V("plates", PlatesUsage, null, "nameplates"),
|
||||
V("server", ServerUsage, null),
|
||||
V("ilt", "Usage: /rc ilt [auto|on|off]", Words("", "on", "ilt", "off", "other", "auto")),
|
||||
V("mastery", "Usage: /rc mastery (the Aelrynth mastery feed's state; asks the server again)", null),
|
||||
V("worldlayer", "Usage: /rc worldlayer [auto|uipass|transition|endscene|status]",
|
||||
Words("", "status", "auto", "uipass", "ui", "transition", "zenable", "endscene")),
|
||||
V("acmouse", "Usage: /rc acmouse [watch [seconds]]", a => a.Length == 0 || IsVerb(a, "watch", out _), "mouseover"),
|
||||
V("video", "Usage: /rc video [status|enable|disable|off|world|unfocused|all|fps <n>]", null, "videopatch"),
|
||||
V("hooks", "Usage: /rc hooks [status] | /rc hooks on|off <name>", null, "uihooks"),
|
||||
V("flightdump", "Usage: /rc flightdump [note] | /rc flightdump auto <reason>", null),
|
||||
V("quit", "Usage: /rc quit (closes the client, as its close button)", null, "exit"),
|
||||
V("report", "Usage: /rc report [what went wrong] (alone: opens the Report a problem panel)", null),
|
||||
V("flight", "Usage: /rc flight [status|mark <text>|on|off|auto on|off]", null),
|
||||
V("autoid", "Usage: /rc autoid [all|limited|off] (alone: status)", null),
|
||||
V("netmsg", "Usage: /rc netmsg [status|on|off|log on|off|capture on|off]", null),
|
||||
V("vtank", "Usage: /rc vtank [clear]", Words("", "clear")),
|
||||
V("bounties", "Usage: /rc bounties [show|hide|toggle]", PanelArgs, "bounty", "bountys"),
|
||||
V("guardian", "Usage: /rc guardian [show|hide|toggle]", PanelArgs, "guardians"),
|
||||
V("dashboard", "Usage: /rc dashboard classic|modern|tab <" + string.Join("|", ClassicTabNames) + ">", DashboardArgs),
|
||||
V("miniremote", "Usage: /rc miniremote [show|hide|toggle|tab <tab>|section <id>]",
|
||||
a => TryPanelMode(a, out _) || IsVerb(a, "tab", out _) || IsVerb(a, "section", out _), "remote"),
|
||||
V("oracle-skills", "Usage: /rc oracle-skills <skills|attrs|progress|off>", a => OracleSkillsTab(a) != InvalidTab),
|
||||
V("skills", "Usage: /rc skills [show|hide|toggle]", PanelArgs),
|
||||
V("progression", "Usage: /rc progression (opens the Progress tab)", NoArgs, "progress"),
|
||||
V("spells", "Usage: /rc spells [show|hide|toggle]", PanelArgs),
|
||||
V("hotkeys", "Usage: /rc hotkeys (opens Settings > Hotkeys) | /rc hotkeys <verb> (as /rc hotkey)", null),
|
||||
V("diagnostics", "Usage: /rc diagnostics (opens Settings > Diagnostics, the server picker)", NoArgs, "serverpick"),
|
||||
V("settings", "Usage: /rc settings [tab]", null),
|
||||
V("shortcuts", "Usage: /rc shortcuts [use <1-18> | set <1-18> [id] | clear <1-18>]", ShortcutsArgs),
|
||||
V("keymap", "Usage: /rc keymap check|bind|unbind <action> <key> | dump, e.g. /rc keymap bind UseQuickSlot_10 F11", KeymapArgs),
|
||||
V("panels", "Usage: /rc panels [open|close|toggle <id>]", PanelsArgs),
|
||||
V("hotkey", HotkeyUsage, null),
|
||||
V("rl", "Usage: /rc rl (reloads RynthCore, as the bar's RL button)", NoArgs, "reload"),
|
||||
V("inventory", "Usage: /rc inventory (opens or closes the Inventory panel)", NoArgs, "inv"),
|
||||
V("sense", "Usage: /rc sense (opens or closes the Sense panel)", NoArgs),
|
||||
V("characters", "Usage: /rc characters (opens or closes RynthNet's Characters window)", NoArgs, "chars"),
|
||||
V("itemcount", "Usage: /rc itemcount (opens or closes the Item Count panel)", NoArgs, "itemhud"),
|
||||
V("resetbar", "Usage: /rc resetbar (moves the RynthCore bar back to the top-left corner)", NoArgs, "barreset"),
|
||||
V("actionstate", "Usage: /rc actionstate (the client's item-action gates)", NoArgs, "actions"),
|
||||
V("unlockactions", "Usage: /rc unlockactions (opens the client's item-action gates now)", NoArgs, "unlock"),
|
||||
V("vitals", "Usage: /rc vitals (the old vitals HUD is gone: /rv plates self)", NoArgs, "hud"),
|
||||
};
|
||||
|
||||
/// <summary>The verb <paramref name="word"/> names (its name or another spelling), or null.</summary>
|
||||
public static ChatVerb? Find(string word)
|
||||
{
|
||||
foreach (ChatVerb v in Verbs)
|
||||
{
|
||||
if (v.Name.Equals(word, StringComparison.OrdinalIgnoreCase)) return v;
|
||||
foreach (string a in v.Aliases)
|
||||
if (a.Equals(word, StringComparison.OrdinalIgnoreCase)) return v;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The usage of the verb called <paramref name="name"/>.</summary>
|
||||
public static string Usage(string name) => Find(name)?.Usage ?? "Usage: /rc " + name;
|
||||
|
||||
/// <summary>The check made before a /rc command runs: <paramref name="sub"/> is the line after "/rc ".</summary>
|
||||
public static ChatVerbCheck Check(string sub)
|
||||
{
|
||||
string s = sub.Trim();
|
||||
int sp = s.IndexOf(' ');
|
||||
string word = sp < 0 ? s : s.Substring(0, sp);
|
||||
string args = sp < 0 ? string.Empty : s.Substring(sp + 1).Trim();
|
||||
if (word.Length == 0)
|
||||
return new ChatVerbCheck(null, string.Empty, "Usage: /rc <command>. " + CommandList());
|
||||
ChatVerb? v = Find(word);
|
||||
if (v == null)
|
||||
return new ChatVerbCheck(null, args, UnknownReply(word));
|
||||
if (v.Args != null && !v.Args(args))
|
||||
return new ChatVerbCheck(v, args, v.Usage);
|
||||
return new ChatVerbCheck(v, args, null);
|
||||
}
|
||||
|
||||
/// <summary>"RynthCore's commands: /rc acmouse, actionstate, ...": every verb by its name.</summary>
|
||||
public static string CommandList()
|
||||
{
|
||||
var names = new List<string>(Verbs.Length);
|
||||
foreach (ChatVerb v in Verbs) names.Add(v.Name);
|
||||
names.Sort(StringComparer.Ordinal);
|
||||
return "RynthCore's commands: /rc " + string.Join(", ", names) + ".";
|
||||
}
|
||||
|
||||
/// <summary>The answer to a /rc verb the engine doesn't have.</summary>
|
||||
public static string UnknownReply(string word) => $"Unknown command '/rc {word}'. {CommandList()}";
|
||||
|
||||
/// <summary>"/rc vendor" for "/rc vendor buy 1": the command's name in a reply.</summary>
|
||||
public static string CommandName(string trimmedLine)
|
||||
{
|
||||
string s = trimmedLine.Trim();
|
||||
int first = s.IndexOf(' ');
|
||||
if (first < 0) return s;
|
||||
int second = s.IndexOf(' ', first + 1);
|
||||
return second < 0 ? s : s.Substring(0, second);
|
||||
}
|
||||
|
||||
// ── argument parsing (shared with RynthCoreChatCommands) ───────────────
|
||||
|
||||
/// <summary>"verb" or "verb args..." (case-insensitive); args trimmed.</summary>
|
||||
public static bool IsVerb(string sub, string verb, out string args)
|
||||
{
|
||||
args = string.Empty;
|
||||
if (sub.Equals(verb, StringComparison.OrdinalIgnoreCase)) return true;
|
||||
if (!sub.StartsWith(verb + " ", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
args = sub.Substring(verb.Length + 1).Trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "" / "toggle" → null (flip), "show" / "on" / "open" → true, "hide" / "off" / "close" →
|
||||
/// false. False for anything else.
|
||||
/// </summary>
|
||||
public static bool TryPanelMode(string args, out bool? show)
|
||||
{
|
||||
show = null;
|
||||
switch (args.Trim().ToLowerInvariant())
|
||||
{
|
||||
case "": case "toggle": return true;
|
||||
case "show": case "on": case "open": show = true; return true;
|
||||
case "hide": case "off": case "close": show = false; return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>What "/rc oracle-skills" can't take.</summary>
|
||||
public const int InvalidTab = -2;
|
||||
|
||||
/// <summary>"/rc oracle-skills <x>": -1 off, 0 skills, 1 attributes, 2 progress, <see cref="InvalidTab"/> for anything else.</summary>
|
||||
public static int OracleSkillsTab(string args) => args.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"off" or "clear" or "none" or "-1" => -1,
|
||||
"0" or "skills" or "skill" => 0,
|
||||
"1" or "attrs" or "attributes" or "vitals" => 1,
|
||||
"2" or "progress" or "progression" => 2,
|
||||
_ => InvalidTab,
|
||||
};
|
||||
|
||||
/// <summary>The Classic look's tab index for <paramref name="name"/>, or -1.</summary>
|
||||
public static int ClassicTab(string name) =>
|
||||
Array.FindIndex(ClassicTabNames, n => n.Equals(name.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private static bool DashboardArgs(string a) =>
|
||||
a.Length == 0 || a.Equals("classic", StringComparison.OrdinalIgnoreCase) || a.Equals("modern", StringComparison.OrdinalIgnoreCase)
|
||||
|| (IsVerb(a, "tab", out string tab) && ClassicTab(tab) >= 0);
|
||||
|
||||
/// <summary>"use N", "set N [id]", "clear N" (more words are ignored, as before), or nothing (the list).</summary>
|
||||
private static bool ShortcutsArgs(string a)
|
||||
{
|
||||
string[] sa = a.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (sa.Length == 0) return true;
|
||||
return sa.Length >= 2 && int.TryParse(sa[1], out _)
|
||||
&& (sa[0].Equals("use", StringComparison.OrdinalIgnoreCase) || sa[0].Equals("set", StringComparison.OrdinalIgnoreCase)
|
||||
|| sa[0].Equals("clear", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>"check|bind|unbind <action> <key>", "dump", or nothing (the keymap's state).</summary>
|
||||
private static bool KeymapArgs(string a)
|
||||
{
|
||||
string[] ka = a.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (ka.Length == 0) return true;
|
||||
string verb = ka[0].ToLowerInvariant();
|
||||
return verb == "dump" || (verb is "check" or "bind" or "unbind" && ka.Length == 3);
|
||||
}
|
||||
|
||||
/// <summary>"<op> <id>" (open, close, anything else toggles, as before), or nothing (the list).</summary>
|
||||
private static bool PanelsArgs(string a)
|
||||
{
|
||||
string[] pa = a.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
return pa.Length == 0 || (pa.Length == 2 && TryPanelId(pa[1], out _));
|
||||
}
|
||||
|
||||
/// <summary>An AC panel id: decimal, or hex with 0x.</summary>
|
||||
public static bool TryPanelId(string text, out uint id) =>
|
||||
uint.TryParse(text.Replace("0x", "", StringComparison.OrdinalIgnoreCase),
|
||||
text.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? NumberStyles.HexNumber : NumberStyles.Integer,
|
||||
null, out id);
|
||||
|
||||
// ── reply texts ────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>"Bounties panel opened." / "... closed." / "... is already open.": a panel after
|
||||
/// show (true), hide (false) or toggle (null), from whether it was open before.</summary>
|
||||
public static string PanelReply(string label, bool? show, bool wasOpen)
|
||||
{
|
||||
if (show is bool want && want == wasOpen)
|
||||
return $"{label} is already {(want ? "open" : "closed")}.";
|
||||
bool nowOpen = show ?? !wasOpen;
|
||||
return $"{label} {(nowOpen ? "opened" : "closed")}.";
|
||||
}
|
||||
|
||||
/// <summary>"Settings opened on Hotkeys." / "Settings switched to Hotkeys."</summary>
|
||||
public static string SettingsTabReply(string tab, bool wasOpen) =>
|
||||
$"Settings {(wasOpen ? "switched to" : "opened on")} {tab}.";
|
||||
|
||||
/// <summary>The answer when a command threw.</summary>
|
||||
public static string Failed(string command, string error, string message) =>
|
||||
$"{command} failed: {error}: {message} (the RynthCore log has more).";
|
||||
|
||||
/// <summary>The answer when a command ran and its handler said nothing (a gap: the log names it).</summary>
|
||||
public static string Done(string command) => $"{command}: done.";
|
||||
|
||||
/// <summary>"/rc oracle-skills": what RynthOracle's window embeds now.</summary>
|
||||
public static string OracleSkillsReply(int tab) => tab switch
|
||||
{
|
||||
0 => "RynthOracle's window shows the Skills tab.",
|
||||
1 => "RynthOracle's window shows the Attributes tab.",
|
||||
2 => "RynthOracle's window shows the Progress tab.",
|
||||
_ => "RynthOracle's window shows none of the Skills tabs.",
|
||||
};
|
||||
|
||||
/// <summary>"/rc dashboard ...": the look now (and the Classic tab), and whether the dashboard opened.</summary>
|
||||
public static string DashboardReply(bool classic, string? tab, bool hasDashboard)
|
||||
{
|
||||
var sb = new StringBuilder("RynthAi dashboard: ").Append(classic ? "Classic" : "Modern").Append(" look");
|
||||
if (tab != null) sb.Append(", ").Append(tab.ToLowerInvariant()).Append(" tab");
|
||||
sb.Append(hasDashboard ? "." : " (RynthAi's dashboard isn't loaded, so nothing opened).");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
51
src/RynthCore.Engine/Compatibility/ChatRateLimiter.cs
Normal file
51
src/RynthCore.Engine/Compatibility/ChatRateLimiter.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/ChatRateLimiter.cs
|
||||
//
|
||||
// How many plugin chat lines (WriteToChat off AC's thread) go to AC's chat, and
|
||||
// when (2026-10-28). A token bucket: a burst of up to Burst lines at once, then
|
||||
// one line per IntervalMs. It used to drop any line within 100 ms of the one
|
||||
// before, so a command's help or list reached chat as its first line only
|
||||
// ("/rn help", "/ilt help", "/rthreads stats"). The steady rate is unchanged
|
||||
// (10 a second), which is what keeps a retry loop's spam ("Casting: X" dozens
|
||||
// of times) away from AC's AddTextToScroll and its 0x00460D1D crash.
|
||||
//
|
||||
// Pure (no AC, no engine state), so tools\ChatCommandReplyTests compiles it in.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
internal sealed class ChatRateLimiter
|
||||
{
|
||||
public const int DefaultBurst = 12;
|
||||
public const int DefaultIntervalMs = 100;
|
||||
|
||||
private readonly int _burst;
|
||||
private readonly int _intervalMs;
|
||||
private readonly object _lock = new();
|
||||
private double _tokens;
|
||||
private long _at;
|
||||
|
||||
public ChatRateLimiter(int burst = DefaultBurst, int intervalMs = DefaultIntervalMs)
|
||||
{
|
||||
_burst = Math.Max(1, burst);
|
||||
_intervalMs = Math.Max(1, intervalMs);
|
||||
_tokens = _burst;
|
||||
}
|
||||
|
||||
/// <summary>True when a line may go at <paramref name="nowMs"/> (a monotonic clock, e.g.
|
||||
/// Environment.TickCount64), and counts it; false when the burst is spent.</summary>
|
||||
public bool TryTake(long nowMs)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_at != 0 && nowMs > _at)
|
||||
_tokens = Math.Min(_burst, _tokens + (nowMs - _at) / (double)_intervalMs);
|
||||
if (_at == 0 || nowMs > _at) _at = nowMs;
|
||||
if (_tokens < 1) return false;
|
||||
_tokens -= 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1112,10 +1112,11 @@ internal static class ClientHelperHooks
|
|||
// also hook the same function in ChatCallbackHooks.IncomingChatAddTextDetour,
|
||||
// which fires when AC processes our own WriteToChat output — guard
|
||||
// against unbounded recursion into ourselves.
|
||||
private const int WriteToChatMinIntervalMs = 100;
|
||||
// A burst of up to 12 lines, then one per 100 ms (ChatRateLimiter, 2026-10-28; it was one line
|
||||
// per 100 ms, which cut every multi-line command reply to its first line).
|
||||
private static readonly ChatRateLimiter _chatLimiter = new();
|
||||
[System.Runtime.CompilerServices.ModuleInitializer]
|
||||
internal static void EnsureChatRateLimiterReady() { /* triggers static init */ }
|
||||
private static long _lastWriteToChatTick;
|
||||
[ThreadStatic] private static int _writeToChatDepth;
|
||||
|
||||
public static bool WriteToChat(string? text, int chatType)
|
||||
|
|
@ -1130,11 +1131,8 @@ internal static class ClientHelperHooks
|
|||
// dropped before they queue, and drained messages are never re-dropped.
|
||||
if (!MainThreadGuard.IsOnMainThread())
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
long last = System.Threading.Interlocked.Read(ref _lastWriteToChatTick);
|
||||
if (last != 0 && now - last < WriteToChatMinIntervalMs)
|
||||
if (!_chatLimiter.TryTake(Environment.TickCount64))
|
||||
return false;
|
||||
System.Threading.Interlocked.Exchange(ref _lastWriteToChatTick, now);
|
||||
return AcMainThreadQueue.EnqueueWriteToChat(text!, chatType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,9 +405,12 @@ internal static unsafe class DecalBridgeHost
|
|||
// VTank, UB and MagTools already ran them).
|
||||
if (arg0 == 0)
|
||||
break;
|
||||
if (RynthCoreChatCommands.TryHandle(text))
|
||||
// Decal hands the bridge typed lines and its plugins' InvokeChatParser lines (a VTank
|
||||
// meta's chat command) alike, so these count as the player's: every reply shows.
|
||||
if (RynthCoreChatCommands.TryHandle(text, ChatCommandOrigin.Player))
|
||||
break;
|
||||
PluginManager.DispatchChatBarEnter(text);
|
||||
using (RynthCoreChatCommands.PlayerLine())
|
||||
PluginManager.DispatchChatBarEnter(text);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -353,7 +353,8 @@ internal static class HotkeyService
|
|||
if (b.IsCommand)
|
||||
{
|
||||
if (b.Command.Trim().Length == 0) return;
|
||||
if (!AcMainThreadQueue.EnqueueChatCommand(b.Command.Trim()))
|
||||
// The player pressed it: a /rc command answers in chat, as typed.
|
||||
if (!AcMainThreadQueue.EnqueueChatCommand(b.Command.Trim(), ChatCommandOrigin.Player))
|
||||
Reply("Hotkey: the chat command queue is full; try again.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -386,7 +387,7 @@ internal static class HotkeyService
|
|||
Reply($"Hotkey {b.Combo}: '{a.Name}' has no {a.Param!.ToLowerInvariant()} (edit it in Settings > Hotkeys).");
|
||||
return;
|
||||
}
|
||||
if (!AcMainThreadQueue.EnqueueChatCommand(HotkeyActions.ChatFor(a, b)))
|
||||
if (!AcMainThreadQueue.EnqueueChatCommand(HotkeyActions.ChatFor(a, b), ChatCommandOrigin.Player))
|
||||
Reply("Hotkey: the chat command queue is full; try again.");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@
|
|||
// nothing out there the margin is 0 and the picture is just the panel. The
|
||||
// window grows by the margin and moves so the panel stays put (LayeredWindow
|
||||
// .Present). Before this, the window was the panel and a tooltip below the
|
||||
// one-button-high popped-out bar was cut off at its edge.
|
||||
// one-button-high popped-out bar was cut off at its edge. A tooltip in the
|
||||
// margin lets clicks through; a menu, or a window of the face's own drawn
|
||||
// past the panel (RynthAi's dashboard drawers, 2026-10-24), takes them where
|
||||
// it is drawn (transparent pixels still let them through).
|
||||
//
|
||||
// Threads: everything here runs on AC's main thread, which both renders
|
||||
// (EndScene) and dispatches the game and pop-out WndProcs. No locks.
|
||||
|
|
@ -507,7 +510,8 @@ internal static unsafe class ImGuiPopOuts
|
|||
// a menu). Only a menu there takes clicks; a tooltip lets them through.
|
||||
ImDrawDataPtr drawData = ImGuiNET.ImGui.GetDrawData();
|
||||
UpdateMargins(pop, drawData.NativePtr, w, h);
|
||||
window.MarginsClickThrough = !ImGuiNET.ImGui.IsPopupOpen("", ImGuiPopupFlags.AnyPopupId | ImGuiPopupFlags.AnyPopupLevel);
|
||||
window.MarginsClickThrough = !ImGuiNET.ImGui.IsPopupOpen("", ImGuiPopupFlags.AnyPopupId | ImGuiPopupFlags.AnyPopupLevel)
|
||||
&& !WindowPastPanel(drawData.NativePtr, pop.OriginX, pop.OriginY, pop.OriginX + w, pop.OriginY + h, pop.DisplayW, pop.DisplayH);
|
||||
int sx = pop.OriginX - pop.MarginL, sy = pop.OriginY - pop.MarginT;
|
||||
int sw = w + pop.MarginL + pop.MarginR, sh = h + pop.MarginT + pop.MarginB;
|
||||
if (drawData.NativePtr != null)
|
||||
|
|
@ -627,46 +631,81 @@ internal static unsafe class ImGuiPopOuts
|
|||
out float x0, out float y0, out float x1, out float y1)
|
||||
{
|
||||
x0 = px0; y0 = py0; x1 = px1; y1 = py1;
|
||||
if (dd == null) return false;
|
||||
ImDrawList** lists = (ImDrawList**)dd->CmdLists.Data;
|
||||
for (int n = 0; n < dd->CmdListsCount; n++)
|
||||
ListOverflow(lists[n], px0, py0, px1, py1, displayW, displayH, ref x0, ref y0, ref x1, ref y1);
|
||||
return px0 - x0 > OverflowSlack || py0 - y0 > OverflowSlack || x1 - px1 > OverflowSlack || y1 - py1 > OverflowSlack;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A window other than a tooltip draws past the panel: a face's own window (a dashboard's
|
||||
/// drawers). Popups count too, but IsPopupOpen already says so. ImGui names a tooltip
|
||||
/// window "##Tooltip_NN" and its draw list after its window.
|
||||
/// </summary>
|
||||
private static bool WindowPastPanel(ImDrawData* dd, float px0, float py0, float px1, float py1, float displayW, float displayH)
|
||||
{
|
||||
if (dd == null) return false;
|
||||
ImDrawList** lists = (ImDrawList**)dd->CmdLists.Data;
|
||||
for (int n = 0; n < dd->CmdListsCount; n++)
|
||||
{
|
||||
ImDrawList* list = lists[n];
|
||||
if (list == null) continue;
|
||||
int vtxCount = list->VtxBuffer.Size, idxCount = list->IdxBuffer.Size;
|
||||
ImDrawVert* vtx = (ImDrawVert*)list->VtxBuffer.Data;
|
||||
ushort* idx = (ushort*)list->IdxBuffer.Data;
|
||||
ImDrawCmd* cmds = (ImDrawCmd*)list->CmdBuffer.Data;
|
||||
for (int c = 0; c < list->CmdBuffer.Size; c++)
|
||||
{
|
||||
ImDrawCmd* cmd = &cmds[c];
|
||||
if (cmd->UserCallback != IntPtr.Zero || cmd->ElemCount == 0) continue;
|
||||
float cx0 = Math.Max(cmd->ClipRect.X, 0f), cy0 = Math.Max(cmd->ClipRect.Y, 0f);
|
||||
float cx1 = Math.Min(cmd->ClipRect.Z, displayW), cy1 = Math.Min(cmd->ClipRect.W, displayH);
|
||||
if (cx1 <= cx0 || cy1 <= cy0) continue;
|
||||
if (cx0 >= px0 && cy0 >= py0 && cx1 <= px1 && cy1 <= py1) continue; // can't draw outside the panel
|
||||
|
||||
float vx0 = float.MaxValue, vy0 = float.MaxValue, vx1 = float.MinValue, vy1 = float.MinValue;
|
||||
long start = cmd->IdxOffset, end = Math.Min((long)idxCount, start + cmd->ElemCount);
|
||||
long vbase = cmd->VtxOffset;
|
||||
for (long i = start; i < end; i++)
|
||||
{
|
||||
long v = vbase + idx[i];
|
||||
if (v >= vtxCount) continue;
|
||||
Vector2 pos = vtx[v].pos;
|
||||
if (pos.X < vx0) vx0 = pos.X;
|
||||
if (pos.Y < vy0) vy0 = pos.Y;
|
||||
if (pos.X > vx1) vx1 = pos.X;
|
||||
if (pos.Y > vy1) vy1 = pos.Y;
|
||||
}
|
||||
vx0 = Math.Max(vx0, cx0); vy0 = Math.Max(vy0, cy0);
|
||||
vx1 = Math.Min(vx1, cx1); vy1 = Math.Min(vy1, cy1);
|
||||
if (vx1 <= vx0 || vy1 <= vy0) continue;
|
||||
x0 = Math.Min(x0, vx0); y0 = Math.Min(y0, vy0);
|
||||
x1 = Math.Max(x1, vx1); y1 = Math.Max(y1, vy1);
|
||||
}
|
||||
if (list == null || IsTooltipList(list)) continue;
|
||||
float x0 = px0, y0 = py0, x1 = px1, y1 = py1;
|
||||
ListOverflow(list, px0, py0, px1, py1, displayW, displayH, ref x0, ref y0, ref x1, ref y1);
|
||||
if (px0 - x0 > OverflowSlack || py0 - y0 > OverflowSlack || x1 - px1 > OverflowSlack || y1 - py1 > OverflowSlack)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsTooltipList(ImDrawList* list)
|
||||
{
|
||||
byte* name = list->_OwnerName;
|
||||
if (name == null) return false;
|
||||
ReadOnlySpan<byte> prefix = "##Tooltip"u8;
|
||||
for (int i = 0; i < prefix.Length; i++)
|
||||
if (name[i] != prefix[i]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Widens the bounds by what one draw list shows outside the panel (see <see cref="OverflowBounds"/>).</summary>
|
||||
private static void ListOverflow(ImDrawList* list, float px0, float py0, float px1, float py1, float displayW, float displayH,
|
||||
ref float x0, ref float y0, ref float x1, ref float y1)
|
||||
{
|
||||
if (list == null) return;
|
||||
int vtxCount = list->VtxBuffer.Size, idxCount = list->IdxBuffer.Size;
|
||||
ImDrawVert* vtx = (ImDrawVert*)list->VtxBuffer.Data;
|
||||
ushort* idx = (ushort*)list->IdxBuffer.Data;
|
||||
ImDrawCmd* cmds = (ImDrawCmd*)list->CmdBuffer.Data;
|
||||
for (int c = 0; c < list->CmdBuffer.Size; c++)
|
||||
{
|
||||
ImDrawCmd* cmd = &cmds[c];
|
||||
if (cmd->UserCallback != IntPtr.Zero || cmd->ElemCount == 0) continue;
|
||||
float cx0 = Math.Max(cmd->ClipRect.X, 0f), cy0 = Math.Max(cmd->ClipRect.Y, 0f);
|
||||
float cx1 = Math.Min(cmd->ClipRect.Z, displayW), cy1 = Math.Min(cmd->ClipRect.W, displayH);
|
||||
if (cx1 <= cx0 || cy1 <= cy0) continue;
|
||||
if (cx0 >= px0 && cy0 >= py0 && cx1 <= px1 && cy1 <= py1) continue; // can't draw outside the panel
|
||||
|
||||
float vx0 = float.MaxValue, vy0 = float.MaxValue, vx1 = float.MinValue, vy1 = float.MinValue;
|
||||
long start = cmd->IdxOffset, end = Math.Min((long)idxCount, start + cmd->ElemCount);
|
||||
long vbase = cmd->VtxOffset;
|
||||
for (long i = start; i < end; i++)
|
||||
{
|
||||
long v = vbase + idx[i];
|
||||
if (v >= vtxCount) continue;
|
||||
Vector2 pos = vtx[v].pos;
|
||||
if (pos.X < vx0) vx0 = pos.X;
|
||||
if (pos.Y < vy0) vy0 = pos.Y;
|
||||
if (pos.X > vx1) vx1 = pos.X;
|
||||
if (pos.Y > vy1) vy1 = pos.Y;
|
||||
}
|
||||
vx0 = Math.Max(vx0, cx0); vy0 = Math.Max(vy0, cy0);
|
||||
vx1 = Math.Min(vx1, cx1); vy1 = Math.Min(vy1, cy1);
|
||||
if (vx1 <= vx0 || vy1 <= vy0) continue;
|
||||
x0 = Math.Min(x0, vx0); y0 = Math.Min(y0, vy0);
|
||||
x1 = Math.Max(x1, vx1); y1 = Math.Max(y1, vy1);
|
||||
}
|
||||
return px0 - x0 > OverflowSlack || py0 - y0 > OverflowSlack || x1 - px1 > OverflowSlack || y1 - py1 > OverflowSlack;
|
||||
}
|
||||
|
||||
/// <summary>Folds the picture's placement into the draw-data hash.</summary>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@
|
|||
// pinned My settings, the rows the player pinned (QuickSettingsDrawer.cs)
|
||||
// Each is the same drawer the engine's own dashboard shows, so a value changed
|
||||
// here is saved the same way and a pin made here is the same pin. A drawer
|
||||
// that wasn't drawn in a frame drops its hub subscriptions (EndFrame).
|
||||
// not drawn for 2 s drops its hub subscriptions (EndFrame). Not "this frame":
|
||||
// a popped-out dashboard draws at its own rate (30 Hz at most, 10 idle), so a
|
||||
// drawer there missed most game frames, let its sources go each time and came
|
||||
// back empty (2026-10-24).
|
||||
//
|
||||
// 2026-10-27: RynthVision draws the whole Vision window itself (it takes over
|
||||
// the engine's VisionFace, "takeOver"), but two of its tabs set things that are
|
||||
|
|
@ -23,8 +26,8 @@
|
|||
// engine's Vision panel shows (MonsterHudSettingsUi), saved the same way:
|
||||
// nameplates the "Nameplates" tab
|
||||
// combattext the "Combat text" tab
|
||||
// They draw popped out too (the engine's Vision panel did); the three drawers
|
||||
// above stay docked-only (UiKit.RenderSettingsDrawer, DrawsPoppedOut).
|
||||
// They draw popped out too (the engine's Vision panel did), as the three
|
||||
// drawers above do since 2026-10-24.
|
||||
//
|
||||
// AC thread only (inside RynthAi's or RynthVision's window, and EndFrame after
|
||||
// the panels).
|
||||
|
|
@ -42,8 +45,9 @@ internal static class SettingsDrawerBodies
|
|||
private static RynthAiFace.PatrolDrawer? _patrol;
|
||||
private static QuickSettingsDrawer? _pinned;
|
||||
|
||||
// The frame each was last drawn in (EndFrame counts frames).
|
||||
private static long _frame, _rangesDrawn = -1, _patrolDrawn = -1, _pinnedDrawn = -1;
|
||||
// When each was last drawn (Environment.TickCount64).
|
||||
private static long _rangesDrawn = long.MinValue / 2, _patrolDrawn = long.MinValue / 2, _pinnedDrawn = long.MinValue / 2;
|
||||
private const long KeepMs = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// Draws <paramref name="key"/>'s body at the cursor, <paramref name="width"/> pixels wide, in at most
|
||||
|
|
@ -65,7 +69,7 @@ internal static class SettingsDrawerBodies
|
|||
case "ranges":
|
||||
{
|
||||
_ranges ??= new RangesSlideOut();
|
||||
_rangesDrawn = _frame;
|
||||
_rangesDrawn = Environment.TickCount64;
|
||||
_ranges.Update(true);
|
||||
float h = RangesSlideOut.BodyHeight(k);
|
||||
ImGuiNET.ImGui.PushID("##sdb_ranges");
|
||||
|
|
@ -78,7 +82,7 @@ internal static class SettingsDrawerBodies
|
|||
case "patrol":
|
||||
{
|
||||
_patrol ??= new RynthAiFace.PatrolDrawer();
|
||||
_patrolDrawn = _frame;
|
||||
_patrolDrawn = Environment.TickCount64;
|
||||
_patrol.Update(true);
|
||||
RynthAiFace.UseScale(k);
|
||||
float h = room > 0 ? room : 400 * k;
|
||||
|
|
@ -93,7 +97,7 @@ internal static class SettingsDrawerBodies
|
|||
case "pinned":
|
||||
{
|
||||
_pinned ??= new QuickSettingsDrawer();
|
||||
_pinnedDrawn = _frame;
|
||||
_pinnedDrawn = Environment.TickCount64;
|
||||
_pinned.Update(true);
|
||||
float h = room > 0 ? room : 120 * k;
|
||||
float want;
|
||||
|
|
@ -114,9 +118,6 @@ internal static class SettingsDrawerBodies
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>True for the bodies that draw in a popped-out window too (the Vision tabs).</summary>
|
||||
public static bool DrawsPoppedOut(string key) => key is "nameplates" or "combattext";
|
||||
|
||||
/// <summary>
|
||||
/// A Vision tab RynthVision's window shows (the engine's rows: MonsterHudSettingsUi), in Ui11 as the
|
||||
/// engine's Vision panel drew them. Returns the height drawn.
|
||||
|
|
@ -138,12 +139,12 @@ internal static class SettingsDrawerBodies
|
|||
return MathF.Max(0f, ImGuiNET.ImGui.GetCursorScreenPos().Y - at.Y);
|
||||
}
|
||||
|
||||
/// <summary>After the panels each frame: a body that wasn't drawn this frame lets its hub sources go.</summary>
|
||||
/// <summary>After the panels each frame: a body not drawn for <see cref="KeepMs"/> lets its hub sources go.</summary>
|
||||
public static void EndFrame()
|
||||
{
|
||||
if (_ranges != null && _rangesDrawn != _frame) _ranges.Update(false);
|
||||
if (_patrol != null && _patrolDrawn != _frame) _patrol.Update(false);
|
||||
if (_pinned != null && _pinnedDrawn != _frame) _pinned.Update(false);
|
||||
_frame++;
|
||||
long now = Environment.TickCount64;
|
||||
if (_ranges != null && now - _rangesDrawn > KeepMs) _ranges.Update(false);
|
||||
if (_patrol != null && now - _patrolDrawn > KeepMs) _patrol.Update(false);
|
||||
if (_pinned != null && now - _pinnedDrawn > KeepMs) _pinned.Update(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,8 +381,11 @@ internal static unsafe class FlightRecorder
|
|||
if (rest.Equals("off", StringComparison.OrdinalIgnoreCase)) { _autoOff = true; return new[] { "Automatic flight dumps off for this session." }; }
|
||||
if (rest.Equals("on", StringComparison.OrdinalIgnoreCase)) { _autoOff = false; return new[] { "Automatic flight dumps on." }; }
|
||||
return new[] { "Usage: /rc flight auto on|off" };
|
||||
default:
|
||||
case "status":
|
||||
return StatusLines();
|
||||
default:
|
||||
// A word it doesn't take: the usage, not the status (every command answers a typo so).
|
||||
return new[] { "Usage: /rc flight [status|mark <text>|on|off|auto on|off]" };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,8 +213,10 @@ internal static unsafe class UiKit
|
|||
/// "patrol", "pinned"; SettingsDrawerBodies) at the cursor, <paramref name="width"/> pixels wide
|
||||
/// and at most <paramref name="room"/> tall (0 = its own height); flags 1: open My settings' list
|
||||
/// of settings to pin. Since 2026-10-27 also the Vision window's engine-owned tabs for RynthVision's
|
||||
/// own window ("nameplates", "combattext"), which draw popped out too. Returns the height it wants
|
||||
/// (pixels), -1 for another key or outside a panel's draw on AC's thread (docked, for the drawers).
|
||||
/// own window ("nameplates", "combattext"). All of them draw popped out too (2026-10-24: RynthAi's
|
||||
/// popped-out dashboard has its drawers; SettingsDrawerBodies keeps a body's sources between its
|
||||
/// draws). Returns the height it wants (pixels), -1 for another key or outside a panel's draw on
|
||||
/// AC's thread.
|
||||
/// </summary>
|
||||
public static float RenderSettingsDrawer(byte* key, float width, float room, int flags)
|
||||
{
|
||||
|
|
@ -224,7 +226,6 @@ internal static unsafe class UiKit
|
|||
|| !float.IsFinite(width) || !float.IsFinite(room)) return -1f;
|
||||
string? name = Marshal.PtrToStringUTF8((IntPtr)key);
|
||||
if (string.IsNullOrEmpty(name) || name.Length > MaxKeyLength) return -1f;
|
||||
if (ImGuiPopOuts.InPopOutFrame && !SettingsDrawerBodies.DrawsPoppedOut(name)) return -1f;
|
||||
return SettingsDrawerBodies.Draw(name, width, MathF.Max(0f, room), (flags & 1) != 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -1137,7 +1137,13 @@ internal static class ChatModel
|
|||
IntPtr send = SendLinePtr;
|
||||
if (text.Length == 0 || send == IntPtr.Zero) return;
|
||||
IntPtr ptr = Marshal.StringToHGlobalAnsi(text);
|
||||
try { ((delegate* unmanaged[Cdecl]<IntPtr, void>)send)(ptr); }
|
||||
// RynthChat sends the line through Host.InvokeChatParser, on this thread: an engine /rc
|
||||
// command in it is the player's, so it answers in chat (RynthCoreChatCommands.PlayerLine).
|
||||
try
|
||||
{
|
||||
using (RynthCoreChatCommands.PlayerLine())
|
||||
((delegate* unmanaged[Cdecl]<IntPtr, void>)send)(ptr);
|
||||
}
|
||||
finally { Marshal.FreeHGlobal(ptr); }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ internal static class ChatDiscord
|
|||
? $"No route{(rest.Length > 0 ? $" named '{rest}'" : "s")}. Add one in Chat > gear > Discord (or /rc discord window)."
|
||||
: $"{(verb == "test" ? "Test sent to" : "Resumed")} {n} route(s).");
|
||||
break;
|
||||
default:
|
||||
case "status":
|
||||
reply.Add($"Discord relay: {SwitchLine()} {StatusLine()}");
|
||||
if (s.Characters.Length > 0)
|
||||
reply.Add(" On for: " + string.Join(", ", Array.ConvertAll(s.Characters, c => c.ToString())));
|
||||
|
|
@ -658,6 +658,10 @@ internal static class ChatDiscord
|
|||
}
|
||||
reply.Add("/rc discord on|off (this character) | window | test [route] | resume [route] | status");
|
||||
break;
|
||||
default:
|
||||
// A word it doesn't take: the usage, not the status (every command answers a typo so).
|
||||
reply.Add("Usage: /rc discord [on|off|status|window|test [route]|resume [route]]");
|
||||
break;
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,13 +74,19 @@ internal static class ServerMenus
|
|||
|
||||
/// <summary>
|
||||
/// Runs an item's command: an engine "/rc" command directly, anything else through the
|
||||
/// chat dispatcher (plugins' commands, as if typed). Render thread.
|
||||
/// chat dispatcher (plugins' commands, as if typed). Render thread. A click on an engine
|
||||
/// button or menu is a Script's command: what it opens is the answer, so only a failure
|
||||
/// reaches chat.
|
||||
/// </summary>
|
||||
public static void Run(string command)
|
||||
/// <param name="showReply">Answer in chat as for a typed command: a click whose result the player
|
||||
/// wants to read (the server window's "Treat this world as ..." prints the server summary). Other
|
||||
/// clicks stay quiet unless they fail.</param>
|
||||
public static void Run(string command, bool showReply = false)
|
||||
{
|
||||
string cmd = SectionManifestParser.Command(command);
|
||||
if (cmd.Length == 0) return;
|
||||
if (Compatibility.RynthCoreChatCommands.TryHandle(cmd)) return;
|
||||
var origin = showReply ? Compatibility.ChatCommandOrigin.Player : Compatibility.ChatCommandOrigin.Script;
|
||||
if (Compatibility.RynthCoreChatCommands.TryHandle(cmd, origin)) return;
|
||||
if (cmd.StartsWith("/rc ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
RynthLog.UI($"ServerMenus: '{cmd}' is not an engine command.");
|
||||
|
|
@ -255,7 +261,7 @@ internal static class ServerMenus
|
|||
foreach (MenuGroup g in groups)
|
||||
{
|
||||
if (ImGuiNET.ImGui.MenuItem("Treat this world as " + g.Server.Name + "##srvforce_" + g.Server.Id))
|
||||
Run(ForceCommand(g.Server.Id));
|
||||
Run(ForceCommand(g.Server.Id), showReply: true);
|
||||
SafeImGui.SetItemTooltip("Saved for this character. Undo with /rc server " + g.Server.Id + " auto, or in the Mini Remote's Char section.");
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue