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
{
[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)>
{
{ "combat-geometry", ("toggles combat geometry overlay.", CombatGeometry) },
{ "render-geometry", ("toggles render geometry overlay.", RenderGeometry) },
{ "screen-map", ("toggles screen map overlay.", ScreenMap) },
{ "depth-buffer", ("toggles depth buffer overlay.", DepthBuffer) },
{ "actor-tags", ("toggles actor tags overlay.", ActorTags) },
{ "combat-geometry", (CombatGeometryDescription, CombatGeometry) },
{ "render-geometry", (RenderGeometryDescription, RenderGeometry) },
{ "screen-map", (ScreenMapOverlayDescription, ScreenMap) },
{ "depth-buffer", (DepthBufferDescription, DepthBuffer) },
{ "actor-tags", (ActorTagsOverlayDescripition, ActorTags) },
};
DebugVisualizations debugVis;

View File

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

View File

@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Commands
[TranslationReference]
static readonly string NoDescription = "no-description";
[TranslationReference]
static readonly string HelpDescription = "help-description";
World world;
ChatCommands console;
@@ -43,7 +46,7 @@ namespace OpenRA.Mods.Common.Commands
console = world.WorldActor.Trait<ChatCommands>();
console.RegisterCommand("help", this);
RegisterHelp("help", "provides useful info about various commands");
RegisterHelp("help", HelpDescription);
}
public void InvokeCommand(string name, string arg)
@@ -61,7 +64,7 @@ namespace OpenRA.Mods.Common.Commands
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;
[TranslationReference]
static readonly string PauseDescription = "pause-description";
[TranslationReference]
static readonly string SurrenderDescription = "surrender-description";
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
@@ -29,9 +35,10 @@ namespace OpenRA.Mods.Common.Commands
var help = world.WorldActor.Trait<HelpCommand>();
console.RegisterCommand("pause", this);
help.RegisterHelp("pause", "pause or unpause the game");
help.RegisterHelp("pause", PauseDescription);
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)

View File

@@ -29,7 +29,9 @@ namespace OpenRA.Mods.Common.Traits
class CustomTerrainDebugOverlay : IWorldLoaded, IChatCommand, IRenderAnnotations
{
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;
@@ -49,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
return;
console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc);
help.RegisterHelp(CommandName, CommandDescription);
}
void IChatCommand.InvokeCommand(string name, string arg)

View File

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

View File

@@ -27,7 +27,9 @@ namespace OpenRA.Mods.Common.Traits
public class ExitsDebugOverlayManager : IWorldLoaded, IChatCommand
{
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 ExitsDebugOverlayManagerInfo Info;
@@ -54,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
return;
console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandHelp);
help.RegisterHelp(CommandName, CommandDescription);
}
void IChatCommand.InvokeCommand(string command, string arg)

View File

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

View File

@@ -40,7 +40,9 @@ namespace OpenRA.Mods.Common.Traits
public class PathFinderOverlay : IRenderAnnotations, IWorldLoaded, IChatCommand
{
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)>
{
@@ -90,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
return;
console.RegisterCommand(CommandName, this);
help.RegisterHelp(CommandName, CommandDesc);
help.RegisterHelp(CommandName, CommandDescription);
}
void IChatCommand.InvokeCommand(string name, string arg)

View File

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

View File

@@ -597,13 +597,58 @@ saved-screenshot = Saved screenshot { $filename }
## ChatCommands
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
cheats-disabled = Cheats are disabled.
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
available-commands = Here are the available commands:
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
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.