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:
@@ -23,17 +23,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
readonly Widget panel;
|
readonly Widget panel;
|
||||||
readonly ProgressBarWidget progressBar;
|
readonly ProgressBarWidget progressBar;
|
||||||
readonly LabelWidget statusLabel;
|
readonly LabelWidget statusLabel;
|
||||||
readonly Action continueLoading;
|
readonly Action afterInstall;
|
||||||
readonly ButtonWidget retryButton, backButton;
|
readonly ButtonWidget retryButton, backButton;
|
||||||
readonly Widget installingContainer, insertDiskContainer;
|
readonly Widget installingContainer, insertDiskContainer;
|
||||||
readonly ContentInstaller installData;
|
readonly ContentInstaller installData;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public InstallFromCDLogic(Widget widget, Action continueLoading, string modId)
|
public InstallFromCDLogic(Widget widget, Action afterInstall, string modId)
|
||||||
{
|
{
|
||||||
this.modId = modId;
|
this.modId = modId;
|
||||||
installData = ModMetadata.AllMods[modId].Content;
|
installData = ModMetadata.AllMods[modId].Content;
|
||||||
this.continueLoading = continueLoading;
|
this.afterInstall = afterInstall;
|
||||||
panel = widget.Get("INSTALL_FROMCD_PANEL");
|
panel = widget.Get("INSTALL_FROMCD_PANEL");
|
||||||
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
|
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
|
||||||
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
|
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
|
||||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continueLoading();
|
afterInstall();
|
||||||
}) { IsBackground = true }.Start();
|
}) { IsBackground = true }.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
statusLabel.GetText = () => "Game assets have been extracted.";
|
statusLabel.GetText = () => "Game assets have been extracted.";
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
continueLoading();
|
afterInstall();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
@@ -16,13 +15,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public class InstallLogic : Widget
|
public class InstallLogic : Widget
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[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 panel = widget.Get("INSTALL_PANEL");
|
||||||
var widgetArgs = new WidgetArgs
|
var widgetArgs = new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
|
{ "afterInstall", () => { Game.InitializeMod(modId, new Arguments()); } },
|
||||||
{ "continueLoading", continueLoading },
|
|
||||||
{ "mirrorListUrl", mirrorListUrl },
|
{ "mirrorListUrl", mirrorListUrl },
|
||||||
{ "modId", modId }
|
{ "modId", modId }
|
||||||
};
|
};
|
||||||
@@ -38,14 +36,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
|
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
|
||||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs);
|
Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs);
|
||||||
|
|
||||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
|
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = Ui.CloseWindow;
|
||||||
{
|
|
||||||
Game.RunAfterTick(() =>
|
|
||||||
{
|
|
||||||
Game.Settings.Game.PreviousMod = Game.ModData.Manifest.Mod.Id;
|
|
||||||
Game.InitializeMod("modchooser", null);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
var installMusicContainer = widget.Get("INSTALL_MUSIC_PANEL");
|
||||||
|
|
||||||
Action loadDefaultMod = () =>
|
Action loadDefaultMod = () => Game.RunAfterTick(() => Game.InitializeMod(modId, null));
|
||||||
Game.RunAfterTick(() => Game.InitializeMod(modId, null));
|
|
||||||
|
|
||||||
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("BACK_BUTTON");
|
var cancelButton = installMusicContainer.GetOrNull<ButtonWidget>("BACK_BUTTON");
|
||||||
if (cancelButton != null)
|
if (cancelButton != null)
|
||||||
@@ -34,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs
|
Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs
|
||||||
{
|
{
|
||||||
{ "continueLoading", loadDefaultMod },
|
{ "afterInstall", loadDefaultMod },
|
||||||
{ "modId", modId }
|
{ "modId", modId }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user