Exemple #1
0
        internal static void Dispose()
        {
            _cursor?.Dispose();
            _cursor = null;

            DirectXHook?.Dispose();
            DirectXHook = null;
        }
Exemple #2
0
        private bool DetectDirectXVersion()
        {
            var d3D9Loaded  = IntPtr.Zero;
            var d3D10Loaded = IntPtr.Zero;
            var d3D11Loaded = IntPtr.Zero;

            const int delayTime  = 100;
            var       retryCount = 0;

            while (d3D9Loaded == IntPtr.Zero && d3D10Loaded == IntPtr.Zero && d3D11Loaded == IntPtr.Zero)
            {
                retryCount++;
                d3D9Loaded  = NativeMethods.GetModuleHandle("d3d9.dll");
                d3D10Loaded = NativeMethods.GetModuleHandle("d3d10.dll");
                d3D11Loaded = NativeMethods.GetModuleHandle("d3d11.dll");

                System.Threading.Thread.Sleep(delayTime);

                if (retryCount * delayTime > 5000)
                {
                    Server.SendMessage("Unsupported Direct3D version, or Direct3D DLL not loaded within 5 seconds.");
                    return(false);
                }
            }

            if (d3D9Loaded != IntPtr.Zero)
            {
                Server.SendMessage("Detected DirectX9!");
                return(false);
            }

            if (d3D10Loaded != IntPtr.Zero)
            {
                Server.SendMessage("Detected DirectX10!");
                return(false);
            }

            if (d3D11Loaded != IntPtr.Zero)
            {
                Server.SendMessage("Detected DirectX11!");
                device = new DirectX11Hook();
                return(true);
            }

            return(false);
        }
Exemple #3
0
        internal static void SetMouseHidden(bool hidden)
        {
            if (DirectXHook == null)
            {
                return;
            }

            if (_cursor == null)
            {
                var cursorPic = new Bitmap(Main.GTANInstallDir + "images\\cef\\cursor.png");
                _cursor = new ImageElement(null, true);
                _cursor.SetBitmap(cursorPic);
                _cursor.Hidden = true;
                DirectXHook.AddImage(_cursor, 1);
            }

            _cursor.Hidden = hidden;
        }