Localize developer debug cheats.

This commit is contained in:
Matthias Mailänder
2022-10-19 18:20:20 +02:00
committed by abcdefg30
parent 44aaf4dd07
commit 8f415bc7af
11 changed files with 163 additions and 36 deletions

View File

@@ -23,13 +23,28 @@ namespace OpenRA.Mods.Common.Commands
public class DebugVisualizationCommands : IChatCommand, IWorldLoaded public class DebugVisualizationCommands : IChatCommand, IWorldLoaded
{ {
[TranslationReference]
static readonly string CombatGeometryDescription = "combat-geometry-description";
[TranslationReference]
static readonly string RenderGeometryDescription = "render-geometry-description";
[TranslationReference]
static readonly string ScreenMapOverlayDescription = "screen-map-overlay-description";
[TranslationReference]
static readonly string DepthBufferDescription = "depth-buffer-description";
[TranslationReference]
static readonly string ActorTagsOverlayDescripition = "actor-tags-overlay-description";
readonly IDictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)> commandHandlers = new Dictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)> readonly IDictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)> commandHandlers = new Dictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)>
{ {
{ "combat-geometry", ("toggles combat geometry overlay.", CombatGeometry) }, { "combat-geometry", (CombatGeometryDescription, CombatGeometry) },
{ "render-geometry", ("toggles render geometry overlay.", RenderGeometry) }, { "render-geometry", (RenderGeometryDescription, RenderGeometry) },
{ "screen-map", ("toggles screen map overlay.", ScreenMap) }, { "screen-map", (ScreenMapOverlayDescription, ScreenMap) },
{ "depth-buffer", ("toggles depth buffer overlay.", DepthBuffer) }, { "depth-buffer", (DepthBufferDescription, DepthBuffer) },
{ "actor-tags", ("toggles actor tags overlay.", ActorTags) }, { "actor-tags", (ActorTagsOverlayDescripition, ActorTags) },
}; };
DebugVisualizations debugVis; DebugVisualizations debugVis;

View File

@@ -30,23 +30,68 @@ namespace OpenRA.Mods.Common.Commands
[TranslationReference] [TranslationReference]
static readonly string InvalidCashAmount = "invalid-cash-amount"; static readonly string InvalidCashAmount = "invalid-cash-amount";
[TranslationReference]
static readonly string ToggleVisiblityDescription = "toggle-visibility";
[TranslationReference]
static readonly string GiveCashDescription = "give-cash";
[TranslationReference]
static readonly string GiveCashAllDescription = "give-cash-all";
[TranslationReference]
static readonly string InstantBuildingDescription = "instant-building";
[TranslationReference]
static readonly string BuildAnywhereDescription = "build-anywhere";
[TranslationReference]
static readonly string UnlimitedPowerDescription = "unlimited-power";
[TranslationReference]
static readonly string EnableTechDescription = "enable-tech";
[TranslationReference]
static readonly string FastChargeDescription = "fast-charge";
[TranslationReference]
static readonly string DevCheatAllDescription = "dev-cheat-all";
[TranslationReference]
static readonly string DevCrashDescription = "dev-crash";
[TranslationReference]
static readonly string LevelUpActorDescription = "levelup-actor";
[TranslationReference]
static readonly string PlayerExperienceDescription = "player-experience";
[TranslationReference]
static readonly string PowerOutageDescription = "power-outage";
[TranslationReference]
static readonly string KillSelectedActorsDescription = "kill-selected-actors";
[TranslationReference]
static readonly string DisposeSelectedActorsDescription = "dispose-selected-actors";
readonly IDictionary<string, (string Description, Action<string, World> Handler)> commandHandlers = new Dictionary<string, (string, Action<string, World>)> readonly IDictionary<string, (string Description, Action<string, World> Handler)> commandHandlers = new Dictionary<string, (string, Action<string, World>)>
{ {
{ "visibility", ("toggles visibility checks and minimap.", Visibility) }, { "visibility", (ToggleVisiblityDescription, Visibility) },
{ "give-cash", ("gives the default or specified amount of money.", GiveCash) }, { "give-cash", (GiveCashDescription, GiveCash) },
{ "give-cash-all", ("gives the default or specified amount of money to all players and ai.", GiveCashAll) }, { "give-cash-all", (GiveCashAllDescription, GiveCashAll) },
{ "instant-build", ("toggles instant building.", InstantBuild) }, { "instant-build", (InstantBuildingDescription, InstantBuild) },
{ "build-anywhere", ("toggles you the ability to build anywhere.", BuildAnywhere) }, { "build-anywhere", (BuildAnywhereDescription, BuildAnywhere) },
{ "unlimited-power", ("toggles infinite power.", UnlimitedPower) }, { "unlimited-power", (UnlimitedPowerDescription, UnlimitedPower) },
{ "enable-tech", ("toggles the ability to build everything.", EnableTech) }, { "enable-tech", (EnableTechDescription, EnableTech) },
{ "fast-charge", ("toggles almost instant support power charging.", FastCharge) }, { "fast-charge", (FastChargeDescription, FastCharge) },
{ "all", ("toggles all cheats and gives you some cash for your trouble.", All) }, { "all", (DevCheatAllDescription, All) },
{ "crash", ("crashes the game.", Crash) }, { "crash", (DevCrashDescription, Crash) },
{ "levelup", ("adds a specified number of levels to the selected actors.", LevelUp) }, { "levelup", (LevelUpActorDescription, LevelUp) },
{ "player-experience", ("adds a specified amount of player experience to the owner(s) of selected actors.", PlayerExperience) }, { "player-experience", (PlayerExperienceDescription, PlayerExperience) },
{ "power-outage", ("causes owner(s) of selected actors to have a 5 second power outage.", PowerOutage) }, { "power-outage", (PowerOutageDescription, PowerOutage) },
{ "kill", ("kills selected actors.", Kill) }, { "kill", (KillSelectedActorsDescription, Kill) },
{ "dispose", ("disposes selected actors.", Dispose) } { "dispose", (DisposeSelectedActorsDescription, Dispose) }
}; };
World world; World world;

