From 19bb255c988f161ce00586cb516de830732efe31 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 16 Nov 2016 17:36:28 -0500 Subject: add emergency interrupt feature (#168) --- src/StardewModdingAPI/Framework/Monitor.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/StardewModdingAPI/Framework') diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs index 4fe1df04..cf46a474 100644 --- a/src/StardewModdingAPI/Framework/Monitor.cs +++ b/src/StardewModdingAPI/Framework/Monitor.cs @@ -65,6 +65,22 @@ namespace StardewModdingAPI.Framework this.LogImpl(this.Source, message, Monitor.Colors[level], level); } + /// Immediately exit the game without saving. This should only be invoked when an irrecoverable fatal error happens that risks save corruption or game-breaking bugs. + /// The reason for the shutdown. + public void ExitGameImmediately(string reason) + { + Program.ExitGameImmediately(this.Source, reason); + Program.gamePtr.Exit(); + } + + /// Log a fatal error message. + /// The message to log. + internal void LogFatal(string message) + { + Console.BackgroundColor = ConsoleColor.Red; + this.LogImpl(this.Source, message, ConsoleColor.White, LogLevel.Error); + } + /// Log a message for the player or developer, using the specified console color. /// The name of the mod logging the message. /// The message to log. -- cgit