1 #region Copyright & License Information 2 /* 3 * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) 4 * This file is part of OpenRA, which is free software. It is made 5 * available to you under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, either version 3 of 7 * the License, or (at your option) any later version. For more 8 * information, see COPYING. 9 */ 10 #endregion 11 12 namespace OpenRA 13 { 14 public class LaunchArguments 15 { 16 [Desc("Connect to the following server given as IP:PORT on startup.")] 17 public string Connect; 18 19 [Desc("Connect to the unified resource identifier openra://IP:PORT on startup.")] 20 public string URI; 21 22 [Desc("Automatically start playing the given replay file.")] 23 public string Replay; 24 25 [Desc("Dump performance data into cpu.csv and render.csv in the logs folder with the given prefix.")] 26 public string Benchmark; 27 28 [Desc("Automatically start playing the given map.")] 29 public string Map; 30 LaunchArguments(Arguments args)31 public LaunchArguments(Arguments args) 32 { 33 if (args == null) 34 return; 35 36 foreach (var f in GetType().GetFields()) 37 if (args.Contains("Launch" + "." + f.Name)) 38 FieldLoader.LoadField(this, f.Name, args.GetValue("Launch" + "." + f.Name, "")); 39 } 40 GetConnectAddress()41 public string GetConnectAddress() 42 { 43 var connect = string.Empty; 44 45 if (!string.IsNullOrEmpty(Connect)) 46 connect = Connect; 47 48 if (!string.IsNullOrEmpty(URI)) 49 connect = URI.Substring(URI.IndexOf("://", System.StringComparison.Ordinal) + 3).TrimEnd('/'); 50 51 return connect; 52 } 53 } 54 } 55