clean up graphics settings in SettingsMenuLogic.cs

This commit is contained in:
Chris Forbes
2011-07-17 12:37:54 +12:00
parent 10cb967711
commit 2d79c7c424

View File

@@ -83,43 +83,42 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Display // Display
var display = bg.GetWidget("DISPLAY_PANE"); var display = bg.GetWidget("DISPLAY_PANE");
var gs = Game.Settings.Graphics;
var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX"); var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX");
fullscreen.IsChecked = () => Game.Settings.Graphics.Mode != WindowMode.Windowed; fullscreen.IsChecked = () => gs.Mode != WindowMode.Windowed;
fullscreen.OnClick = () => Game.Settings.Graphics.Mode = (Game.Settings.Graphics.Mode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed; fullscreen.OnClick = () => gs.Mode = (gs.Mode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH"); var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
Game.Settings.Graphics.WindowedSize.X = (Game.Settings.Graphics.WindowedSize.X < Game.Settings.Graphics.MinResolution.X)? gs.WindowedSize.X = Math.Max(gs.WindowedSize.X, gs.MinResolution.X);
Game.Settings.Graphics.MinResolution.X : Game.Settings.Graphics.WindowedSize.X; width.Text = gs.WindowedSize.X.ToString();
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
width.OnLoseFocus = () => width.OnLoseFocus = () =>
{ {
try { try {
var w = int.Parse(width.Text); var w = int.Parse(width.Text);
if (w > Game.Settings.Graphics.MinResolution.X) if (w > gs.MinResolution.X)
Game.Settings.Graphics.WindowedSize = new int2(w, Game.Settings.Graphics.WindowedSize.Y); gs.WindowedSize = new int2(w, gs.WindowedSize.Y);
} }
catch (FormatException) { catch (FormatException) {
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString(); width.Text = gs.WindowedSize.X.ToString();
} }
}; };
width.OnEnterKey = () => { width.LoseFocus(); return true; }; width.OnEnterKey = () => { width.LoseFocus(); return true; };
var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT"); var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT");
Game.Settings.Graphics.WindowedSize.Y = (Game.Settings.Graphics.WindowedSize.Y < Game.Settings.Graphics.MinResolution.Y)? gs.WindowedSize.Y = Math.Max(gs.WindowedSize.Y, gs.MinResolution.Y);
Game.Settings.Graphics.MinResolution.Y : Game.Settings.Graphics.WindowedSize.Y; height.Text = gs.WindowedSize.Y.ToString();
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
height.OnLoseFocus = () => height.OnLoseFocus = () =>
{ {
try { try {
var h = int.Parse(height.Text); var h = int.Parse(height.Text);
if (h > Game.Settings.Graphics.MinResolution.Y) if (h > gs.MinResolution.Y)
Game.Settings.Graphics.WindowedSize = new int2(Game.Settings.Graphics.WindowedSize.X, h); gs.WindowedSize = new int2(gs.WindowedSize.X, h);
else else
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString(); height.Text = gs.WindowedSize.Y.ToString();
} }
catch (FormatException) { catch (FormatException) {
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString(); height.Text = gs.WindowedSize.Y.ToString();
} }
}; };
height.OnEnterKey = () => { height.LoseFocus(); return true; }; height.OnEnterKey = () => { height.LoseFocus(); return true; };