organize launch arguments in it's own class

This commit is contained in:
Matthias Mailänder
2015-07-26 11:54:47 +02:00
parent baa798d831
commit 7c86519242
4 changed files with 49 additions and 26 deletions

View File

@@ -0,0 +1,44 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
namespace OpenRA
{
public class LaunchArguments
{
[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 LaunchArguments(Arguments args)
{
foreach (var f in this.GetType().GetFields())
if (args.Contains("Launch" + "." + f.Name))
FieldLoader.LoadField(this, f.Name, args.GetValue("Launch" + "." + f.Name, ""));
}
public string GetConnectAddress()
{
var connect = string.Empty;
if (!string.IsNullOrEmpty(Connect))
connect = Connect;
if (!string.IsNullOrEmpty(URI))
connect = URI.Replace("openra://", "").TrimEnd('/');
return connect;
}
}
}