summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Inheritance
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-12-12 11:52:34 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-12-12 11:52:34 -0500
commit28e2695a19f7babf35d177367840a82b798beb55 (patch)
tree591b2badd77a7c9c0c36b8e09abdb6a323513307 /src/StardewModdingAPI/Inheritance
parentaaf354761f18a18b0bcb81c9bd32819bb28deac9 (diff)
parenta3376e2a6257c01c52a3c64c4f5f1f8de9a9c906 (diff)
downloadSMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.gz
SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.bz2
SMAPI-28e2695a19f7babf35d177367840a82b798beb55.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Inheritance')
-rw-r--r--src/StardewModdingAPI/Inheritance/SGame.cs42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Inheritance/SGame.cs
index 93d56553..f70d0696 100644
--- a/src/StardewModdingAPI/Inheritance/SGame.cs
+++ b/src/StardewModdingAPI/Inheritance/SGame.cs
@@ -373,7 +373,7 @@ namespace StardewModdingAPI.Inheritance
/// <summary>The method called to draw everything to the screen.</summary>
/// <param name="gameTime">A snapshot of the game timing state.</param>
- /// <remarks>This implementation is identical to <see cref="Game1.Draw"/>, except for minor formatting and added events.</remarks>
+ /// <remarks>This implementation is identical to <see cref="Game1.Draw"/>, except for try..catch around menu draw code, minor formatting, and added events.</remarks>
protected override void Draw(GameTime gameTime)
{
// track frame rate
@@ -388,9 +388,25 @@ namespace StardewModdingAPI.Inheritance
if (Game1.options.showMenuBackground && Game1.activeClickableMenu != null && Game1.activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
{
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- Game1.activeClickableMenu.drawBackground(Game1.spriteBatch);
+ try
+ {
+ Game1.activeClickableMenu.drawBackground(Game1.spriteBatch);
+ }
+ catch (Exception ex)
+ {
+ this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing its background. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error);
+ Game1.activeClickableMenu.exitThisMenu();
+ }
GraphicsEvents.InvokeOnPreRenderGuiEvent(this.Monitor);
- Game1.activeClickableMenu.draw(Game1.spriteBatch);
+ try
+ {
+ Game1.activeClickableMenu.draw(Game1.spriteBatch);
+ }
+ catch (Exception ex)
+ {
+ this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing itself. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error);
+ Game1.activeClickableMenu.exitThisMenu();
+ }
GraphicsEvents.InvokeOnPostRenderGuiEvent(this.Monitor);
Game1.spriteBatch.End();
if (!this.ZoomLevelIsOne)
@@ -434,7 +450,15 @@ namespace StardewModdingAPI.Inheritance
if (Game1.showingEndOfNightStuff)
{
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- Game1.activeClickableMenu?.draw(Game1.spriteBatch);
+ try
+ {
+ Game1.activeClickableMenu?.draw(Game1.spriteBatch);
+ }
+ catch (Exception ex)
+ {
+ this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing itself. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error);
+ Game1.activeClickableMenu.exitThisMenu();
+ }
Game1.spriteBatch.End();
if (!this.ZoomLevelIsOne)
{
@@ -742,7 +766,15 @@ namespace StardewModdingAPI.Inheritance
if (Game1.activeClickableMenu != null)
{
GraphicsEvents.InvokeOnPreRenderGuiEvent(this.Monitor);
- Game1.activeClickableMenu.draw(Game1.spriteBatch);
+ try
+ {
+ Game1.activeClickableMenu.draw(Game1.spriteBatch);
+ }
+ catch (Exception ex)
+ {
+ this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing itself. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error);
+ Game1.activeClickableMenu.exitThisMenu();
+ }
GraphicsEvents.InvokeOnPostRenderGuiEvent(this.Monitor);
}
else