Refactoring mouse handling into a separate class.
This commit is contained in:
		| @@ -8,9 +8,9 @@ namespace stardew_access.Features | |||||||
|     public class MouseHandler |     public class MouseHandler | ||||||
|     { |     { | ||||||
|  |  | ||||||
|         public Vector2 ViewingOffset { get; set; } = Vector2.Zero; |         private Vector2 ViewingOffset = Vector2.Zero; | ||||||
|  |  | ||||||
|         public Vector2 PlayerFacingVector |         private Vector2 PlayerFacingVector | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
| @@ -30,7 +30,7 @@ switch (Game1.player.FacingDirection) | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public Vector2 PlayerPosition |         private Vector2 PlayerPosition | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
| @@ -40,11 +40,18 @@ switch (Game1.player.FacingDirection) | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void SnapMouseToPlayer() |         private void SnapMouseToPlayer() | ||||||
|         { |         { | ||||||
|             Vector2 snapPosition = this.PlayerPosition + this.PlayerFacingVector + this.ViewingOffset; |             Vector2 snapPosition = this.PlayerPosition + this.PlayerFacingVector + this.ViewingOffset; | ||||||
|             if (Utility.isOnScreen(snapPosition, 0)) |             Point snapPoint = new Point((int)snapPosition.X, (int)snapPosition.Y); | ||||||
|             Game1.setMousePosition((int)snapPosition.X, (int)snapPosition.Y); |             if (Utility.isOnScreen(snapPoint, 0)) | ||||||
|  |             Game1.setMousePosition(snapPoint.X, snapPoint.Y); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  | public void update() | ||||||
|  |         { | ||||||
|  |             if (MainClass.Config.SnapMouse) | ||||||
|  |             this.SnapMouseToPlayer(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -142,8 +142,7 @@ get | |||||||
|             // Narrate current location's name |             // Narrate current location's name | ||||||
|             Other.narrateCurrentLocation(); |             Other.narrateCurrentLocation(); | ||||||
|  |  | ||||||
|             if (Config.SnapMouse) |             Mouse.update(); | ||||||
|                 Mouse.SnapMouseToPlayer(); |  | ||||||
|  |  | ||||||
|             if (!ReadTile.isReadingTile && Config.ReadTile) |             if (!ReadTile.isReadingTile && Config.ReadTile) | ||||||
|             { |             { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user