feat(engine,launcher): ILT Hub panel button, ImGui windows over Avalonia, live per-category logging

RynthAi Avalonia panel gains an ILT Hub button (hub show via ApplyRemoteCommand). ImGui draw data is submitted after the Avalonia blit and ImGui gets mouse priority when hovered. Engine reads LoggingLevel (now incl. Off) and LogCategories from engine.json live; launcher 0.1.5 edits engine and RynthAi log levels on the fly.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BlankenshipG 2026-10-04 18:52:01 -04:00
commit 6b94752128
15 changed files with 855 additions and 67 deletions

View file

@ -73,6 +73,11 @@ internal static class EngineFrameController
/// </summary>
internal static volatile IntPtr CachedDevice;
private static int _pluginPumpInFrame; // re-entrancy guard for the pump
// ImGui draw data built by RunImGuiFrame, submitted later by RenderDeferredImGui
// (after the Avalonia blit). Render thread only. Device == 0 means nothing pending.
private static ImDrawDataPtr _deferredDrawData;
private static IntPtr _deferredDrawDevice;
private static long _lastFrameTicks;
private static int _frameCount;
@ -465,6 +470,9 @@ internal static class EngineFrameController
bool frameStarted = false;
bool frameEnded = false;
// A frame that throws before Render must not resubmit last frame's draw data.
_deferredDrawDevice = IntPtr.Zero;
try
{
_frameCount++;
@ -536,10 +544,12 @@ internal static class EngineFrameController
ImDrawDataPtr drawData = ImGuiNET.ImGui.GetDrawData();
DX9Backend.RenderDrawData(drawData, pDevice);
// OverlayTextureRenderer.Render is now driven from EndSceneHook.EndSceneDetour
// directly so the Avalonia compositor runs even when EnableImGuiBackend=false.
// Leaving it out of this call site avoids double-blit when ImGui is also active.
// Submission is deferred to RenderDeferredImGui, which EndSceneHook calls
// AFTER OverlayTextureRenderer has blitted the Avalonia layer, so ImGui
// windows (plugin overlay windows such as the ILT Hub) sit on top of the
// Avalonia panels. The draw data stays valid until the next NewFrame.
_deferredDrawData = drawData;
_deferredDrawDevice = pDevice;
if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) != 0)
{
@ -567,6 +577,35 @@ internal static class EngineFrameController
}
}
/// <summary>
/// Submits this frame's ImGui draw data. EndSceneHook calls it after
/// OverlayTextureRenderer.Render so ImGui windows draw on top of the Avalonia
/// layer. Runs whether or not the Avalonia blit ran (character select, Avalonia
/// off), and is a no-op when RunImGuiFrame produced nothing this frame.
/// </summary>
public static void RenderDeferredImGui()
{
IntPtr device = _deferredDrawDevice;
if (device == IntPtr.Zero)
return;
_deferredDrawDevice = IntPtr.Zero; // one submission per frame, even if it throws
IntPtr previousContext = ImGuiNET.ImGui.GetCurrentContext();
ImGuiNET.ImGui.SetCurrentContext(_context);
try
{
DX9Backend.RenderDrawData(_deferredDrawData, device);
}
catch (Exception ex)
{
RynthLog.Info($"EngineFrameController: frame {_frameCount} deferred ImGui draw error: {ex.GetType().Name}: {ex.Message}");
}
finally
{
ImGuiNET.ImGui.SetCurrentContext(previousContext);
}
}
internal static IntPtr FindGameWindow()
{
uint pid = GetCurrentProcessId();

View file

@ -927,7 +927,7 @@ internal static unsafe class Win32Backend
{
// fall through: AC gets the message
}
else if (IsMouseMessage(msg))
else if (IsMouseMessage(msg) && !ImGuiOwnsMouseOverAvalonia())
{
bool handled = TryForwardToAvalonia(msg, wParam, lParam);
if (handled)
@ -1007,6 +1007,17 @@ internal static unsafe class Win32Backend
/// If the cursor is over the Avalonia shell panel, PostMessage the mouse event to
/// the off-screen Avalonia HWND and return true (caller should suppress game delivery).
/// </summary>
/// <summary>
/// ImGui windows are drawn on top of the Avalonia layer, so when the cursor is over
/// an ImGui window (or an ImGui widget is active) mouse input must go to ImGui
/// instead of the Avalonia panel underneath. An Avalonia drag/resize that is already
/// in progress keeps its capture so the release is never lost.
/// </summary>
private static bool ImGuiOwnsMouseOverAvalonia()
{
return _wantCaptureMouse && !AvaloniaOverlay.HasPointerCapture;
}
private static bool TryForwardToAvalonia(uint msg, IntPtr wParam, IntPtr lParam)
{
IntPtr avHwnd = AvaloniaOverlay.AvaloniaHwnd;