Exemple #1
0
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry--;

                    if (SelectedEntry < 0)
                    {
                        SelectedEntry = MenuEntries.Count - 1;
                    }
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry--;

                    if (ResolutionSelectedEntry < 0)
                    {
                        ResolutionSelectedEntry = ResolutionEntries.Count - 1;
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry++;

                    if (SelectedEntry >= MenuEntries.Count)
                    {
                        SelectedEntry = 0;
                    }
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry++;

                    if (ResolutionSelectedEntry >= ResolutionEntries.Count)
                    {
                        ResolutionSelectedEntry = 0;
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                switch (SelectedEntry)
                {
                case (int)OptionsEntry.Resolution:
                    if (ResolutionActive)
                    {
                        Resolution res = Resolutions[ResolutionSelectedEntry];
                        this.ScreenManager.Graphics.PreferredBackBufferWidth  = res.Width;
                        this.ScreenManager.Graphics.PreferredBackBufferHeight = res.Height;
                        ClientOptions.SetResolution(res.Height, res.Width);

                        ResolutionChanged = true;
                        ResolutionActive  = false;
                    }
                    else if (!ResolutionActive)
                    {
                        ResolutionActive = true;
                    }
                    break;

                case (int)OptionsEntry.Fullscreen:
                    if (ClientOptions.Fullscreen)
                    {
                        this.ScreenManager.Graphics.ToggleFullScreen();
                        ClientOptions.SetFullscreen(false);
                    }
                    else
                    {
                        this.ScreenManager.Graphics.ToggleFullScreen();
                        ClientOptions.SetFullscreen(true);
                    }
                    FullscreenChanged = true;
                    break;

                case (int)OptionsEntry.Exit:
                    ClientOptions.Save();     // save client options
                    ScreenManager.RemoveScreen(this);
                    ParentScreen.CurrentScreenState = ScreenState.Active;
                    break;
                }
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                if (ResolutionActive)
                {
                    ResolutionActive = false;
                }
                else
                {
                    ClientOptions.Save();
                    ScreenManager.RemoveScreen(this);
                    ParentScreen.CurrentScreenState = ScreenState.Active;
                }
            }
        }