コード例 #1
0
        public override void Update(out State state, MainMenuScreen mainMenuScreen, ResolutionScreen resolutionScreen)
        {
            base.Update(out state, mainMenuScreen, resolutionScreen);

            for (int i = 0; i < menuItems.Count; i++)
            {
                if (mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released && mouseState.X > Window.ClientBounds.Width / 2 - 150 * scaleIndex && mouseState.X < Window.ClientBounds.Width / 2 + 150 * scaleIndex && mouseState.Y > Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) && mouseState.Y < Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) + 50 * scaleIndex)
                {
                    switch (i)
                    {
                    case 0:
                        graphics.PreferredBackBufferWidth  = 800;
                        graphics.PreferredBackBufferHeight = 600;


                        break;

                    case 1:
                        graphics.PreferredBackBufferWidth  = 1024;
                        graphics.PreferredBackBufferHeight = 768;

                        break;

                    case 2:
                        graphics.PreferredBackBufferWidth  = 1152;
                        graphics.PreferredBackBufferHeight = 864;

                        break;

                    case 3:
                        graphics.PreferredBackBufferWidth  = 1280;
                        graphics.PreferredBackBufferHeight = 720;

                        break;

                    case 4:
                        graphics.PreferredBackBufferWidth  = 1280;
                        graphics.PreferredBackBufferHeight = 768;

                        break;

                    case 5:
                        graphics.PreferredBackBufferWidth  = 1280;
                        graphics.PreferredBackBufferHeight = 800;

                        break;

                    case 6:
                        graphics.PreferredBackBufferWidth  = 1280;
                        graphics.PreferredBackBufferHeight = 1024;

                        break;

                    case 7:
                        graphics.PreferredBackBufferWidth  = 1360;
                        graphics.PreferredBackBufferHeight = 768;

                        break;

                    case 8:
                        graphics.PreferredBackBufferWidth  = 1366;
                        graphics.PreferredBackBufferHeight = 768;

                        break;

                    case 9:
                        graphics.PreferredBackBufferWidth  = 1440;
                        graphics.PreferredBackBufferHeight = 900;

                        break;

                    case 10:
                        graphics.PreferredBackBufferWidth  = 1600;
                        graphics.PreferredBackBufferHeight = 1200;

                        break;

                    case 11:
                        graphics.IsFullScreen = true;
                        graphics.ApplyChanges();
                        graphics.PreferredBackBufferWidth  = Window.ClientBounds.Width;
                        graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
                        graphics.ApplyChanges();
                        break;

                    case 12:

                        graphics.IsFullScreen = false;

                        break;

                    case 13:
                        state = State.mainMenuScreen;
                        mainMenuScreen.initialize(mouseState);
                        break;
                    }
                    if (i >= 0 && i < 13 && i != 11)
                    {
                        graphics.IsFullScreen = true;
                        graphics.ApplyChanges();
                        int width  = Window.ClientBounds.Width;
                        int height = Window.ClientBounds.Height;
                        graphics.IsFullScreen = false;
                        graphics.ApplyChanges();
                        Window.Position = new Point(width / 2 - Window.ClientBounds.Width / 2, height / 2 - Window.ClientBounds.Height / 2);
                    }
                }
            }
            prevMouseState = mouseState;
        }