Merge pull request #8247 from Mailaender/man-openra

Added a UNIX man page
This commit is contained in:
abcdefg30
2015-08-01 12:06:14 +02:00
9 changed files with 169 additions and 27 deletions

View File

@@ -20,6 +20,8 @@ namespace OpenRA.Mods.Common.LoadScreens
{
public class BlankLoadScreen : ILoadScreen
{
public LaunchArguments Launch;
public virtual void Init(Manifest m, Dictionary<string, string> info) { }
public virtual void Display()
@@ -34,6 +36,7 @@ namespace OpenRA.Mods.Common.LoadScreens
public void StartGame(Arguments args)
{
Launch = new LaunchArguments(args);
Ui.ResetAll();
Game.Settings.Save();
@@ -62,23 +65,7 @@ namespace OpenRA.Mods.Common.LoadScreens
}
// Join a server directly
var connect = string.Empty;
if (args != null)
{
if (args.Contains("Launch.Connect"))
connect = args.GetValue("Launch.Connect", null);
if (args.Contains("Launch.URI"))
{
connect = args.GetValue("Launch.URI", null);
if (connect != null)
{
connect = connect.Replace("openra://", "");
connect = connect.TrimEnd('/');
}
}
}
var connect = Launch.GetConnectAddress();
if (!string.IsNullOrEmpty(connect))
{
var parts = connect.Split(':');
@@ -94,12 +81,11 @@ namespace OpenRA.Mods.Common.LoadScreens
}
// Load a replay directly
var replayFilename = args != null ? args.GetValue("Launch.Replay", null) : null;
if (!string.IsNullOrEmpty(replayFilename))
if (!string.IsNullOrEmpty(Launch.Replay))
{
var replayMeta = ReplayMetadata.Read(replayFilename);
var replayMeta = ReplayMetadata.Read(Launch.Replay);
if (ReplayUtils.PromptConfirmReplayCompatibility(replayMeta, Game.LoadShellMap))
Game.JoinReplay(replayFilename);
Game.JoinReplay(Launch.Replay);
if (replayMeta != null)
{

View File

@@ -529,6 +529,7 @@
<Compile Include="UtilityCommands\CheckCodeStyle.cs" />
<Compile Include="UtilityCommands\ConvertPngToShpCommand.cs" />
<Compile Include="UtilityCommands\ConvertSpriteToPngCommand.cs" />
<Compile Include="UtilityCommands\CreateManPage.cs" />
<Compile Include="UtilityCommands\ExportCharacterSeparatedRules.cs" />
<Compile Include="UtilityCommands\Extensions.cs" />
<Compile Include="UtilityCommands\ExtractFilesCommand.cs" />

View File

@@ -0,0 +1,68 @@
#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
using System;
using System.Linq;
namespace OpenRA.Mods.Common.UtilityCommands
{
class CreateManPage : IUtilityCommand
{
public string Name { get { return "--man-page"; } }
[Desc("Create a man page in troff format.")]
public void Run(ModData modData, string[] args)
{
Console.WriteLine(".TH OPENRA 6");
Console.WriteLine(".SH NAME");
Console.WriteLine("openra \\- An Open Source modernization of the early 2D Command & Conquer games.");
Console.WriteLine(".SH SYNOPSIS");
Console.WriteLine(".B openra");
Console.WriteLine("[\\fB\\Game.Mod=\\fR\\fImodchooser\\fR]");
Console.WriteLine(".SH DESCRIPTION");
Console.WriteLine(".B openra");
Console.WriteLine("starts the game.");
Console.WriteLine(".SH OPTIONS");
var sections = Game.Settings.Sections;
sections.Add("Launch", new LaunchArguments(new Arguments(new string[0])));
foreach (var section in sections.OrderBy(s => s.Key))
{
var fields = section.Value.GetType().GetFields();
foreach (var field in fields)
{
if (!field.HasAttribute<DescAttribute>())
continue;
Console.WriteLine(".TP");
Console.Write(".BR {0}.{1}=".F(section.Key, field.Name));
var value = field.GetValue(section.Value);
if (value != null && !value.ToString().StartsWith("System."))
Console.WriteLine("\\fI{0}\\fR".F(value));
else
Console.WriteLine();
var lines = field.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines);
foreach (var line in lines)
Console.WriteLine(line);
}
}
Console.WriteLine(".SH FILES");
Console.WriteLine("Settings are stored in the ~/.openra user folder.");
Console.WriteLine(".SH BUGS");
Console.WriteLine("Known issues are tracked at http://bugs.openra.net");
Console.WriteLine(".SH COPYRIGHT");
Console.WriteLine("Copyright 2007-2015 The OpenRA Developers (see AUTHORS)");
Console.WriteLine("This manual is part of OpenRA, which is free software. It is GNU GPL v3 licensed. See COPYING for details.");
}
}
}