Esempio n. 1
0
        private void playGame_Click(object sender, EventArgs e)
        {
            //Need to boot game here
            // new inGame().Show();

            //Modified by AZ: we need to generate a XNA window here to display the game window with hardware boost:
            // XNA_InGame g = new XNA_InGame();
            buttonSnd();
            menuMusic.controls.stop();

            // g.Run();
            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;
                XNA_InGame g = new XNA_InGame();
                g.Run();
                //Console.WriteLine("Hello, world");
            }).Start();
            this.Hide();

            //new MiniMap().Show();

            //this.Hide(); //Don't hide form so can do multiple
        }
Esempio n. 2
0
        private void select_Click(object sender, EventArgs e)
        {
            MainMenu.buttonClickSnd.controls.play();
            MainMenu.menuMusic.controls.stop();//stop the menu music.

            // JD: 2/24, set the next showed window size, location, WindowState
            if (this.WindowState == FormWindowState.Normal)
            {
                Properties.Settings.Default.WindowLocation = this.Location;
                Properties.Settings.Default.WindowSize     = this.Size;
                Properties.Settings.Default.WindowMax      = false;
            }
            else
            {
                Properties.Settings.Default.WindowSize     = this.RestoreBounds.Size;
                Properties.Settings.Default.WindowLocation = this.RestoreBounds.Location;
                Properties.Settings.Default.WindowMax      = true;
            }

            //New method of starting a game:

            /*new Thread(() =>
             * {
             *  Thread.CurrentThread.IsBackground = true;
             *
             *
             *
             *  XNA_InGame g = new XNA_InGame();
             *  g.Run();
             *  //Console.WriteLine("Hello, world");
             * }).Start();*/

            Thread tempGame = new Thread(() =>
            {
                //Thread.CurrentThread.IsBackground = true;
                XNA_InGame g = new XNA_InGame();
                g.Run();
                //Console.WriteLine("Hello, world");
            });

            Thread main = Thread.CurrentThread;

            tempGame.Start();

            //this.Hide(); //hides the form

            if (Thread.CurrentThread == main)
            {
                this.Hide();
                tempGame.Join();                    //wait for game thread to end
                //Thread.CurrentThread.IsBackground = false;
                this.Show();                        //reshow form

                MainMenu.menuMusic.controls.play(); //play the menu music.

                //Not working
                tempGame = null;                  //need to free thread memory
                SplashScreen.coloredUnits = null; //need to free (as we re-init on new XNA)

                //new MainMenu();
            }
        }