Localize the faction dropdown.
This commit is contained in:
committed by
Gustas
parent
59f6a6a2c2
commit
5ddc7b1177
@@ -255,7 +255,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined)
|
||||
{
|
||||
flag.GetImageName = () => pp.Faction.InternalName;
|
||||
factionName = pp.Faction.Name != factionName ? $"{factionName} ({pp.Faction.Name})" : pp.Faction.Name;
|
||||
factionName = pp.Faction.Name != factionName
|
||||
? $"{TranslationProvider.GetString(factionName)} ({TranslationProvider.GetString(pp.Faction.Name)})"
|
||||
: TranslationProvider.GetString(pp.Faction.Name);
|
||||
}
|
||||
else
|
||||
flag.GetImageName = () => pp.DisplayFaction.InternalName;
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
colorManager = modRules.Actors[SystemActors.World].TraitInfo<IColorPickerManagerInfo>();
|
||||
|
||||
foreach (var f in modRules.Actors[SystemActors.World].TraitInfos<FactionInfo>())
|
||||
factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description?.Replace(@"\n", "\n") });
|
||||
factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
|
||||
|
||||
var gameStarting = false;
|
||||
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting ||
|
||||
|
||||
@@ -222,14 +222,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var faction = factions[factionId];
|
||||
|
||||
var label = item.Get<LabelWidget>("LABEL");
|
||||
var labelText = WidgetUtils.TruncateText(faction.Name, label.Bounds.Width, Game.Renderer.Fonts[label.Font]);
|
||||
var labelText = WidgetUtils.TruncateText(TranslationProvider.GetString(faction.Name), label.Bounds.Width, Game.Renderer.Fonts[label.Font]);
|
||||
label.GetText = () => labelText;
|
||||
|
||||
var flag = item.Get<ImageWidget>("FLAG");
|
||||
flag.GetImageCollection = () => "flags";
|
||||
flag.GetImageName = () => factionId;
|
||||
|
||||
var (text, desc) = SplitOnFirstToken(faction.Description);
|
||||
var description = faction.Description != null ? TranslationProvider.GetString(faction.Description) : null;
|
||||
var (text, desc) = SplitOnFirstToken(description);
|
||||
item.GetTooltipText = () => text;
|
||||
item.GetTooltipDesc = () => desc;
|
||||
|
||||
@@ -237,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side)
|
||||
.ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key));
|
||||
.ToDictionary(g => g.Key != null ? TranslationProvider.GetString(g.Key) : "", g => g.Select(f => TranslationProvider.GetString(f.Key)));
|
||||
|
||||
dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, SetupItem);
|
||||
}
|
||||
@@ -551,7 +552,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dropdown.IsDisabled = () => s.LockFaction || orderManager.LocalClient.IsReady;
|
||||
dropdown.OnMouseDown = _ => ShowFactionDropDown(dropdown, c, orderManager, factions);
|
||||
|
||||
var (text, desc) = SplitOnFirstToken(factions[c.Faction].Description);
|
||||
var description = factions[c.Faction].Description != null ? TranslationProvider.GetString(factions[c.Faction].Description) : null;
|
||||
var (text, desc) = SplitOnFirstToken(description);
|
||||
dropdown.GetTooltipText = () => text;
|
||||
dropdown.GetTooltipDesc = () => desc;
|
||||
|
||||
@@ -563,7 +565,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var factionName = parent.Get<LabelWidget>("FACTIONNAME");
|
||||
var font = Game.Renderer.Fonts[factionName.Font];
|
||||
var truncated = new CachedTransform<string, string>(clientFaction =>
|
||||
WidgetUtils.TruncateText(factions[clientFaction].Name, factionName.Bounds.Width, font));
|
||||
WidgetUtils.TruncateText(TranslationProvider.GetString(factions[clientFaction].Name), factionName.Bounds.Width, font));
|
||||
factionName.GetText = () => truncated.Update(c.Faction);
|
||||
|
||||
var factionFlag = parent.Get<ImageWidget>("FACTIONFLAG");
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
options.Insert(0, null); // no filter
|
||||
|
||||
var anyText = ddb.GetText();
|
||||
ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : filter.Faction;
|
||||
ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : TranslationProvider.GetString(filter.Faction);
|
||||
ddb.OnMouseDown = _ =>
|
||||
{
|
||||
ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl)
|
||||
@@ -452,7 +452,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
tpl,
|
||||
() => string.Equals(filter.Faction, option, StringComparison.CurrentCultureIgnoreCase),
|
||||
() => { filter.Faction = option; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option ?? anyText;
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option != null ? TranslationProvider.GetString(option) : anyText;
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user