Move the mod-level initialisation code back into the load screen.
This commit is contained in:
78
OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs
Normal file
78
OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public class BlankLoadScreen : ILoadScreen
|
||||
{
|
||||
public virtual void Init(Manifest m, Dictionary<string, string> info) { }
|
||||
|
||||
public virtual void Display()
|
||||
{
|
||||
if (Game.Renderer == null)
|
||||
return;
|
||||
|
||||
// Draw a black screen
|
||||
Game.Renderer.BeginFrame(int2.Zero, 1f);
|
||||
Game.Renderer.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
void TestAndContinue()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
if (!installData.TestFiles.All(f => GlobalFileSystem.Exists(f)))
|
||||
{
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
};
|
||||
|
||||
if (installData.InstallerBackgroundWidget != null)
|
||||
Ui.LoadWidget(installData.InstallerBackgroundWidget, Ui.Root, args);
|
||||
|
||||
Ui.OpenWindow(installData.InstallerMenuWidget, args);
|
||||
}
|
||||
else
|
||||
Game.LoadShellMap();
|
||||
|
||||
Game.Settings.Save();
|
||||
}
|
||||
|
||||
public void StartGame(Arguments args)
|
||||
{
|
||||
var window = args != null ? args.GetValue("Launch.Window", null) : null;
|
||||
if (!string.IsNullOrEmpty(window))
|
||||
{
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
if (installData.InstallerBackgroundWidget != null)
|
||||
Ui.LoadWidget(installData.InstallerBackgroundWidget, Ui.Root, new WidgetArgs());
|
||||
|
||||
Ui.OpenWindow(window, new WidgetArgs());
|
||||
}
|
||||
else
|
||||
{
|
||||
TestAndContinue();
|
||||
|
||||
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
|
||||
if (!string.IsNullOrEmpty(replay))
|
||||
Game.JoinReplay(replay);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public sealed class DefaultLoadScreen : ILoadScreen
|
||||
public sealed class LogoStripeLoadScreen : BlankLoadScreen
|
||||
{
|
||||
Stopwatch lastUpdate = Stopwatch.StartNew();
|
||||
Renderer r;
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
Sprite stripe, logo;
|
||||
string[] messages;
|
||||
|
||||
public void Init(Manifest m, Dictionary<string, string> info)
|
||||
public override void Init(Manifest m, Dictionary<string, string> info)
|
||||
{
|
||||
// Avoid standard loading mechanisms so we
|
||||
// can display the loadscreen as early as possible
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
logoPos = new float2(r.Resolution.Width / 2 - 128, r.Resolution.Height / 2 - 128);
|
||||
}
|
||||
|
||||
public void Display()
|
||||
public override void Display()
|
||||
{
|
||||
if (r == null)
|
||||
return;
|
||||
@@ -66,12 +66,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
r.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
Game.TestAndContinue();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
if (sheet != null)
|
||||
sheet.Dispose();
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
r.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
public void StartGame(Arguments args)
|
||||
{
|
||||
Ui.LoadWidget("MODCHOOSER", Ui.Root, new WidgetArgs());
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.LoadScreens
|
||||
{
|
||||
public sealed class NullLoadScreen : ILoadScreen
|
||||
{
|
||||
public void Init(Manifest m, Dictionary<string, string> info) { }
|
||||
|
||||
public void Display()
|
||||
{
|
||||
if (Game.Renderer == null)
|
||||
return;
|
||||
|
||||
// Draw a black screen
|
||||
Game.Renderer.BeginFrame(int2.Zero, 1f);
|
||||
Game.Renderer.EndFrame(new NullInputHandler());
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
Ui.ResetAll();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user