Simplify mod content installation plumbing.

This commit is contained in:
Paul Chote
2014-12-13 13:34:36 +13:00
parent ec7a32184e
commit 7bfffeadc2
7 changed files with 46 additions and 46 deletions

View File

@@ -20,8 +20,9 @@ namespace OpenRA
{
public class InstallData
{
public readonly string InstallerMenuWidget = null;
public readonly string InstallerBackgroundWidget = null;
public readonly string MenuWidget = null;
public readonly string MusicMenuWidget = null;
public readonly string BackgroundWidget = null;
public readonly string[] TestFiles = {};
public readonly string[] DiskTestFiles = {};
public readonly string PackageToExtractFromCD = null;

View File

@@ -29,50 +29,45 @@ namespace OpenRA.Mods.Common.LoadScreens
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.ResetAll();
Game.Settings.Save();
Ui.OpenWindow(window, new WidgetArgs());
}
else
{
TestAndContinue();
// Check whether the mod content is installed
// TODO: The installation code has finally been beaten into shape, so we can
// finally move it all into the planned "Manage Content" panel in the modchooser mod.
var installData = Game.modData.Manifest.ContentInstaller;
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
var installModMusic = args != null && args.Contains("Install.Music");
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
if (!string.IsNullOrEmpty(replay))
Game.JoinReplay(replay);
if (installModContent || installModMusic)
{
var widgetArgs = new WidgetArgs()
{
{ "continueLoading", () => Game.InitializeMod(Game.Settings.Game.Mod, args) },
};
if (installData.BackgroundWidget != null)
Ui.LoadWidget(installData.BackgroundWidget, Ui.Root, widgetArgs);
var menu = installModContent ? installData.MenuWidget : installData.MusicMenuWidget;
Ui.OpenWindow(menu, widgetArgs);
return;
}
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
if (!string.IsNullOrEmpty(replay))
{
Game.JoinReplay(replay);
return;
}
Game.LoadShellMap();
Game.Settings.Save();
}
public virtual void Dispose() { }
}
}
}

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (installButton != null)
{
installButton.IsDisabled = () => world == null || !world.IsShellmap;
var args = new string[] { "Launch.Window=INSTALL_MUSIC_PANEL" };
var args = new string[] { "Install.Music=true" };
installButton.OnClick = () =>
{
Game.modData.LoadScreen.Display(); // HACK: prevent a flicker when transitioning to the installation dialog

View File

@@ -138,8 +138,9 @@ LoadScreen: CncLoadScreen
ContentInstaller:
TestFiles: conquer.mix, desert.mix, sounds.mix, speech.mix, temperat.mix, tempicnh.mix, winter.mix
InstallerBackgroundWidget: INSTALL_BACKGROUND
InstallerMenuWidget: INSTALL_PANEL
BackgroundWidget: INSTALL_BACKGROUND
MenuWidget: INSTALL_PANEL
MusicMenuWidget: INSTALL_MUSIC_PANEL
FilesToCopy: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
FilesToExtract: speech.mix, tempicnh.mix, transit.mix
PackageMirrorList: http://www.openra.net/packages/cnc-mirrors.txt

View File

@@ -122,7 +122,8 @@ LoadScreen: LogoStripeLoadScreen
Text: Filling Crates..., Breeding Sandworms...
ContentInstaller:
InstallerMenuWidget: INSTALL_PANEL
MenuWidget: INSTALL_PANEL
MusicMenuWidget: INSTALL_MUSIC_PANEL
# TODO: check if DATA.R8 is at 1.03 patch level with 4840 frames
TestFiles: BLOXBASE.R8, BLOXBAT.R8, BLOXBGBS.R8, BLOXICE.R8, BLOXTREE.R8, BLOXWAST.R8, DATA.R8, SOUND.RS
PackageMirrorList: http://www.openra.net/packages/d2k-103-mirrors.txt

View File

@@ -137,7 +137,8 @@ LoadScreen: LogoStripeLoadScreen
Text: Filling Crates..., Charging Capacitors..., Reticulating Splines..., Planting Trees..., Building Bridges..., Aging Empires..., Compiling EVA..., Constructing Pylons..., Activating Skynet..., Splitting Atoms...
ContentInstaller:
InstallerMenuWidget: INSTALL_PANEL
MenuWidget: INSTALL_PANEL
MusicMenuWidget: INSTALL_MUSIC_PANEL
TestFiles: allies.mix, conquer.mix, interior.mix, redalert.mix, russian.mix, snow.mix, sounds.mix, temperat.mix
PackageMirrorList: http://www.openra.net/packages/ra-mirrors.txt
DiskTestFiles: MAIN.MIX, INSTALL/REDALERT.MIX

View File

@@ -167,7 +167,8 @@ LoadScreen: LogoStripeLoadScreen
Text: Updating EVA installation..., Changing perspective...
ContentInstaller:
InstallerMenuWidget: INSTALL_PANEL
MenuWidget: INSTALL_PANEL
MusicMenuWidget: INSTALL_MUSIC_PANEL
TestFiles: cache.mix, conquer.mix, isosnow.mix, isotemp.mix, local.mix, sidec01.mix, sidec02.mix, sno.mix, snow.mix, sounds.mix, speech01.mix, tem.mix, temperat.mix
PackageMirrorList: http://www.openra.net/packages/ts-mirrors.txt
DiskTestFiles: MULTI.MIX, INSTALL/TIBSUN.MIX