/// <summary> /// Disables the <see cref="ImguiHook"/> temporarily. /// </summary> public static void Disable() { WndProcHook?.Disable(); if (Implementations == null) { return; } foreach (var implementation in Implementations) { implementation?.Disable(); } }
/// <summary> /// [Internal] Called from renderer implementation, renders a new frame. /// </summary> public static unsafe void InitializeWithHandle(IntPtr windowHandle) { if (!Initialized) { WindowHandle = windowHandle; if (WindowHandle == IntPtr.Zero) { return; } Debug.WriteLine($"[ImguiHook] Init with Window Handle {(long)WindowHandle:X}"); ImGui.ImGuiImplWin32Init(WindowHandle); var wndProcHandlerPtr = (IntPtr)SDK.Hooks.Utilities.GetFunctionPointer(typeof(ImguiHook), nameof(WndProcHandler)); WndProcHook = WndProcHook.Create(WindowHandle, Unsafe.As <IntPtr, WndProcHook.WndProc>(ref wndProcHandlerPtr)); Initialized = true; } }
/// <summary> /// Called from renderer implementation, renders a new frame. /// </summary> internal void NewFrame() { if (!Initialized) { if (WindowHandle == IntPtr.Zero) { WindowHandle = Implementation.GetWindowHandle(); } if (WindowHandle == IntPtr.Zero) { return; } ImGui.ImGuiImplWin32Init(WindowHandle); WndProcHook = new WndProcHook(WindowHandle, WndProcHandler); Initialized = true; } ImGui.ImGuiImplWin32NewFrame(); ImGui.NewFrame(); Render(); ImGui.Render(); }
public void Disable() { WndProcHook?.Disable(); Implementation?.Disable(); }
public void Enable() { WndProcHook?.Enable(); Implementation?.Enable(); }