Expose default UI labels and tooltips to yaml.

This commit is contained in:
Paul Chote
2017-11-19 17:32:05 +00:00
committed by reaperrr
parent 99908c4d80
commit ea32c758eb
10 changed files with 123 additions and 43 deletions

View File

@@ -17,6 +17,14 @@ namespace OpenRA.Traits
{ {
public class PlayerResourcesInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Starting cash options that are available in the lobby options.")]
public readonly int[] SelectableCash = { 2500, 5000, 10000, 20000 }; 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()); var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString());
if (startingCash.Any()) if (startingCash.Any())
yield return new LobbyOption("startingcash", "Starting Cash", "Change the amount of cash that players start with", yield return new LobbyOption("startingcash", Label, Description, DefaultCashVisible, DefaultCashDisplayOrder,
DefaultCashVisible, DefaultCashDisplayOrder, new ReadOnlyDictionary<string, string>(startingCash), DefaultCash.ToString(), DefaultCashLocked);
new ReadOnlyDictionary<string, string>(startingCash),
DefaultCash.ToString(), DefaultCashLocked);
} }
public object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); } public object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }

View File

@@ -17,6 +17,14 @@ namespace OpenRA.Traits
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")] [Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
public class ShroudInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Default value of the fog checkbox in the lobby.")]
public readonly bool FogEnabled = true; public readonly bool FogEnabled = true;
@@ -29,6 +37,14 @@ namespace OpenRA.Traits
[Desc("Display order for the fog checkbox in the lobby.")] [Desc("Display order for the fog checkbox in the lobby.")]
public readonly int FogDisplayOrder = 0; 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.")] [Desc("Default value of the explore map checkbox in the lobby.")]
public readonly bool ExploredMapEnabled = false; public readonly bool ExploredMapEnabled = false;
@@ -43,12 +59,10 @@ namespace OpenRA.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("explored", "Explored Map", "Initial map shroud is revealed", yield return new LobbyBooleanOption("explored", ExploredMapLabel, ExploredMapDescription,
ExploredMapVisible, ExploredMapDisplayOrder, ExploredMapVisible, ExploredMapDisplayOrder, ExploredMapEnabled, ExploredMapLocked);
ExploredMapEnabled, ExploredMapLocked); yield return new LobbyBooleanOption("fog", FogLabel, FogDescription,
yield return new LobbyBooleanOption("fog", "Fog of War", "Line of sight is required to view enemy forces", FogVisible, FogDisplayOrder, FogEnabled, FogLocked);
FogVisible, FogDisplayOrder,
FogEnabled, FogLocked);
} }
public object Create(ActorInitializer init) { return new Shroud(init.Self, this); } public object Create(ActorInitializer init) { return new Shroud(init.Self, this); }

View File

@@ -18,6 +18,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Attach this to the player actor.")] [Desc("Attach this to the player actor.")]
public class DeveloperModeInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Default value of the developer mode checkbox in the lobby.")]
public readonly bool Enabled = false; public readonly bool Enabled = false;
@@ -56,9 +64,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("cheats", "Debug Menu", yield return new LobbyBooleanOption("cheats", Label, Description, Visible, DisplayOrder, Enabled, Locked);
"Enables cheats and developer commands",
Visible, DisplayOrder, Enabled, Locked);
} }
public object Create(ActorInitializer init) { return new DeveloperMode(this); } public object Create(ActorInitializer init) { return new DeveloperMode(this); }

View File

@@ -21,6 +21,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class CrateSpawnerInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Default value of the crates checkbox in the lobby.")]
public readonly bool Enabled = true; public readonly bool Enabled = true;
@@ -73,9 +81,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("crates", "Crates", yield return new LobbyBooleanOption("crates", Label, Description, Visible, DisplayOrder, Enabled, Locked);
"Collect crates with units to recieve random bonuses or penalties",
Visible, DisplayOrder, Enabled, Locked);
} }
public object Create(ActorInitializer init) { return new CrateSpawner(init.Self, this); } public object Create(ActorInitializer init) { return new CrateSpawner(init.Self, this); }

