From bc39fcda9823d46de401ae24d6357f7c7cb29f2b Mon Sep 17 00:00:00 2001 From: Guido L Date: Tue, 25 Aug 2015 20:44:38 +0200 Subject: [PATCH] LoadScreen: Add fallback message when no Text or Image is specified. --- .../LoadScreens/LogoStripeLoadScreen.cs | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs index 2fe692e827..28b926fe25 100644 --- a/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.LoadScreens float2 logoPos; Sheet sheet; Sprite stripe, logo; - string[] messages; + string[] messages = { "Loading..." }; public override void Init(Manifest m, Dictionary info) { @@ -35,12 +35,17 @@ namespace OpenRA.Mods.Common.LoadScreens if (r == null) return; - messages = info["Text"].Split(','); - sheet = new Sheet(Platform.ResolvePath(info["Image"])); - logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha); - stripe = new Sprite(sheet, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha); - stripeRect = new Rectangle(0, r.Resolution.Height / 2 - 128, r.Resolution.Width, 256); - logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128); + if (info.ContainsKey("Text")) + messages = info["Text"].Split(','); + + if (info.ContainsKey("Image")) + { + sheet = new Sheet(Platform.ResolvePath(info["Image"])); + logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha); + stripe = new Sprite(sheet, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha); + stripeRect = new Rectangle(0, r.Resolution.Height / 2 - 128, r.Resolution.Width, 256); + logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128); + } } public override void Display() @@ -60,8 +65,13 @@ namespace OpenRA.Mods.Common.LoadScreens var textSize = r.Fonts["Bold"].Measure(text); r.BeginFrame(int2.Zero, 1f); - WidgetUtils.FillRectWithSprite(stripeRect, stripe); - r.RgbaSpriteRenderer.DrawSprite(logo, logoPos); + + if (stripe != null) + WidgetUtils.FillRectWithSprite(stripeRect, stripe); + + if (logo != null) + r.RgbaSpriteRenderer.DrawSprite(logo, logoPos); + r.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White); r.EndFrame(new NullInputHandler()); }