Add multi-viewport support, FPS governor, mana stone looting, and viewport focus fixes

Engine:
- ViewportPlatformBackend: Win32 platform backend for ImGui multi-viewport (pop-out windows)
- ViewportRendererBackend: D3D9 swap chain rendering for viewport windows
- ViewportPlatformBackend: WS_EX_NOACTIVATE + MA_NOACTIVATE always + SW_SHOWNA — viewport
  windows never steal focus; single click works without prior window activation
- ImGuiController/RynthCoreShell: wire multi-viewport callbacks, map always renders
  independent of main dashboard visibility
- Win32Backend: improved input handling for viewport windows
- EndSceneHook: FPS governor (focused/background targets), periodic FPS measurement
- D3D9VTable: vtable discovery improvements
- PluginContract/PluginManager/RynthCoreHost: expose UseObjectOn, GetItemType,
  GetObjectIntProperty to plugins

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
tombohar 2026-04-19 20:29:34 -04:00
commit 0d8579b796
24 changed files with 1876 additions and 38 deletions

View file

@ -28,6 +28,7 @@ internal static class DeviceVTableIndex
public const int SetTransform = 44;
public const int GetTransform = 45;
public const int GetRenderTarget = 38;
public const int SetRenderTarget = 37;
public const int SetViewport = 47;
public const int GetViewport = 48;
public const int GetTexture = 64;
@ -77,6 +78,25 @@ internal static class TextureVTableIndex
public const int UnlockRect = 20;
}
/// <summary>
/// IDirect3DSwapChain9 vtable indices.
/// </summary>
internal static class SwapChain9VTableIndex
{
public const int Release = 2;
public const int Present = 3;
// IDirect3DSwapChain9 vtable: 3=Present, 4=GetFrontBufferData, 5=GetBackBuffer.
public const int GetBackBuffer = 5;
}
/// <summary>
/// IDirect3DSurface9 vtable indices.
/// </summary>
internal static class Surface9VTableIndex
{
public const int Release = 2;
}
/// <summary>
/// IDirect3D9 vtable indices.
/// </summary>

View file

@ -27,12 +27,6 @@ internal static class EndSceneHook
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
[DllImport("kernel32.dll")]
private static extern uint GetCurrentProcessId();
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int EndSceneDelegate(IntPtr pDevice);
@ -278,9 +272,8 @@ internal static class EndSceneHook
if (FpsLimitEnabled)
{
IntPtr fgWnd = GetForegroundWindow();
GetWindowThreadProcessId(fgWnd, out uint fgPid);
uint thisPid = GetCurrentProcessId();
bool isFocused = fgPid == thisPid;
// Only "focused" when the AC game window itself is foreground — not viewport popups.
bool isFocused = fgWnd != IntPtr.Zero && fgWnd == Win32Backend.GameHwnd;
int targetFps = isFocused ? FpsTargetFocused : FpsTargetBackground;
double minFrameMs = 1000.0 / Math.Max(targetFps, 1);
@ -291,7 +284,7 @@ internal static class EndSceneHook
if (!_fpsLimiterLoggedOnce)
{
_fpsLimiterLoggedOnce = true;
RynthLog.D3D9($"EndSceneHook: FPS governor active — max={FpsTargetFocused} focused, max={FpsTargetBackground} background, pid={thisPid}");
RynthLog.D3D9($"EndSceneHook: FPS governor active — max={FpsTargetFocused} focused, max={FpsTargetBackground} background, gameHwnd=0x{Win32Backend.GameHwnd.ToInt64():X}");
}
// Periodic FPS measurement — log every 60 seconds