From e6477120036db9734d169f3afc16768509e44627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 13 May 2014 09:16:34 +0200 Subject: [PATCH 1/4] move all console traits into one folder --- OpenRA.Mods.RA/{ => Console}/ChatCommands.cs | 0 OpenRA.Mods.RA/{ => Console}/DevCommands.cs | 0 OpenRA.Mods.RA/{ => Console}/HelpCommand.cs | 0 OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 7 ++++--- 4 files changed, 4 insertions(+), 3 deletions(-) rename OpenRA.Mods.RA/{ => Console}/ChatCommands.cs (100%) rename OpenRA.Mods.RA/{ => Console}/DevCommands.cs (100%) rename OpenRA.Mods.RA/{ => Console}/HelpCommand.cs (100%) diff --git a/OpenRA.Mods.RA/ChatCommands.cs b/OpenRA.Mods.RA/Console/ChatCommands.cs similarity index 100% rename from OpenRA.Mods.RA/ChatCommands.cs rename to OpenRA.Mods.RA/Console/ChatCommands.cs diff --git a/OpenRA.Mods.RA/DevCommands.cs b/OpenRA.Mods.RA/Console/DevCommands.cs similarity index 100% rename from OpenRA.Mods.RA/DevCommands.cs rename to OpenRA.Mods.RA/Console/DevCommands.cs diff --git a/OpenRA.Mods.RA/HelpCommand.cs b/OpenRA.Mods.RA/Console/HelpCommand.cs similarity index 100% rename from OpenRA.Mods.RA/HelpCommand.cs rename to OpenRA.Mods.RA/Console/HelpCommand.cs diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9f58aaed35..77dd8ee5d7 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -523,9 +523,9 @@ - - - + + + @@ -574,5 +574,6 @@ cd "$(SolutionDir)" + \ No newline at end of file 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 2/4] 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: From 667f92bc75dd47968e87b08a4192f155fc224042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 13 May 2014 10:35:13 +0200 Subject: [PATCH 3/4] add a console command to surrender the game --- OpenRA.Mods.RA/Console/SurrenderCommand.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 + 6 files changed, 44 insertions(+) create mode 100644 OpenRA.Mods.RA/Console/SurrenderCommand.cs diff --git a/OpenRA.Mods.RA/Console/SurrenderCommand.cs b/OpenRA.Mods.RA/Console/SurrenderCommand.cs new file mode 100644 index 0000000000..35baf2e4b6 --- /dev/null +++ b/OpenRA.Mods.RA/Console/SurrenderCommand.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 SurrenderCommandInfo : TraitInfo { } + + public class SurrenderCommand : IChatCommand, IWorldLoaded + { + World world; + + public SurrenderCommand() { } + + public void WorldLoaded(World w, WorldRenderer wr) + { + world = w; + var console = world.WorldActor.Trait(); + var help = world.WorldActor.Trait(); + + console.RegisterCommand("surrender", this); + help.RegisterHelp("surrender", "self-destruct everything and lose the game"); + } + + public void InvokeCommand(string name, string arg) + { + world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); + } + } +} \ 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 9e18adc616..69e4662d08 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -527,6 +527,7 @@ + diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 12c18a3c49..23897fd534 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 751667fda9..0f9faac9cf 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 87d22a36f3..53c22165b1 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index b7b8aa4618..b0738be03a 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: From 8e79879ee8c29f587574cb85f8ee796be1445f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 17 May 2014 14:13:44 +0200 Subject: [PATCH 4/4] merged Pause/Surrender into PlayerCommands --- OpenRA.Mods.RA/Console/PauseCommand.cs | 39 ------------------- ...{SurrenderCommand.cs => PlayerCommands.cs} | 19 +++++++-- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 3 +- mods/cnc/rules/world.yaml | 3 +- mods/d2k/rules/world.yaml | 3 +- mods/ra/rules/world.yaml | 3 +- mods/ts/rules/world.yaml | 3 +- 7 files changed, 20 insertions(+), 53 deletions(-) delete mode 100644 OpenRA.Mods.RA/Console/PauseCommand.cs rename OpenRA.Mods.RA/Console/{SurrenderCommand.cs => PlayerCommands.cs} (59%) diff --git a/OpenRA.Mods.RA/Console/PauseCommand.cs b/OpenRA.Mods.RA/Console/PauseCommand.cs deleted file mode 100644 index dd7413603d..0000000000 --- a/OpenRA.Mods.RA/Console/PauseCommand.cs +++ /dev/null @@ -1,39 +0,0 @@ -#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/Console/SurrenderCommand.cs b/OpenRA.Mods.RA/Console/PlayerCommands.cs similarity index 59% rename from OpenRA.Mods.RA/Console/SurrenderCommand.cs rename to OpenRA.Mods.RA/Console/PlayerCommands.cs index 35baf2e4b6..5df5326dbd 100644 --- a/OpenRA.Mods.RA/Console/SurrenderCommand.cs +++ b/OpenRA.Mods.RA/Console/PlayerCommands.cs @@ -13,13 +13,13 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class SurrenderCommandInfo : TraitInfo { } + public class PlayerCommandsInfo : TraitInfo { } - public class SurrenderCommand : IChatCommand, IWorldLoaded + public class PlayerCommands : IChatCommand, IWorldLoaded { World world; - public SurrenderCommand() { } + public PlayerCommands() { } public void WorldLoaded(World w, WorldRenderer wr) { @@ -27,13 +27,24 @@ namespace OpenRA.Mods.RA var console = world.WorldActor.Trait(); var help = world.WorldActor.Trait(); + console.RegisterCommand("pause", this); + help.RegisterHelp("pause", "pause or unpause the game"); console.RegisterCommand("surrender", this); help.RegisterHelp("surrender", "self-destruct everything and lose the game"); } public void InvokeCommand(string name, string arg) { - world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); + switch (name) + { + case "pause": + world.IssueOrder(new Order("PauseGame", null, false) + { TargetString = world.Paused ? "UnPause" : "Pause" }); + break; + case "surrender": + world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); + break; + } } } } \ 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 69e4662d08..683a94eec1 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -526,8 +526,7 @@ - - + diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 23897fd534..f40d5491ca 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -1,8 +1,7 @@ World: ChatCommands: DevCommands: - PauseCommand: - SurrenderCommand: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 0f9faac9cf..f6f6141b76 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -1,8 +1,7 @@ World: ChatCommands: DevCommands: - PauseCommand: - SurrenderCommand: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 53c22165b1..f86e32085d 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -1,8 +1,7 @@ World: ChatCommands: DevCommands: - PauseCommand: - SurrenderCommand: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index b0738be03a..3e346f1406 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -1,8 +1,7 @@ World: ChatCommands: DevCommands: - PauseCommand: - SurrenderCommand: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: