diff --git a/OpenRA.FileFormats/FieldLoader.cs b/OpenRA.FileFormats/FieldLoader.cs index 8fcba641a9..6329ea7231 100644 --- a/OpenRA.FileFormats/FieldLoader.cs +++ b/OpenRA.FileFormats/FieldLoader.cs @@ -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().Select(a => a.ToString()).ToArray()) : v.ToString(); diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 6d267ddbe8..741c5dbe20 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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 desktopResolution = Screen.PrimaryScreen.Bounds.Size; + 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; diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index 52408cc37c..4120f5013d 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -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"; diff --git a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs index a42339adb5..946b2eebbd 100644 --- a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using OpenRA.FileFormats.Graphics; namespace OpenRA.Widgets.Delegates { @@ -11,7 +12,16 @@ namespace OpenRA.Widgets.Delegates { var r = Chrome.rootWidget; - // Checkboxes + // Checkboxes + + // Should actually be a listbox; hack with a checkbox for now + r.GetWidget("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("SETTINGS_CHECKBOX_UNITDEBUG").Checked = () => {return Game.Settings.UnitDebug;}; r.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi => { Game.Settings.UnitDebug ^= true; diff --git a/mods/cnc/menus.yaml b/mods/cnc/menus.yaml index 6119b0ba36..1f762d6c63 100644 --- a/mods/cnc/menus.yaml +++ b/mods/cnc/menus.yaml @@ -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 diff --git a/mods/ra/menus.yaml b/mods/ra/menus.yaml index caceb65b49..25fd67b4d8 100644 --- a/mods/ra/menus.yaml +++ b/mods/ra/menus.yaml @@ -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