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 dt = t - lastTime;
|
||||
if (dt >= Settings.Timestep)
|
||||
if (dt >= Settings.General.Timestep)
|
||||
{
|
||||
using (new PerfSample("tick_time"))
|
||||
{
|
||||
lastTime += Settings.Timestep;
|
||||
lastTime += Settings.General.Timestep;
|
||||
Widget.DoTick(world);
|
||||
|
||||
orderManager.TickImmediate(world);
|
||||
@@ -261,12 +261,12 @@ namespace OpenRA
|
||||
Log.AddChannel("debug", "debug.log");
|
||||
Log.AddChannel("sync", "syncreport.log");
|
||||
|
||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
||||
LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods;
|
||||
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();
|
||||
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.InitialMods;
|
||||
LobbyInfo.GlobalSettings.Mods = Settings.General.InitialMods;
|
||||
JoinLocal();
|
||||
StartGame(shellmap);
|
||||
|
||||
|
||||
@@ -14,32 +14,56 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.GameRules
|
||||
{
|
||||
public class Settings
|
||||
public class ServerSettings
|
||||
{
|
||||
// Behaviour settings
|
||||
public bool ViewportEdgeScroll = true;
|
||||
public bool InverseDragScroll = false;
|
||||
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;
|
||||
}
|
||||
|
||||
// Debug settings
|
||||
public class DebugSettings
|
||||
{
|
||||
public bool PerfDebug = false;
|
||||
public bool RecordSyncReports = true;
|
||||
public bool ShowGameTimer = true;
|
||||
public bool UnitDebug = false;
|
||||
}
|
||||
|
||||
// Window settings
|
||||
public class GraphicSettings
|
||||
{
|
||||
public WindowMode WindowMode = 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);
|
||||
}
|
||||
|
||||
//Sound Settings
|
||||
public class SoundSettings
|
||||
{
|
||||
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 class GeneralSettings
|
||||
{
|
||||
// Behaviour settings
|
||||
public bool ViewportEdgeScroll = true;
|
||||
public bool InverseDragScroll = false;
|
||||
|
||||
// Internal game settings
|
||||
public int Timestep = 40;
|
||||
@@ -47,40 +71,39 @@ namespace OpenRA.GameRules
|
||||
|
||||
// External game settings
|
||||
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" };
|
||||
}
|
||||
|
||||
// Server settings
|
||||
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 Settings
|
||||
{
|
||||
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)
|
||||
{
|
||||
defaults = new Settings();
|
||||
SettingsFile = Game.SupportDir + "settings.yaml";
|
||||
Sections = new Dictionary<string, object>()
|
||||
{
|
||||
{"Player", Player},
|
||||
{"General", General},
|
||||
{"Sound", Sound},
|
||||
{"Graphics", Graphics},
|
||||
{"Server", Server},
|
||||
{"Debug", Debug}
|
||||
};
|
||||
|
||||
// Override settings loading to not crash
|
||||
// Override fieldloader to ignore invalid entries
|
||||
var err1 = FieldLoader.UnknownFieldAction;
|
||||
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) =>
|
||||
{
|
||||
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);
|
||||
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())
|
||||
if (args.Contains(f.Name))
|
||||
OpenRA.FileFormats.FieldLoader.LoadField( this, f.Name, args.GetValue(f.Name, "") );
|
||||
// Override with commandline args
|
||||
foreach (var kv in Sections)
|
||||
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.InvalidValueAction = err2;
|
||||
@@ -104,8 +131,28 @@ namespace OpenRA.GameRules
|
||||
public void Save()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Network
|
||||
public static Session Deserialize(string data)
|
||||
{
|
||||
var session = new Session();
|
||||
session.GlobalSettings.Mods = Game.Settings.InitialMods;
|
||||
session.GlobalSettings.Mods = Game.Settings.General.InitialMods;
|
||||
|
||||
var ys = MiniYaml.FromString(data);
|
||||
foreach (var y in ys)
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace OpenRA.Network
|
||||
|
||||
internal void UpdateSyncReport()
|
||||
{
|
||||
if (!Game.Settings.RecordSyncReports)
|
||||
if (!Game.Settings.Debug.RecordSyncReports)
|
||||
return;
|
||||
|
||||
while (syncReports.Count >= numSyncReports) syncReports.Dequeue();
|
||||
|
||||
@@ -53,19 +53,19 @@ namespace OpenRA.Server
|
||||
Log.AddChannel("server", "server.log");
|
||||
|
||||
isInitialPing = true;
|
||||
Server.masterServerUrl = settings.MasterServer;
|
||||
isInternetServer = settings.AdvertiseOnline;
|
||||
listener = new TcpListener(IPAddress.Any, settings.ListenPort);
|
||||
Name = settings.LastServerTitle;
|
||||
ExternalPort = settings.ExternalPort;
|
||||
Server.masterServerUrl = settings.Server.MasterServer;
|
||||
isInternetServer = settings.Server.AdvertiseOnline;
|
||||
listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort);
|
||||
Name = settings.Server.LastServerTitle;
|
||||
ExternalPort = settings.Server.ExternalPort;
|
||||
randomSeed = (int)DateTime.Now.ToBinary();
|
||||
ModData = modData;
|
||||
|
||||
lobbyInfo = new Session();
|
||||
lobbyInfo.GlobalSettings.Mods = settings.InitialMods;
|
||||
lobbyInfo.GlobalSettings.Mods = settings.General.InitialMods;
|
||||
lobbyInfo.GlobalSettings.RandomSeed = randomSeed;
|
||||
lobbyInfo.GlobalSettings.Map = map;
|
||||
lobbyInfo.GlobalSettings.AllowCheats = settings.AllowCheats;
|
||||
lobbyInfo.GlobalSettings.AllowCheats = settings.Server.AllowCheats;
|
||||
|
||||
LoadMap(); // populates the Session's slots, too.
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Server
|
||||
newConn.socket.Send(BitConverter.GetBytes(newConn.PlayerIndex));
|
||||
conns.Add(newConn);
|
||||
|
||||
var defaults = new GameRules.Settings();
|
||||
var defaults = new GameRules.PlayerSettings();
|
||||
lobbyInfo.Clients.Add(
|
||||
new Session.Client()
|
||||
{
|
||||
|
||||
@@ -141,20 +141,20 @@ namespace OpenRA
|
||||
|
||||
public static float SoundVolume
|
||||
{
|
||||
get { return Game.Settings.SoundVolume; }
|
||||
get { return Game.Settings.Sound.SoundVolume; }
|
||||
set
|
||||
{
|
||||
Game.Settings.SoundVolume = value;
|
||||
Game.Settings.Sound.SoundVolume = value;
|
||||
soundEngine.SetSoundVolume(value, music, video);
|
||||
}
|
||||
}
|
||||
|
||||
public static float MusicVolume
|
||||
{
|
||||
get { return Game.Settings.MusicVolume; }
|
||||
get { return Game.Settings.Sound.MusicVolume; }
|
||||
set
|
||||
{
|
||||
Game.Settings.MusicVolume = value;
|
||||
Game.Settings.Sound.MusicVolume = value;
|
||||
if (music != null)
|
||||
music.Volume = value;
|
||||
}
|
||||
@@ -162,10 +162,10 @@ namespace OpenRA
|
||||
|
||||
public static float VideoVolume
|
||||
{
|
||||
get { return Game.Settings.VideoVolume; }
|
||||
get { return Game.Settings.Sound.VideoVolume; }
|
||||
set
|
||||
{
|
||||
Game.Settings.VideoVolume = value;
|
||||
Game.Settings.Sound.VideoVolume = value;
|
||||
if (video != null)
|
||||
video.Volume = value;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Traits
|
||||
case "DevUnitDebug":
|
||||
{
|
||||
if (self.World.LocalPlayer == self.Owner)
|
||||
Game.Settings.UnitDebug ^= true;
|
||||
Game.Settings.Debug.UnitDebug ^= true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA
|
||||
|
||||
public void Draw( World world )
|
||||
{
|
||||
if (Game.Settings.UnitDebug)
|
||||
if (Game.Settings.Debug.UnitDebug)
|
||||
{
|
||||
var uim = world.WorldActor.Trait<UnitInfluence>();
|
||||
|
||||
|
||||
@@ -36,29 +36,29 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
var map = Game.modData.AvailableMaps.Keys.FirstOrDefault();
|
||||
|
||||
settings.LastServerTitle = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
||||
settings.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
||||
settings.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
||||
settings.Server.LastServerTitle = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
||||
settings.Server.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
||||
settings.Server.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
||||
settings.Save();
|
||||
|
||||
Server.Server.ServerMain(Game.modData, settings, map);
|
||||
|
||||
Game.JoinServer(IPAddress.Loopback.ToString(), settings.ListenPort);
|
||||
Game.JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
||||
return true;
|
||||
};
|
||||
|
||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.LastServerTitle;
|
||||
cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.ListenPort.ToString();
|
||||
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = settings.ExternalPort.ToString();
|
||||
cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => settings.AdvertiseOnline;
|
||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.LastServerTitle;
|
||||
cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
||||
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = settings.Server.ExternalPort.ToString();
|
||||
cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => settings.Server.AdvertiseOnline;
|
||||
cs.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => {
|
||||
settings.AdvertiseOnline ^= true;
|
||||
settings.Server.AdvertiseOnline ^= true;
|
||||
settings.Save();
|
||||
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 => {
|
||||
settings.AllowCheats ^=true;
|
||||
settings.Server.AllowCheats ^=true;
|
||||
settings.Save();
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
};
|
||||
|
||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_UNITDEBUG").Checked =
|
||||
() => Game.Settings.UnitDebug;
|
||||
() => Game.Settings.Debug.UnitDebug;
|
||||
devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi =>
|
||||
{
|
||||
Game.IssueOrder(new Order("DevUnitDebug", Game.world.LocalPlayer.PlayerActor));
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||
UpdateCurrentMap();
|
||||
|
||||
CurrentColorPreview1 = Game.Settings.PlayerColor1;
|
||||
CurrentColorPreview2 = Game.Settings.PlayerColor2;
|
||||
CurrentColorPreview1 = Game.Settings.Player.PlayerColor1;
|
||||
CurrentColorPreview2 = Game.Settings.Player.PlayerColor2;
|
||||
|
||||
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.PlayerColor1 = c1;
|
||||
Game.Settings.PlayerColor2 = c2;
|
||||
Game.Settings.Player.PlayerColor1 = c1;
|
||||
Game.Settings.Player.PlayerColor2 = 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,16 +220,15 @@ namespace OpenRA.Widgets.Delegates
|
||||
return;
|
||||
hasJoined = true;
|
||||
|
||||
if (Game.LocalClient.Name != Game.Settings.PlayerName)
|
||||
Game.IssueOrder(Order.Command("name " + Game.Settings.PlayerName));
|
||||
if (Game.LocalClient.Name != Game.Settings.Player.PlayerName)
|
||||
Game.IssueOrder(Order.Command("name " + Game.Settings.Player.PlayerName));
|
||||
|
||||
if (Game.LocalClient.Color1 != Game.Settings.PlayerColor1 || Game.LocalClient.Color2 != Game.Settings.PlayerColor2)
|
||||
{
|
||||
var c1 = Game.Settings.PlayerColor1;
|
||||
var c2 = Game.Settings.PlayerColor2;
|
||||
var c1 = Game.Settings.Player.PlayerColor1;
|
||||
var c2 = Game.Settings.Player.PlayerColor2;
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
void ResetConnectionState()
|
||||
{
|
||||
@@ -265,7 +264,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
|
||||
Game.IssueOrder(Order.Command("name " + name.Text));
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Player.PlayerName = name.Text;
|
||||
Game.Settings.Save();
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
var r = Widget.RootWidget;
|
||||
var perfRoot = r.GetWidget("PERF_BG");
|
||||
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.PerfDebug;
|
||||
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfDebug;
|
||||
|
||||
// Perf text
|
||||
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
||||
GameButtons.Clear();
|
||||
|
||||
MasterServerQuery.Refresh(Game.Settings.MasterServer);
|
||||
MasterServerQuery.Refresh(Game.Settings.Server.MasterServer);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.Children.RemoveAll(a => GameButtons.Contains(a));
|
||||
GameButtons.Clear();
|
||||
|
||||
MasterServerQuery.Refresh(Game.Settings.MasterServer);
|
||||
MasterServerQuery.Refresh(Game.Settings.Server.MasterServer);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
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");
|
||||
return true;
|
||||
};
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
if (cpts.Length != 2)
|
||||
return true;
|
||||
|
||||
Game.Settings.LastServer = address;
|
||||
Game.Settings.General.LastServer = address;
|
||||
Game.Settings.Save();
|
||||
|
||||
r.CloseWindow();
|
||||
|
||||
@@ -34,31 +34,31 @@ namespace OpenRA.Widgets.Delegates
|
||||
var general = bg.GetWidget("GENERAL_PANE");
|
||||
|
||||
var name = general.GetWidget<TextFieldWidget>("NAME");
|
||||
name.Text = Game.Settings.PlayerName;
|
||||
name.Text = Game.Settings.Player.PlayerName;
|
||||
name.OnLoseFocus = () =>
|
||||
{
|
||||
name.Text = name.Text.Trim();
|
||||
|
||||
if (name.Text.Length == 0)
|
||||
name.Text = Game.Settings.PlayerName;
|
||||
name.Text = Game.Settings.Player.PlayerName;
|
||||
else
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Player.PlayerName = name.Text;
|
||||
};
|
||||
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
||||
|
||||
var edgeScroll = general.GetWidget<CheckboxWidget>("EDGE_SCROLL");
|
||||
edgeScroll.Checked = () => Game.Settings.ViewportEdgeScroll;
|
||||
edgeScroll.Checked = () => Game.Settings.General.ViewportEdgeScroll;
|
||||
edgeScroll.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.ViewportEdgeScroll ^= true;
|
||||
Game.Settings.General.ViewportEdgeScroll ^= true;
|
||||
return true;
|
||||
};
|
||||
|
||||
var inverseScroll = general.GetWidget<CheckboxWidget>("INVERSE_SCROLL");
|
||||
inverseScroll.Checked = () => Game.Settings.InverseDragScroll;
|
||||
inverseScroll.Checked = () => Game.Settings.General.InverseDragScroll;
|
||||
inverseScroll.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.InverseDragScroll ^= true;
|
||||
Game.Settings.General.InverseDragScroll ^= true;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -77,47 +77,47 @@ namespace OpenRA.Widgets.Delegates
|
||||
// Display
|
||||
var display = bg.GetWidget("DISPLAY_PANE");
|
||||
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 =>
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
||||
Game.Settings.WindowedSize.X = (Game.Settings.WindowedSize.X < Game.Settings.MinResolution.X)?
|
||||
Game.Settings.MinResolution.X : Game.Settings.WindowedSize.X;
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
Game.Settings.Graphics.WindowedSize.X = (Game.Settings.Graphics.WindowedSize.X < Game.Settings.Graphics.MinResolution.X)?
|
||||
Game.Settings.Graphics.MinResolution.X : Game.Settings.Graphics.WindowedSize.X;
|
||||
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||
width.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var w = int.Parse(width.Text);
|
||||
if (w > Game.Settings.MinResolution.X && w <= Screen.PrimaryScreen.Bounds.Size.Width)
|
||||
Game.Settings.WindowedSize = new int2(w, Game.Settings.WindowedSize.Y);
|
||||
if (w > Game.Settings.Graphics.MinResolution.X && w <= Screen.PrimaryScreen.Bounds.Size.Width)
|
||||
Game.Settings.Graphics.WindowedSize = new int2(w, Game.Settings.Graphics.WindowedSize.Y);
|
||||
else
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||
}
|
||||
catch (FormatException) {
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||
}
|
||||
};
|
||||
width.OnEnterKey = () => { width.LoseFocus(); return true; };
|
||||
|
||||
var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT");
|
||||
Game.Settings.WindowedSize.Y = (Game.Settings.WindowedSize.Y < Game.Settings.MinResolution.Y)?
|
||||
Game.Settings.MinResolution.Y : Game.Settings.WindowedSize.Y;
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
Game.Settings.Graphics.WindowedSize.Y = (Game.Settings.Graphics.WindowedSize.Y < Game.Settings.Graphics.MinResolution.Y)?
|
||||
Game.Settings.Graphics.MinResolution.Y : Game.Settings.Graphics.WindowedSize.Y;
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
height.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var h = int.Parse(height.Text);
|
||||
if (h > Game.Settings.MinResolution.Y && h <= Screen.PrimaryScreen.Bounds.Size.Height)
|
||||
Game.Settings.WindowedSize = new int2(Game.Settings.WindowedSize.X, h);
|
||||
if (h > Game.Settings.Graphics.MinResolution.Y && h <= Screen.PrimaryScreen.Bounds.Size.Height)
|
||||
Game.Settings.Graphics.WindowedSize = new int2(Game.Settings.Graphics.WindowedSize.X, h);
|
||||
else
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
}
|
||||
catch (FormatException) {
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
}
|
||||
};
|
||||
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
||||
@@ -125,26 +125,26 @@ namespace OpenRA.Widgets.Delegates
|
||||
// Debug
|
||||
var debug = bg.GetWidget("DEBUG_PANE");
|
||||
var perfdebug = debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX");
|
||||
perfdebug.Checked = () => {return Game.Settings.PerfDebug;};
|
||||
perfdebug.Checked = () => {return Game.Settings.Debug.PerfDebug;};
|
||||
perfdebug.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.PerfDebug ^= true;
|
||||
Game.Settings.Debug.PerfDebug ^= true;
|
||||
return true;
|
||||
};
|
||||
|
||||
var syncreports = debug.GetWidget<CheckboxWidget>("SYNCREPORTS_CHECKBOX");
|
||||
syncreports.Checked = () => { return Game.Settings.RecordSyncReports; };
|
||||
syncreports.Checked = () => { return Game.Settings.Debug.RecordSyncReports; };
|
||||
syncreports.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.RecordSyncReports ^= true;
|
||||
Game.Settings.Debug.RecordSyncReports ^= true;
|
||||
return true;
|
||||
};
|
||||
|
||||
var timedebug = debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX");
|
||||
timedebug.Checked = () => {return Game.Settings.ShowGameTimer;};
|
||||
timedebug.Checked = () => {return Game.Settings.Debug.ShowGameTimer;};
|
||||
timedebug.OnMouseDown = mi =>
|
||||
{
|
||||
Game.Settings.ShowGameTimer ^= true;
|
||||
Game.Settings.Debug.ShowGameTimer ^= true;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public TimerWidget ()
|
||||
{
|
||||
IsVisible = () => Game.Settings.ShowGameTimer;
|
||||
IsVisible = () => Game.Settings.Debug.ShowGameTimer;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
|
||||
@@ -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.InverseDragScroll ? -1 : 1;
|
||||
int InverseScroll = Game.Settings.General.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.ViewportEdgeScroll)
|
||||
if (!Game.Settings.General.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.ViewportEdgeScroll)
|
||||
if (Game.Settings.General.ViewportEdgeScroll)
|
||||
{
|
||||
// Check for edge-scroll
|
||||
if (Viewport.LastMousePos.X < EdgeScrollThreshold)
|
||||
|
||||
Reference in New Issue
Block a user