extract Launch args for automatic manpage creation

This commit is contained in:
Matthias Mailänder
2015-06-28 22:18:48 +02:00
parent 9d32667d15
commit 88e16a890d

View File

@@ -20,6 +20,20 @@ namespace OpenRA.Mods.Common.LoadScreens
{ {
public class BlankLoadScreen : ILoadScreen public class BlankLoadScreen : ILoadScreen
{ {
public class LaunchArgs
{
[Desc("Connect to the following server given as IP:PORT on startup.")]
public string Connect;
[Desc("Connect to the unified resource identifier openra://IP:PORT on startup.")]
public string URI;
[Desc("Automatically start playing the given replay file.")]
public string Replay;
}
public LaunchArgs Launch = new LaunchArgs();
public virtual void Init(Manifest m, Dictionary<string, string> info) { } public virtual void Init(Manifest m, Dictionary<string, string> info) { }
public virtual void Display() public virtual void Display()
@@ -34,6 +48,10 @@ namespace OpenRA.Mods.Common.LoadScreens
public void StartGame(Arguments args) public void StartGame(Arguments args)
{ {
foreach (var f in Launch.GetType().GetFields())
if (args.Contains("Launch" + "." + f.Name))
FieldLoader.LoadField(Launch, f.Name, args.GetValue("Launch" + "." + f.Name, ""));
Ui.ResetAll(); Ui.ResetAll();
Game.Settings.Save(); Game.Settings.Save();
@@ -63,21 +81,12 @@ namespace OpenRA.Mods.Common.LoadScreens
// Join a server directly // Join a server directly
var connect = string.Empty; var connect = string.Empty;
if (args != null)
{
if (args.Contains("Launch.Connect"))
connect = args.GetValue("Launch.Connect", null);
if (args.Contains("Launch.URI")) if (!string.IsNullOrEmpty(Launch.Connect))
{ connect = Launch.Connect;
connect = args.GetValue("Launch.URI", null);
if (connect != null) if (!string.IsNullOrEmpty(Launch.URI))
{ connect = Launch.URI.Replace("openra://", "").TrimEnd('/');
connect = connect.Replace("openra://", "");
connect = connect.TrimEnd('/');
}
}
}
if (!string.IsNullOrEmpty(connect)) if (!string.IsNullOrEmpty(connect))
{ {
@@ -94,12 +103,11 @@ namespace OpenRA.Mods.Common.LoadScreens
} }
// Load a replay directly // Load a replay directly
var replayFilename = args != null ? args.GetValue("Launch.Replay", null) : null; if (!string.IsNullOrEmpty(Launch.Replay))
if (!string.IsNullOrEmpty(replayFilename))
{ {
var replayMeta = ReplayMetadata.Read(replayFilename); var replayMeta = ReplayMetadata.Read(Launch.Replay);
if (ReplayUtils.PromptConfirmReplayCompatibility(replayMeta, Game.LoadShellMap)) if (ReplayUtils.PromptConfirmReplayCompatibility(replayMeta, Game.LoadShellMap))
Game.JoinReplay(replayFilename); Game.JoinReplay(Launch.Replay);
if (replayMeta != null) if (replayMeta != null)
{ {