organize launch arguments in it's own class
This commit is contained in:
44
OpenRA.Game/Support/LaunchArguments.cs
Normal file
44
OpenRA.Game/Support/LaunchArguments.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user