summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/SGame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework/SGame.cs')
-rw-r--r--src/StardewModdingAPI/Framework/SGame.cs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs
index bec6538b..65191931 100644
--- a/src/StardewModdingAPI/Framework/SGame.cs
+++ b/src/StardewModdingAPI/Framework/SGame.cs
@@ -53,10 +53,6 @@ namespace StardewModdingAPI.Framework
/// <summary>Whether the game is saving and SMAPI has already raised <see cref="SaveEvents.BeforeSave"/>.</summary>
private bool IsBetweenSaveEvents;
- /// <summary>Whether the game's zoom level is at 100% (i.e. nothing should be scaled).</summary>
- public bool ZoomLevelIsOne => Game1.options.zoomLevel.Equals(1.0f);
-
-
/****
** Game state
****/
@@ -75,7 +71,10 @@ namespace StardewModdingAPI.Framework
/// <summary>The previous mouse position on the screen adjusted for the zoom level.</summary>
private Point PreviousMousePosition;
- /// <summary>The previous save ID at last check.</summary>
+ /// <summary>The window size value at last check.</summary>
+ private Point PreviousWindowSize;
+
+ /// <summary>The save ID at last check.</summary>
private ulong PreviousSaveID;
/// <summary>A hash of <see cref="Game1.locations"/> at last check.</summary>
@@ -353,6 +352,20 @@ namespace StardewModdingAPI.Framework
}
/*********
+ ** Window events
+ *********/
+ // Here we depend on the game's viewport instead of listening to the Window.Resize
+ // event because we need to notify mods after the game handles the resize, so the
+ // game's metadata (like Game1.viewport) are updated. That's a bit complicated
+ // since the game adds & removes its own handler on the fly.
+ if (Game1.viewport.Width != this.PreviousWindowSize.X || Game1.viewport.Height != this.PreviousWindowSize.Y)
+ {
+ Point size = new Point(Game1.viewport.Width, Game1.viewport.Height);
+ GraphicsEvents.InvokeResize(this.Monitor);
+ this.PreviousWindowSize = size;
+ }
+
+ /*********
** Input events (if window has focus)
*********/
if (Game1.game1.IsActive)