Expose mod.yaml content to localisation.
Mod metadata, load screens and mod content is all now sourced from ftl files, allowing these items to be translated. Translations are now initialized as part of ModData creation, as currently they are made available too late for the usage we need here. The "modcontent" mod learns a new parameter for "Content.TranslationFile" - this allows a mod to provide the path of a translation file to the mod which it can load. This allows mods such as ra, cnc, d2k, ts to own the translations for their ModContent, yet still make them accessible to the modcontent mod. CheckFluentReference learns to validate all these new fields to ensure translations have been set.
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Primitives;
|
||||
@@ -18,6 +20,9 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public sealed class LogoStripeLoadScreen : SheetLoadScreen
|
||||
{
|
||||
[FluentReference]
|
||||
const string Loading = "loadscreen-loading";
|
||||
|
||||
Rectangle stripeRect;
|
||||
float2 logoPos;
|
||||
Sprite stripe, logo;
|
||||
@@ -26,14 +31,13 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
int lastDensity;
|
||||
Size lastResolution;
|
||||
|
||||
string[] messages = { "Loading..." };
|
||||
string[] messages = Array.Empty<string>();
|
||||
|
||||
public override void Init(ModData modData, Dictionary<string, string> info)
|
||||
{
|
||||
base.Init(modData, info);
|
||||
|
||||
if (info.TryGetValue("Text", out var text))
|
||||
messages = text.Split(',');
|
||||
messages = FluentProvider.GetString(Loading).Split(',').Select(x => x.Trim()).ToArray();
|
||||
}
|
||||
|
||||
public override void DisplayInner(Renderer r, Sheet s, int density)
|
||||
@@ -59,7 +63,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
if (logo != null)
|
||||
r.RgbaSpriteRenderer.DrawSprite(logo, logoPos);
|
||||
|
||||
if (r.Fonts != null)
|
||||
if (r.Fonts != null && messages.Length > 0)
|
||||
{
|
||||
var text = messages.Random(Game.CosmeticRandom);
|
||||
var textSize = r.Fonts["Bold"].Measure(text);
|
||||
|
||||
Reference in New Issue
Block a user