From 83a38358024df7e5e275fe791564770b46634192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 13 May 2014 10:30:36 +0200 Subject: [PATCH] add a new /pause command --- OpenRA.Mods.RA/Console/HelpCommand.cs | 4 +-- OpenRA.Mods.RA/Console/PauseCommand.cs | 39 ++++++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + mods/cnc/rules/world.yaml | 1 + mods/d2k/rules/world.yaml | 1 + mods/ra/rules/world.yaml | 1 + mods/ts/rules/world.yaml | 1 + 7 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 OpenRA.Mods.RA/Console/PauseCommand.cs diff --git a/OpenRA.Mods.RA/Console/HelpCommand.cs b/OpenRA.Mods.RA/Console/HelpCommand.cs index 62f8b35b90..16a9b254c3 100644 --- a/OpenRA.Mods.RA/Console/HelpCommand.cs +++ b/OpenRA.Mods.RA/Console/HelpCommand.cs @@ -38,9 +38,9 @@ namespace OpenRA.Mods.RA } public void InvokeCommand(string name, string arg) - { + { Game.Debug("Here are the available commands:"); - + foreach (var key in console.Commands.Keys) { var description = ""; diff --git a/OpenRA.Mods.RA/Console/PauseCommand.cs b/OpenRA.Mods.RA/Console/PauseCommand.cs new file mode 100644 index 0000000000..dd7413603d --- /dev/null +++ b/OpenRA.Mods.RA/Console/PauseCommand.cs @@ -0,0 +1,39 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 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 OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + public class PauseCommandInfo : TraitInfo { } + + public class PauseCommand : IChatCommand, IWorldLoaded + { + World world; + + public PauseCommand() { } + + public void WorldLoaded(World w, WorldRenderer wr) + { + world = w; + var console = world.WorldActor.Trait(); + var help = world.WorldActor.Trait(); + + console.RegisterCommand("pause", this); + help.RegisterHelp("pause", "pause or unpause the game"); + } + + public void InvokeCommand(string name, string arg) + { + world.IssueOrder(new Order("PauseGame", null, false) { TargetString = world.Paused ? "UnPause" : "Pause" }); + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 77dd8ee5d7..9e18adc616 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -526,6 +526,7 @@ + diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 887ad1e34f..12c18a3c49 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PauseCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 2287278f01..751667fda9 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PauseCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 4bc3c40787..87d22a36f3 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PauseCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index c7dbd97836..b7b8aa4618 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PauseCommand: HelpCommand: ScreenMap: ActorMap: