Initial commit: OpenRA game engine
Fork from OpenRA/OpenRA with one-click launch script (start-ra.cmd) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
73
OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs
Normal file
73
OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
#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.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
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 = [];
|
||||
|
||||
public override void Init(Manifest manifest, IReadOnlyFileSystem fileSystem)
|
||||
{
|
||||
base.Init(manifest, fileSystem);
|
||||
|
||||
messages = FluentProvider.GetMessage(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user