Streamline mod changing after installation

- Don't return to the ModChooser after a successful installation.
 - Don't reload the ModChooser after a cancelled installation.
This commit is contained in:
Pavel Penev
2015-09-08 22:25:05 +03:00
parent 4401e1aa0c
commit 50ea12723c
3 changed files with 10 additions and 20 deletions

View File

@@ -23,17 +23,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Widget panel;
readonly ProgressBarWidget progressBar;
readonly LabelWidget statusLabel;
readonly Action continueLoading;
readonly Action afterInstall;
readonly ButtonWidget retryButton, backButton;
readonly Widget installingContainer, insertDiskContainer;
readonly ContentInstaller installData;
[ObjectCreator.UseCtor]
public InstallFromCDLogic(Widget widget, Action continueLoading, string modId)
public InstallFromCDLogic(Widget widget, Action afterInstall, string modId)
{
this.modId = modId;
installData = ModMetadata.AllMods[modId].Content;
this.continueLoading = continueLoading;
this.afterInstall = afterInstall;
panel = widget.Get("INSTALL_FROMCD_PANEL");
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
continueLoading();
afterInstall();
}) { IsBackground = true }.Start();
}
@@ -198,7 +198,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
statusLabel.GetText = () => "Game assets have been extracted.";
Ui.CloseWindow();
continueLoading();
afterInstall();
});
}
catch (Exception e)

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
@@ -16,13 +15,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public class InstallLogic : Widget
{
[ObjectCreator.UseCtor]
public InstallLogic(Widget widget, Action continueLoading, string mirrorListUrl, string modId)
public InstallLogic(Widget widget, string mirrorListUrl, string modId)
{
var panel = widget.Get("INSTALL_PANEL");
var widgetArgs = new WidgetArgs
{
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
{ "continueLoading", continueLoading },
{ "afterInstall", () => { Game.InitializeMod(modId, new Arguments()); } },
{ "mirrorListUrl", mirrorListUrl },
{ "modId", modId }
};
@@ -38,14 +36,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs);
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
{
Game.RunAfterTick(() =>
{
Game.Settings.Game.PreviousMod = Game.ModData.Manifest.Mod.Id;
Game.InitializeMod("modchooser", null);
});
};
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = Ui.CloseWindow;
}
}
}

View File

@@ -20,8 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
Action loadDefaultMod = () =>
Game.RunAfterTick(() => Game.InitializeMod(modId, null));
Action loadDefaultMod = () => Game.RunAfterTick(() => Game.InitializeMod(modId, null));
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("BACK_BUTTON");
if (cancelButton != null)
@@ -34,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs
{
{ "continueLoading", loadDefaultMod },
{ "afterInstall", loadDefaultMod },
{ "modId", modId }
});
};