Fullscreen toggle & don't crash when saving null fields

This commit is contained in:
Paul Chote
2010-07-10 15:42:50 +12:00
parent 636bfd5e0a
commit 77405a7700
6 changed files with 44 additions and 11 deletions

View File

@@ -149,6 +149,9 @@ namespace OpenRA.FileFormats
public static string FormatValue(object o, FieldInfo f)
{
var v = f.GetValue(o);
if (v == null)
return "";
return f.FieldType.IsArray
? string.Join(",", ((Array)v).OfType<object>().Select(a => a.ToString()).ToArray())
: v.ToString();

View File

@@ -27,6 +27,7 @@ using System.Reflection;
using System.Text;
using System.Windows.Forms;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Network;
@@ -546,13 +547,15 @@ namespace OpenRA
controller.SetModifiers(mods);
}
static Size GetResolution(Settings settings)
static Size GetResolution(Settings settings, WindowMode windowmode)
{
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
if (Settings.Width > 0 && Settings.Height > 0)
var customSize = (windowmode == WindowMode.Windowed) ? Settings.WindowedSize : Settings.FullscreenSize;
if (customSize.X > 0 && customSize.Y > 0)
{
desktopResolution.Width = Settings.Width;
desktopResolution.Height = Settings.Height;
desktopResolution.Width = customSize.X;
desktopResolution.Height = customSize.Y;
}
return new Size(
desktopResolution.Width,
@@ -581,7 +584,7 @@ namespace OpenRA
Renderer.SheetSize = Settings.SheetSize;
var resolution = GetResolution(settings);
var resolution = GetResolution(settings, Game.Settings.WindowMode);
renderer = new Renderer(resolution, Game.Settings.WindowMode);
resolution = renderer.Resolution;

View File

@@ -22,6 +22,7 @@ using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
namespace OpenRA.GameRules
{
@@ -35,9 +36,11 @@ namespace OpenRA.GameRules
public bool RecordSyncReports = true;
// Window settings
public readonly int Width = 0;
public readonly int Height = 0;
public readonly WindowMode WindowMode = WindowMode.PseudoFullscreen;
public WindowMode WindowMode = WindowMode.PseudoFullscreen;
public int2 FullscreenSize = new int2(0,0);
public int2 WindowedSize = new int2(1024,768);
public bool MusicPlayer = true;
// Internal game settings
@@ -48,7 +51,7 @@ namespace OpenRA.GameRules
public readonly string NetworkHost = null;
public readonly int NetworkPort = 0;
public readonly string Replay = null;
public readonly string PlayerName = null;
public string PlayerName = null;
public readonly string[] InitialMods = { "ra" };
public readonly string GameName = "OpenRA Game";

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRA.FileFormats.Graphics;
namespace OpenRA.Widgets.Delegates
{
@@ -12,6 +13,15 @@ namespace OpenRA.Widgets.Delegates
var r = Chrome.rootWidget;
// Checkboxes
// Should actually be a listbox; hack with a checkbox for now
r.GetWidget<CheckboxWidget>("CHECKBOX_FULLSCREEN").Checked = () => {return Game.Settings.WindowMode != WindowMode.Windowed;};
r.GetWidget("CHECKBOX_FULLSCREEN").OnMouseDown = mi => {
Game.Settings.WindowMode = (Game.Settings.WindowMode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
Game.Settings.Save();
return true;
};
r.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_UNITDEBUG").Checked = () => {return Game.Settings.UnitDebug;};
r.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi => {
Game.Settings.UnitDebug ^= true;

View File

@@ -158,6 +158,13 @@ Container:
Width:300
Height:20
Text:Show Music Player
Checkbox@CHECKBOX_FULLSCREEN:
Id:CHECKBOX_FULLSCREEN
X:100
Y:240
Width:300
Height:20
Text:Fullscreen (Requires restart)
Button@SETTINGS_BUTTON_OK:
Id:SETTINGS_BUTTON_OK
X:PARENT_RIGHT - 180

View File

@@ -158,6 +158,13 @@ Container:
Width:300
Height:20
Text:Show Music Player
Checkbox@CHECKBOX_FULLSCREEN:
Id:CHECKBOX_FULLSCREEN
X:100
Y:240
Width:300
Height:20
Text:Fullscreen (Requires restart)
Button@SETTINGS_BUTTON_OK:
Id:SETTINGS_BUTTON_OK
X:PARENT_RIGHT - 180