public IState UpdateState(ref GameSettings gameSettings, GameTime gameTime, Camera camera, KeyboardState currentKey, KeyboardState prevKey, MouseState currentMouse, MouseState prevMouse) { if (currentKey.IsKeyDown(Keys.Escape) && prevKey.IsKeyUp(Keys.Escape)) { return(this._prevState); } if (currentKey.IsKeyDown(Keys.Up) && prevKey.IsKeyUp(Keys.Up)) { _selectedOption -= 1; if (_selectedOption < 0) { _selectedOption = Enum.GetNames(typeof(Options)).Length - 1; } if (_selectedOption > Enum.GetNames(typeof(Options)).Length - 1) { _selectedOption = 0; } } if (currentKey.IsKeyDown(Keys.Down) && prevKey.IsKeyUp(Keys.Down)) { _selectedOption += 1; if (_selectedOption < 0) { _selectedOption = Enum.GetNames(typeof(Options)).Length - 1; } if (_selectedOption > Enum.GetNames(typeof(Options)).Length - 1) { _selectedOption = 0; } } if (currentKey.IsKeyDown(Keys.Left) && prevKey.IsKeyUp(Keys.Left) && _optionItems[_selectedOption].OptionsCollection != null) { _optionItems[_selectedOption].Selection -= 1; if (_optionItems[_selectedOption].Selection < 0) { _optionItems[_selectedOption].Selection = _optionItems[_selectedOption].OptionsCollection.Count - 1; } if (_optionItems[_selectedOption].Selection >= _optionItems[_selectedOption].OptionsCollection.Count) { _optionItems[_selectedOption].Selection = 0; } } if (currentKey.IsKeyDown(Keys.Right) && prevKey.IsKeyUp(Keys.Right) && _optionItems[_selectedOption].OptionsCollection != null) { _optionItems[_selectedOption].Selection += 1; if (_optionItems[_selectedOption].Selection < 0) { _optionItems[_selectedOption].Selection = _optionItems[_selectedOption].OptionsCollection.Count - 1; } if (_optionItems[_selectedOption].Selection >= _optionItems[_selectedOption].OptionsCollection.Count) { _optionItems[_selectedOption].Selection = 0; } } if (currentKey.IsKeyDown(Keys.Enter) && prevKey.IsKeyUp(Keys.Enter)) { switch (_selectedOption) { case (int)Options.ACCEPT_CHANGES: this._gameSettings.Resolution = (Vector2)_optionItems[(int)Options.RESOLUTION].OptionsCollection[_optionItems[(int)Options.RESOLUTION].Selection]; this._gameSettings.Borderless = (bool)_optionItems[(int)Options.BORDERLESS_WINDOW].OptionsCollection[_optionItems[(int)Options.BORDERLESS_WINDOW].Selection]; this._gameSettings.Vsync = (bool)_optionItems[(int)Options.VSYNC].OptionsCollection[_optionItems[(int)Options.VSYNC].Selection]; SettingsIO.SaveGameSettings(ref this._gameSettings); return(this._prevState); case (int)Options.DEFAULT_SETTINGS: SettingsIO.ResetGameSettings(); gameSettings = SettingsIO.LoadGameSettings(); return(new SettingsState(ref gameSettings, this._content, this._prevState)); case (int)Options.CANCEL: return(this._prevState); } } return(this); }