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.
75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
#region Copyright & License Information
|
|
/*
|
|
* Copyright (c) The OpenRA Developers and Contributors
|
|
* This file is part of OpenRA, which is free software. It is made
|
|
* available to you under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation, either version 3 of
|
|
* the License, or (at your option) any later version. For more
|
|
* information, see COPYING.
|
|
*/
|
|
#endregion
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using OpenRA.Graphics;
|
|
using OpenRA.Mods.Common.Widgets;
|
|
using OpenRA.Primitives;
|
|
|
|
namespace OpenRA.Mods.Common.LoadScreens
|
|
{
|
|
public sealed class LogoStripeLoadScreen : SheetLoadScreen
|
|
{
|
|
[FluentReference]
|
|
const string Loading = "loadscreen-loading";
|
|
|
|
Rectangle stripeRect;
|
|
float2 logoPos;
|
|
Sprite stripe, logo;
|
|
|
|
Sheet lastSheet;
|
|
int lastDensity;
|
|
Size lastResolution;
|
|
|
|
string[] messages = Array.Empty<string>();
|
|
|
|
public override void Init(ModData modData, Dictionary<string, string> info)
|
|
{
|
|
base.Init(modData, info);
|
|
|
|
messages = FluentProvider.GetString(Loading).Split(',').Select(x => x.Trim()).ToArray();
|
|
}
|
|
|
|
public override void DisplayInner(Renderer r, Sheet s, int density)
|
|
{
|
|
if (s != lastSheet || density != lastDensity)
|
|
{
|
|
lastSheet = s;
|
|
lastDensity = density;
|
|
logo = CreateSprite(s, density, new Rectangle(0, 0, 256, 256));
|
|
stripe = CreateSprite(s, density, new Rectangle(258, 0, 253, 256));
|
|
}
|
|
|
|
if (r.Resolution != lastResolution)
|
|
{
|
|
lastResolution = r.Resolution;
|
|
stripeRect = new Rectangle(0, lastResolution.Height / 2 - 128, lastResolution.Width, 256);
|
|
logoPos = new float2(lastResolution.Width / 2 - 128, lastResolution.Height / 2 - 128);
|
|
}
|
|
|
|
if (stripe != null)
|
|
WidgetUtils.FillRectWithSprite(stripeRect, stripe);
|
|
|
|
if (logo != null)
|
|
r.RgbaSpriteRenderer.DrawSprite(logo, logoPos);
|
|
|
|
if (r.Fonts != null && messages.Length > 0)
|
|
{
|
|
var text = messages.Random(Game.CosmeticRandom);
|
|
var textSize = r.Fonts["Bold"].Measure(text);
|
|
r.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White);
|
|
}
|
|
}
|
|
}
|
|
}
|