Extract strings from resource renderer.
This commit is contained in:
committed by
Gustas
parent
6c9e33b76c
commit
97c61e0068
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user