From baa798d8313733c566f9f265330aeca354f1d5b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 4 Jul 2015 21:13:00 +0200 Subject: [PATCH] autogenerate and install a UNIX man page --- .gitignore | 1 + Makefile | 9 +++ OpenRA.Game/Settings.cs | 41 +++++++++-- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../UtilityCommands/CreateManPage.cs | 68 +++++++++++++++++++ packaging/linux/buildpackage.sh | 1 + 6 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 OpenRA.Mods.Common/UtilityCommands/CreateManPage.cs diff --git a/.gitignore b/.gitignore index b6069737a3..2042aa7c8c 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3 DOCUMENTATION.md Lua-API.md *.html +openra.6 # StyleCop *.Cache diff --git a/Makefile b/Makefile index b1ec5246e8..e6bc54600c 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ endif prefix ?= /usr/local datarootdir ?= $(prefix)/share datadir ?= $(datarootdir) +mandir ?= $(datarootdir)/man/ bindir ?= $(prefix)/bin libdir ?= $(prefix)/lib gameinstalldir ?= $(libdir)/openra @@ -320,6 +321,9 @@ docs: utility mods version @mono --debug OpenRA.Utility.exe all --docs > DOCUMENTATION.md @mono --debug OpenRA.Utility.exe ra --lua-docs > Lua-API.md +man-page: utility mods + @mono --debug OpenRA.Utility.exe all --man-page > openra.6 + install: install-core install-all: install-core install-tools @@ -389,6 +393,10 @@ install-linux-appdata: @$(INSTALL_DIR) "$(DESTDIR)$(datadir)/appdata/" @$(INSTALL_DATA) packaging/linux/openra.appdata.xml "$(DESTDIR)$(datadir)/appdata/" +install-man-page: man-page + @$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man6/" + @$(INSTALL_DATA) openra.6 "$(DESTDIR)$(mandir)/man6/" + install-linux-scripts: @echo "#!/bin/sh" > openra @echo 'cd "$(gameinstalldir)"' >> openra @@ -419,6 +427,7 @@ uninstall: @-$(RM_F) "$(DESTDIR)$(datadir)/icons/hicolor/128x128/apps/openra.png" @-$(RM_F) "$(DESTDIR)$(datadir)/mime/packages/openra.xml" @-$(RM_F) "$(DESTDIR)$(datadir)/appdata/openra.appdata.xml" + @-$(RM_F) "$(DESTDIR)$(mandir)/man6/openra.6" help: @echo to compile, run: diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 066a615742..297f93b2c6 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -23,23 +23,55 @@ namespace OpenRA public class ServerSettings { + [Desc("Sets the server name.")] public string Name = "OpenRA Game"; + + [Desc("Sets the internal port.")] public int ListenPort = 1234; + + [Desc("Sets the port advertised to the master server.")] public int ExternalPort = 1234; + + [Desc("Reports the game to the master server list.")] public bool AdvertiseOnline = true; + + [Desc("Locks the game with a password.")] public string Password = ""; + public string MasterServer = "http://master.openra.net/"; - public bool DiscoverNatDevices = false; // Allow users to disable NAT discovery if problems occur - public bool AllowPortForward = true; // let the user disable it even if compatible devices are found + + [Desc("Allow users to enable NAT discovery for external IP detection and automatic port forwarding.")] + public bool DiscoverNatDevices = false; + + [Desc("Set this to false to disable UPnP even if compatible devices are found.")] + public bool AllowPortForward = true; + public bool NatDeviceAvailable = false; // internal check if discovery succeeded - public int NatDiscoveryTimeout = 1000; // ms to search for UPnP enabled NATs - public bool VerboseNatDiscovery = false; // print very detailed logs for debugging + + [Desc("Time in miliseconds to search for UPnP enabled NAT devices.")] + public int NatDiscoveryTimeout = 1000; + + [Desc("Print very detailed logs for debugging issues with routers.")] + public bool VerboseNatDiscovery = false; + + [Desc("Starts the game with a default map. Input as hash that can be obtained by the utility.")] public string Map = null; + + [Desc("Takes a comma separated list of IP addresses that are not allowed to join.")] public string[] Ban = { }; + + [Desc("Value in miliseconds when to terminate the game. Needs to be at least 10000 (10 s) to enable the timer.")] public int TimeOut = 0; + + [Desc("Run in headless mode with an empty renderer and without sound output.")] public bool Dedicated = false; + + [Desc("Automatically restart when a game ends. Disable this when something else already takes care about it.")] public bool DedicatedLoop = true; + + [Desc("Disallow AI bots.")] public bool LockBots = false; + public string TimestampFormat = "HH:mm"; public ServerSettings() { } @@ -122,6 +154,7 @@ namespace OpenRA public class GameSettings { + [Desc("Load a specific mod on startup. Shipped ones include: ra, cnc and d2k")] public string Mod = "modchooser"; public string PreviousMod = "ra"; diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 687d3c95b4..564ab510c2 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -529,6 +529,7 @@ + diff --git a/OpenRA.Mods.Common/UtilityCommands/CreateManPage.cs b/OpenRA.Mods.Common/UtilityCommands/CreateManPage.cs new file mode 100644 index 0000000000..880f146a2a --- /dev/null +++ b/OpenRA.Mods.Common/UtilityCommands/CreateManPage.cs @@ -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 OpenRA.Mods.Common.LoadScreens.BlankLoadScreen.LaunchArgs()); + foreach (var section in sections.OrderBy(s => s.Key)) + { + var fields = section.Value.GetType().GetFields(); + foreach (var field in fields) + { + if (!field.HasAttribute()) + 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(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."); + } + } +} diff --git a/packaging/linux/buildpackage.sh b/packaging/linux/buildpackage.sh index c26f43b7b3..38908d459b 100755 --- a/packaging/linux/buildpackage.sh +++ b/packaging/linux/buildpackage.sh @@ -24,6 +24,7 @@ make install-all prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" make install-linux-shortcuts prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" make install-linux-mime prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" make install-linux-appdata prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" +make install-man-page prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR" # Documentation mkdir -p $PWD/packaging/linux/$ROOTDIR/usr/share/doc/openra/