Extract translation strings.
This commit is contained in:
committed by
teinarss
parent
8201a57b10
commit
cc58fe1a0f
@@ -25,6 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
enum ActorIDStatus { Normal = 0, Duplicate = 1, Empty = 3 }
|
||||
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly ModData modData;
|
||||
readonly EditorActorLayer editorActorLayer;
|
||||
readonly EditorActionManager editorActionManager;
|
||||
readonly EditorViewportControllerWidget editor;
|
||||
@@ -42,6 +43,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly int editPanelPadding; // Padding between right edge of actor and the edit panel.
|
||||
readonly long scrollVisibleTimeout = 100; // Delay after scrolling map before edit widget becomes visible again.
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string DuplicateActorId = "duplicate-actor-id";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string EnterActorId = "enter-actor-id";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Owner = "owner";
|
||||
|
||||
long lastScrollTime = 0;
|
||||
int2 lastScrollPosition = int2.Zero;
|
||||
|
||||
@@ -74,9 +85,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ActorEditLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
||||
public ActorEditLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.worldRenderer = worldRenderer;
|
||||
|
||||
editorActorLayer = world.WorldActor.Trait<EditorActorLayer>();
|
||||
editorActionManager = world.WorldActor.Trait<EditorActionManager>();
|
||||
|
||||
@@ -101,7 +114,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
actorIDErrorLabel = actorEditPanel.Get<LabelWidget>("ACTOR_ID_ERROR_LABEL");
|
||||
actorIDErrorLabel.IsVisible = () => actorIDStatus != ActorIDStatus.Normal;
|
||||
actorIDErrorLabel.GetText = () => actorIDStatus == ActorIDStatus.Duplicate ?
|
||||
"Duplicate Actor ID" : "Enter an Actor ID";
|
||||
modData.Translation.GetString(DuplicateActorId)
|
||||
: modData.Translation.GetString(EnterActorId);
|
||||
|
||||
if (logicArgs.TryGetValue("EditPanelPadding", out var yaml))
|
||||
editPanelPadding = FieldLoader.GetValue<int>("EditPanelPadding", yaml.Value);
|
||||
@@ -131,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (editorActorLayer[actorId] != null)
|
||||
{
|
||||
nextActorIDStatus = ActorIDStatus.Duplicate;
|
||||
actorIDErrorLabel.Text = "Duplicate ActorID";
|
||||
actorIDErrorLabel.Text = modData.Translation.GetString(DuplicateActorId);
|
||||
actorIDErrorLabel.Visible = true;
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +229,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// Add owner dropdown
|
||||
var ownerContainer = dropdownOptionTemplate.Clone();
|
||||
ownerContainer.Get<LabelWidget>("LABEL").GetText = () => "Owner";
|
||||
var owner = modData.Translation.GetString(Owner);
|
||||
ownerContainer.Get<LabelWidget>("LABEL").GetText = () => owner;
|
||||
var ownerDropdown = ownerContainer.Get<DropDownButtonWidget>("OPTION");
|
||||
var selectedOwner = actor.Owner;
|
||||
|
||||
|
||||
@@ -42,11 +42,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly ActorSelectorActor[] allActors;
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Type = "type";
|
||||
|
||||
PlayerReference selectedOwner;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ActorSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, world, worldRenderer, "ACTORTEMPLATE_LIST", "ACTORPREVIEW_TEMPLATE")
|
||||
public ActorSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, modData, world, worldRenderer, "ACTORTEMPLATE_LIST", "ACTORPREVIEW_TEMPLATE")
|
||||
{
|
||||
mapRules = world.Map.Rules;
|
||||
ownersDropDown = widget.Get<DropDownButtonWidget>("OWNERS_DROPDOWN");
|
||||
@@ -112,7 +115,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (tooltip != null)
|
||||
searchTerms.Add(tooltip.Name);
|
||||
|
||||
var tooltipText = (tooltip == null ? "Type: " : tooltip.Name + "\nType: ") + a.Name;
|
||||
var type = modData.Translation.GetString(Type);
|
||||
var tooltipText = (tooltip == null ? $"{type}: " : tooltip.Name + $"\n{type}: ") + a.Name;
|
||||
allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), tooltipText));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public abstract class CommonSelectorLogic : ChromeLogic
|
||||
{
|
||||
protected readonly Widget Widget;
|
||||
protected readonly ModData ModData;
|
||||
protected readonly TextFieldWidget SearchTextField;
|
||||
protected readonly World World;
|
||||
protected readonly WorldRenderer WorldRenderer;
|
||||
@@ -33,9 +34,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
protected string[] allCategories;
|
||||
protected string searchFilter;
|
||||
|
||||
public CommonSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer, string templateListId, string previewTemplateId)
|
||||
[TranslationReference]
|
||||
static readonly string None = "none";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string SearchResults = "search-results";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string All = "all";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Multiple = "multiple";
|
||||
|
||||
public CommonSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer, string templateListId, string previewTemplateId)
|
||||
{
|
||||
Widget = widget;
|
||||
ModData = modData;
|
||||
World = world;
|
||||
WorldRenderer = worldRenderer;
|
||||
Editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||
@@ -61,18 +75,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
categorySelector.GetText = () =>
|
||||
{
|
||||
if (SelectedCategories.Count == 0)
|
||||
return "None";
|
||||
return ModData.Translation.GetString(None);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchFilter))
|
||||
return "Search Results";
|
||||
return ModData.Translation.GetString(SearchResults);
|
||||
|
||||
if (SelectedCategories.Count == 1)
|
||||
return SelectedCategories.First();
|
||||
|
||||
if (SelectedCategories.Count == allCategories.Length)
|
||||
return "All";
|
||||
return ModData.Translation.GetString(All);
|
||||
|
||||
return "Multiple";
|
||||
return ModData.Translation.GetString(Multiple);
|
||||
};
|
||||
|
||||
categorySelector.OnMouseDown = _ =>
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public TileSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, world, worldRenderer, "TILETEMPLATE_LIST", "TILEPREVIEW_TEMPLATE")
|
||||
public TileSelectorLogic(Widget widget, ModData modData, World world, WorldRenderer worldRenderer)
|
||||
: base(widget, modData, world, worldRenderer, "TILETEMPLATE_LIST", "TILEPREVIEW_TEMPLATE")
|
||||
{
|
||||
terrainInfo = world.Map.Rules.TerrainInfo as ITemplatedTerrainInfo;
|
||||
if (terrainInfo == null)
|
||||
|
||||
Reference in New Issue
Block a user