WIP on inputs going through gui
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m32s
Build / Build Nuget package (NuGet) (push) Successful in 2m13s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m27s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m36s
Build / Build Launcher (push) Successful in 3m41s
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m32s
Build / Build Nuget package (NuGet) (push) Successful in 2m13s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m27s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m36s
Build / Build Launcher (push) Successful in 3m41s
This commit is contained in:
@@ -21,6 +21,8 @@ internal class ImGuiHandler : IDisposable
|
|||||||
public static ImGuiHandler? Instance;
|
public static ImGuiHandler? Instance;
|
||||||
|
|
||||||
public static RenderTargetView? Rtv;
|
public static RenderTargetView? Rtv;
|
||||||
|
|
||||||
|
public ImGuiIOPtr Io { get; private set; }
|
||||||
private readonly IRootRenderComponent _renderHandler = new RenderHandler();
|
private readonly IRootRenderComponent _renderHandler = new RenderHandler();
|
||||||
|
|
||||||
public unsafe void Init(nint windowHandle, Device1 device, DeviceContext deviceContext)
|
public unsafe void Init(nint windowHandle, Device1 device, DeviceContext deviceContext)
|
||||||
@@ -29,14 +31,14 @@ internal class ImGuiHandler : IDisposable
|
|||||||
|
|
||||||
CreateContext();
|
CreateContext();
|
||||||
|
|
||||||
var io = GetIO();
|
Io = GetIO();
|
||||||
|
|
||||||
var path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher", "imgui.ini");
|
var path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher", "imgui.ini");
|
||||||
|
|
||||||
io.NativePtr->IniFilename = AnsiStringMarshaller.ConvertToUnmanaged(path);
|
Io.NativePtr->IniFilename = AnsiStringMarshaller.ConvertToUnmanaged(path);
|
||||||
|
|
||||||
io.ConfigWindowsMoveFromTitleBarOnly = true;
|
Io.ConfigWindowsMoveFromTitleBarOnly = true;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags.DockingEnable | ImGuiConfigFlags.ViewportsEnable;
|
Io.ConfigFlags |= ImGuiConfigFlags.DockingEnable | ImGuiConfigFlags.ViewportsEnable;
|
||||||
|
|
||||||
ImGui_ImplWin32_Init(windowHandle);
|
ImGui_ImplWin32_Init(windowHandle);
|
||||||
ImGui_ImplDX11_Init(device.NativePointer, deviceContext.NativePointer);
|
ImGui_ImplDX11_Init(device.NativePointer, deviceContext.NativePointer);
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using SharpDX.DXGI;
|
using SharpDX.DXGI;
|
||||||
using VRage.Platform.Windows.Forms;
|
using VRage.Platform.Windows.Forms;
|
||||||
|
using SharpDX.Windows;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace CringeLauncher.Patches;
|
namespace CringeLauncher.Patches;
|
||||||
|
|
||||||
@@ -19,4 +21,32 @@ public class RenderHookPatch
|
|||||||
{
|
{
|
||||||
ImGuiHandler.Instance?.HookWindow((HWND)__instance.Handle);
|
ImGuiHandler.Instance?.HookWindow((HWND)__instance.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HarmonyPatch]
|
||||||
|
public static class RenderMessagePatches
|
||||||
|
{
|
||||||
|
[HarmonyTargetMethods]
|
||||||
|
private static IEnumerable<MethodInfo> TargetMethods()
|
||||||
|
{
|
||||||
|
yield return AccessTools.Method(typeof(MyGameForm), nameof(MyGameWindow.WndProc));
|
||||||
|
yield return AccessTools.Method(typeof(RenderForm), "WndProc");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
private static bool WndProcPrefix(MyGameForm __instance, ref Message m)
|
||||||
|
{
|
||||||
|
if (ImGuiHandler.Instance is not { } handler)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (m.Msg is >= 256 and <= 265)
|
||||||
|
return !handler.Io.WantTextInput;
|
||||||
|
|
||||||
|
if (__instance.ShowCursor && m.Msg is >= 512 and <= 526)
|
||||||
|
return !handler.Io.WantCaptureMouse;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user