Fix map level lobby options not being translated
This commit is contained in:
committed by
Matthias Mailänder
parent
efe135e38b
commit
a065e6a47c
@@ -199,6 +199,15 @@ namespace OpenRA
|
||||
public long DownloadBytes { get; private set; }
|
||||
public int DownloadPercentage { get; private set; }
|
||||
|
||||
public string GetLocalisedString(string key, IDictionary<string, object> args = null)
|
||||
{
|
||||
// PERF: instead of loading mod level Translation for each MapPreview, reuse the already loaded one in modData.
|
||||
if (modData.Translation.TryGetString(key, out var message, args))
|
||||
return message;
|
||||
|
||||
return innerData.Translation?.GetString(key, args) ?? key;
|
||||
}
|
||||
|
||||
Sprite minimap;
|
||||
bool generatingMinimap;
|
||||
public Sprite GetMinimap()
|
||||
|
||||
@@ -60,11 +60,9 @@ namespace OpenRA.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("explored", Game.ModData.Translation.GetString(ExploredMapCheckboxLabel),
|
||||
Game.ModData.Translation.GetString(ExploredMapCheckboxDescription),
|
||||
yield return new LobbyBooleanOption(map, "explored", ExploredMapCheckboxLabel, ExploredMapCheckboxDescription,
|
||||
ExploredMapCheckboxVisible, ExploredMapCheckboxDisplayOrder, ExploredMapCheckboxEnabled, ExploredMapCheckboxLocked);
|
||||
yield return new LobbyBooleanOption("fog", Game.ModData.Translation.GetString(FogCheckboxLabel),
|
||||
Game.ModData.Translation.GetString(FogCheckboxDescription),
|
||||
yield return new LobbyBooleanOption(map, "fog", FogCheckboxLabel, FogCheckboxDescription,
|
||||
FogCheckboxVisible, FogCheckboxDisplayOrder, FogCheckboxEnabled, FogCheckboxLocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -543,12 +543,12 @@ namespace OpenRA.Traits
|
||||
public readonly bool IsVisible;
|
||||
public readonly int DisplayOrder;
|
||||
|
||||
public LobbyOption(string id, string name, string description, bool visible, int displayorder,
|
||||
public LobbyOption(MapPreview map, string id, string name, string description, bool visible, int displayorder,
|
||||
IReadOnlyDictionary<string, string> values, string defaultValue, bool locked)
|
||||
{
|
||||
Id = id;
|
||||
Name = Game.ModData.Translation.GetString(name);
|
||||
Description = Game.ModData.Translation.GetString(description);
|
||||
Name = map.GetLocalisedString(name);
|
||||
Description = map.GetLocalisedString(description);
|
||||
IsVisible = visible;
|
||||
DisplayOrder = displayorder;
|
||||
Values = values;
|
||||
@@ -570,8 +570,8 @@ namespace OpenRA.Traits
|
||||
{ false.ToString(), "Disabled" }
|
||||
};
|
||||
|
||||
public LobbyBooleanOption(string id, string name, string description, bool visible, int displayorder, bool defaultValue, bool locked)
|
||||
: base(id, name, description, visible, displayorder, new ReadOnlyDictionary<string, string>(BoolValues), defaultValue.ToString(), locked) { }
|
||||
public LobbyBooleanOption(MapPreview map, string id, string name, string description, bool visible, int displayorder, bool defaultValue, bool locked)
|
||||
: base(map, id, name, description, visible, displayorder, new ReadOnlyDictionary<string, string>(BoolValues), defaultValue.ToString(), locked) { }
|
||||
|
||||
public override string Label(string newValue)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("cheats", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
yield return new LobbyBooleanOption(map, "cheats", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new DeveloperMode(this); }
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption(ID, Label, Description,
|
||||
yield return new LobbyBooleanOption(map, ID, Label, Description,
|
||||
Visible, DisplayOrder, Enabled, Locked);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString());
|
||||
|
||||
if (startingCash.Count > 0)
|
||||
yield return new LobbyOption("startingcash", DefaultCashDropdownLabel, DefaultCashDropdownDescription, DefaultCashDropdownVisible, DefaultCashDropdownDisplayOrder,
|
||||
yield return new LobbyOption(map, "startingcash", DefaultCashDropdownLabel, DefaultCashDropdownDescription, DefaultCashDropdownVisible, DefaultCashDropdownDisplayOrder,
|
||||
startingCash, DefaultCash.ToString(), DefaultCashDropdownLocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("crates", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
yield return new LobbyBooleanOption(map, "crates", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CrateSpawner(init.Self, this); }
|
||||
|
||||
@@ -60,10 +60,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("allybuild", AllyBuildRadiusCheckboxLabel, AllyBuildRadiusCheckboxDescription,
|
||||
yield return new LobbyBooleanOption(map, "allybuild", AllyBuildRadiusCheckboxLabel, AllyBuildRadiusCheckboxDescription,
|
||||
AllyBuildRadiusCheckboxVisible, AllyBuildRadiusCheckboxDisplayOrder, AllyBuildRadiusCheckboxEnabled, AllyBuildRadiusCheckboxLocked);
|
||||
|
||||
yield return new LobbyBooleanOption("buildradius", BuildRadiusCheckboxLabel, BuildRadiusCheckboxDescription,
|
||||
yield return new LobbyBooleanOption(map, "buildradius", BuildRadiusCheckboxLabel, BuildRadiusCheckboxDescription,
|
||||
BuildRadiusCheckboxVisible, BuildRadiusCheckboxDisplayOrder, BuildRadiusCheckboxEnabled, BuildRadiusCheckboxLocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("creeps", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
yield return new LobbyBooleanOption(map, "creeps", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new MapCreeps(this); }
|
||||
|
||||
@@ -81,22 +81,24 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption("shortgame", ShortGameCheckboxLabel, ShortGameCheckboxDescription,
|
||||
yield return new LobbyBooleanOption(map, "shortgame", ShortGameCheckboxLabel, ShortGameCheckboxDescription,
|
||||
ShortGameCheckboxVisible, ShortGameCheckboxDisplayOrder, ShortGameCheckboxEnabled, ShortGameCheckboxLocked);
|
||||
|
||||
var techLevels = map.PlayerActorInfo.TraitInfos<ProvidesTechPrerequisiteInfo>()
|
||||
.ToDictionary(t => t.Id, t => Game.ModData.Translation.GetString(t.Name));
|
||||
.ToDictionary(t => t.Id, t => map.GetLocalisedString(t.Name));
|
||||
|
||||
if (techLevels.Count > 0)
|
||||
yield return new LobbyOption("techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
yield return new LobbyOption(map, "techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
techLevels, TechLevel, TechLevelDropdownLocked);
|
||||
|
||||
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>();
|
||||
var speeds = gameSpeeds.Speeds.ToDictionary(s => s.Key, s => Game.ModData.Translation.GetString(s.Value.Name));
|
||||
|
||||
// NOTE: This is just exposing the UI, the backend logic for this option is hardcoded in World
|
||||
yield return new LobbyOption("gamespeed", GameSpeedDropdownLabel, GameSpeedDropdownDescription, GameSpeedDropdownVisible, GameSpeedDropdownDisplayOrder,
|
||||
speeds, GameSpeed ?? gameSpeeds.DefaultSpeed, GameSpeedDropdownLocked);
|
||||
// NOTE: This is just exposing the UI, the backend logic for this option is hardcoded in World.
|
||||
yield return new LobbyOption(map, "gamespeed",
|
||||
GameSpeedDropdownLabel, GameSpeedDropdownDescription,
|
||||
GameSpeedDropdownVisible, GameSpeedDropdownDisplayOrder, speeds,
|
||||
GameSpeed ?? gameSpeeds.DefaultSpeed, GameSpeedDropdownLocked);
|
||||
}
|
||||
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyBooleanOption(
|
||||
map,
|
||||
"separateteamspawns",
|
||||
SeparateTeamSpawnsCheckboxLabel,
|
||||
SeparateTeamSpawnsCheckboxDescription,
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
|
||||
{
|
||||
yield return new LobbyOption(ID, Label, Description, Visible, DisplayOrder,
|
||||
yield return new LobbyOption(map, ID, Label, Description, Visible, DisplayOrder,
|
||||
Values, Default, Locked);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Duplicate classes are defined for different race variants
|
||||
foreach (var t in map.WorldActorInfo.TraitInfos<StartingUnitsInfo>())
|
||||
startingUnits[t.Class] = Game.ModData.Translation.GetString(t.ClassName);
|
||||
startingUnits[t.Class] = map.GetLocalisedString(t.ClassName);
|
||||
|
||||
if (startingUnits.Count > 0)
|
||||
yield return new LobbyOption("startingunits", DropdownLabel, DropdownDescription, DropdownVisible, DropdownDisplayOrder,
|
||||
yield return new LobbyOption(map, "startingunits", DropdownLabel, DropdownDescription, DropdownVisible, DropdownDisplayOrder,
|
||||
startingUnits, StartingUnitsClass, DropdownLocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return Game.ModData.Translation.GetString(TimeLimitOption, Translation.Arguments("minutes", m));
|
||||
});
|
||||
|
||||
yield return new LobbyOption("timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,
|
||||
yield return new LobbyOption(map, "timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,
|
||||
timelimits, TimeLimitDefault.ToString(), TimeLimitLocked);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user