From 7a58cdc0959c44a8804b6dc0ade56d1fd4a4299f Mon Sep 17 00:00:00 2001 From: BlankenshipG Date: Sun, 4 Oct 2026 17:37:55 -0400 Subject: [PATCH] feat(engine): RynthPluginRenderOverlay - plugin extra windows while the ImGui shell is off PluginManager.RenderOverlayAll runs the optional export when EnableImGuiShell is off (engine.json EnablePluginOverlayWindows, default true). A throw disables only that plugin's overlay, never the plugin. Fixes RynthAi ILT Hub window never showing. Co-authored-by: Cursor --- .../2026-10-04-plugin-overlay-windows.md | 31 ++++++++++++++++++ .../ImGui/EngineFrameController.cs | 6 ++++ .../Plugins/EngineSettings.cs | 21 ++++++++++++ src/RynthCore.Engine/Plugins/LoadedPlugin.cs | 3 ++ .../Plugins/PluginContract.cs | 6 +++- src/RynthCore.Engine/Plugins/PluginLoader.cs | 4 +++ src/RynthCore.Engine/Plugins/PluginManager.cs | 32 +++++++++++++++++++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Changelog/2026-10-04-plugin-overlay-windows.md diff --git a/Changelog/2026-10-04-plugin-overlay-windows.md b/Changelog/2026-10-04-plugin-overlay-windows.md new file mode 100644 index 0000000..a5ca6be --- /dev/null +++ b/Changelog/2026-10-04-plugin-overlay-windows.md @@ -0,0 +1,31 @@ +# Engine — plugin overlay windows while the ImGui shell is off + +**Date:** 2026-10-04 +**Branch:** `SK-local` +**Ships in:** installer 2026.10.4.9 (previous 2026.10.4.8) + +## Problem +`EngineSettings.EnableImGuiShell` is hard-off unless the developer env var +`RYNTHCORE_FORCE_IMGUI=1` is set. `EngineFrameController.RunImGuiFrame` skipped both +`RynthCoreShell.Render` and `PluginManager.RenderAll`, so any plugin window without an Avalonia +panel could never show. That included RynthAi's ILT Hub (log: the Hub was created and the server +features came back, but no window) and its Item Info settings window. + +## Added +- **Optional plugin export `void RynthPluginRenderOverlay()`** (`PluginContract.cs`, + `PluginLoader.cs`, `LoadedPlugin.RenderOverlay`). With the ImGui shell off, the engine calls it + every frame through the new `PluginManager.RenderOverlayAll()`. A plugin draws only its extra + windows there, beside the Avalonia UI. Plugins without the export are unaffected. Their full ImGui + UIs stay hidden, so nothing duplicates an Avalonia panel. The old ImGui bar stays hidden too. +- **Failure isolation:** if `RenderOverlay` throws, only that plugin's overlay windows are switched + off for the session. The plugin is **not** marked `Failed`, so its tick, automation and Avalonia + panels keep running. (`RenderAll` keeps its old behaviour.) +- **engine.json `"EnablePluginOverlayWindows"`** (default `true`) to hide the overlay windows. + `EngineSettings.Save` writes it, and the launcher's `EngineJsonStore` preserves it. + The windows need `EnableImGuiBackend` (default `true`). +- Same not-in-world guard as `RenderAll` (no drawing between logoff and the next login complete). + +## Build +- `RynthCore.Engine` Release build succeeds (no new warnings). Shipped with RynthAi 0.6.15, which + exports `RynthPluginRenderOverlay` (ILT Hub + Item Info windows). +- Not yet verified in game. diff --git a/src/RynthCore.Engine/ImGui/EngineFrameController.cs b/src/RynthCore.Engine/ImGui/EngineFrameController.cs index 9fd4f18..cb9e293 100644 --- a/src/RynthCore.Engine/ImGui/EngineFrameController.cs +++ b/src/RynthCore.Engine/ImGui/EngineFrameController.cs @@ -517,6 +517,12 @@ internal static class EngineFrameController RynthCoreShell.Render(_frameCount); PluginManager.RenderAll(); } + else if (Plugins.EngineSettings.EnablePluginOverlayWindows) + { + // Avalonia mode: only the opt-in extra windows (RynthPluginRenderOverlay), + // never the plugins' full ImGui UIs that Avalonia panels already cover. + PluginManager.RenderOverlayAll(); + } bool captureMouse = ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AnyWindow) || diff --git a/src/RynthCore.Engine/Plugins/EngineSettings.cs b/src/RynthCore.Engine/Plugins/EngineSettings.cs index 35b1299..41ea007 100644 --- a/src/RynthCore.Engine/Plugins/EngineSettings.cs +++ b/src/RynthCore.Engine/Plugins/EngineSettings.cs @@ -21,6 +21,7 @@ internal static class EngineSettings private static bool _enableEngine = true; private static int _engineHookCount = int.MaxValue; private static bool _enableImGuiBackend = true; + private static bool _enablePluginOverlayWindows = true; private static bool _enableHangMinidump = true; private static bool _drawCustomVitalBars = true; private static bool _preventIdleLogoff = true; @@ -146,6 +147,19 @@ internal static class EngineSettings } } + /// When true (default) and the ImGui shell is off, plugins that export + /// RynthPluginRenderOverlay draw their extra ImGui windows (RynthAi: ILT Hub, Item Info) + /// beside the Avalonia UI. engine.json "EnablePluginOverlayWindows": false hides them. + /// Needs . + public static bool EnablePluginOverlayWindows + { + get + { + EnsureLoaded(); + return _enablePluginOverlayWindows; + } + } + /// When true, MainThreadHangWatchdog writes a minidump to /// Logs\dumps\ the first time AC's main thread is confirmed permanently /// wedged — a targeted post-mortem to replace always-on procdump (which @@ -304,6 +318,12 @@ internal static class EngineSettings _enableImGuiBackend = ibEl.GetBoolean(); } + if (doc.RootElement.TryGetProperty("EnablePluginOverlayWindows", out var powEl) && + (powEl.ValueKind == JsonValueKind.True || powEl.ValueKind == JsonValueKind.False)) + { + _enablePluginOverlayWindows = powEl.GetBoolean(); + } + if (doc.RootElement.TryGetProperty("EnableHangMinidump", out var hmEl) && (hmEl.ValueKind == JsonValueKind.True || hmEl.ValueKind == JsonValueKind.False)) { @@ -359,6 +379,7 @@ internal static class EngineSettings w.WriteBoolean("EnableEngine", _enableEngine); w.WriteNumber("EngineHookCount", _engineHookCount); w.WriteBoolean("EnableImGuiBackend", _enableImGuiBackend); + w.WriteBoolean("EnablePluginOverlayWindows", _enablePluginOverlayWindows); w.WriteBoolean("EnableHangMinidump", _enableHangMinidump); w.WriteBoolean("DrawCustomVitalBars", _drawCustomVitalBars); w.WriteBoolean("PreventIdleLogoff", _preventIdleLogoff); diff --git a/src/RynthCore.Engine/Plugins/LoadedPlugin.cs b/src/RynthCore.Engine/Plugins/LoadedPlugin.cs index b59b154..9778be8 100644 --- a/src/RynthCore.Engine/Plugins/LoadedPlugin.cs +++ b/src/RynthCore.Engine/Plugins/LoadedPlugin.cs @@ -54,6 +54,8 @@ internal sealed class LoadedPlugin public PluginOnEnchantmentRemovedDelegate? OnEnchantmentRemoved { get; set; } public PluginTickDelegate? Tick { get; set; } public PluginRenderDelegate? Render { get; set; } + /// Optional RynthPluginRenderOverlay: ImGui windows drawn while the ImGui shell is off. + public PluginRenderDelegate? RenderOverlay { get; set; } // ─── Runtime state ─────────────────────────────────────────────── public bool Initialized { get; set; } @@ -100,5 +102,6 @@ internal sealed class LoadedPlugin OnEnchantmentRemoved = null; Tick = null; Render = null; + RenderOverlay = null; } } diff --git a/src/RynthCore.Engine/Plugins/PluginContract.cs b/src/RynthCore.Engine/Plugins/PluginContract.cs index 116fc52..1206976 100644 --- a/src/RynthCore.Engine/Plugins/PluginContract.cs +++ b/src/RynthCore.Engine/Plugins/PluginContract.cs @@ -10,7 +10,11 @@ // const char* RynthPluginName() — human-readable name // const char* RynthPluginVersion() — version string (e.g. "1.0.0") // void RynthPluginTick() — per-frame logic (before render) -// void RynthPluginRender() — per-frame ImGui drawing +// void RynthPluginRender() — per-frame ImGui drawing (ImGui shell on) +// void RynthPluginRenderOverlay() — per-frame ImGui drawing while the ImGui shell is +// off (Avalonia mode): only windows that have no +// Avalonia panel. Gated by engine.json +// "EnablePluginOverlayWindows" (default true). // ============================================================================ using System; diff --git a/src/RynthCore.Engine/Plugins/PluginLoader.cs b/src/RynthCore.Engine/Plugins/PluginLoader.cs index f6ed726..ba6b541 100644 --- a/src/RynthCore.Engine/Plugins/PluginLoader.cs +++ b/src/RynthCore.Engine/Plugins/PluginLoader.cs @@ -482,6 +482,10 @@ internal static class PluginLoader if (renderPtr != IntPtr.Zero) plugin.Render = Marshal.GetDelegateForFunctionPointer(renderPtr); + IntPtr renderOverlayPtr = GetProcAddress(handle, "RynthPluginRenderOverlay"); + if (renderOverlayPtr != IntPtr.Zero) + plugin.RenderOverlay = Marshal.GetDelegateForFunctionPointer(renderOverlayPtr); + // Read name/version from the plugin if available if (plugin.GetName != null) { diff --git a/src/RynthCore.Engine/Plugins/PluginManager.cs b/src/RynthCore.Engine/Plugins/PluginManager.cs index 35db83e..771fada 100644 --- a/src/RynthCore.Engine/Plugins/PluginManager.cs +++ b/src/RynthCore.Engine/Plugins/PluginManager.cs @@ -1043,6 +1043,38 @@ internal static class PluginManager } } + /// + /// ImGui-shell-off counterpart of : calls the optional + /// RynthPluginRenderOverlay export, where a plugin draws only the extra windows that have + /// no Avalonia panel (e.g. RynthAi's ILT Hub). They float beside the Avalonia UI and add to it. + /// A throw switches off just that plugin's overlay windows; the plugin is NOT marked Failed, + /// so its tick/automation and Avalonia panels keep running. + /// + public static void RenderOverlayAll() + { + if (!_loginCompleteObserved) + return; // same not-in-world crash zone guard as RenderAll + + LoadedPlugin[] plugins = System.Threading.Volatile.Read(ref _pluginsRenderSnapshot); + for (int i = 0; i < plugins.Length; i++) + { + var plugin = plugins[i]; + var overlay = plugin.RenderOverlay; + if (!plugin.Initialized || plugin.Failed || overlay == null) + continue; + + try + { + overlay(); + } + catch (Exception ex) + { + plugin.RenderOverlay = null; + RynthLog.Error($"PluginManager: {plugin.DisplayName} RenderOverlay threw {ex.GetType().Name}: {ex.Message} - overlay windows off for this session (plugin keeps running)."); + } + } + } + public static void ShutdownAll() { RynthLog.Plugin($"PluginManager: Shutting down {_plugins.Count} plugin(s)...");