Merge pull request #12795 from pchote/settings-restart
Use external mod switching plumbing to restart after settings changes.
This commit is contained in:
@@ -470,10 +470,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var argsString = mod.LaunchArgs.Append(launchArguments)
|
var args = launchArguments != null ? mod.LaunchArgs.Append(launchArguments) : mod.LaunchArgs;
|
||||||
.Select(a => "\"" + a + "\"").JoinWith(" ");
|
var p = Process.Start(mod.LaunchPath, args.Select(a => "\"" + a + "\"").JoinWith(" "));
|
||||||
|
|
||||||
var p = Process.Start(mod.LaunchPath, argsString);
|
|
||||||
if (p == null || p.HasExited)
|
if (p == null || p.HasExited)
|
||||||
onFailed();
|
onFailed();
|
||||||
else
|
else
|
||||||
@@ -482,8 +480,10 @@ namespace OpenRA
|
|||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Log.Write("debug", "Failed to switch to external mod.");
|
||||||
|
Log.Write("debug", "Error was: " + e.Message);
|
||||||
onFailed();
|
onFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,11 +803,6 @@ namespace OpenRA
|
|||||||
state = RunStatus.Success;
|
state = RunStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Restart()
|
|
||||||
{
|
|
||||||
state = RunStatus.Restart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddChatLine(Color color, string name, string text)
|
public static void AddChatLine(Color color, string name, string text)
|
||||||
{
|
{
|
||||||
OrderManager.AddChatLine(color, name, text);
|
OrderManager.AddChatLine(color, name, text);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
Error = -1,
|
Error = -1,
|
||||||
Success = 0,
|
Success = 0,
|
||||||
Restart = 1,
|
|
||||||
Running = int.MaxValue
|
Running = int.MaxValue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,11 +130,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
Game.Initialize(new Arguments(args));
|
Game.Initialize(new Arguments(args));
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
var status = Game.Run();
|
return Game.Run();
|
||||||
if (status == RunStatus.Restart)
|
|
||||||
using (var p = Process.GetCurrentProcess())
|
|
||||||
Process.Start(Assembly.GetEntryAssembly().Location, p.StartInfo.Arguments);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
static void GameProcessExited(object sender, EventArgs e)
|
static void GameProcessExited(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!(gameProcess.ExitCode == (int)RunStatus.Success || gameProcess.ExitCode == (int)RunStatus.Restart))
|
if (gameProcess.ExitCode != (int)RunStatus.Success)
|
||||||
ShowErrorDialog();
|
ShowErrorDialog();
|
||||||
|
|
||||||
Exit();
|
Exit();
|
||||||
|
|||||||
@@ -74,13 +74,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
OriginalGraphicsWindowedSize != current.Graphics.WindowedSize ||
|
OriginalGraphicsWindowedSize != current.Graphics.WindowedSize ||
|
||||||
OriginalGraphicsFullscreenSize != current.Graphics.FullscreenSize ||
|
OriginalGraphicsFullscreenSize != current.Graphics.FullscreenSize ||
|
||||||
OriginalServerDiscoverNatDevices != current.Server.DiscoverNatDevices)
|
OriginalServerDiscoverNatDevices != current.Server.DiscoverNatDevices)
|
||||||
|
{
|
||||||
|
Action restart = () =>
|
||||||
|
{
|
||||||
|
var external = Game.ExternalMods[ExternalMod.MakeKey(Game.ModData.Manifest)];
|
||||||
|
Game.SwitchToExternalMod(external, null, closeAndExit);
|
||||||
|
};
|
||||||
|
|
||||||
ConfirmationDialogs.ButtonPrompt(
|
ConfirmationDialogs.ButtonPrompt(
|
||||||
title: "Restart Now?",
|
title: "Restart Now?",
|
||||||
text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
|
text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
|
||||||
onConfirm: Game.Restart,
|
onConfirm: restart,
|
||||||
onCancel: closeAndExit,
|
onCancel: closeAndExit,
|
||||||
confirmText: "Restart Now",
|
confirmText: "Restart Now",
|
||||||
cancelText: "Restart Later");
|
cancelText: "Restart Later");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
closeAndExit();
|
closeAndExit();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user