restart the game instead of unmounting on the fly
avoid more redundancy between the load screens
This commit is contained in:
@@ -19,56 +19,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
public class InstallMusicLogic
|
||||
{
|
||||
ButtonWidget installButton;
|
||||
Ruleset modRules;
|
||||
IReadOnlyDictionary<string, string> installData;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallMusicLogic(Widget widget, Ruleset modRules)
|
||||
public InstallMusicLogic(Widget widget)
|
||||
{
|
||||
this.modRules = modRules;
|
||||
|
||||
installData = Game.modData.Manifest.ContentInstaller;
|
||||
|
||||
installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
|
||||
if (installButton != null)
|
||||
{
|
||||
installButton.OnClick = () => LoadInstallMusicContainer();
|
||||
installButton.IsVisible = () =>
|
||||
modRules.InstalledMusic.ToArray().Length <= Exts.ParseIntegerInvariant(installData["ShippedSoundtracks"]);
|
||||
}
|
||||
}
|
||||
|
||||
bool previousShowShellSetting;
|
||||
void LoadInstallMusicContainer()
|
||||
{
|
||||
var installMusicContainer = Ui.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs());
|
||||
|
||||
Action after = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
||||
modRules.Music.Do(m => m.Value.Reload());
|
||||
var musicPlayerLogic = (MusicPlayerLogic)installButton.Parent.LogicObject;
|
||||
musicPlayerLogic.BuildMusicTable();
|
||||
Ui.CloseWindow();
|
||||
Game.Settings.Game.ShowShellmap = previousShowShellSetting;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Write("debug", "Mounting the new MIX file and rebuild of scores list failed:\n{0}", e);
|
||||
}
|
||||
};
|
||||
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
||||
|
||||
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("CANCEL_BUTTON");
|
||||
if (cancelButton != null)
|
||||
{
|
||||
cancelButton.OnClick = () =>
|
||||
{
|
||||
Game.Settings.Game.ShowShellmap = previousShowShellSetting;
|
||||
Ui.CloseWindow();
|
||||
};
|
||||
cancelButton.OnClick = () => Game.InitializeMod(Game.Settings.Game.Mod, null);
|
||||
}
|
||||
|
||||
var copyFromDiscButton = installMusicContainer.GetOrNull<ButtonWidget>("COPY_FROM_CD_BUTTON");
|
||||
@@ -76,11 +35,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
copyFromDiscButton.OnClick = () =>
|
||||
{
|
||||
previousShowShellSetting = Game.Settings.Game.ShowShellmap;
|
||||
Game.Settings.Game.ShowShellmap = false;
|
||||
GlobalFileSystem.UnmountAll();
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs() {
|
||||
{ "continueLoading", after },
|
||||
{ "continueLoading", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -88,17 +44,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_BUTTON");
|
||||
if (downloadButton != null)
|
||||
{
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData["MusicPackageMirrorList"]);
|
||||
var musicInstallData = new Dictionary<string, string> { };
|
||||
musicInstallData["PackageMirrorList"] = installData["MusicPackageMirrorList"];
|
||||
|
||||
downloadButton.OnClick = () =>
|
||||
{
|
||||
previousShowShellSetting = Game.Settings.Game.ShowShellmap;
|
||||
Game.Settings.Game.ShowShellmap = false;
|
||||
GlobalFileSystem.UnmountAll();
|
||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs() {
|
||||
{ "afterInstall", after },
|
||||
{ "afterInstall", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
{ "installData", new ReadOnlyDictionary<string, string>(musicInstallData) },
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user