Part 2 of 3: Split Settings into logical units.
Syntax for command line overrides is now <section>.<setting>=<value> eg `General.InitialMods=cnc'
This commit is contained in:
@@ -115,11 +115,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
int t = Environment.TickCount;
|
int t = Environment.TickCount;
|
||||||
int dt = t - lastTime;
|
int dt = t - lastTime;
|
||||||
if (dt >= Settings.Timestep)
|
if (dt >= Settings.General.Timestep)
|
||||||
{
|
{
|
||||||
using (new PerfSample("tick_time"))
|
using (new PerfSample("tick_time"))
|
||||||
{
|
{
|
||||||
lastTime += Settings.Timestep;
|
lastTime += Settings.General.Timestep;
|
||||||
Widget.DoTick(world);
|
Widget.DoTick(world);
|
||||||
|
|
||||||
orderManager.TickImmediate(world);
|
orderManager.TickImmediate(world);
|
||||||
@@ -261,12 +261,12 @@ namespace OpenRA
|
|||||||
Log.AddChannel("debug", "debug.log");
|
Log.AddChannel("debug", "debug.log");
|
||||||
Log.AddChannel("sync", "syncreport.log");
|
Log.AddChannel("sync", "syncreport.log");
|
||||||
|
|
||||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods;
|
||||||
modData = new ModData( LobbyInfo.GlobalSettings.Mods );
|
modData = new ModData( LobbyInfo.GlobalSettings.Mods );
|
||||||
|
|
||||||
Renderer.SheetSize = Settings.SheetSize;
|
Renderer.SheetSize = Settings.General.SheetSize;
|
||||||
|
|
||||||
Renderer.Initialize( Game.Settings.WindowMode );
|
Renderer.Initialize( Game.Settings.Graphics.WindowMode );
|
||||||
|
|
||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
PerfHistory.items["render"].hasNormalTick = false;
|
PerfHistory.items["render"].hasNormalTick = false;
|
||||||
@@ -307,7 +307,7 @@ namespace OpenRA
|
|||||||
orderManager.Dispose();
|
orderManager.Dispose();
|
||||||
var shellmap = modData.Manifest.ShellmapUid;
|
var shellmap = modData.Manifest.ShellmapUid;
|
||||||
LobbyInfo = new Session();
|
LobbyInfo = new Session();
|
||||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods;
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
StartGame(shellmap);
|
StartGame(shellmap);
|
||||||
|
|
||||||
|
|||||||
@@ -14,32 +14,56 @@ using System.IO;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenRA.GameRules
|
namespace OpenRA.GameRules
|
||||||
{
|
{
|
||||||
public class Settings
|
public class ServerSettings
|
||||||
|
{
|
||||||
|
public string LastServerTitle = "OpenRA Game";
|
||||||
|
public int ListenPort = 1234;
|
||||||
|
public int ExternalPort = 1234;
|
||||||
|
public bool AdvertiseOnline = true;
|
||||||
|
public string MasterServer = "http://open-ra.org/master/";
|
||||||
|
public bool AllowCheats = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DebugSettings
|
||||||
{
|
{
|
||||||
// Behaviour settings
|
|
||||||
public bool ViewportEdgeScroll = true;
|
|
||||||
public bool InverseDragScroll = false;
|
|
||||||
|
|
||||||
// Debug settings
|
|
||||||
public bool PerfDebug = false;
|
public bool PerfDebug = false;
|
||||||
public bool RecordSyncReports = true;
|
public bool RecordSyncReports = true;
|
||||||
public bool ShowGameTimer = true;
|
public bool ShowGameTimer = true;
|
||||||
public bool UnitDebug = false;
|
public bool UnitDebug = false;
|
||||||
|
}
|
||||||
// Window settings
|
|
||||||
|
public class GraphicSettings
|
||||||
|
{
|
||||||
public WindowMode WindowMode = WindowMode.PseudoFullscreen;
|
public WindowMode WindowMode = WindowMode.PseudoFullscreen;
|
||||||
public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
|
public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
|
||||||
public int2 WindowedSize = new int2(1024,768);
|
public int2 WindowedSize = new int2(1024,768);
|
||||||
public readonly int2 MinResolution = new int2(800, 600);
|
public readonly int2 MinResolution = new int2(800, 600);
|
||||||
|
}
|
||||||
//Sound Settings
|
|
||||||
|
public class SoundSettings
|
||||||
|
{
|
||||||
public float SoundVolume = 0.5f;
|
public float SoundVolume = 0.5f;
|
||||||
public float MusicVolume = 0.5f;
|
public float MusicVolume = 0.5f;
|
||||||
public float VideoVolume = 0.5f;
|
public float VideoVolume = 0.5f;
|
||||||
public bool MusicPlayer = false;
|
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 class GeneralSettings
|
||||||
|
{
|
||||||
|
// Behaviour settings
|
||||||
|
public bool ViewportEdgeScroll = true;
|
||||||
|
public bool InverseDragScroll = false;
|
||||||
|
|
||||||
// Internal game settings
|
// Internal game settings
|
||||||
public int Timestep = 40;
|
public int Timestep = 40;
|
||||||
@@ -47,40 +71,39 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
// External game settings
|
// External game settings
|
||||||
public string LastServer = "localhost:1234";
|
public string LastServer = "localhost:1234";
|
||||||
public string PlayerName = "Newbie";
|
|
||||||
public Color PlayerColor1 = Color.FromArgb(255,160,238);
|
|
||||||
public Color PlayerColor2 = Color.FromArgb(68,0,56);
|
|
||||||
|
|
||||||
public string[] InitialMods = { "ra" };
|
public string[] InitialMods = { "ra" };
|
||||||
|
}
|
||||||
// Server settings
|
|
||||||
public string LastServerTitle = "OpenRA Game";
|
public class Settings
|
||||||
public int ListenPort = 1234;
|
{
|
||||||
public int ExternalPort = 1234;
|
|
||||||
public bool AdvertiseOnline = true;
|
|
||||||
public string MasterServer = "http://open-ra.org/master/";
|
|
||||||
public bool AllowCheats = false;
|
|
||||||
|
|
||||||
string SettingsFile;
|
string SettingsFile;
|
||||||
Settings defaults;
|
|
||||||
|
|
||||||
public Settings() {}
|
public PlayerSettings Player = new PlayerSettings();
|
||||||
|
public GeneralSettings General = new GeneralSettings();
|
||||||
|
public SoundSettings Sound = new SoundSettings();
|
||||||
|
public GraphicSettings Graphics = new GraphicSettings();
|
||||||
|
public ServerSettings Server = new ServerSettings();
|
||||||
|
public DebugSettings Debug = new DebugSettings();
|
||||||
|
|
||||||
|
Dictionary<string, object> Sections;
|
||||||
public Settings(Arguments args)
|
public Settings(Arguments args)
|
||||||
{
|
{
|
||||||
defaults = new Settings();
|
|
||||||
SettingsFile = Game.SupportDir + "settings.yaml";
|
SettingsFile = Game.SupportDir + "settings.yaml";
|
||||||
|
Sections = new Dictionary<string, object>()
|
||||||
// Override settings loading to not crash
|
{
|
||||||
|
{"Player", Player},
|
||||||
|
{"General", General},
|
||||||
|
{"Sound", Sound},
|
||||||
|
{"Graphics", Graphics},
|
||||||
|
{"Server", Server},
|
||||||
|
{"Debug", Debug}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Override fieldloader to ignore invalid entries
|
||||||
var err1 = FieldLoader.UnknownFieldAction;
|
var err1 = FieldLoader.UnknownFieldAction;
|
||||||
var err2 = FieldLoader.InvalidValueAction;
|
var err2 = FieldLoader.InvalidValueAction;
|
||||||
|
|
||||||
FieldLoader.InvalidValueAction = (s,t,f) =>
|
|
||||||
{
|
|
||||||
object ret = defaults.GetType().GetField(f).GetValue(defaults);
|
|
||||||
System.Console.WriteLine("FieldLoader: Cannot parse `{0}` into `{2}:{1}`; substituting default `{3}`".F(s,t.Name,f,ret) );
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
FieldLoader.UnknownFieldAction = (s,f) =>
|
FieldLoader.UnknownFieldAction = (s,f) =>
|
||||||
{
|
{
|
||||||
System.Console.WriteLine( "Ignoring unknown field `{0}` on `{1}`".F( s, f.Name ) );
|
System.Console.WriteLine( "Ignoring unknown field `{0}` on `{1}`".F( s, f.Name ) );
|
||||||
@@ -90,12 +113,16 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
System.Console.WriteLine("Loading settings file {0}",SettingsFile);
|
System.Console.WriteLine("Loading settings file {0}",SettingsFile);
|
||||||
var yaml = MiniYaml.FromFile(SettingsFile);
|
var yaml = MiniYaml.FromFile(SettingsFile);
|
||||||
FieldLoader.Load(this, yaml["Settings"]);
|
|
||||||
|
foreach (var kv in Sections)
|
||||||
|
LoadSectionYaml(yaml[kv.Key], kv.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var f in this.GetType().GetFields())
|
// Override with commandline args
|
||||||
if (args.Contains(f.Name))
|
foreach (var kv in Sections)
|
||||||
OpenRA.FileFormats.FieldLoader.LoadField( this, f.Name, args.GetValue(f.Name, "") );
|
foreach (var f in kv.Value.GetType().GetFields())
|
||||||
|
if (args.Contains(kv.Key+"."+f.Name))
|
||||||
|
OpenRA.FileFormats.FieldLoader.LoadField( kv.Value, f.Name, args.GetValue(kv.Key+"."+f.Name, "") );
|
||||||
|
|
||||||
FieldLoader.UnknownFieldAction = err1;
|
FieldLoader.UnknownFieldAction = err1;
|
||||||
FieldLoader.InvalidValueAction = err2;
|
FieldLoader.InvalidValueAction = err2;
|
||||||
@@ -104,8 +131,28 @@ namespace OpenRA.GameRules
|
|||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
||||||
root.Add("Settings", FieldSaver.SaveDifferences(this, defaults));
|
foreach (var kv in Sections)
|
||||||
|
root.Add(kv.Key, SectionYaml(kv.Value));
|
||||||
|
|
||||||
root.WriteToFile(SettingsFile);
|
root.WriteToFile(SettingsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MiniYaml SectionYaml(object section)
|
||||||
|
{
|
||||||
|
return FieldSaver.SaveDifferences(section, Activator.CreateInstance(section.GetType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadSectionYaml(MiniYaml yaml, object section)
|
||||||
|
{
|
||||||
|
object defaults = Activator.CreateInstance(section.GetType());
|
||||||
|
FieldLoader.InvalidValueAction = (s,t,f) =>
|
||||||
|
{
|
||||||
|
object ret = defaults.GetType().GetField(f).GetValue(defaults);
|
||||||
|
System.Console.WriteLine("FieldLoader: Cannot parse `{0}` into `{2}:{1}`; substituting default `{3}`".F(s,t.Name,f,ret) );
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
FieldLoader.Load(section, yaml);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace OpenRA.Graphics
|
|||||||
static Size GetResolution(WindowMode windowmode)
|
static Size GetResolution(WindowMode windowmode)
|
||||||
{
|
{
|
||||||
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
||||||
var customSize = (windowmode == WindowMode.Windowed) ? Game.Settings.WindowedSize : Game.Settings.FullscreenSize;
|
var customSize = (windowmode == WindowMode.Windowed) ? Game.Settings.Graphics.WindowedSize : Game.Settings.Graphics.FullscreenSize;
|
||||||
|
|
||||||
if (customSize.X > 0 && customSize.Y > 0)
|
if (customSize.X > 0 && customSize.Y > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace OpenRA.Network
|
|||||||
public static Session Deserialize(string data)
|
public static Session Deserialize(string data)
|
||||||
{
|
{
|
||||||
var session = new Session();
|
var session = new Session();
|
||||||
session.GlobalSettings.Mods = Game.Settings.InitialMods;
|
session.GlobalSettings.Mods = Game.Settings.General.InitialMods;
|
||||||
|
|
||||||
var ys = MiniYaml.FromString(data);
|
var ys = MiniYaml.FromString(data);
|
||||||
foreach (var y in ys)
|
foreach (var y in ys)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
internal void UpdateSyncReport()
|
internal void UpdateSyncReport()
|
||||||
{
|
{
|
||||||
if (!Game.Settings.RecordSyncReports)
|
if (!Game.Settings.Debug.RecordSyncReports)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (syncReports.Count >= numSyncReports) syncReports.Dequeue();
|
while (syncReports.Count >= numSyncReports) syncReports.Dequeue();
|
||||||
|
|||||||
@@ -53,19 +53,19 @@ namespace OpenRA.Server
|
|||||||
Log.AddChannel("server", "server.log");
|
Log.AddChannel("server", "server.log");
|
||||||
|
|
||||||
isInitialPing = true;
|
isInitialPing = true;
|
||||||
Server.masterServerUrl = settings.MasterServer;
|
Server.masterServerUrl = settings.Server.MasterServer;
|
||||||
isInternetServer = settings.AdvertiseOnline;
|
isInternetServer = settings.Server.AdvertiseOnline;
|
||||||
listener = new TcpListener(IPAddress.Any, settings.ListenPort);
|
listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort);
|
||||||
Name = settings.LastServerTitle;
|
Name = settings.Server.LastServerTitle;
|
||||||
ExternalPort = settings.ExternalPort;
|
ExternalPort = settings.Server.ExternalPort;
|
||||||
randomSeed = (int)DateTime.Now.ToBinary();
|
randomSeed = (int)DateTime.Now.ToBinary();
|
||||||
ModData = modData;
|
ModData = modData;
|
||||||
|
|
||||||
lobbyInfo = new Session();
|
lobbyInfo = new Session();
|
||||||
lobbyInfo.GlobalSettings.Mods = settings.InitialMods;
|
lobbyInfo.GlobalSettings.Mods = settings.General.InitialMods;
|
||||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||||
lobbyInfo.GlobalSettings.Map = map;
|
lobbyInfo.GlobalSettings.Map = map;
|
||||||
lobbyInfo.GlobalSettings.AllowCheats = settings.AllowCheats;
|
lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats;
|
||||||
|
|
||||||
LoadMap(); // populates the Session's slots, too.
|
LoadMap(); // populates the Session's slots, too.
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ namespace OpenRA.Server
|
|||||||
newConn.socket.Send(BitConverter.GetBytes(newConn.PlayerIndex));
|
newConn.socket.Send(BitConverter.GetBytes(newConn.PlayerIndex));
|
||||||
conns.Add(newConn);
|
conns.Add(newConn);
|
||||||
|
|
||||||
var defaults = new GameRules.Settings();
|
var defaults = new GameRules.PlayerSettings();
|
||||||
lobbyInfo.Clients.Add(
|
lobbyInfo.Clients.Add(
|
||||||
new Session.Client()
|
new Session.Client()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,20 +141,20 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static float SoundVolume
|
public static float SoundVolume
|
||||||
{
|
{
|
||||||
get { return Game.Settings.SoundVolume; }
|
get { return Game.Settings.Sound.SoundVolume; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Game.Settings.SoundVolume = value;
|
Game.Settings.Sound.SoundVolume = value;
|
||||||
soundEngine.SetSoundVolume(value, music, video);
|
soundEngine.SetSoundVolume(value, music, video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float MusicVolume
|
public static float MusicVolume
|
||||||
{
|
{
|
||||||
get { return Game.Settings.MusicVolume; }
|
get { return Game.Settings.Sound.MusicVolume; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Game.Settings.MusicVolume = value;
|
Game.Settings.Sound.MusicVolume = value;
|
||||||
if (music != null)
|
if (music != null)
|
||||||
music.Volume = value;
|
music.Volume = value;
|
||||||
}
|
}
|
||||||
@@ -162,10 +162,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static float VideoVolume
|
public static float VideoVolume
|
||||||
{
|
{
|
||||||
get { return Game.Settings.VideoVolume; }
|
get { return Game.Settings.Sound.VideoVolume; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Game.Settings.VideoVolume = value;
|
Game.Settings.Sound.VideoVolume = value;
|
||||||
if (video != null)
|
if (video != null)
|
||||||
video.Volume = value;
|
video.Volume = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Traits
|
|||||||
case "DevUnitDebug":
|
case "DevUnitDebug":
|
||||||
{
|
{
|
||||||
if (self.World.LocalPlayer == self.Owner)
|
if (self.World.LocalPlayer == self.Owner)
|
||||||
Game.Settings.UnitDebug ^= true;
|
Game.Settings.Debug.UnitDebug ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Draw( World world )
|
public void Draw( World world )
|
||||||
{
|
{
|
||||||
if (Game.Settings.UnitDebug)
|
if (Game.Settings.Debug.UnitDebug)
|
||||||
{
|
{
|
||||||
var uim = world.WorldActor.Trait<UnitInfluence>();
|
var uim = world.WorldActor.Trait<UnitInfluence>();
|
||||||
|
|
||||||
|
|||||||
@@ -36,29 +36,29 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
var map = Game.modData.AvailableMaps.Keys.FirstOrDefault();
|
var map = Game.modData.AvailableMaps.Keys.FirstOrDefault();
|
||||||
|
|
||||||
settings.LastServerTitle = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
settings.Server.LastServerTitle = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
||||||
settings.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
settings.Server.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
||||||
settings.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
settings.Server.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
||||||
settings.Save();
|
settings.Save();
|
||||||
|
|
||||||
Server.Server.ServerMain(Game.modData, settings, map);
|
Server.Server.ServerMain(Game.modData, settings, map);
|
||||||
|
|
||||||
Game.JoinServer(IPAddress.Loopback.ToString(), settings.ListenPort);
|
Game.JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.LastServerTitle;
|
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.LastServerTitle;
|
||||||
cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.ListenPort.ToString();
|
cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
||||||
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = settings.ExternalPort.ToString();
|
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = settings.Server.ExternalPort.ToString();
|
||||||
cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => settings.AdvertiseOnline;
|
cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => settings.Server.AdvertiseOnline;
|
||||||
cs.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => {
|
cs.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => {
|
||||||
settings.AdvertiseOnline ^= true;
|
settings.Server.AdvertiseOnline ^= true;
|
||||||
settings.Save();
|
settings.Save();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
cs.GetWidget<CheckboxWidget>("CHECKBOX_CHEATS").Checked = () => settings.AllowCheats;
|
cs.GetWidget<CheckboxWidget>("CHECKBOX_CHEATS").Checked = () => settings.Server.AllowCheats;
|
||||||
cs.GetWidget<CheckboxWidget>("CHECKBOX_CHEATS").OnMouseDown = mi => {
|
cs.GetWidget<CheckboxWidget>("CHECKBOX_CHEATS").OnMouseDown = mi => {
|
||||||
settings.AllowCheats ^=true;
|
settings.Server.AllowCheats ^=true;
|
||||||
settings.Save();
|
settings.Save();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_UNITDEBUG").Checked =
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_UNITDEBUG").Checked =
|
||||||
() => Game.Settings.UnitDebug;
|
() => Game.Settings.Debug.UnitDebug;
|
||||||
devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi =>
|
devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.IssueOrder(new Order("DevUnitDebug", Game.world.LocalPlayer.PlayerActor));
|
Game.IssueOrder(new Order("DevUnitDebug", Game.world.LocalPlayer.PlayerActor));
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||||
UpdateCurrentMap();
|
UpdateCurrentMap();
|
||||||
|
|
||||||
CurrentColorPreview1 = Game.Settings.PlayerColor1;
|
CurrentColorPreview1 = Game.Settings.Player.PlayerColor1;
|
||||||
CurrentColorPreview2 = Game.Settings.PlayerColor2;
|
CurrentColorPreview2 = Game.Settings.Player.PlayerColor2;
|
||||||
|
|
||||||
var r = Widget.RootWidget;
|
var r = Widget.RootWidget;
|
||||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||||
@@ -162,8 +162,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var c1 = ColorFromHSL(hf, sf, lf);
|
var c1 = ColorFromHSL(hf, sf, lf);
|
||||||
var c2 = ColorFromHSL(hf, sf, r*lf);
|
var c2 = ColorFromHSL(hf, sf, r*lf);
|
||||||
|
|
||||||
Game.Settings.PlayerColor1 = c1;
|
Game.Settings.Player.PlayerColor1 = c1;
|
||||||
Game.Settings.PlayerColor2 = c2;
|
Game.Settings.Player.PlayerColor2 = c2;
|
||||||
Game.Settings.Save();
|
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)));
|
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,15 +220,14 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return;
|
return;
|
||||||
hasJoined = true;
|
hasJoined = true;
|
||||||
|
|
||||||
if (Game.LocalClient.Name != Game.Settings.PlayerName)
|
if (Game.LocalClient.Name != Game.Settings.Player.PlayerName)
|
||||||
Game.IssueOrder(Order.Command("name " + Game.Settings.PlayerName));
|
Game.IssueOrder(Order.Command("name " + Game.Settings.Player.PlayerName));
|
||||||
|
|
||||||
|
var c1 = Game.Settings.Player.PlayerColor1;
|
||||||
|
var c2 = Game.Settings.Player.PlayerColor2;
|
||||||
|
|
||||||
if (Game.LocalClient.Color1 != Game.Settings.PlayerColor1 || Game.LocalClient.Color2 != Game.Settings.PlayerColor2)
|
if (Game.LocalClient.Color1 != c1 || Game.LocalClient.Color2 != c2)
|
||||||
{
|
|
||||||
var c1 = Game.Settings.PlayerColor1;
|
|
||||||
var c2 = Game.Settings.PlayerColor2;
|
|
||||||
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
|
Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetConnectionState()
|
void ResetConnectionState()
|
||||||
@@ -265,7 +264,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
Game.IssueOrder(Order.Command("name " + name.Text));
|
Game.IssueOrder(Order.Command("name " + name.Text));
|
||||||
Game.Settings.PlayerName = name.Text;
|
Game.Settings.Player.PlayerName = name.Text;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
var r = Widget.RootWidget;
|
var r = Widget.RootWidget;
|
||||||
var perfRoot = r.GetWidget("PERF_BG");
|
var perfRoot = r.GetWidget("PERF_BG");
|
||||||
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.PerfDebug;
|
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfDebug;
|
||||||
|
|
||||||
// Perf text
|
// Perf text
|
||||||
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
||||||
GameButtons.Clear();
|
GameButtons.Clear();
|
||||||
|
|
||||||
MasterServerQuery.Refresh(Game.Settings.MasterServer);
|
MasterServerQuery.Refresh(Game.Settings.Server.MasterServer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
||||||
GameButtons.Clear();
|
GameButtons.Clear();
|
||||||
|
|
||||||
MasterServerQuery.Refresh(Game.Settings.MasterServer);
|
MasterServerQuery.Refresh(Game.Settings.Server.MasterServer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
|
|
||||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.LastServer;
|
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.General.LastServer;
|
||||||
r.OpenWindow("DIRECTCONNECT_BG");
|
r.OpenWindow("DIRECTCONNECT_BG");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -133,7 +133,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
if (cpts.Length != 2)
|
if (cpts.Length != 2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Game.Settings.LastServer = address;
|
Game.Settings.General.LastServer = address;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
|
|
||||||
r.CloseWindow();
|
r.CloseWindow();
|
||||||
|
|||||||
@@ -34,31 +34,31 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var general = bg.GetWidget("GENERAL_PANE");
|
var general = bg.GetWidget("GENERAL_PANE");
|
||||||
|
|
||||||
var name = general.GetWidget<TextFieldWidget>("NAME");
|
var name = general.GetWidget<TextFieldWidget>("NAME");
|
||||||
name.Text = Game.Settings.PlayerName;
|
name.Text = Game.Settings.Player.PlayerName;
|
||||||
name.OnLoseFocus = () =>
|
name.OnLoseFocus = () =>
|
||||||
{
|
{
|
||||||
name.Text = name.Text.Trim();
|
name.Text = name.Text.Trim();
|
||||||
|
|
||||||
if (name.Text.Length == 0)
|
if (name.Text.Length == 0)
|
||||||
name.Text = Game.Settings.PlayerName;
|
name.Text = Game.Settings.Player.PlayerName;
|
||||||
else
|
else
|
||||||
Game.Settings.PlayerName = name.Text;
|
Game.Settings.Player.PlayerName = name.Text;
|
||||||
};
|
};
|
||||||
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
||||||
|
|
||||||
var edgeScroll = general.GetWidget<CheckboxWidget>("EDGE_SCROLL");
|
var edgeScroll = general.GetWidget<CheckboxWidget>("EDGE_SCROLL");
|
||||||
edgeScroll.Checked = () => Game.Settings.ViewportEdgeScroll;
|
edgeScroll.Checked = () => Game.Settings.General.ViewportEdgeScroll;
|
||||||
edgeScroll.OnMouseDown = mi =>
|
edgeScroll.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.ViewportEdgeScroll ^= true;
|
Game.Settings.General.ViewportEdgeScroll ^= true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var inverseScroll = general.GetWidget<CheckboxWidget>("INVERSE_SCROLL");
|
var inverseScroll = general.GetWidget<CheckboxWidget>("INVERSE_SCROLL");
|
||||||
inverseScroll.Checked = () => Game.Settings.InverseDragScroll;
|
inverseScroll.Checked = () => Game.Settings.General.InverseDragScroll;
|
||||||
inverseScroll.OnMouseDown = mi =>
|
inverseScroll.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.InverseDragScroll ^= true;
|
Game.Settings.General.InverseDragScroll ^= true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,47 +77,47 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
// Display
|
// Display
|
||||||
var display = bg.GetWidget("DISPLAY_PANE");
|
var display = bg.GetWidget("DISPLAY_PANE");
|
||||||
var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX");
|
var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX");
|
||||||
fullscreen.Checked = () => {return Game.Settings.WindowMode != WindowMode.Windowed;};
|
fullscreen.Checked = () => {return Game.Settings.Graphics.WindowMode != WindowMode.Windowed;};
|
||||||
fullscreen.OnMouseDown = mi =>
|
fullscreen.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.WindowMode = (Game.Settings.WindowMode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
|
Game.Settings.Graphics.WindowMode = (Game.Settings.Graphics.WindowMode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
||||||
Game.Settings.WindowedSize.X = (Game.Settings.WindowedSize.X < Game.Settings.MinResolution.X)?
|
Game.Settings.Graphics.WindowedSize.X = (Game.Settings.Graphics.WindowedSize.X < Game.Settings.Graphics.MinResolution.X)?
|
||||||
Game.Settings.MinResolution.X : Game.Settings.WindowedSize.X;
|
Game.Settings.Graphics.MinResolution.X : Game.Settings.Graphics.WindowedSize.X;
|
||||||
width.Text = Game.Settings.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.MinResolution.X && w <= Screen.PrimaryScreen.Bounds.Size.Width)
|
if (w > Game.Settings.Graphics.MinResolution.X && w <= Screen.PrimaryScreen.Bounds.Size.Width)
|
||||||
Game.Settings.WindowedSize = new int2(w, Game.Settings.WindowedSize.Y);
|
Game.Settings.Graphics.WindowedSize = new int2(w, Game.Settings.Graphics.WindowedSize.Y);
|
||||||
else
|
else
|
||||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||||
}
|
}
|
||||||
catch (FormatException) {
|
catch (FormatException) {
|
||||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
width.Text = Game.Settings.Graphics.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.WindowedSize.Y = (Game.Settings.WindowedSize.Y < Game.Settings.MinResolution.Y)?
|
Game.Settings.Graphics.WindowedSize.Y = (Game.Settings.Graphics.WindowedSize.Y < Game.Settings.Graphics.MinResolution.Y)?
|
||||||
Game.Settings.MinResolution.Y : Game.Settings.WindowedSize.Y;
|
Game.Settings.Graphics.MinResolution.Y : Game.Settings.Graphics.WindowedSize.Y;
|
||||||
height.Text = Game.Settings.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.MinResolution.Y && h <= Screen.PrimaryScreen.Bounds.Size.Height)
|
if (h > Game.Settings.Graphics.MinResolution.Y && h <= Screen.PrimaryScreen.Bounds.Size.Height)
|
||||||
Game.Settings.WindowedSize = new int2(Game.Settings.WindowedSize.X, h);
|
Game.Settings.Graphics.WindowedSize = new int2(Game.Settings.Graphics.WindowedSize.X, h);
|
||||||
else
|
else
|
||||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||||
}
|
}
|
||||||
catch (FormatException) {
|
catch (FormatException) {
|
||||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
||||||
@@ -125,26 +125,26 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
// Debug
|
// Debug
|
||||||
var debug = bg.GetWidget("DEBUG_PANE");
|
var debug = bg.GetWidget("DEBUG_PANE");
|
||||||
var perfdebug = debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX");
|
var perfdebug = debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX");
|
||||||
perfdebug.Checked = () => {return Game.Settings.PerfDebug;};
|
perfdebug.Checked = () => {return Game.Settings.Debug.PerfDebug;};
|
||||||
perfdebug.OnMouseDown = mi =>
|
perfdebug.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.PerfDebug ^= true;
|
Game.Settings.Debug.PerfDebug ^= true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var syncreports = debug.GetWidget<CheckboxWidget>("SYNCREPORTS_CHECKBOX");
|
var syncreports = debug.GetWidget<CheckboxWidget>("SYNCREPORTS_CHECKBOX");
|
||||||
syncreports.Checked = () => { return Game.Settings.RecordSyncReports; };
|
syncreports.Checked = () => { return Game.Settings.Debug.RecordSyncReports; };
|
||||||
syncreports.OnMouseDown = mi =>
|
syncreports.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.RecordSyncReports ^= true;
|
Game.Settings.Debug.RecordSyncReports ^= true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var timedebug = debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX");
|
var timedebug = debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX");
|
||||||
timedebug.Checked = () => {return Game.Settings.ShowGameTimer;};
|
timedebug.Checked = () => {return Game.Settings.Debug.ShowGameTimer;};
|
||||||
timedebug.OnMouseDown = mi =>
|
timedebug.OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.Settings.ShowGameTimer ^= true;
|
Game.Settings.Debug.ShowGameTimer ^= true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public TimerWidget ()
|
public TimerWidget ()
|
||||||
{
|
{
|
||||||
IsVisible = () => Game.Settings.ShowGameTimer;
|
IsVisible = () => Game.Settings.Debug.ShowGameTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Widgets
|
|||||||
if (mi.Event == MouseInputEvent.Move &&
|
if (mi.Event == MouseInputEvent.Move &&
|
||||||
(mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right)))
|
(mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right)))
|
||||||
{
|
{
|
||||||
int InverseScroll = Game.Settings.InverseDragScroll ? -1 : 1;
|
int InverseScroll = Game.Settings.General.InverseDragScroll ? -1 : 1;
|
||||||
Game.viewport.Scroll((Viewport.LastMousePos - mi.Location) * InverseScroll);
|
Game.viewport.Scroll((Viewport.LastMousePos - mi.Location) * InverseScroll);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
if (!Game.Settings.ViewportEdgeScroll)
|
if (!Game.Settings.General.ViewportEdgeScroll)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left))
|
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left))
|
||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Widgets
|
|||||||
public override void Tick(World world)
|
public override void Tick(World world)
|
||||||
{
|
{
|
||||||
Edge = ScrollDirection.None;
|
Edge = ScrollDirection.None;
|
||||||
if (Game.Settings.ViewportEdgeScroll)
|
if (Game.Settings.General.ViewportEdgeScroll)
|
||||||
{
|
{
|
||||||
// Check for edge-scroll
|
// Check for edge-scroll
|
||||||
if (Viewport.LastMousePos.X < EdgeScrollThreshold)
|
if (Viewport.LastMousePos.X < EdgeScrollThreshold)
|
||||||
|
|||||||
Reference in New Issue
Block a user