Rename some settings
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<string, object> Sections;
|
||||
public Settings(Arguments args)
|
||||
public Settings(string file, Arguments args)
|
||||
{
|
||||
SettingsFile = Game.SupportDir + "settings.yaml";
|
||||
SettingsFile = file;
|
||||
Sections = new Dictionary<string, object>()
|
||||
{
|
||||
{"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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UnitInfluence>();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
var map = Game.modData.AvailableMaps.Keys.FirstOrDefault();
|
||||
|
||||
settings.Server.LastServerTitle = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
||||
settings.Server.Name = 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();
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
};
|
||||
|
||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.LastServerTitle;
|
||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.Name;
|
||||
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;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
};
|
||||
|
||||
devmodeBG.GetWidget<CheckboxWidget>("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));
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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<LabelWidget>("TEXT");
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
r.CloseWindow();
|
||||
|
||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.General.LastServer;
|
||||
dc.GetWidget<TextFieldWidget>("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();
|
||||
|
||||
26
OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs
Executable file → Normal file
26
OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs
Executable file → Normal file
@@ -34,31 +34,31 @@ namespace OpenRA.Widgets.Delegates
|
||||
var general = bg.GetWidget("GENERAL_PANE");
|
||||
|
||||
var name = general.GetWidget<TextFieldWidget>("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<CheckboxWidget>("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<CheckboxWidget>("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<CheckboxWidget>("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<CheckboxWidget>("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<CheckboxWidget>("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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
6
OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs
Executable file → Normal file
6
OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs
Executable file → Normal file
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user