Extract strings from resource renderer.
This commit is contained in:
committed by
Gustas
parent
6c9e33b76c
commit
97c61e0068
@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
public readonly string Palette = TileSet.TerrainPaletteInternalName;
|
||||
|
||||
[FieldLoader.Require]
|
||||
[TranslationReference]
|
||||
[Desc("Resource name used by tooltips.")]
|
||||
public readonly string Name = null;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Linguini.Syntax.Ast;
|
||||
using Linguini.Syntax.Parser;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -136,6 +137,19 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var speed in gameSpeeds.Speeds.Values)
|
||||
usedKeys.Add(speed.Name, gameSpeedTranslationReference, $"`{nameof(GameSpeed)}.{nameof(GameSpeed.Name)}`");
|
||||
|
||||
// TODO: linter does not work with LoadUsing
|
||||
foreach (var actorInfo in modData.DefaultRules.Actors)
|
||||
{
|
||||
foreach (var info in actorInfo.Value.TraitInfos<ResourceRendererInfo>())
|
||||
{
|
||||
var resourceTypeNameField = typeof(ResourceRendererInfo.ResourceTypeInfo).GetField(nameof(ResourceRendererInfo.ResourceTypeInfo.Name));
|
||||
var resourceTypeTranslationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(resourceTypeNameField, true)[0];
|
||||
testedFields.Add(resourceTypeNameField);
|
||||
foreach (var resourceTypes in info.ResourceTypes)
|
||||
usedKeys.Add(resourceTypes.Value.Name, resourceTypeTranslationReference, $"`{nameof(ResourceRendererInfo.ResourceTypeInfo)}.{nameof(ResourceRendererInfo.ResourceTypeInfo.Name)}`");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var modType in modData.ObjectCreator.GetTypes())
|
||||
{
|
||||
const BindingFlags Binding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Resource name used by tooltips.")]
|
||||
[TranslationReference]
|
||||
public readonly string Name = null;
|
||||
|
||||
public ResourceTypeInfo(MiniYaml yaml)
|
||||
@@ -266,7 +267,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected virtual string GetRenderedResourceType(CPos cell) { return RenderContents[cell].Type; }
|
||||
|
||||
protected virtual string GetRenderedResourceTooltip(CPos cell) { return RenderContents[cell].Info?.Name; }
|
||||
protected virtual string GetRenderedResourceTooltip(CPos cell)
|
||||
{
|
||||
var info = RenderContents[cell].Info;
|
||||
if (info == null)
|
||||
return null;
|
||||
|
||||
return TranslationProvider.GetString(info.Name);
|
||||
}
|
||||
|
||||
IEnumerable<string> IResourceRenderer.ResourceTypes => Info.ResourceTypes.Keys;
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ dropdown-map-creeps =
|
||||
.label = Creep Actors
|
||||
.description = Hostile forces spawn on the battlefield
|
||||
|
||||
resource-tiberium = Tiberium
|
||||
|
||||
## defaults.yaml
|
||||
notification-unit-lost = Unit lost.
|
||||
notification-unit-promoted = Unit promoted.
|
||||
|
||||
@@ -142,11 +142,11 @@
|
||||
Tiberium:
|
||||
Sequences: ti1, ti2, ti3, ti4, ti5, ti6, ti7, ti8, ti9, ti10, ti11, ti12
|
||||
Palette: staticterrain
|
||||
Name: Tiberium
|
||||
Name: resource-tiberium
|
||||
BlueTiberium:
|
||||
Sequences: bti1, bti2, bti3, bti4, bti5, bti6, bti7, bti8, bti9, bti10, bti11, bti12
|
||||
Palette: bluetiberium
|
||||
Name: Tiberium
|
||||
Name: resource-tiberium
|
||||
|
||||
World:
|
||||
Inherits: ^BaseWorld
|
||||
|
||||
@@ -31,6 +31,8 @@ options-starting-units =
|
||||
.light-support = Light Support
|
||||
.heavy-support = Heavy Support
|
||||
|
||||
resource-spice = Spice
|
||||
|
||||
## defaults.yaml
|
||||
notification-unit-lost = Unit lost.
|
||||
notification-unit-promoted = Unit promoted.
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
Spice:
|
||||
Sequences: spicea, spiceb, spicec, spiced
|
||||
Palette: d2k
|
||||
Name: Spice
|
||||
Name: resource-spice
|
||||
|
||||
World:
|
||||
Inherits: ^BaseWorld
|
||||
|
||||
@@ -32,6 +32,8 @@ options-starting-units =
|
||||
.light-support = Light Support
|
||||
.heavy-support = Heavy Support
|
||||
|
||||
resource-minerals = Valuable Minerals
|
||||
|
||||
## aircraft.yaml
|
||||
actor-badr-name = Badger
|
||||
|
||||
|
||||
@@ -155,11 +155,11 @@
|
||||
Ore:
|
||||
Sequences: gold01, gold02, gold03, gold04
|
||||
Palette: player
|
||||
Name: Valuable Minerals
|
||||
Name: resource-minerals
|
||||
Gems:
|
||||
Sequences: gem01, gem02, gem03, gem04
|
||||
Palette: player
|
||||
Name: Valuable Minerals
|
||||
Name: resource-minerals
|
||||
|
||||
World:
|
||||
Inherits: ^BaseWorld
|
||||
|
||||
@@ -29,6 +29,9 @@ dropdown-map-creeps =
|
||||
.label = Creep Actors
|
||||
.description = Hostile forces spawn on the battlefield
|
||||
|
||||
resource-veins = Veins
|
||||
resource-tiberium = Tiberium
|
||||
|
||||
## Structures
|
||||
notification-construction-complete = Construction complete.
|
||||
notification-unit-ready = Unit ready.
|
||||
|
||||
@@ -209,11 +209,11 @@
|
||||
Tiberium:
|
||||
Sequences: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
||||
Palette: greentiberium
|
||||
Name: Tiberium
|
||||
Name: resource-tiberium
|
||||
BlueTiberium:
|
||||
Sequences: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
||||
Palette: bluetiberium
|
||||
Name: Tiberium
|
||||
Name: resource-tiberium
|
||||
Ramp1Sequences:
|
||||
Tiberium: tib13, tib14
|
||||
BlueTiberium: tib13, tib14
|
||||
@@ -228,7 +228,7 @@
|
||||
BlueTiberium: tib19, tib20
|
||||
TSVeinsRenderer:
|
||||
ResourceType: Veins
|
||||
Name: Veins
|
||||
Name: resource-veins
|
||||
Palette: player
|
||||
VeinholeActors: veinhole
|
||||
|
||||
|
||||
Reference in New Issue
Block a user