Add Checkbox/Dropdown to lobby options yaml fields.
This commit is contained in:
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Explore map-placed actors if the "Explore Map" option is enabled
|
||||
var shroudInfo = init.World.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
|
||||
var exploredMap = init.World.LobbyInfo.GlobalSettings.OptionOrDefault("explored", shroudInfo.ExploredMapEnabled);
|
||||
var exploredMap = init.World.LobbyInfo.GlobalSettings.OptionOrDefault("explored", shroudInfo.ExploredMapCheckboxEnabled);
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
|
||||
var buildingInfo = init.Self.Info.TraitInfoOrDefault<BuildingInfo>();
|
||||
var footprintCells = buildingInfo != null ? buildingInfo.FrozenUnderFogTiles(init.Self.Location).ToList() : new List<CPos>() { init.Self.Location };
|
||||
|
||||
@@ -20,23 +20,23 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the developer mode checkbox in the lobby.")]
|
||||
public readonly string Label = "Debug Menu";
|
||||
public readonly string CheckboxLabel = "Debug Menu";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the developer mode checkbox in the lobby.")]
|
||||
public readonly string Description = "Enables cheats and developer commands";
|
||||
public readonly string CheckboxDescription = "Enables cheats and developer commands";
|
||||
|
||||
[Desc("Default value of the developer mode checkbox in the lobby.")]
|
||||
public readonly bool Enabled = false;
|
||||
public readonly bool CheckboxEnabled = false;
|
||||
|
||||
[Desc("Prevent the developer mode state from being changed in the lobby.")]
|
||||
public readonly bool Locked = false;
|
||||
public readonly bool CheckboxLocked = false;
|
||||
|
||||
[Desc("Whether to display the developer mode checkbox in the lobby.")]
|
||||
public readonly bool Visible = true;
|
||||
public readonly bool CheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the developer mode checkbox in the lobby.")]
|
||||
public readonly int DisplayOrder = 0;
|
||||
public readonly int CheckboxDisplayOrder = 0;
|
||||
|
||||
[Desc("Default cash bonus granted by the give cash cheat.")]
|
||||
public readonly int Cash = 20000;
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("cheats", Label, Description, Visible, DisplayOrder, Enabled, Locked);
|
||||
yield return new LobbyBooleanOption("cheats", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new DeveloperMode(this); }
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
Enabled = self.World.LobbyInfo.NonBotPlayers.Count() == 1 || self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("cheats", info.Enabled);
|
||||
.OptionOrDefault("cheats", info.CheckboxEnabled);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
|
||||
@@ -23,23 +23,23 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the crates checkbox in the lobby.")]
|
||||
public readonly string Label = "Crates";
|
||||
public readonly string CheckboxLabel = "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";
|
||||
public readonly string CheckboxDescription = "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;
|
||||
public readonly bool CheckboxEnabled = true;
|
||||
|
||||
[Desc("Prevent the crates state from being changed in the lobby.")]
|
||||
public readonly bool Locked = false;
|
||||
public readonly bool CheckboxLocked = false;
|
||||
|
||||
[Desc("Whether to display the crates checkbox in the lobby.")]
|
||||
public readonly bool Visible = true;
|
||||
public readonly bool CheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the crates checkbox in the lobby.")]
|
||||
public readonly int DisplayOrder = 0;
|
||||
public readonly int CheckboxDisplayOrder = 0;
|
||||
|
||||
[Desc("Minimum number of crates.")]
|
||||
public readonly int Minimum = 1;
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("crates", Label, Description, Visible, DisplayOrder, Enabled, Locked);
|
||||
yield return new LobbyBooleanOption("crates", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new CrateSpawner(init.Self, this); }
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
enabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("crates", info.Enabled);
|
||||
.OptionOrDefault("crates", info.CheckboxEnabled);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
|
||||
@@ -19,51 +19,51 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the ally build radius checkbox in the lobby.")]
|
||||
public readonly string AllyBuildRadiusLabel = "Build off Allies";
|
||||
public readonly string AllyBuildRadiusCheckboxLabel = "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";
|
||||
public readonly string AllyBuildRadiusCheckboxDescription = "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;
|
||||
public readonly bool AllyBuildRadiusCheckboxEnabled = true;
|
||||
|
||||
[Desc("Prevent the ally build radius state from being changed in the lobby.")]
|
||||
public readonly bool AllyBuildRadiusLocked = false;
|
||||
public readonly bool AllyBuildRadiusCheckboxLocked = false;
|
||||
|
||||
[Desc("Whether to display the ally build radius checkbox in the lobby.")]
|
||||
public readonly bool AllyBuildRadiusVisible = true;
|
||||
public readonly bool AllyBuildRadiusCheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the ally build radius checkbox in the lobby.")]
|
||||
public readonly int AllyBuildRadiusDisplayOrder = 0;
|
||||
public readonly int AllyBuildRadiusCheckboxDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the build radius checkbox in the lobby.")]
|
||||
public readonly string BuildRadiusLabel = "Limit Build Area";
|
||||
public readonly string BuildRadiusCheckboxLabel = "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";
|
||||
public readonly string BuildRadiusCheckboxDescription = "Limits structure placement to areas around Construction Yards";
|
||||
|
||||
[Desc("Default value of the build radius checkbox in the lobby.")]
|
||||
public readonly bool BuildRadiusEnabled = true;
|
||||
public readonly bool BuildRadiusCheckboxEnabled = true;
|
||||
|
||||
[Desc("Prevent the build radius state from being changed in the lobby.")]
|
||||
public readonly bool BuildRadiusLocked = false;
|
||||
public readonly bool BuildRadiusCheckboxLocked = false;
|
||||
|
||||
[Desc("Display the build radius checkbox in the lobby.")]
|
||||
public readonly bool BuildRadiusVisible = true;
|
||||
public readonly bool BuildRadiusCheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the build radius checkbox in the lobby.")]
|
||||
public readonly int BuildRadiusDisplayOrder = 0;
|
||||
public readonly int BuildRadiusCheckboxDisplayOrder = 0;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("allybuild", AllyBuildRadiusLabel, AllyBuildRadiusDescription,
|
||||
AllyBuildRadiusVisible, AllyBuildRadiusDisplayOrder, AllyBuildRadiusEnabled, AllyBuildRadiusLocked);
|
||||
yield return new LobbyBooleanOption("allybuild", AllyBuildRadiusCheckboxLabel, AllyBuildRadiusCheckboxDescription,
|
||||
AllyBuildRadiusCheckboxVisible, AllyBuildRadiusCheckboxDisplayOrder, AllyBuildRadiusCheckboxEnabled, AllyBuildRadiusCheckboxLocked);
|
||||
|
||||
yield return new LobbyBooleanOption("buildradius", BuildRadiusLabel, BuildRadiusDescription,
|
||||
BuildRadiusVisible, BuildRadiusDisplayOrder, BuildRadiusEnabled, BuildRadiusLocked);
|
||||
yield return new LobbyBooleanOption("buildradius", BuildRadiusCheckboxLabel, BuildRadiusCheckboxDescription,
|
||||
BuildRadiusCheckboxVisible, BuildRadiusCheckboxDisplayOrder, BuildRadiusCheckboxEnabled, BuildRadiusCheckboxLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new MapBuildRadius(this); }
|
||||
@@ -83,9 +83,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
|
||||
.OptionOrDefault("allybuild", info.AllyBuildRadiusCheckboxEnabled);
|
||||
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("buildradius", info.BuildRadiusEnabled);
|
||||
.OptionOrDefault("buildradius", info.BuildRadiusCheckboxEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the creeps checkbox in the lobby.")]
|
||||
public readonly string Label = "Creep Actors";
|
||||
public readonly string CheckboxLabel = "Creep Actors";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the creeps checkbox in the lobby.")]
|
||||
public readonly string Description = "Hostile forces spawn on the battlefield";
|
||||
public readonly string CheckboxDescription = "Hostile forces spawn on the battlefield";
|
||||
|
||||
[Desc("Default value of the creeps checkbox in the lobby.")]
|
||||
public readonly bool Enabled = true;
|
||||
public readonly bool CheckboxEnabled = true;
|
||||
|
||||
[Desc("Prevent the creeps state from being changed in the lobby.")]
|
||||
public readonly bool Locked = false;
|
||||
public readonly bool CheckboxLocked = false;
|
||||
|
||||
[Desc("Whether to display the creeps checkbox in the lobby.")]
|
||||
public readonly bool Visible = true;
|
||||
public readonly bool CheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the creeps checkbox in the lobby.")]
|
||||
public readonly int DisplayOrder = 0;
|
||||
public readonly int CheckboxDisplayOrder = 0;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("creeps", Label, Description, Visible, DisplayOrder, Enabled, Locked);
|
||||
yield return new LobbyBooleanOption("creeps", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new MapCreeps(this); }
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
Enabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("creeps", info.Enabled);
|
||||
.OptionOrDefault("creeps", info.CheckboxEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,82 +20,82 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the short game checkbox in the lobby.")]
|
||||
public readonly string ShortGameLabel = "Short Game";
|
||||
public readonly string ShortGameCheckboxLabel = "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";
|
||||
public readonly string ShortGameCheckboxDescription = "Players are defeated when their bases are destroyed";
|
||||
|
||||
[Desc("Default value of the short game checkbox in the lobby.")]
|
||||
public readonly bool ShortGameEnabled = true;
|
||||
public readonly bool ShortGameCheckboxEnabled = true;
|
||||
|
||||
[Desc("Prevent the short game enabled state from being changed in the lobby.")]
|
||||
public readonly bool ShortGameLocked = false;
|
||||
public readonly bool ShortGameCheckboxLocked = false;
|
||||
|
||||
[Desc("Whether to display the short game checkbox in the lobby.")]
|
||||
public readonly bool ShortGameVisible = true;
|
||||
public readonly bool ShortGameCheckboxVisible = true;
|
||||
|
||||
[Desc("Display order for the short game checkbox in the lobby.")]
|
||||
public readonly int ShortGameDisplayOrder = 0;
|
||||
public readonly int ShortGameCheckboxDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the tech level option in the lobby.")]
|
||||
public readonly string TechLevelLabel = "Tech Level";
|
||||
public readonly string TechLevelDropdownLabel = "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";
|
||||
public readonly string TechLevelDropdownDescription = "Change the units and abilities at your disposal";
|
||||
|
||||
[Desc("Default tech level.")]
|
||||
public readonly string TechLevel = "unrestricted";
|
||||
|
||||
[Desc("Prevent the tech level from being changed in the lobby.")]
|
||||
public readonly bool TechLevelLocked = false;
|
||||
public readonly bool TechLevelDropdownLocked = false;
|
||||
|
||||
[Desc("Display the tech level option in the lobby.")]
|
||||
public readonly bool TechLevelVisible = true;
|
||||
public readonly bool TechLevelDropdownVisible = true;
|
||||
|
||||
[Desc("Display order for the tech level option in the lobby.")]
|
||||
public readonly int TechLevelDisplayOrder = 0;
|
||||
public readonly int TechLevelDropdownDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the game speed option in the lobby.")]
|
||||
public readonly string GameSpeedLabel = "Game Speed";
|
||||
public readonly string GameSpeedDropdownLabel = "Game Speed";
|
||||
|
||||
[Translate]
|
||||
[Desc("Description of the game speed option in the lobby.")]
|
||||
public readonly string GameSpeedDescription = "Change the rate at which time passes";
|
||||
public readonly string GameSpeedDropdownDescription = "Change the rate at which time passes";
|
||||
|
||||
[Desc("Default game speed.")]
|
||||
public readonly string GameSpeed = "default";
|
||||
|
||||
[Desc("Prevent the game speed from being changed in the lobby.")]
|
||||
public readonly bool GameSpeedLocked = false;
|
||||
public readonly bool GameSpeedDropdownLocked = false;
|
||||
|
||||
[Desc("Display the game speed option in the lobby.")]
|
||||
public readonly bool GameSpeedVisible = true;
|
||||
public readonly bool GameSpeedDropdownVisible = true;
|
||||
|
||||
[Desc("Display order for the game speed option in the lobby.")]
|
||||
public readonly int GameSpeedDisplayOrder = 0;
|
||||
public readonly int GameSpeedDropdownDisplayOrder = 0;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("shortgame", ShortGameLabel, ShortGameDescription,
|
||||
ShortGameVisible, ShortGameDisplayOrder, ShortGameEnabled, ShortGameLocked);
|
||||
yield return new LobbyBooleanOption("shortgame", ShortGameCheckboxLabel, ShortGameCheckboxDescription,
|
||||
ShortGameCheckboxVisible, ShortGameCheckboxDisplayOrder, ShortGameCheckboxEnabled, ShortGameCheckboxLocked);
|
||||
|
||||
var techLevels = rules.Actors["player"].TraitInfos<ProvidesTechPrerequisiteInfo>()
|
||||
.ToDictionary(t => t.Id, t => t.Name);
|
||||
|
||||
if (techLevels.Any())
|
||||
yield return new LobbyOption("techlevel", TechLevelLabel, TechLevelDescription, TechLevelVisible, TechLevelDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(techLevels), TechLevel, TechLevelLocked);
|
||||
yield return new LobbyOption("techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(techLevels), TechLevel, TechLevelDropdownLocked);
|
||||
|
||||
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().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", GameSpeedLabel, GameSpeedDescription, GameSpeedVisible, GameSpeedDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(gameSpeeds), GameSpeed, GameSpeedLocked);
|
||||
yield return new LobbyOption("gamespeed", GameSpeedDropdownLabel, GameSpeedDropdownDescription, GameSpeedDropdownVisible, GameSpeedDropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(gameSpeeds), GameSpeed, GameSpeedDropdownLocked);
|
||||
}
|
||||
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
ShortGame = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("shortgame", info.ShortGameEnabled);
|
||||
.OptionOrDefault("shortgame", info.ShortGameCheckboxEnabled);
|
||||
|
||||
TechLevel = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("techlevel", info.TechLevel);
|
||||
|
||||
@@ -25,20 +25,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the starting units option in the lobby.")]
|
||||
public readonly string Label = "Starting Units";
|
||||
public readonly string DropdownLabel = "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";
|
||||
public readonly string DropdownDescription = "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;
|
||||
public readonly bool DropdownLocked = false;
|
||||
|
||||
[Desc("Whether to display the starting units option in the lobby.")]
|
||||
public readonly bool Visible = true;
|
||||
public readonly bool DropdownVisible = true;
|
||||
|
||||
[Desc("Display order for the starting units option in the lobby.")]
|
||||
public readonly int DisplayOrder = 0;
|
||||
public readonly int DropdownDisplayOrder = 0;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
@@ -49,8 +49,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
startingUnits[t.Class] = t.ClassName;
|
||||
|
||||
if (startingUnits.Any())
|
||||
yield return new LobbyOption("startingunits", Label, Description, Visible, DisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(startingUnits), StartingUnitsClass, Locked);
|
||||
yield return new LobbyOption("startingunits", DropdownLabel, DropdownDescription, DropdownVisible, DropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(startingUnits), StartingUnitsClass, DropdownLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new SpawnMPUnits(this); }
|
||||
|
||||
Reference in New Issue
Block a user