void BackMenuEntrySelected(object sender, PlayerIndexEventArgs e) { // Save settings var manager = new Settings.SettingsManager(); var settings = manager.Load <Settings.GeneralSettings>(); settings.Fullscreen = _fullScreen; settings.Width = (int)_resolutions[_currentResolution].X; settings.Height = (int)_resolutions[_currentResolution].Y; manager.Save(settings); // Go to previous menu OnCancel(sender, e); }
public OptionsMenuScreen() : base("Options") { _fullScreen = Static.Game.GraphicsDeviceManager.IsFullScreen; var screen = Screen.AllScreens.First(n => n.Primary); var ratio = (float)screen.Bounds.Width / screen.Bounds.Height; foreach (var res in _availableResolutions.Where(res => Math.Abs(res.X / res.Y - ratio) < 0.001 && res.X <= screen.Bounds.Width || (int)res.X == 800 && (int)res.Y == 600)) { _resolutions.Add(res); } // Load settings var manager = new Settings.SettingsManager(); var settings = manager.Load <Settings.GeneralSettings>(); _fullScreen = settings.Fullscreen; if (_fullScreen) { _oldSize = new Vector2( settings.Width, settings.Height); } // Create our menu entries. _languageMenuEntry = new MenuEntry(string.Empty); _fullScreenMenuEntry = new MenuEntry(string.Empty); _resolutionMenuEntry = new MenuEntry(string.Empty); SetMenuEntryText(); var back = new MenuEntry("Back"); // Hook up menu event handlers. _languageMenuEntry.Selected += LanguageMenuEntrySelected; _fullScreenMenuEntry.Selected += FullScreenMenuEntrySelected; _resolutionMenuEntry.Selected += ResolutionMenuEntrySelected; back.Selected += BackMenuEntrySelected; // Add entries to the menu. MenuEntries.Add(_languageMenuEntry); MenuEntries.Add(_fullScreenMenuEntry); MenuEntries.Add(_resolutionMenuEntry); MenuEntries.Add(back); }