From 4275e87c57c909a8cbf2e18674b90a00fc1428d9 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 25 Sep 2021 11:18:56 +0100 Subject: [PATCH] Show an error prompt if restart mod switch fails. --- .../Widgets/Logic/Settings/SettingsLogic.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs index cf1a4b551d..f5e3e30994 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs @@ -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");