Extract editor brush texts.

This commit is contained in:
Matthias Mailänder
2023-05-20 19:55:17 +02:00
committed by abcdefg30
parent 8433bc0948
commit c9dddc342c
8 changed files with 69 additions and 11 deletions

View File

@@ -81,6 +81,9 @@ namespace OpenRA.Mods.Common.Widgets
{
public string Text { get; private set; }
[TranslationReference("name", "id")]
const string AddedActor = "notification-added-actor";
readonly EditorActorLayer editorLayer;
readonly ActorReference actor;
@@ -102,7 +105,8 @@ namespace OpenRA.Mods.Common.Widgets
public void Do()
{
editorActorPreview = editorLayer.Add(actor);
Text = $"Added {editorActorPreview.Info.Name} ({editorActorPreview.ID})";
Text = TranslationProvider.GetString(AddedActor,
Translation.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID));
}
public void Undo()

View File

@@ -176,6 +176,9 @@ namespace OpenRA.Mods.Common.Widgets
class CopyPasteEditorAction : IEditorAction
{
[TranslationReference("amount")]
const string CopiedTiles = "notification-copied-tiles";
public string Text { get; }
readonly MapCopyFilters copyFilters;
@@ -205,7 +208,7 @@ namespace OpenRA.Mods.Common.Widgets
mapHeight = map.Height;
mapResources = map.Resources;
Text = $"Copied {tiles.Count} tiles";
Text = TranslationProvider.GetString(CopiedTiles, Translation.Arguments("amount", tiles.Count));
}
public void Execute()

View File

@@ -110,6 +110,9 @@ namespace OpenRA.Mods.Common.Widgets
class RemoveActorAction : IEditorAction
{
[TranslationReference("name", "id")]
const string RemovedActor = "notification-removed-actor";
public string Text { get; }
readonly EditorActorLayer editorActorLayer;
@@ -120,7 +123,8 @@ namespace OpenRA.Mods.Common.Widgets
this.editorActorLayer = editorActorLayer;
this.actor = actor;
Text = $"Removed {actor.Info.Name} ({actor.ID})";
Text = TranslationProvider.GetString(RemovedActor,
Translation.Arguments("name", actor.Info.Name, "id", actor.ID));
}
public void Execute()
@@ -141,6 +145,9 @@ namespace OpenRA.Mods.Common.Widgets
class RemoveResourceAction : IEditorAction
{
[TranslationReference("type")]
const string RemovedResource = "notification-removed-resource";
public string Text { get; }
readonly IResourceLayer resourceLayer;
@@ -153,7 +160,7 @@ namespace OpenRA.Mods.Common.Widgets
this.resourceLayer = resourceLayer;
this.cell = cell;
Text = $"Removed {resourceType}";
Text = TranslationProvider.GetString(RemovedResource, Translation.Arguments("type", resourceType));
}
public void Execute()

View File

@@ -105,6 +105,9 @@ namespace OpenRA.Mods.Common.Widgets
class AddResourcesEditorAction : IEditorAction
{
[TranslationReference("amount", "type")]
const string AddedResource = "notification-added-resource";
public string Text { get; private set; }
readonly IResourceLayer resourceLayer;
@@ -145,9 +148,7 @@ namespace OpenRA.Mods.Common.Widgets
resourceLayer.ClearResources(resourceCell.Cell);
resourceLayer.AddResource(resourceCell.NewResourceType, resourceCell.Cell, resourceLayer.GetMaxDensity(resourceCell.NewResourceType));
cellResources.Add(resourceCell);
var cellText = cellResources.Count != 1 ? "cells" : "cell";
Text = $"Added {cellResources.Count} {cellText} of {resourceType}";
Text = TranslationProvider.GetString(AddedResource, Translation.Arguments("amount", cellResources.Count, "type", resourceType));
}
}
}

View File

@@ -155,6 +155,9 @@ namespace OpenRA.Mods.Common.Widgets
class PaintTileEditorAction : IEditorAction
{
[TranslationReference("id")]
const string AddedTile = "notification-added-tile";
public string Text { get; }
readonly ushort template;
@@ -172,7 +175,7 @@ namespace OpenRA.Mods.Common.Widgets
var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo;
terrainTemplate = terrainInfo.Templates[template];
Text = $"Added tile {terrainTemplate.Id}";
Text = TranslationProvider.GetString(AddedTile, Translation.Arguments("id", terrainTemplate.Id));
}
public void Execute()
@@ -224,6 +227,9 @@ namespace OpenRA.Mods.Common.Widgets
class FloodFillEditorAction : IEditorAction
{
[TranslationReference("id")]
const string FilledTile = "notification-filled-tile";
public string Text { get; }
readonly ushort template;
@@ -241,7 +247,7 @@ namespace OpenRA.Mods.Common.Widgets
var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo;
terrainTemplate = terrainInfo.Templates[template];
Text = $"Filled with tile {terrainTemplate.Id}";
Text = TranslationProvider.GetString(FilledTile, Translation.Arguments("id", terrainTemplate.Id));
}
public void Execute()

View File

@@ -146,9 +146,12 @@ namespace OpenRA.Mods.Common.Traits
class OpenMapAction : IEditorAction
{
[TranslationReference]
const string Opened = "notification-opened";
public OpenMapAction()
{
Text = "Opened";
Text = TranslationProvider.GetString(Opened);
}
public void Execute()

View File

@@ -463,6 +463,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
class EditActorEditorAction : IEditorAction
{
[TranslationReference("name", "id")]
const string EditedActor = "notification-edited-actor";
public string Text { get; }
readonly IEnumerable<IEditActorHandle> handles;
@@ -476,7 +479,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
actorId = actor.ID;
this.actor = actor;
this.handles = handles;
Text = $"Edited {actor.Info.Name} ({actor.ID})";
Text = TranslationProvider.GetString(EditedActor, Translation.Arguments("name", actor.Info.Name, "id", actor.ID));
}
public void Execute()

View File

@@ -717,3 +717,34 @@ options-time-limit =
}
notification-time-limit-expired = Time limit has expired.
## EditorActorBrush
notification-added-actor = Added { $name } ({ $id })
## EditorCopyPasteBrush
notification-copied-tiles =
{ $amount ->
[one] Copied one tile
*[other] Copied { $amount } tiles
}
## EditorDefaultBrush
notification-removed-actor = Removed { $name } ({ $id })
notification-removed-resource = Removed { $type }
## EditorResourceBrush
notification-added-resource =
{ $amount ->
[one] Added one cell of { $type }
*[other] Added { $amount } cells of { $type }
}
## EditorTileBrush
notification-added-tile = Added tile { $id }
notification-filled-tile = Filled with tile { $id }
## EditorActionManager
notification-opened = Opened
## ActorEditLogic
notification-edited-actor = Edited { $name } ({ $id })