Extract unit names and descriptions
This commit is contained in:
committed by
Matthias Mailänder
parent
a5e472dfe6
commit
0f5b78442b
@@ -111,13 +111,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var tooltip = a.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(ti => ti.EnabledByDefault) as TooltipInfoBase
|
||||
?? a.TraitInfos<TooltipInfo>().FirstOrDefault(ti => ti.EnabledByDefault);
|
||||
|
||||
var actorType = TranslationProvider.GetString(ActorTypeTooltip, Translation.Arguments("actorType", a.Name));
|
||||
|
||||
var searchTerms = new List<string>() { a.Name };
|
||||
if (tooltip != null)
|
||||
searchTerms.Add(tooltip.Name);
|
||||
|
||||
var actorType = TranslationProvider.GetString(ActorTypeTooltip, Translation.Arguments("actorType", a.Name));
|
||||
var tooltipText = tooltip == null ? actorType : tooltip.Name + $"\n{actorType}";
|
||||
allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), tooltipText));
|
||||
{
|
||||
var actorName = TranslationProvider.GetString(tooltip.Name);
|
||||
searchTerms.Add(actorName);
|
||||
allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), actorName + $"\n{actorType}"));
|
||||
}
|
||||
else
|
||||
allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), actorType));
|
||||
}
|
||||
|
||||
allActors = allActorsTemp.ToArray();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var label = item.Get<LabelWithTooltipWidget>("TITLE");
|
||||
var name = actor.TraitInfoOrDefault<TooltipInfo>()?.Name;
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
WidgetUtils.TruncateLabelToTooltip(label, name);
|
||||
WidgetUtils.TruncateLabelToTooltip(label, TranslationProvider.GetString(name));
|
||||
|
||||
if (firstItem == null)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var info = actor.TraitInfoOrDefault<EncyclopediaInfo>();
|
||||
if (info != null && !string.IsNullOrEmpty(info.Description))
|
||||
text += WidgetUtils.WrapText(info.Description.Replace("\\n", "\n") + "\n\n", descriptionLabel.Bounds.Width, descriptionFont);
|
||||
text += WidgetUtils.WrapText(TranslationProvider.GetString(info.Description) + "\n\n", descriptionLabel.Bounds.Width, descriptionFont);
|
||||
|
||||
var height = descriptionFont.Measure(text).Y;
|
||||
descriptionLabel.Text = text;
|
||||
@@ -175,7 +175,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var actorTooltip = actor.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||
if (actorTooltip != null)
|
||||
return actorTooltip.Name;
|
||||
return TranslationProvider.GetString(actorTooltip.Name);
|
||||
}
|
||||
|
||||
return name;
|
||||
|
||||
@@ -38,15 +38,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return;
|
||||
|
||||
var tooltip = armyUnit.TooltipInfo;
|
||||
var name = tooltip?.Name ?? armyUnit.ActorInfo.Name;
|
||||
var name = tooltip != null ? TranslationProvider.GetString(tooltip.Name) : armyUnit.ActorInfo.Name;
|
||||
var buildable = armyUnit.BuildableInfo;
|
||||
|
||||
nameLabel.Text = name;
|
||||
|
||||
var nameSize = font.Measure(name);
|
||||
|
||||
descLabel.Text = buildable.Description.Replace("\\n", "\n");
|
||||
var descSize = descFont.Measure(descLabel.Text);
|
||||
var desc = string.IsNullOrEmpty(buildable.Description) ? "" : TranslationProvider.GetString(buildable.Description);
|
||||
descLabel.Text = desc;
|
||||
var descSize = descFont.Measure(desc);
|
||||
descLabel.Bounds.Width = descSize.X;
|
||||
descLabel.Bounds.Height = descSize.Y + descLabelPadding;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return;
|
||||
|
||||
var tooltip = actor.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||
var name = tooltip?.Name ?? actor.Name;
|
||||
var name = tooltip != null ? TranslationProvider.GetString(tooltip.Name) : actor.Name;
|
||||
var buildable = actor.TraitInfo<BuildableInfo>();
|
||||
|
||||
var cost = 0;
|
||||
@@ -137,8 +137,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
costLabel.GetColor = () => pr.GetCashAndResources() >= cost ? Color.White : Color.Red;
|
||||
var costSize = font.Measure(costLabel.Text);
|
||||
|
||||
descLabel.Text = buildable.Description.Replace("\\n", "\n");
|
||||
var descSize = descFont.Measure(descLabel.Text);
|
||||
var desc = string.IsNullOrEmpty(buildable.Description) ? "" : TranslationProvider.GetString(buildable.Description);
|
||||
descLabel.Text = desc;
|
||||
var descSize = descFont.Measure(desc);
|
||||
descLabel.Bounds.Width = descSize.X;
|
||||
descLabel.Bounds.Height = descSize.Y + descLabelPadding;
|
||||
|
||||
@@ -170,7 +171,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var actorTooltip = ai.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||
if (actorTooltip != null)
|
||||
return actorTooltip.Name;
|
||||
return TranslationProvider.GetString(actorTooltip.Name);
|
||||
}
|
||||
|
||||
return a;
|
||||
|
||||
Reference in New Issue
Block a user