View File

@@ -17,6 +17,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Controls the build radius checkboxes in the lobby options.")] [Desc("Controls the build radius checkboxes in the lobby options.")]
public class MapBuildRadiusInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Default value of the ally build radius checkbox in the lobby.")]
public readonly bool AllyBuildRadiusEnabled = true; 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.")] [Desc("Display order for the ally build radius checkbox in the lobby.")]
public readonly int AllyBuildRadiusDisplayOrder = 0; 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.")] [Desc("Default value of the build radius checkbox in the lobby.")]
public readonly bool BuildRadiusEnabled = true; public readonly bool BuildRadiusEnabled = true;
@@ -43,13 +59,11 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("allybuild", "Build off Allies", "Allow allies to place structures inside your build area", yield return new LobbyBooleanOption("allybuild", AllyBuildRadiusLabel, AllyBuildRadiusDescription,
AllyBuildRadiusVisible, AllyBuildRadiusDisplayOrder, AllyBuildRadiusVisible, AllyBuildRadiusDisplayOrder, AllyBuildRadiusEnabled, AllyBuildRadiusLocked);
AllyBuildRadiusEnabled, AllyBuildRadiusLocked);
yield return new LobbyBooleanOption("buildradius", "Limit Build Area", "Limits structure placement to areas around Construction Yards", yield return new LobbyBooleanOption("buildradius", BuildRadiusLabel, BuildRadiusDescription,
BuildRadiusVisible, BuildRadiusDisplayOrder, BuildRadiusVisible, BuildRadiusDisplayOrder, BuildRadiusEnabled, BuildRadiusLocked);
BuildRadiusEnabled, BuildRadiusLocked);
} }
public object Create(ActorInitializer init) { return new MapBuildRadius(this); } public object Create(ActorInitializer init) { return new MapBuildRadius(this); }

View File

@@ -17,6 +17,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Controls the 'Creeps' checkbox in the lobby options.")] [Desc("Controls the 'Creeps' checkbox in the lobby options.")]
public class MapCreepsInfo : ITraitInfo, ILobbyOptions 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.")] [Desc("Default value of the creeps checkbox in the lobby.")]
public readonly bool Enabled = true; public readonly bool Enabled = true;
@@ -31,8 +39,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("creeps", "Worms", "Worms roam the map and devour unprepared forces", yield return new LobbyBooleanOption("creeps", Label, Description, Visible, DisplayOrder, Enabled, Locked);
Visible, DisplayOrder, Enabled, Locked);
} }
public object Create(ActorInitializer init) { return new MapCreeps(this); } public object Create(ActorInitializer init) { return new MapCreeps(this); }

View File

