Merge pull request #9143 from LipkeGu/mod_loadscreen_crash
LoadScreen: Do not crash when Image or Text is not defined.
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
float2 logoPos;
|
float2 logoPos;
|
||||||
Sheet sheet;
|
Sheet sheet;
|
||||||
Sprite stripe, logo;
|
Sprite stripe, logo;
|
||||||
string[] messages;
|
string[] messages = { "Loading..." };
|
||||||
|
|
||||||
public override void Init(Manifest m, Dictionary<string, string> info)
|
public override void Init(Manifest m, Dictionary<string, string> info)
|
||||||
{
|
{
|
||||||
@@ -35,13 +35,18 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
if (r == null)
|
if (r == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (info.ContainsKey("Text"))
|
||||||
messages = info["Text"].Split(',');
|
messages = info["Text"].Split(',');
|
||||||
|
|
||||||
|
if (info.ContainsKey("Image"))
|
||||||
|
{
|
||||||
sheet = new Sheet(Platform.ResolvePath(info["Image"]));
|
sheet = new Sheet(Platform.ResolvePath(info["Image"]));
|
||||||
logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
|
logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
|
||||||
stripe = new Sprite(sheet, new Rectangle(256, 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);
|
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);
|
logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Display()
|
public override void Display()
|
||||||
{
|
{
|
||||||
@@ -60,8 +65,13 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
var textSize = r.Fonts["Bold"].Measure(text);
|
var textSize = r.Fonts["Bold"].Measure(text);
|
||||||
|
|
||||||
r.BeginFrame(int2.Zero, 1f);
|
r.BeginFrame(int2.Zero, 1f);
|
||||||
|
|
||||||
|
if (stripe != null)
|
||||||
WidgetUtils.FillRectWithSprite(stripeRect, stripe);
|
WidgetUtils.FillRectWithSprite(stripeRect, stripe);
|
||||||
|
|
||||||
|
if (logo != null)
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user