From 7d0cd22f1ec0465c666cf0c69cbfa4da5fd3fe1a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 31 Oct 2016 17:01:16 -0400 Subject: add zoom-adjusted mouse position to mouse-changed event arguments (#129) --- src/StardewModdingAPI/Inheritance/SGame.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/StardewModdingAPI/Inheritance') diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Inheritance/SGame.cs index c595fae3..b0e6bebc 100644 --- a/src/StardewModdingAPI/Inheritance/SGame.cs +++ b/src/StardewModdingAPI/Inheritance/SGame.cs @@ -54,6 +54,12 @@ namespace StardewModdingAPI.Inheritance /// public MouseState MStatePrior { get; private set; } + /// The current mouse position on the screen adjusted for the zoom level. + public Point MPositionNow { get; private set; } + + /// The previous mouse position on the screen adjusted for the zoom level. + public Point MPositionPrior { get; private set; } + /// /// All keys pressed on the current frame /// @@ -261,7 +267,7 @@ namespace StardewModdingAPI.Inheritance { return WasButtonJustPressed(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); } - + /// /// Whether or not an analog button was just released on the controller /// @@ -767,7 +773,7 @@ namespace StardewModdingAPI.Inheritance //typeof (Game).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, new object[] {gameTime}); //base.Update(gameTime); - + #endregion } else @@ -1403,6 +1409,7 @@ namespace StardewModdingAPI.Inheritance KStateNow = Keyboard.GetState(); MStateNow = Mouse.GetState(); + MPositionNow = new Point(Game1.getMouseX(), Game1.getMouseY()); foreach (var k in FramePressedKeys) ControlEvents.InvokeKeyPressed(k); @@ -1449,8 +1456,9 @@ namespace StardewModdingAPI.Inheritance if (MStateNow != MStatePrior) { - ControlEvents.InvokeMouseChanged(MStatePrior, MStateNow); + ControlEvents.InvokeMouseChanged(MStatePrior, MStateNow, MPositionPrior, MPositionNow); MStatePrior = MStateNow; + MPositionPrior = MPositionPrior; } if (activeClickableMenu != null && activeClickableMenu != PreviousActiveMenu) -- cgit