If changed settings require a restart, offer the user to do it now.

Add a dialog when closing the settings screen asking the user if they would like to restart the game now in order to apply any settings that are only applied after restarting the game. The game is reloaded in-process by spinning up a new AppDomain in order to reset state.
This commit is contained in:
RoosterDragon
2014-06-10 16:17:27 +01:00
parent 6d2f180cd4
commit 52b09bdfe8
4 changed files with 82 additions and 19 deletions

View File

@@ -14,8 +14,8 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using OpenRA.FileSystem;
using MaxMind.GeoIP2;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Primitives;
@@ -464,7 +464,7 @@ namespace OpenRA
return shellmaps.Random(CosmeticRandom);
}
static bool quit;
static RunStatus state = RunStatus.Running;
public static event Action OnQuit = () => { };
static double idealFrameTime;
@@ -473,7 +473,7 @@ namespace OpenRA
idealFrameTime = 1.0 / fps;
}
internal static void Run()
internal static RunStatus Run()
{
if (Settings.Graphics.MaxFramerate < 1)
{
@@ -483,7 +483,7 @@ namespace OpenRA
SetIdealFrameTime(Settings.Graphics.MaxFramerate);
while (!quit)
while (state == RunStatus.Running)
{
if (Settings.Graphics.CapFramerate)
{
@@ -506,9 +506,19 @@ namespace OpenRA
Renderer.Device.Dispose();
OnQuit();
return state;
}
public static void Exit() { quit = true; }
public static void Exit()
{
state = RunStatus.Success;
}
public static void Restart()
{
state = RunStatus.Restart;
}
public static Action<Color, string, string> AddChatLine = (c, n, s) => { };