View File

@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Commands
[TranslationReference] [TranslationReference]
static readonly string NoDescription = "no-description"; static readonly string NoDescription = "no-description";
[TranslationReference]
static readonly string HelpDescription = "help-description";
World world; World world;
ChatCommands console; ChatCommands console;
@@ -43,7 +46,7 @@ namespace OpenRA.Mods.Common.Commands
console = world.WorldActor.Trait<ChatCommands>(); console = world.WorldActor.Trait<ChatCommands>();
console.RegisterCommand("help", this); console.RegisterCommand("help", this);
RegisterHelp("help", "provides useful info about various commands"); RegisterHelp("help", HelpDescription);
} }
public void InvokeCommand(string name, string arg) public void InvokeCommand(string name, string arg)
@@ -61,7 +64,7 @@ namespace OpenRA.Mods.Common.Commands
public void RegisterHelp(string name, string description) public void RegisterHelp(string name, string description)
{ {
helpDescriptions[name] = description; helpDescriptions[name] = Game.ModData.Translation.GetString(description);
} }
} }
} }

View File

@@ -22,6 +22,12 @@ namespace OpenRA.Mods.Common.Commands
{ {
World world; World world;
[TranslationReference]
static readonly string PauseDescription = "pause-description";
[TranslationReference]
static readonly string SurrenderDescription = "surrender-description";
public void WorldLoaded(World w, WorldRenderer wr) public void WorldLoaded(World w, WorldRenderer wr)
{ {
world = w; world = w;
@@ -29,9 +35,10 @@ namespace OpenRA.Mods.Common.Commands
var help = world.WorldActor.Trait<HelpCommand>(); var help = world.WorldActor.Trait<HelpCommand>();
console.RegisterCommand("pause", this); console.RegisterCommand("pause", this);
help.RegisterHelp("pause", "pause or unpause the game"); help.RegisterHelp("pause", PauseDescription);
console.RegisterCommand("surrender", this); console.RegisterCommand("surrender", this);
help.RegisterHelp("surrender", "self-destruct everything and lose the game"); help.RegisterHelp("surrender", SurrenderDescription);
} }
public void InvokeCommand(string name, string arg) public void InvokeCommand(string name, string arg)

View File

@@ -29,7 +29,9 @@ namespace OpenRA.Mods.Common.Traits
class CustomTerrainDebugOverlay : IWorldLoaded, IChatCommand, IRenderAnnotations class CustomTerrainDebugOverlay : IWorldLoaded, IChatCommand, IRenderAnnotations
{ {
const string CommandName = "custom-terrain"; const string CommandName = "custom-terrain";
const string CommandDesc = "toggles the custom terrain debug overlay.";
[TranslationReference]
const string CommandDescription = "custom-terrain-debug-overlay-description";
public bool Enabled; public bool Enabled;
@@ -49,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string name, string arg) void IChatCommand.InvokeCommand(string name, string arg)

View File

@@ -32,7 +32,9 @@ namespace OpenRA.Mods.Common.Traits
public class CellTriggerOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand public class CellTriggerOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand
{ {
const string CommandName = "triggers"; const string CommandName = "triggers";
const string CommandDesc = "toggles the script triggers overlay.";
[TranslationReference]
const string CommandDescription = "cell-trigger-overlay-description";
bool enabled; bool enabled;
@@ -54,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string name, string arg) void IChatCommand.InvokeCommand(string name, string arg)

View File

@@ -27,7 +27,9 @@ namespace OpenRA.Mods.Common.Traits
public class ExitsDebugOverlayManager : IWorldLoaded, IChatCommand public class ExitsDebugOverlayManager : IWorldLoaded, IChatCommand
{ {
const string CommandName = "exits-overlay"; const string CommandName = "exits-overlay";
const string CommandHelp = "Displays exits for factories.";
[TranslationReference]
const string CommandDescription = "exits-debug-overlay-description";
public readonly SpriteFont Font; public readonly SpriteFont Font;
public readonly ExitsDebugOverlayManagerInfo Info; public readonly ExitsDebugOverlayManagerInfo Info;
@@ -54,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandHelp); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string command, string arg) void IChatCommand.InvokeCommand(string command, string arg)

View File

@@ -35,7 +35,9 @@ namespace OpenRA.Mods.Common.Traits
public class HierarchicalPathFinderOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand public class HierarchicalPathFinderOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand
{ {
const string CommandName = "hpf"; const string CommandName = "hpf";
const string CommandDesc = "toggles the hierarchical pathfinder overlay.";
[TranslationReference]
const string CommandDescription = "hpf-overlay-description";
readonly HierarchicalPathFinderOverlayInfo info; readonly HierarchicalPathFinderOverlayInfo info;
readonly SpriteFont font; readonly SpriteFont font;
@@ -68,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string name, string arg) void IChatCommand.InvokeCommand(string name, string arg)

View File

@@ -40,7 +40,9 @@ namespace OpenRA.Mods.Common.Traits
public class PathFinderOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand public class PathFinderOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand
{ {
const string CommandName = "path-debug"; const string CommandName = "path-debug";
const string CommandDesc = "toggles a visualization of path searching.";
[TranslationReference]
const string CommandDescription = "path-debug-description";
sealed class Record : PathSearch.IRecorder, IEnumerable<(CPos Source, CPos Destination, int CostSoFar, int EstimatedRemainingCost)> sealed class Record : PathSearch.IRecorder, IEnumerable<(CPos Source, CPos Destination, int CostSoFar, int EstimatedRemainingCost)>
{ {
@@ -90,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string name, string arg) void IChatCommand.InvokeCommand(string name, string arg)

View File

@@ -25,7 +25,9 @@ namespace OpenRA.Mods.Common.Traits
public class TerrainGeometryOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand public class TerrainGeometryOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand
{ {
const string CommandName = "terrain-geometry"; const string CommandName = "terrain-geometry";
const string CommandDesc = "toggles the terrain geometry overlay.";
[TranslationReference]
const string CommandDescription = "terrain-geometry-overlay";
public bool Enabled; public bool Enabled;
@@ -38,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
console.RegisterCommand(CommandName, this); console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc); help.RegisterHelp(CommandName, CommandDescription);
} }
void IChatCommand.InvokeCommand(string name, string arg) void IChatCommand.InvokeCommand(string name, string arg)

View File

@@ -597,13 +597,58 @@ saved-screenshot = Saved screenshot { $filename }
## ChatCommands ## ChatCommands
invalid-command = { $name } is not a valid command. invalid-command = { $name } is not a valid command.
## DebugVisualizationCommands
combat-geometry-description = toggles combat geometry overlay.
render-geometry-description = toggles render geometry overlay.
screen-map-overlay-description = toggles screen map overlay.
depth-buffer-description = toggles depth buffer overlay.
actor-tags-overlay-description = toggles actor tags overlay.
## DevCommands ## DevCommands
cheats-disabled = Cheats are disabled. cheats-disabled = Cheats are disabled.
invalid-cash-amount = Invalid amount of cash. invalid-cash-amount = Invalid amount of cash.
toggle-visibility = toggles visibility checks and minimap.
give-cash = gives the default or specified amount of money.
give-cash-all = gives the default or specified amount of money to all players and ai.
instant-building = toggles instant building.
build-anywhere = toggles the ability to build anywhere.
unlimited-power = toggles infinite power.
enable-tech = toggles the ability to build everything.
fast-charge = toggles almost instant support power charging.
dev-cheat-all = toggles all cheats and gives you some cash for your trouble.
dev-crash = crashes the game.
levelup-actor = adds a specified number of levels to the selected actors.
player-experience = adds a specified amount of player experience to the owner(s) of selected actors.
power-outage = causes owner(s) of selected actors to have a 5 second power outage.
kill-selected-actors = kills selected actors.
dispose-selected-actors = disposes selected actors.
## HelpCommands ## HelpCommands
available-commands = Here are the available commands: available-commands = Here are the available commands:
no-description = no description available. no-description = no description available.
help-description = provides useful info about various commands
## PlayerCommands
pause-description = pause or unpause the game
surrender-description = self-destruct everything and lose the game
## DeveloperMode ## DeveloperMode
cheat-used = Cheat used: { $cheat } by { $player }{ $suffix } cheat-used = Cheat used: { $cheat } by { $player }{ $suffix }
## CustomTerrainDebugOverlay
custom-terrain-debug-overlay-description = toggles the custom terrain debug overlay.
## CellTriggerOverlay
cell-trigger-overlay-description = toggles the script triggers overlay.
## ExitsDebugOverlay
exits-debug-overlay-description = Displays exits for factories.
## HierarchicalPathFinderOverlay
hpf-overlay-description = toggles the hierarchical pathfinder overlay.
## PathFinderOverlay
path-debug-description = toggles a visualization of path searching.
## TerrainGeometryOverlay
terrain-geometry-overlay = toggles the terrain geometry overlay.