Use TryGet instead of Get and assign a default Fallback Color

This Fixes a crash in Situations when custom mods are used and reset OpenRA to its initial state.
This commit is contained in:
LipkeGu
2019-04-28 14:03:11 +02:00
committed by reaperrr
parent c7b8f9f09f
commit 7f7809fe70

View File

@@ -465,8 +465,8 @@ namespace OpenRA
Log.Write("nat", e.ToString()); Log.Write("nat", e.ToString());
} }
chatMessageColor = ChromeMetrics.Get<Color>("ChatMessageColor"); ChromeMetrics.TryGet("ChatMessageColor", out chatMessageColor);
systemMessageColor = ChromeMetrics.Get<Color>("SystemMessageColor"); ChromeMetrics.TryGet("SystemMessageColor", out systemMessageColor);
ModData.LoadScreen.StartGame(args); ModData.LoadScreen.StartGame(args);
} }
@@ -527,8 +527,8 @@ namespace OpenRA
// Note: These delayed actions should only be used by widgets or disposing objects // Note: These delayed actions should only be used by widgets or disposing objects
// - things that depend on a particular world should be queuing them on the world actor. // - things that depend on a particular world should be queuing them on the world actor.
static volatile ActionQueue delayedActions = new ActionQueue(); static volatile ActionQueue delayedActions = new ActionQueue();
static Color systemMessageColor; static Color systemMessageColor = Color.White;
static Color chatMessageColor; static Color chatMessageColor = Color.White;
public static void RunAfterTick(Action a) { delayedActions.Add(a, RunTime); } public static void RunAfterTick(Action a) { delayedActions.Add(a, RunTime); }
public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, RunTime + delayMilliseconds); } public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, RunTime + delayMilliseconds); }