From c3b3947b9d8f614fd1796c4e910ebf69a3640b46 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 24 Aug 2010 19:45:36 +1200 Subject: [PATCH] Rename some settings --- OpenRA.Game/Game.cs | 14 +++---- OpenRA.Game/GameRules/Settings.cs | 40 +++++++++---------- OpenRA.Game/Network/Session.cs | 2 +- OpenRA.Game/Server/Server.cs | 10 ++--- OpenRA.Game/Traits/Player/DeveloperMode.cs | 2 +- OpenRA.Game/UiOverlay.cs | 2 +- .../Delegates/CreateServerMenuDelegate.cs | 4 +- .../Delegates/DeveloperModeDelegate.cs | 2 +- .../Widgets/Delegates/LobbyDelegate.cs | 18 ++++----- .../Widgets/Delegates/PerfDebugDelegate.cs | 2 +- .../Delegates/ServerBrowserDelegate.cs | 4 +- .../Widgets/Delegates/SettingsMenuDelegate.cs | 26 ++++++------ OpenRA.Game/Widgets/TimerWidget.cs | 2 +- .../Widgets/ViewportScrollControllerWidget.cs | 6 +-- 14 files changed, 66 insertions(+), 68 deletions(-) mode change 100755 => 100644 OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs mode change 100755 => 100644 OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 9cf4b9e959..84d13746e4 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -115,11 +115,11 @@ namespace OpenRA int t = Environment.TickCount; int dt = t - lastTime; - if (dt >= Settings.General.Timestep) + if (dt >= Settings.Game.Timestep) { using (new PerfSample("tick_time")) { - lastTime += Settings.General.Timestep; + lastTime += Settings.Game.Timestep; Widget.DoTick(world); orderManager.TickImmediate(world); @@ -254,19 +254,19 @@ namespace OpenRA + Path.DirectorySeparatorChar + "OpenRA"; SupportDir = args.GetValue("SupportDir", defaultSupport); - Settings = new Settings(args); + Settings = new Settings(SupportDir + "settings.yaml", args); Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar; Log.AddChannel("perf", "perf.log"); Log.AddChannel("debug", "debug.log"); Log.AddChannel("sync", "syncreport.log"); - LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods; + LobbyInfo.GlobalSettings.Mods = Settings.Game.Mods; modData = new ModData( LobbyInfo.GlobalSettings.Mods ); - Renderer.SheetSize = Settings.General.SheetSize; + Renderer.SheetSize = Settings.Game.SheetSize; - Renderer.Initialize( Game.Settings.Graphics.WindowMode ); + Renderer.Initialize( Game.Settings.Graphics.Mode ); Sound.Initialize(); PerfHistory.items["render"].hasNormalTick = false; @@ -307,7 +307,7 @@ namespace OpenRA orderManager.Dispose(); var shellmap = modData.Manifest.ShellmapUid; LobbyInfo = new Session(); - LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods; + LobbyInfo.GlobalSettings.Mods = Settings.Game.Mods; JoinLocal(); StartGame(shellmap); diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index 37639a481c..23d5276cc3 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -20,7 +20,7 @@ namespace OpenRA.GameRules { public class ServerSettings { - public string LastServerTitle = "OpenRA Game"; + public string Name = "OpenRA Game"; public int ListenPort = 1234; public int ExternalPort = 1234; public bool AdvertiseOnline = true; @@ -30,15 +30,14 @@ namespace OpenRA.GameRules public class DebugSettings { - public bool PerfDebug = false; + public bool PerfGraph = false; public bool RecordSyncReports = true; - public bool ShowGameTimer = true; - public bool UnitDebug = false; + public bool ShowCollisions = false; } public class GraphicSettings { - public WindowMode WindowMode = WindowMode.PseudoFullscreen; + public WindowMode Mode = WindowMode.PseudoFullscreen; public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height); public int2 WindowedSize = new int2(1024,768); public readonly int2 MinResolution = new int2(800, 600); @@ -49,30 +48,28 @@ namespace OpenRA.GameRules public float SoundVolume = 0.5f; public float MusicVolume = 0.5f; public float VideoVolume = 0.5f; - public bool MusicPlayer = false; } public class PlayerSettings { - public string PlayerName = "Newbie"; - public Color PlayerColor1 = Color.FromArgb(255,160,238); - public Color PlayerColor2 = Color.FromArgb(68,0,56); + public string Name = "Newbie"; + public Color Color1 = Color.FromArgb(255,160,238); + public Color Color2 = Color.FromArgb(68,0,56); + public string LastServer = "localhost:1234"; } - public class GeneralSettings + public class GameSettings { + public string[] Mods = { "ra" }; + public bool MatchTimer = true; + // Behaviour settings public bool ViewportEdgeScroll = true; public bool InverseDragScroll = false; - + // Internal game settings public int Timestep = 40; public int SheetSize = 2048; - - // External game settings - public string LastServer = "localhost:1234"; - - public string[] InitialMods = { "ra" }; } public class Settings @@ -80,20 +77,20 @@ namespace OpenRA.GameRules string SettingsFile; public PlayerSettings Player = new PlayerSettings(); - public GeneralSettings General = new GeneralSettings(); + public GameSettings Game = new GameSettings(); public SoundSettings Sound = new SoundSettings(); public GraphicSettings Graphics = new GraphicSettings(); public ServerSettings Server = new ServerSettings(); public DebugSettings Debug = new DebugSettings(); Dictionary Sections; - public Settings(Arguments args) + public Settings(string file, Arguments args) { - SettingsFile = Game.SupportDir + "settings.yaml"; + SettingsFile = file; Sections = new Dictionary() { {"Player", Player}, - {"General", General}, + {"Game", Game}, {"Sound", Sound}, {"Graphics", Graphics}, {"Server", Server}, @@ -115,7 +112,8 @@ namespace OpenRA.GameRules var yaml = MiniYaml.FromFile(SettingsFile); foreach (var kv in Sections) - LoadSectionYaml(yaml[kv.Key], kv.Value); + if (yaml.ContainsKey(kv.Key)) + LoadSectionYaml(yaml[kv.Key], kv.Value); } // Override with commandline args diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index 760cd87579..d3552b0449 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -75,7 +75,7 @@ namespace OpenRA.Network public static Session Deserialize(string data) { var session = new Session(); - session.GlobalSettings.Mods = Game.Settings.General.InitialMods; + session.GlobalSettings.Mods = Game.Settings.Game.Mods; var ys = MiniYaml.FromString(data); foreach (var y in ys) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 6249b8a33c..c0b318ea79 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -56,13 +56,13 @@ namespace OpenRA.Server Server.masterServerUrl = settings.Server.MasterServer; isInternetServer = settings.Server.AdvertiseOnline; listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort); - Name = settings.Server.LastServerTitle; + Name = settings.Server.Name; ExternalPort = settings.Server.ExternalPort; randomSeed = (int)DateTime.Now.ToBinary(); ModData = modData; lobbyInfo = new Session(); - lobbyInfo.GlobalSettings.Mods = settings.General.InitialMods; + lobbyInfo.GlobalSettings.Mods = settings.Game.Mods; lobbyInfo.GlobalSettings.RandomSeed = randomSeed; lobbyInfo.GlobalSettings.Map = map; lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats; @@ -156,9 +156,9 @@ namespace OpenRA.Server new Session.Client() { Index = newConn.PlayerIndex, - Color1 = defaults.PlayerColor1, - Color2 = defaults.PlayerColor2, - Name = defaults.PlayerName, + Color1 = defaults.Color1, + Color2 = defaults.Color2, + Name = defaults.Name, Country = "random", State = Session.ClientState.NotReady, SpawnPoint = 0, diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index cbbad53970..38b6a89e04 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -79,7 +79,7 @@ namespace OpenRA.Traits case "DevUnitDebug": { if (self.World.LocalPlayer == self.Owner) - Game.Settings.Debug.UnitDebug ^= true; + Game.Settings.Debug.ShowCollisions ^= true; break; } } diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs index 3b32b116d0..2fd3074a9c 100644 --- a/OpenRA.Game/UiOverlay.cs +++ b/OpenRA.Game/UiOverlay.cs @@ -42,7 +42,7 @@ namespace OpenRA public void Draw( World world ) { - if (Game.Settings.Debug.UnitDebug) + if (Game.Settings.Debug.ShowCollisions) { var uim = world.WorldActor.Trait(); diff --git a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs index 785990d673..76f248c273 100644 --- a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs @@ -36,7 +36,7 @@ namespace OpenRA.Widgets.Delegates var map = Game.modData.AvailableMaps.Keys.FirstOrDefault(); - settings.Server.LastServerTitle = cs.GetWidget("GAME_TITLE").Text; + settings.Server.Name = cs.GetWidget("GAME_TITLE").Text; settings.Server.ListenPort = int.Parse(cs.GetWidget("LISTEN_PORT").Text); settings.Server.ExternalPort = int.Parse(cs.GetWidget("EXTERNAL_PORT").Text); settings.Save(); @@ -47,7 +47,7 @@ namespace OpenRA.Widgets.Delegates return true; }; - cs.GetWidget("GAME_TITLE").Text = settings.Server.LastServerTitle; + cs.GetWidget("GAME_TITLE").Text = settings.Server.Name; cs.GetWidget("LISTEN_PORT").Text = settings.Server.ListenPort.ToString(); cs.GetWidget("EXTERNAL_PORT").Text = settings.Server.ExternalPort.ToString(); cs.GetWidget("CHECKBOX_ONLINE").Checked = () => settings.Server.AdvertiseOnline; diff --git a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs index ea086a4042..d459639846 100644 --- a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs @@ -49,7 +49,7 @@ namespace OpenRA.Widgets.Delegates }; devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").Checked = - () => Game.Settings.Debug.UnitDebug; + () => Game.Settings.Debug.ShowCollisions; devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi => { Game.IssueOrder(new Order("DevUnitDebug", Game.world.LocalPlayer.PlayerActor)); diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 127e3b4ab8..c61d5ffa23 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -33,8 +33,8 @@ namespace OpenRA.Widgets.Delegates Game.LobbyInfoChanged += UpdateCurrentMap; UpdateCurrentMap(); - CurrentColorPreview1 = Game.Settings.Player.PlayerColor1; - CurrentColorPreview2 = Game.Settings.Player.PlayerColor2; + CurrentColorPreview1 = Game.Settings.Player.Color1; + CurrentColorPreview2 = Game.Settings.Player.Color2; var r = Widget.RootWidget; var lobby = r.GetWidget("SERVER_LOBBY"); @@ -162,8 +162,8 @@ namespace OpenRA.Widgets.Delegates var c1 = ColorFromHSL(hf, sf, lf); var c2 = ColorFromHSL(hf, sf, r*lf); - Game.Settings.Player.PlayerColor1 = c1; - Game.Settings.Player.PlayerColor2 = c2; + Game.Settings.Player.Color1 = c1; + Game.Settings.Player.Color2 = c2; Game.Settings.Save(); Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B))); } @@ -220,11 +220,11 @@ namespace OpenRA.Widgets.Delegates return; hasJoined = true; - if (Game.LocalClient.Name != Game.Settings.Player.PlayerName) - Game.IssueOrder(Order.Command("name " + Game.Settings.Player.PlayerName)); + if (Game.LocalClient.Name != Game.Settings.Player.Name) + Game.IssueOrder(Order.Command("name " + Game.Settings.Player.Name)); - var c1 = Game.Settings.Player.PlayerColor1; - var c2 = Game.Settings.Player.PlayerColor2; + var c1 = Game.Settings.Player.Color1; + var c2 = Game.Settings.Player.Color2; if (Game.LocalClient.Color1 != c1 || Game.LocalClient.Color2 != c2) Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B))); @@ -264,7 +264,7 @@ namespace OpenRA.Widgets.Delegates return true; Game.IssueOrder(Order.Command("name " + name.Text)); - Game.Settings.Player.PlayerName = name.Text; + Game.Settings.Player.Name = name.Text; Game.Settings.Save(); return true; }; diff --git a/OpenRA.Game/Widgets/Delegates/PerfDebugDelegate.cs b/OpenRA.Game/Widgets/Delegates/PerfDebugDelegate.cs index bfa5852a84..beaf16ced6 100644 --- a/OpenRA.Game/Widgets/Delegates/PerfDebugDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/PerfDebugDelegate.cs @@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates { var r = Widget.RootWidget; var perfRoot = r.GetWidget("PERF_BG"); - perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfDebug; + perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfGraph; // Perf text var perfText = perfRoot.GetWidget("TEXT"); diff --git a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs index ec3eb07700..22d53df936 100644 --- a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs @@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates { r.CloseWindow(); - dc.GetWidget("SERVER_ADDRESS").Text = Game.Settings.General.LastServer; + dc.GetWidget("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer; r.OpenWindow("DIRECTCONNECT_BG"); return true; }; @@ -133,7 +133,7 @@ namespace OpenRA.Widgets.Delegates if (cpts.Length != 2) return true; - Game.Settings.General.LastServer = address; + Game.Settings.Player.LastServer = address; Game.Settings.Save(); r.CloseWindow(); diff --git a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs old mode 100755 new mode 100644 index c3aeb3b98a..62bb46e4c9 --- a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs @@ -34,31 +34,31 @@ namespace OpenRA.Widgets.Delegates var general = bg.GetWidget("GENERAL_PANE"); var name = general.GetWidget("NAME"); - name.Text = Game.Settings.Player.PlayerName; + name.Text = Game.Settings.Player.Name; name.OnLoseFocus = () => { name.Text = name.Text.Trim(); if (name.Text.Length == 0) - name.Text = Game.Settings.Player.PlayerName; + name.Text = Game.Settings.Player.Name; else - Game.Settings.Player.PlayerName = name.Text; + Game.Settings.Player.Name = name.Text; }; name.OnEnterKey = () => { name.LoseFocus(); return true; }; var edgeScroll = general.GetWidget("EDGE_SCROLL"); - edgeScroll.Checked = () => Game.Settings.General.ViewportEdgeScroll; + edgeScroll.Checked = () => Game.Settings.Game.ViewportEdgeScroll; edgeScroll.OnMouseDown = mi => { - Game.Settings.General.ViewportEdgeScroll ^= true; + Game.Settings.Game.ViewportEdgeScroll ^= true; return true; }; var inverseScroll = general.GetWidget("INVERSE_SCROLL"); - inverseScroll.Checked = () => Game.Settings.General.InverseDragScroll; + inverseScroll.Checked = () => Game.Settings.Game.InverseDragScroll; inverseScroll.OnMouseDown = mi => { - Game.Settings.General.InverseDragScroll ^= true; + Game.Settings.Game.InverseDragScroll ^= true; return true; }; @@ -77,10 +77,10 @@ namespace OpenRA.Widgets.Delegates // Display var display = bg.GetWidget("DISPLAY_PANE"); var fullscreen = display.GetWidget("FULLSCREEN_CHECKBOX"); - fullscreen.Checked = () => {return Game.Settings.Graphics.WindowMode != WindowMode.Windowed;}; + fullscreen.Checked = () => {return Game.Settings.Graphics.Mode != WindowMode.Windowed;}; fullscreen.OnMouseDown = mi => { - Game.Settings.Graphics.WindowMode = (Game.Settings.Graphics.WindowMode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed; + Game.Settings.Graphics.Mode = (Game.Settings.Graphics.Mode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed; return true; }; @@ -125,10 +125,10 @@ namespace OpenRA.Widgets.Delegates // Debug var debug = bg.GetWidget("DEBUG_PANE"); var perfdebug = debug.GetWidget("PERFDEBUG_CHECKBOX"); - perfdebug.Checked = () => {return Game.Settings.Debug.PerfDebug;}; + perfdebug.Checked = () => {return Game.Settings.Debug.PerfGraph;}; perfdebug.OnMouseDown = mi => { - Game.Settings.Debug.PerfDebug ^= true; + Game.Settings.Debug.PerfGraph ^= true; return true; }; @@ -141,10 +141,10 @@ namespace OpenRA.Widgets.Delegates }; var timedebug = debug.GetWidget("GAMETIME_CHECKBOX"); - timedebug.Checked = () => {return Game.Settings.Debug.ShowGameTimer;}; + timedebug.Checked = () => {return Game.Settings.Game.MatchTimer;}; timedebug.OnMouseDown = mi => { - Game.Settings.Debug.ShowGameTimer ^= true; + Game.Settings.Game.MatchTimer ^= true; return true; }; diff --git a/OpenRA.Game/Widgets/TimerWidget.cs b/OpenRA.Game/Widgets/TimerWidget.cs index 10e6280c39..fb75af9029 100644 --- a/OpenRA.Game/Widgets/TimerWidget.cs +++ b/OpenRA.Game/Widgets/TimerWidget.cs @@ -19,7 +19,7 @@ namespace OpenRA.Widgets public TimerWidget () { - IsVisible = () => Game.Settings.Debug.ShowGameTimer; + IsVisible = () => Game.Settings.Game.MatchTimer; } public override void DrawInner(World world) diff --git a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs old mode 100755 new mode 100644 index 81686c64e0..bc91a4f936 --- a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs @@ -39,7 +39,7 @@ namespace OpenRA.Widgets if (mi.Event == MouseInputEvent.Move && (mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right))) { - int InverseScroll = Game.Settings.General.InverseDragScroll ? -1 : 1; + int InverseScroll = Game.Settings.Game.InverseDragScroll ? -1 : 1; Game.viewport.Scroll((Viewport.LastMousePos - mi.Location) * InverseScroll); return true; } @@ -48,7 +48,7 @@ namespace OpenRA.Widgets public override string GetCursor(int2 pos) { - if (!Game.Settings.General.ViewportEdgeScroll) + if (!Game.Settings.Game.ViewportEdgeScroll) return null; if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left)) @@ -93,7 +93,7 @@ namespace OpenRA.Widgets public override void Tick(World world) { Edge = ScrollDirection.None; - if (Game.Settings.General.ViewportEdgeScroll) + if (Game.Settings.Game.ViewportEdgeScroll) { // Check for edge-scroll if (Viewport.LastMousePos.X < EdgeScrollThreshold)