fix(engine): hand plugins the ImGui context for overlay windows, Char/Hub on the ImGui dashboard, warn on hidden log categories
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b4488ecb6f
commit
08c63f4cc3
5 changed files with 124 additions and 12 deletions
|
|
@ -154,11 +154,14 @@ public static class EntryPoint
|
|||
|
||||
InstallManagedExceptionHandlers();
|
||||
|
||||
RynthLog.Info("================================================================");
|
||||
RynthLog.Info($"RynthCore.Engine init build={BuildStamp} initCount={_initCount} pid={Environment.ProcessId}");
|
||||
RynthLog.Info($" os={Environment.OSVersion} clr={Environment.Version} cwd={Environment.CurrentDirectory}");
|
||||
RynthLog.Info($" logging {logSummary}");
|
||||
RynthLog.Info("================================================================");
|
||||
// The banner bypasses the category levels: it must be in every log, whatever engine.json says.
|
||||
LogTagged("engine", "================================================================", "INF");
|
||||
LogTagged("engine", $"RynthCore.Engine init build={BuildStamp} initCount={_initCount} pid={Environment.ProcessId}", "INF");
|
||||
LogTagged("engine", $" os={Environment.OSVersion} clr={Environment.Version} cwd={Environment.CurrentDirectory}", "INF");
|
||||
LogTagged("engine", $" logging {logSummary}", "INF");
|
||||
LogTagged("engine", "================================================================", "INF");
|
||||
string hiddenCategories = LogSettings.HiddenCategoriesWarning();
|
||||
if (hiddenCategories.Length > 0) RynthLog.Warn(hiddenCategories);
|
||||
|
||||
// Live logging config: launcher edits to engine.json apply without a client restart.
|
||||
// Stopped in EngineLifecycle.Shutdown before the module can be unloaded.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ internal static class EngineFrameController
|
|||
private static bool _imguiInitFailed;
|
||||
private static bool _coreResolved;
|
||||
private static bool _pluginsInitialized;
|
||||
// Pump frames plugin init has waited for the ImGui context (PumpPluginFrame; ~16 ms each).
|
||||
private static int _pluginInitContextWaits;
|
||||
private const int PluginInitContextMaxWaits = 300;
|
||||
private static IntPtr _context;
|
||||
private static IntPtr _gameHwnd;
|
||||
|
||||
|
|
@ -473,14 +476,26 @@ internal static class EngineFrameController
|
|||
return; // never re-enter PluginManager from two stacks
|
||||
try
|
||||
{
|
||||
// Plugins only get the ImGui context when they may draw with it
|
||||
// (EnableImGuiShell, FORCE-gated). The engine's own ImGui panels
|
||||
// don't need plugins to see it, and handing it over switched
|
||||
// RynthAi into its legacy-ImGui setup (first ImGui-on test,
|
||||
// 2026-09-28) - plugins must behave exactly as in Avalonia-only mode.
|
||||
IntPtr pluginContext = Plugins.EngineSettings.EnableImGuiShell ? _context : IntPtr.Zero;
|
||||
// Plugins only get the ImGui context when they may draw with it: the
|
||||
// ImGui shell (EnableImGuiShell, FORCE-gated) or their own overlay
|
||||
// windows (EnablePluginOverlayWindows: RynthAi's ILT Hub, HUDs, Item
|
||||
// Info; RynthPluginRenderOverlay). RynthAi only reads the context for
|
||||
// those windows, so this does not switch it into a legacy-ImGui setup.
|
||||
bool pluginsDraw = Plugins.EngineSettings.EnableImGuiShell
|
||||
|| (Plugins.EngineSettings.EnablePluginOverlayWindows && Plugins.EngineSettings.EnableImGuiBackend);
|
||||
// _context is written by the render thread (Init); this is the pump thread.
|
||||
IntPtr pluginContext = pluginsDraw ? System.Threading.Volatile.Read(ref _context) : IntPtr.Zero;
|
||||
if (!_pluginsInitialized)
|
||||
{
|
||||
// The plugin host copies the context once at init, so wait for the
|
||||
// render path's ImGui init (first ImGui frame) rather than hand over
|
||||
// zero for the whole session. Bounded: a failed or stalled ImGui init
|
||||
// must not hold plugins (and the bot) back.
|
||||
if (pluginsDraw && pluginContext == IntPtr.Zero && !_imguiInitFailed
|
||||
&& ++_pluginInitContextWaits <= PluginInitContextMaxWaits)
|
||||
return;
|
||||
if (pluginsDraw && pluginContext == IntPtr.Zero)
|
||||
RynthLog.Warn($"EngineFrameController: plugins initialised without an ImGui context (imguiInitFailed={_imguiInitFailed}, waits={_pluginInitContextWaits}) - plugin overlay windows will not draw this session.");
|
||||
_pluginsInitialized = true;
|
||||
PluginManager.InitPlugins(pluginContext, device, _gameHwnd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
private void Launchers(float x0, float width)
|
||||
{
|
||||
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
|
||||
const int buttons = 8;
|
||||
const int buttons = 10;
|
||||
float bw = MathF.Floor((width - buttons * LauncherGap) / buttons);
|
||||
// Short labels only when every button has room for its icon and label.
|
||||
bool labels = bw >= 68;
|
||||
|
|
@ -516,6 +516,18 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
}
|
||||
else _drawers.Toggle(_patrol);
|
||||
}
|
||||
x += bw + LauncherGap;
|
||||
|
||||
// Char and Hub open RynthAi's own ImGui overlay windows (ILT Hub, Mini Remote, Inventory
|
||||
// HUDs). They draw only when the engine hands plugins its ImGui context.
|
||||
Launcher("##l_char", PhosphorIcons.User, "Char", "Character hub (ILT Hub) - same as /ra hub show",
|
||||
x, y, bw, labels, () => RynthAiCommands.ApplyRemoteCommand("hub", "show"));
|
||||
x += bw + LauncherGap;
|
||||
Launcher("##l_hub", PhosphorIcons.SquaresFour, "Hub",
|
||||
"Hub. Left-click: Mini Remote (/ra remote). Right-click: Inventory HUDs setup (/ra huds).",
|
||||
x, y, bw, labels, () => RynthAiCommands.ApplyRemoteCommand("remote", "toggle"));
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
RynthAiCommands.ApplyRemoteCommand("huds", "show");
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x0, y + LauncherH));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,27 @@ internal static class LogSettings
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Categories whose emit level is more verbose than the global level, so none of their lines
|
||||
/// are written (e.g. every category at Trace with LoggingLevel Info: an almost empty log).
|
||||
/// Empty when nothing is hidden.
|
||||
/// </summary>
|
||||
internal static string HiddenCategoriesWarning()
|
||||
{
|
||||
EntryPoint.EngineLogLevel global = EntryPoint.LoggingLevel;
|
||||
EntryPoint.EngineLogLevel[] levels = Volatile.Read(ref _levels);
|
||||
var hidden = new StringBuilder();
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
if (levels[i] == EntryPoint.EngineLogLevel.Off || levels[i] <= global) continue;
|
||||
if (hidden.Length > 0) hidden.Append(", ");
|
||||
hidden.Append((LogCategory)i).Append('=').Append(levels[i]);
|
||||
}
|
||||
return hidden.Length == 0 ? ""
|
||||
: $"LogSettings: {hidden} write above the global LoggingLevel ({global}), so those lines are NOT logged. " +
|
||||
"Raise LoggingLevel to the most verbose category level, or set the categories to Info.";
|
||||
}
|
||||
|
||||
/// <summary>Starts the once-a-second engine.json poll. Idempotent.</summary>
|
||||
internal static void StartWatcher()
|
||||
{
|
||||
|
|
@ -199,6 +220,8 @@ internal static class LogSettings
|
|||
// Bypasses the category levels so a change is visible whenever Info is in range.
|
||||
if (EntryPoint.ShouldLog(EntryPoint.EngineLogLevel.Info))
|
||||
EntryPoint.LogTagged("engine", $"LogSettings: engine.json changed - logging reloaded ({summary}).", "INF");
|
||||
string hidden = HiddenCategoriesWarning();
|
||||
if (hidden.Length > 0) RynthLog.Warn(hidden);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue