Show an error prompt if restart mod switch fails.

This commit is contained in:
Paul Chote
2021-09-25 11:18:56 +01:00
committed by teinarss
parent c5a6577cee
commit 4275e87c57

View File

@@ -75,16 +75,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
if (needsRestart)
{
Action restart = () =>
Action noRestart = () => ConfirmationDialogs.ButtonPrompt(
title: "Restart Required",
text: "Some changes will not be applied until\nthe game is restarted.",
onCancel: closeAndExit,
cancelText: "Continue");
if (!Game.ExternalMods.TryGetValue(ExternalMod.MakeKey(Game.ModData.Manifest), out var external))
{
var external = Game.ExternalMods[ExternalMod.MakeKey(Game.ModData.Manifest)];
Game.SwitchToExternalMod(external, null, closeAndExit);
};
noRestart();
return;
}
ConfirmationDialogs.ButtonPrompt(
title: "Restart Now?",
text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
onConfirm: restart,
onConfirm: () => Game.SwitchToExternalMod(external, null, noRestart),
onCancel: closeAndExit,
confirmText: "Restart Now",
cancelText: "Restart Later");