Ejemplo n.º 1
0
        public override void ShowDialog(object sender, EventArgs e)
        {
            if (d3d == null)
            {
                d3d = new Direct3D();
                var pm = new SlimDX.Direct3D9.PresentParameters();
                pm.Windowed = true;
                device = new Device(d3d, 0, DeviceType.Reference, IntPtr.Zero, CreateFlags.FpuPreserve, pm);
            }

            string[] files;
            string path;
            if (ConvDlg.Show(Name, GetOpenFilter(), out files, out path) == DialogResult.OK)
            {
                ProgressDlg pd = new ProgressDlg(DevStringTable.Instance["GUI:Converting"]);

                pd.MinVal = 0;
                pd.Value = 0;
                pd.MaxVal = files.Length;

                pd.Show();
                for (int i = 0; i < files.Length; i++)
                {
                    string dest = Path.Combine(path, Path.GetFileNameWithoutExtension(files[i]) + ".x");

                    Convert(new DevFileLocation(files[i]), new DevFileLocation(dest));
                    pd.Value = i;
                }
                pd.Close();
                pd.Dispose();
            }
        }
Ejemplo n.º 2
0
        public override void ShowDialog(object sender, EventArgs e)
        {
            if (d3d == null)
            {
                d3d = new Direct3D();
                var pm = new SlimDX.Direct3D9.PresentParameters();
                pm.Windowed = true;
                device      = new Device(d3d, 0, DeviceType.Reference, IntPtr.Zero, CreateFlags.FpuPreserve, pm);
            }

            string[] files;
            string   path;

            if (ConvDlg.Show(Name, GetOpenFilter(), out files, out path) == DialogResult.OK)
            {
                ProgressDlg pd = new ProgressDlg(DevStringTable.Instance["GUI:Converting"]);

                pd.MinVal = 0;
                pd.Value  = 0;
                pd.MaxVal = files.Length;

                pd.Show();
                for (int i = 0; i < files.Length; i++)
                {
                    string dest = Path.Combine(path, Path.GetFileNameWithoutExtension(files[i]) + ".x");

                    Convert(new DevFileLocation(files[i]), new DevFileLocation(dest));
                    pd.Value = i;
                }
                pd.Close();
                pd.Dispose();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes)
 /// </summary>
 /// <param name="devicePtr"></param>
 /// <param name="presentParameters"></param>
 /// <returns></returns>
 int ResetHook(IntPtr devicePtr, ref SlimDX.Direct3D9.PresentParameters presentParameters)
 {
     using (Device device = Device.FromPointer(devicePtr))
     {
         Cleanup();
         return(device.Reset(presentParameters).Code);
     }
 }
Ejemplo n.º 4
0
        public static void Initialize()
        {
            frm = new Form();
            frm.Show();

            d3d = new DX.Direct3D();

            DX.PresentParameters pm = new DX.PresentParameters();
            pm.Windowed = true; pm.AutoDepthStencilFormat = DX.Format.D24S8;

            device = new DX.Device(d3d, 0, DX.DeviceType.Reference, frm.Handle, DX.CreateFlags.SoftwareVertexProcessing, pm);
        }
Ejemplo n.º 5
0
        private void Main_Load(object sender, EventArgs e)
        {
            HotKey = new Hotkey();
            HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.Insert); // Delete //Insert
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F1);
            HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.N);
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F3);
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F5);
            //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.CapsLock);
            //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.Q);

            Native.SetWindowLong(this.Handle, -20, (IntPtr)((Native.GetWindowLong(this.Handle, -20) ^ 0x80000) ^ 0x20));
            Native.SetLayeredWindowAttributes(this.Handle, 0, 0xff, 2);

            PresentParameters parameters = new SlimDX.Direct3D9.PresentParameters();
            parameters.Windowed = true;
            parameters.SwapEffect = SwapEffect.Discard;
            parameters.BackBufferFormat = Format.A8R8G8B8;
            parameters.BackBufferHeight = this.Height;
            parameters.BackBufferWidth = this.Width;
            parameters.PresentationInterval = PresentInterval.One;

            DXDevice = new SlimDX.Direct3D9.Device(new Direct3D(), 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[] { parameters });
            if (System.IO.File.Exists("map_large.png")) DXTextrureMapLarge = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map_large.png");
            if (System.IO.File.Exists("map.png")) DXTextrureMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map.png");
            if (System.IO.File.Exists("LagerMap.jpg")) DXTextureGameMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "LagerMap.jpg");
            CircleVertices = new VertexBuffer(DXDevice, (circleComplexity + 2) * TexVertex.SizeBytes, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            DXSprite = new SlimDX.Direct3D9.Sprite(DXDevice);
            DXLine = new SlimDX.Direct3D9.Line(DXDevice);
            DXFont = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("NewRoman", 9f)); //NewRoman
            DXFontB = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("Tahoma", 12f)); //NewRoman

            if (this.GameMemory.Attach("H1Z1 PlayClient (Live)") == false) { Application.Exit(); return; }
            Thread dxThread = new Thread(new ThreadStart(DoProcess));
            dxThread.IsBackground = true;
            dxThread.Start();

            //Thread aimThread = new Thread(new ThreadStart(DoAiming));
            //aimThread.IsBackground = true;
            //aimThread.Start();
        }
Ejemplo n.º 6
0
		public override void WindowMovedOrResized()
		{
			if ( GetForm( hWnd ) == null || GetForm( hWnd ).WindowState == SWF.FormWindowState.Minimized )
			{
				return;
			}

			// top and left represent outer window position
			top = hWnd.Top;
			left = hWnd.Left;
			// width and height represent drawable area only
			int width = hWnd.ClientRectangle.Width;
			int height = hWnd.ClientRectangle.Height;
			LogManager.Instance.Write( "[D3D] RenderWindow Resized - new dimensions L:{0},T:{1},W:{2},H:{3}", hWnd.Left, hWnd.Top, hWnd.ClientRectangle.Width, hWnd.ClientRectangle.Height );

			if ( Width == width && Height == height )
			{
				return;
			}

			if ( _isSwapChain )
			{
				D3D.PresentParameters pp = _d3dpp;

				pp.BackBufferWidth = width;
				pp.BackBufferHeight = height;

				_swapChain.Dispose();
				_swapChain = null;

				try
				{
					_swapChain = new D3D.SwapChain( D3DDevice, pp );
					_d3dpp = pp;

					this.width = width;
					this.height = height;
				}
				catch ( Exception )
				{
					LogManager.Instance.Write( "Failed to reset device to new dimensions {0}x{1}. Trying to recover.", width, height );
					try
					{
						_swapChain = new D3D.SwapChain( D3DDevice, _d3dpp );
					}
					catch ( Exception ex )
					{
						throw new Exception( "Reset window to last size failed.", ex );
					}
				}
			}
			else // primary windows must reset the device
			{
				_d3dpp.BackBufferWidth = this.width = width;
				_d3dpp.BackBufferHeight = this.height = height;
			}

			// Notify viewports of resize
			foreach ( Viewport entry in this.ViewportList.Values )
			{
				//entry.UpdateDimensions();
			}
		}