Ejemplo n.º 1
0
        /// <summary>
        /// Class constructor. Instantiates both the overlay and DirectX Stuff.
        /// Note: This method is blocking and Reloaded mods are required to return in order
        /// to boot up the games, please do not assign this statically - instead assign it in a background thread!
        /// </summary>
        /// <param name="renderDelegate">
        ///     The user delegate which you may use for rendering to the external overlay
        ///     window with Direct2D.
        /// </param>
        /// <param name="hookDelay">
        ///     Specifies the amount of time to wait until the hook is instantiation begins.
        ///     Some games are known to crash if DirectX is hooked too early.
        /// </param>
        /// <returns>An instance of self (ExternalWindowOverlay) with the overlay enabled and running.</returns>
        public static async Task <ExternalWindowOverlay> CreateExternalWindowOverlay(D2DWindowRenderer.DelegateRenderDirect2D renderDelegate, int hookDelay)
        {
            // Apply hook delay
            await Task.Delay(hookDelay);

            // Game process
            System.Diagnostics.Process gameProcess = Bindings.TargetProcess.GetProcessFromReloadedProcess();

            // Try to get game window handle.
            while (gameProcess.MainWindowHandle == IntPtr.Zero)
            {
                await Task.Delay(32);
            }

            // Wait for the Window to show itself to screen before configuring.
            while (WindowFunctions.IsWindowVisible(gameProcess.MainWindowHandle) == false)
            {
                await Task.Delay(32);
            }

            // Create self.
            ExternalWindowOverlay externalWindowOverlay = new ExternalWindowOverlay();

            // Enable the overlay.
            externalWindowOverlay.EnableOverlay(renderDelegate, gameProcess.MainWindowHandle);

            // Return self
            return(externalWindowOverlay);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Class constructor. Instantiates both the overlay and DirectX Stuff.
        /// </summary>
        /// <param name="gameWindowName">
        ///     The name of the window to be overlayed.
        ///     The window may be the game window or another window elsewhere.
        /// </param>
        /// <param name="renderDelegate">
        ///     The user delegate which you may use for rendering to the external overlay
        ///     window with Direct2D.
        /// </param>
        /// <param name="hookDelay">
        ///     Specifies the amount of time to wait until the hook is instantiation begins.
        ///     Some games are known to crash if DirectX is hooked too early.
        /// </param>
        /// <returns>
        ///     1. True if the window has been found and overlay has been instantiated, else false.
        ///     2. An instance of self (ExternalWindowOverlay) with the overlay enabled and running.
        /// </returns>
        public static async Task <(bool success, ExternalWindowOverlay overlay)> CreateExternalWindowOverlay(string gameWindowName, D2DWindowRenderer.DelegateRenderDirect2D renderDelegate, int hookDelay)
        {
            // Apply hook delay
            await Task.Delay(hookDelay);

            // Create self.
            ExternalWindowOverlay externalWindowOverlay = new ExternalWindowOverlay();

            // Wait for and find the game window.
            IntPtr windowHandle = await FindWindowHandleByName(gameWindowName);

            // If the handle has been acquired.
            if (windowHandle != (IntPtr)0)
            {
                // Wait for the Window to show itself to screen before configuring.
                while (WindowFunctions.IsWindowVisible(windowHandle) == false)
                {
                    await Task.Delay(32);
                }

                // Enable the overlay.
                externalWindowOverlay.EnableOverlay(renderDelegate, windowHandle);

                // Returns true.
                return(true, externalWindowOverlay);
            }

            // Return false, window was not found.
            return(false, externalWindowOverlay);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Class constructor. Instantiates both the overlay and DirectX Stuff.
        /// Note: This method is blocking and Reloaded mods are required to return in order
        /// to boot up the games, please do not assign this statically - instead assign it in a background thread!
        /// </summary>
        /// <param name="gameWindowHandle">
        ///     The handle of the game window to be overlayed.
        ///     The handle may be obtained via ReloadedProcess.GetProcessFromReloadedProcess().MainWindowHandle.
        /// </param>
        /// <param name="renderDelegate">
        ///     The user delegate which you may use for rendering to the external overlay
        ///     window with Direct2D.
        /// </param>
        /// <param name="hookDelay">
        ///     Specifies the amount of time to wait until the hook is instantiation begins.
        ///     Some games are known to crash if DirectX is hooked too early.
        /// </param>
        /// <returns>An instance of self (ExternalWindowOverlay) with the overlay enabled and running.</returns>
        public static async Task <ExternalWindowOverlay> CreateExternalWindowOverlay(IntPtr gameWindowHandle, D2DWindowRenderer.DelegateRenderDirect2D renderDelegate, int hookDelay)
        {
            // Apply hook delay
            await Task.Delay(hookDelay);

            // Wait for the Window to show itself to screen before configuring.
            while (WindowFunctions.IsWindowVisible(gameWindowHandle) == false)
            {
                await Task.Delay(32);
            }

            // Create self.
            ExternalWindowOverlay externalWindowOverlay = new ExternalWindowOverlay();

            // Enable the overlay.
            externalWindowOverlay.EnableOverlay(renderDelegate, gameWindowHandle);

            // Return self
            return(externalWindowOverlay);
        }