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 <cursoragent@cursor.com>
This commit is contained in:
parent
10c45ec412
commit
7a58cdc095
7 changed files with 102 additions and 1 deletions
|
|
@ -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) ||
|
||||
|
|
|
|||
|
|
@ -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
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>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 <see cref="EnableImGuiBackend"/>.</summary>
|
||||
public static bool EnablePluginOverlayWindows
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureLoaded();
|
||||
return _enablePluginOverlayWindows;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>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);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ internal sealed class LoadedPlugin
|
|||
public PluginOnEnchantmentRemovedDelegate? OnEnchantmentRemoved { get; set; }
|
||||
public PluginTickDelegate? Tick { get; set; }
|
||||
public PluginRenderDelegate? Render { get; set; }
|
||||
/// <summary>Optional RynthPluginRenderOverlay: ImGui windows drawn while the ImGui shell is off.</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -482,6 +482,10 @@ internal static class PluginLoader
|
|||
if (renderPtr != IntPtr.Zero)
|
||||
plugin.Render = Marshal.GetDelegateForFunctionPointer<PluginRenderDelegate>(renderPtr);
|
||||
|
||||
IntPtr renderOverlayPtr = GetProcAddress(handle, "RynthPluginRenderOverlay");
|
||||
if (renderOverlayPtr != IntPtr.Zero)
|
||||
plugin.RenderOverlay = Marshal.GetDelegateForFunctionPointer<PluginRenderDelegate>(renderOverlayPtr);
|
||||
|
||||
// Read name/version from the plugin if available
|
||||
if (plugin.GetName != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1043,6 +1043,38 @@ internal static class PluginManager
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ImGui-shell-off counterpart of <see cref="RenderAll"/>: 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.
|
||||
/// </summary>
|
||||
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)...");
|
||||
|
|
|
|||
Loading…
Reference in a new issue