@@ -18,6 +18,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Controls the game speed, tech level, and short game lobby options.")] [Desc("Controls the game speed, tech level, and short game lobby options.")]
public class MapOptionsInfo : ITraitInfo, ILobbyOptions, IRulesetLoaded 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.")] [Desc("Default value of the short game checkbox in the lobby.")]
public readonly bool ShortGameEnabled = true; 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.")] [Desc("Display order for the short game checkbox in the lobby.")]
public readonly int ShortGameDisplayOrder = 0; 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.")] [Desc("Default tech level.")]
public readonly string TechLevel = "unrestricted"; 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.")] [Desc("Display order for the tech level option in the lobby.")]
public readonly int TechLevelDisplayOrder = 0; 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.")] [Desc("Default game speed.")]
public readonly string GameSpeed = "default"; public readonly string GameSpeed = "default";
@@ -56,27 +80,22 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyBooleanOption("shortgame", "Short Game", "Players are defeated when their bases are destroyed", yield return new LobbyBooleanOption("shortgame", ShortGameLabel, ShortGameDescription,
ShortGameVisible, ShortGameDisplayOrder, ShortGameVisible, ShortGameDisplayOrder, ShortGameEnabled, ShortGameLocked);
ShortGameEnabled, ShortGameLocked);
var techLevels = rules.Actors["player"].TraitInfos<ProvidesTechPrerequisiteInfo>() var techLevels = rules.Actors["player"].TraitInfos<ProvidesTechPrerequisiteInfo>()
.ToDictionary(t => t.Id, t => t.Name); .ToDictionary(t => t.Id, t => t.Name);
if (techLevels.Any()) if (techLevels.Any())
yield return new LobbyOption("techlevel", "Tech Level", "Change the units and abilities at your disposal", yield return new LobbyOption("techlevel", TechLevelLabel, TechLevelDescription, TechLevelVisible, TechLevelDisplayOrder,
TechLevelVisible, TechLevelDisplayOrder, new ReadOnlyDictionary<string, string>(techLevels), TechLevel, TechLevelLocked);
new ReadOnlyDictionary<string, string>(techLevels),
TechLevel, TechLevelLocked);
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds
.ToDictionary(s => s.Key, s => s.Value.Name); .ToDictionary(s => s.Key, s => s.Value.Name);
// NOTE: The server hardcodes special-case logic for this option id // 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", yield return new LobbyOption("gamespeed", GameSpeedLabel, GameSpeedDescription, GameSpeedVisible, GameSpeedDisplayOrder,
GameSpeedVisible, GameSpeedDisplayOrder, new ReadOnlyDictionary<string, string>(gameSpeeds), GameSpeed, GameSpeedLocked);
new ReadOnlyDictionary<string, string>(gameSpeeds),
GameSpeed, GameSpeedLocked);
} }
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info) void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)

View File

@@ -22,10 +22,12 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Internal id for this option.")] [Desc("Internal id for this option.")]
public readonly string ID = null; public readonly string ID = null;
[Translate]
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Descriptive label for this option.")] [Desc("Descriptive label for this option.")]
public readonly string Label = null; public readonly string Label = null;
[Translate]
[Desc("Tooltip description for this option.")] [Desc("Tooltip description for this option.")]
public readonly string Description = null; public readonly string Description = null;
@@ -48,10 +50,8 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules) IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{ {
yield return new LobbyOption(ID, Label, Description, yield return new LobbyOption(ID, Label, Description, Visible, DisplayOrder,
Visible, DisplayOrder, new ReadOnlyDictionary<string, string>(Values), Default, Locked);
new ReadOnlyDictionary<string, string>(Values),
Default, Locked);
} }
public object Create(ActorInitializer init) { return new ScriptLobbyDropdown(this); } public object Create(ActorInitializer init) { return new ScriptLobbyDropdown(this); }

View File

@@ -23,6 +23,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly string StartingUnitsClass = "none"; 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.")] [Desc("Prevent the starting units option from being changed in the lobby.")]
public readonly bool Locked = false; public readonly bool Locked = false;
@@ -41,10 +49,8 @@ namespace OpenRA.Mods.Common.Traits
startingUnits[t.Class] = t.ClassName; startingUnits[t.Class] = t.ClassName;
if (startingUnits.Any()) if (startingUnits.Any())
yield return new LobbyOption("startingunits", "Starting Units", "Change the units that you start the game with", yield return new LobbyOption("startingunits", Label, Description, Visible, DisplayOrder,
Visible, DisplayOrder, new ReadOnlyDictionary<string, string>(startingUnits), StartingUnitsClass, Locked);
new ReadOnlyDictionary<string, string>(startingUnits),
StartingUnitsClass, Locked);
} }
public object Create(ActorInitializer init) { return new SpawnMPUnits(this); } public object Create(ActorInitializer init) { return new SpawnMPUnits(this); }

View File

@@ -96,6 +96,8 @@ World:
Sequence: sandcraters Sequence: sandcraters
SmokePercentage: 0 SmokePercentage: 0
MapCreeps: MapCreeps:
Label: Worms
Description: Worms roam the map and devour unprepared forces
DisplayOrder: 5 DisplayOrder: 5
SpawnMapActors: SpawnMapActors:
MapBuildRadius: MapBuildRadius: