Fix DefaultLoadScreen coding style.

This commit is contained in:
Paul Chote
2013-10-06 11:04:15 +13:00
parent 7604a60894
commit 2d0028396a

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -20,29 +20,31 @@ namespace OpenRA.Mods.RA
{ {
public class DefaultLoadScreen : ILoadScreen public class DefaultLoadScreen : ILoadScreen
{ {
Dictionary<string, string> Info; Dictionary<string, string> info;
Stopwatch lastUpdate = new Stopwatch();
Stopwatch lastLoadScreen = new Stopwatch();
Rectangle StripeRect;
Sprite Stripe, Logo;
float2 LogoPos;
Renderer r; Renderer r;
Rectangle stripeRect;
float2 logoPos;
Sprite stripe, logo;
string[] messages;
public void Init(Dictionary<string, string> info) public void Init(Dictionary<string, string> info)
{ {
Info = info; this.info = info;
// Avoid standard loading mechanisms so we // Avoid standard loading mechanisms so we
// can display the loadscreen as early as possible // can display the loadscreen as early as possible
r = Game.Renderer; r = Game.Renderer;
if (r == null) return; if (r == null)
return;
var s = new Sheet(Info["Image"]); messages = info["Text"].Split(',');
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha); var s = new Sheet(info["Image"]);
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha); logo = new Sprite(s, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
StripeRect = new Rectangle(0, r.Resolution.Height/2 - 128, r.Resolution.Width, 256); stripe = new Sprite(s, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha);
LogoPos = new float2(r.Resolution.Width/2 - 128, r.Resolution.Height/2 - 128); 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 void Display() public void Display()
@@ -51,19 +53,19 @@ namespace OpenRA.Mods.RA
return; return;
// Update text at most every 0.5 seconds // Update text at most every 0.5 seconds
if (lastLoadScreen.ElapsedTime() < 0.5) if (lastUpdate.ElapsedTime() < 0.5)
return; return;
if (r.Fonts == null) if (r.Fonts == null)
return; return;
lastLoadScreen.Reset(); lastUpdate.Reset();
var text = Info["Text"].Split(',').Random(Game.CosmeticRandom); var text = messages.Random(Game.CosmeticRandom);
var textSize = r.Fonts["Bold"].Measure(text); var textSize = r.Fonts["Bold"].Measure(text);
r.BeginFrame(float2.Zero, 1f); r.BeginFrame(float2.Zero, 1f);
WidgetUtils.FillRectWithSprite(StripeRect, Stripe); WidgetUtils.FillRectWithSprite(stripeRect, stripe);
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos); 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.Fonts["Bold"].DrawText(text, new float2(r.Resolution.Width - textSize.X - 20, r.Resolution.Height - textSize.Y - 20), Color.White);
r.EndFrame(new NullInputHandler()); r.EndFrame(new NullInputHandler());
} }
@@ -76,18 +78,17 @@ namespace OpenRA.Mods.RA
void TestAndContinue() void TestAndContinue()
{ {
Ui.ResetAll(); Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"])) if (!FileSystem.Exists(info["TestFile"]))
{ {
var args = new WidgetArgs() var args = new WidgetArgs()
{ {
{ "continueLoading", () => TestAndContinue() }, { "continueLoading", () => TestAndContinue() },
{ "installData", Info } { "installData", info }
}; };
Ui.OpenWindow(Info["InstallerMenuWidget"], args); Ui.OpenWindow(info["InstallerMenuWidget"], args);
} }
else else
Game.LoadShellMap(); Game.LoadShellMap();
} }
} }
} }