From ea32c758ebff3c9b3ec6edda38298b99a2d68b42 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 19 Nov 2017 17:32:05 +0000 Subject: [PATCH] Expose default UI labels and tooltips to yaml. --- OpenRA.Game/Traits/Player/PlayerResources.cs | 14 +++++-- OpenRA.Game/Traits/Player/Shroud.cs | 26 +++++++++--- .../Traits/Player/DeveloperMode.cs | 12 ++++-- .../Traits/World/CrateSpawner.cs | 12 ++++-- .../Traits/World/MapBuildRadius.cs | 26 +++++++++--- OpenRA.Mods.Common/Traits/World/MapCreeps.cs | 11 ++++- OpenRA.Mods.Common/Traits/World/MapOptions.cs | 41 ++++++++++++++----- .../Traits/World/ScriptLobbyDropdown.cs | 8 ++-- .../Traits/World/SpawnMPUnits.cs | 14 +++++-- mods/d2k/rules/world.yaml | 2 + 10 files changed, 123 insertions(+), 43 deletions(-) diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index c4be846b04..f3db961291 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -17,6 +17,14 @@ namespace OpenRA.Traits { public class PlayerResourcesInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the starting cash option in the lobby.")] + public readonly string Label = "Starting Cash"; + + [Translate] + [Desc("Tooltip description for the starting cash option in the lobby.")] + public readonly string Description = "Change the amount of cash that players start with"; + [Desc("Starting cash options that are available in the lobby options.")] public readonly int[] SelectableCash = { 2500, 5000, 10000, 20000 }; @@ -43,10 +51,8 @@ namespace OpenRA.Traits var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString()); if (startingCash.Any()) - yield return new LobbyOption("startingcash", "Starting Cash", "Change the amount of cash that players start with", - DefaultCashVisible, DefaultCashDisplayOrder, - new ReadOnlyDictionary(startingCash), - DefaultCash.ToString(), DefaultCashLocked); + yield return new LobbyOption("startingcash", Label, Description, DefaultCashVisible, DefaultCashDisplayOrder, + new ReadOnlyDictionary(startingCash), DefaultCash.ToString(), DefaultCashLocked); } public object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); } diff --git a/OpenRA.Game/Traits/Player/Shroud.cs b/OpenRA.Game/Traits/Player/Shroud.cs index 2f52435eae..bf193aa3ee 100644 --- a/OpenRA.Game/Traits/Player/Shroud.cs +++ b/OpenRA.Game/Traits/Player/Shroud.cs @@ -17,6 +17,14 @@ namespace OpenRA.Traits [Desc("Required for shroud and fog visibility checks. Add this to the player actor.")] public class ShroudInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the fog checkbox in the lobby.")] + public readonly string FogLabel = "Fog of War"; + + [Translate] + [Desc("Tooltip description for the fog checkbox in the lobby.")] + public readonly string FogDescription = "Line of sight is required to view enemy forces"; + [Desc("Default value of the fog checkbox in the lobby.")] public readonly bool FogEnabled = true; @@ -29,6 +37,14 @@ namespace OpenRA.Traits [Desc("Display order for the fog checkbox in the lobby.")] public readonly int FogDisplayOrder = 0; + [Translate] + [Desc("Descriptive label for the explored map checkbox in the lobby.")] + public readonly string ExploredMapLabel = "Explored Map"; + + [Translate] + [Desc("Tooltip description for the explored map checkbox in the lobby.")] + public readonly string ExploredMapDescription = "Initial map shroud is revealed"; + [Desc("Default value of the explore map checkbox in the lobby.")] public readonly bool ExploredMapEnabled = false; @@ -43,12 +59,10 @@ namespace OpenRA.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("explored", "Explored Map", "Initial map shroud is revealed", - ExploredMapVisible, ExploredMapDisplayOrder, - ExploredMapEnabled, ExploredMapLocked); - yield return new LobbyBooleanOption("fog", "Fog of War", "Line of sight is required to view enemy forces", - FogVisible, FogDisplayOrder, - FogEnabled, FogLocked); + yield return new LobbyBooleanOption("explored", ExploredMapLabel, ExploredMapDescription, + ExploredMapVisible, ExploredMapDisplayOrder, ExploredMapEnabled, ExploredMapLocked); + yield return new LobbyBooleanOption("fog", FogLabel, FogDescription, + FogVisible, FogDisplayOrder, FogEnabled, FogLocked); } public object Create(ActorInitializer init) { return new Shroud(init.Self, this); } diff --git a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs index b5b1d361b8..4173b6b3b0 100644 --- a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs @@ -18,6 +18,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Attach this to the player actor.")] public class DeveloperModeInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the developer mode checkbox in the lobby.")] + public readonly string Label = "Debug Menu"; + + [Translate] + [Desc("Tooltip description for the developer mode checkbox in the lobby.")] + public readonly string Description = "Enables cheats and developer commands"; + [Desc("Default value of the developer mode checkbox in the lobby.")] public readonly bool Enabled = false; @@ -56,9 +64,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("cheats", "Debug Menu", - "Enables cheats and developer commands", - Visible, DisplayOrder, Enabled, Locked); + yield return new LobbyBooleanOption("cheats", Label, Description, Visible, DisplayOrder, Enabled, Locked); } public object Create(ActorInitializer init) { return new DeveloperMode(this); } diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 86ce878e75..d9a7bc6299 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -21,6 +21,14 @@ namespace OpenRA.Mods.Common.Traits { public class CrateSpawnerInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the crates checkbox in the lobby.")] + public readonly string Label = "Crates"; + + [Translate] + [Desc("Tooltip description for the crates checkbox in the lobby.")] + public readonly string Description = "Collect crates with units to recieve random bonuses or penalties"; + [Desc("Default value of the crates checkbox in the lobby.")] public readonly bool Enabled = true; @@ -73,9 +81,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("crates", "Crates", - "Collect crates with units to recieve random bonuses or penalties", - Visible, DisplayOrder, Enabled, Locked); + yield return new LobbyBooleanOption("crates", Label, Description, Visible, DisplayOrder, Enabled, Locked); } public object Create(ActorInitializer init) { return new CrateSpawner(init.Self, this); } diff --git a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs index 0609d96673..2d052f55f1 100644 --- a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs +++ b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs @@ -17,6 +17,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Controls the build radius checkboxes in the lobby options.")] public class MapBuildRadiusInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the ally build radius checkbox in the lobby.")] + public readonly string AllyBuildRadiusLabel = "Build off Allies"; + + [Translate] + [Desc("Tooltip description for the ally build radius checkbox in the lobby.")] + public readonly string AllyBuildRadiusDescription = "Allow allies to place structures inside your build area"; + [Desc("Default value of the ally build radius checkbox in the lobby.")] public readonly bool AllyBuildRadiusEnabled = true; @@ -29,6 +37,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the ally build radius checkbox in the lobby.")] public readonly int AllyBuildRadiusDisplayOrder = 0; + [Translate] + [Desc("Tooltip description for the build radius checkbox in the lobby.")] + public readonly string BuildRadiusLabel = "Limit Build Area"; + + [Translate] + [Desc("Tooltip description for the build radius checkbox in the lobby.")] + public readonly string BuildRadiusDescription = "Limits structure placement to areas around Construction Yards"; + [Desc("Default value of the build radius checkbox in the lobby.")] public readonly bool BuildRadiusEnabled = true; @@ -43,13 +59,11 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("allybuild", "Build off Allies", "Allow allies to place structures inside your build area", - AllyBuildRadiusVisible, AllyBuildRadiusDisplayOrder, - AllyBuildRadiusEnabled, AllyBuildRadiusLocked); + yield return new LobbyBooleanOption("allybuild", AllyBuildRadiusLabel, AllyBuildRadiusDescription, + AllyBuildRadiusVisible, AllyBuildRadiusDisplayOrder, AllyBuildRadiusEnabled, AllyBuildRadiusLocked); - yield return new LobbyBooleanOption("buildradius", "Limit Build Area", "Limits structure placement to areas around Construction Yards", - BuildRadiusVisible, BuildRadiusDisplayOrder, - BuildRadiusEnabled, BuildRadiusLocked); + yield return new LobbyBooleanOption("buildradius", BuildRadiusLabel, BuildRadiusDescription, + BuildRadiusVisible, BuildRadiusDisplayOrder, BuildRadiusEnabled, BuildRadiusLocked); } public object Create(ActorInitializer init) { return new MapBuildRadius(this); } diff --git a/OpenRA.Mods.Common/Traits/World/MapCreeps.cs b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs index 2107c15eb9..d0fc6c84c1 100644 --- a/OpenRA.Mods.Common/Traits/World/MapCreeps.cs +++ b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs @@ -17,6 +17,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Controls the 'Creeps' checkbox in the lobby options.")] public class MapCreepsInfo : ITraitInfo, ILobbyOptions { + [Translate] + [Desc("Descriptive label for the creeps checkbox in the lobby.")] + public readonly string Label = "Creep Actors"; + + [Translate] + [Desc("Tooltip description for the creeps checkbox in the lobby.")] + public readonly string Description = "Hostile forces spawn on the battlefield"; + [Desc("Default value of the creeps checkbox in the lobby.")] public readonly bool Enabled = true; @@ -31,8 +39,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("creeps", "Worms", "Worms roam the map and devour unprepared forces", - Visible, DisplayOrder, Enabled, Locked); + yield return new LobbyBooleanOption("creeps", Label, Description, Visible, DisplayOrder, Enabled, Locked); } public object Create(ActorInitializer init) { return new MapCreeps(this); } diff --git a/OpenRA.Mods.Common/Traits/World/MapOptions.cs b/OpenRA.Mods.Common/Traits/World/MapOptions.cs index 35e0585894..804bced24e 100644 --- a/OpenRA.Mods.Common/Traits/World/MapOptions.cs +++ b/OpenRA.Mods.Common/Traits/World/MapOptions.cs @@ -18,6 +18,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Controls the game speed, tech level, and short game lobby options.")] public class MapOptionsInfo : ITraitInfo, ILobbyOptions, IRulesetLoaded { + [Translate] + [Desc("Descriptive label for the short game checkbox in the lobby.")] + public readonly string ShortGameLabel = "Short Game"; + + [Translate] + [Desc("Tooltip description for the short game checkbox in the lobby.")] + public readonly string ShortGameDescription = "Players are defeated when their bases are destroyed"; + [Desc("Default value of the short game checkbox in the lobby.")] public readonly bool ShortGameEnabled = true; @@ -30,6 +38,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the short game checkbox in the lobby.")] public readonly int ShortGameDisplayOrder = 0; + [Translate] + [Desc("Descriptive label for the tech level option in the lobby.")] + public readonly string TechLevelLabel = "Tech Level"; + + [Translate] + [Desc("Tooltip description for the tech level option in the lobby.")] + public readonly string TechLevelDescription = "Change the units and abilities at your disposal"; + [Desc("Default tech level.")] public readonly string TechLevel = "unrestricted"; @@ -42,6 +58,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the tech level option in the lobby.")] public readonly int TechLevelDisplayOrder = 0; + [Translate] + [Desc("Tooltip description for the game speed option in the lobby.")] + public readonly string GameSpeedLabel = "Game Speed"; + + [Translate] + [Desc("Description of the game speed option in the lobby.")] + public readonly string GameSpeedDescription = "Change the rate at which time passes"; + [Desc("Default game speed.")] public readonly string GameSpeed = "default"; @@ -56,27 +80,22 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyBooleanOption("shortgame", "Short Game", "Players are defeated when their bases are destroyed", - ShortGameVisible, ShortGameDisplayOrder, - ShortGameEnabled, ShortGameLocked); + yield return new LobbyBooleanOption("shortgame", ShortGameLabel, ShortGameDescription, + ShortGameVisible, ShortGameDisplayOrder, ShortGameEnabled, ShortGameLocked); var techLevels = rules.Actors["player"].TraitInfos() .ToDictionary(t => t.Id, t => t.Name); if (techLevels.Any()) - yield return new LobbyOption("techlevel", "Tech Level", "Change the units and abilities at your disposal", - TechLevelVisible, TechLevelDisplayOrder, - new ReadOnlyDictionary(techLevels), - TechLevel, TechLevelLocked); + yield return new LobbyOption("techlevel", TechLevelLabel, TechLevelDescription, TechLevelVisible, TechLevelDisplayOrder, + new ReadOnlyDictionary(techLevels), TechLevel, TechLevelLocked); var gameSpeeds = Game.ModData.Manifest.Get().Speeds .ToDictionary(s => s.Key, s => s.Value.Name); // NOTE: The server hardcodes special-case logic for this option id - yield return new LobbyOption("gamespeed", "Game Speed", "Change the rate at which time passes", - GameSpeedVisible, GameSpeedDisplayOrder, - new ReadOnlyDictionary(gameSpeeds), - GameSpeed, GameSpeedLocked); + yield return new LobbyOption("gamespeed", GameSpeedLabel, GameSpeedDescription, GameSpeedVisible, GameSpeedDisplayOrder, + new ReadOnlyDictionary(gameSpeeds), GameSpeed, GameSpeedLocked); } void IRulesetLoaded.RulesetLoaded(Ruleset rules, ActorInfo info) diff --git a/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs b/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs index 16e56562d6..8d9dd7c05b 100644 --- a/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs +++ b/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs @@ -22,10 +22,12 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal id for this option.")] public readonly string ID = null; + [Translate] [FieldLoader.Require] [Desc("Descriptive label for this option.")] public readonly string Label = null; + [Translate] [Desc("Tooltip description for this option.")] public readonly string Description = null; @@ -48,10 +50,8 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { - yield return new LobbyOption(ID, Label, Description, - Visible, DisplayOrder, - new ReadOnlyDictionary(Values), - Default, Locked); + yield return new LobbyOption(ID, Label, Description, Visible, DisplayOrder, + new ReadOnlyDictionary(Values), Default, Locked); } public object Create(ActorInitializer init) { return new ScriptLobbyDropdown(this); } diff --git a/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs b/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs index 1b0db4dc1e..8529205391 100644 --- a/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs @@ -23,6 +23,14 @@ namespace OpenRA.Mods.Common.Traits { public readonly string StartingUnitsClass = "none"; + [Translate] + [Desc("Descriptive label for the starting units option in the lobby.")] + public readonly string Label = "Starting Units"; + + [Translate] + [Desc("Tooltip description for the starting units option in the lobby.")] + public readonly string Description = "Change the units that you start the game with"; + [Desc("Prevent the starting units option from being changed in the lobby.")] public readonly bool Locked = false; @@ -41,10 +49,8 @@ namespace OpenRA.Mods.Common.Traits startingUnits[t.Class] = t.ClassName; if (startingUnits.Any()) - yield return new LobbyOption("startingunits", "Starting Units", "Change the units that you start the game with", - Visible, DisplayOrder, - new ReadOnlyDictionary(startingUnits), - StartingUnitsClass, Locked); + yield return new LobbyOption("startingunits", Label, Description, Visible, DisplayOrder, + new ReadOnlyDictionary(startingUnits), StartingUnitsClass, Locked); } public object Create(ActorInitializer init) { return new SpawnMPUnits(this); } diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 4114c8583d..04d60138b2 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -96,6 +96,8 @@ World: Sequence: sandcraters SmokePercentage: 0 MapCreeps: + Label: Worms + Description: Worms roam the map and devour unprepared forces DisplayOrder: 5 SpawnMapActors: MapBuildRadius: