Пример #1
0
        /// <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();
            }
        }
Пример #2
0
        /// <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;
            }
        }
Пример #3
0
        /// <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();
        }
Пример #4
0
 public void Disable()
 {
     WndProcHook?.Disable();
     Implementation?.Disable();
 }
Пример #5
0
 public void Enable()
 {
     WndProcHook?.Enable();
     Implementation?.Enable();
 }