From 2239463c3753f32403baa7dde83417c6a28f477f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Nov 2018 19:49:49 -0500 Subject: [PATCH 1/5] migrate to new NuGet package reference format --- SmartCursor/SmartCursor.csproj | 16 +++------------- SmartCursor/packages.config | 4 ---- 2 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 SmartCursor/packages.config diff --git a/SmartCursor/SmartCursor.csproj b/SmartCursor/SmartCursor.csproj index 9650216..bfc6eab 100644 --- a/SmartCursor/SmartCursor.csproj +++ b/SmartCursor/SmartCursor.csproj @@ -11,8 +11,6 @@ SmartCursor v4.5 512 - - true @@ -50,6 +48,9 @@ MinimumRecommendedRules.ruleset true + + + @@ -67,17 +68,6 @@ - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - \ No newline at end of file diff --git a/SmartCursor/packages.config b/SmartCursor/packages.config deleted file mode 100644 index 170a804..0000000 --- a/SmartCursor/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From e91d9f785b3db614af4bf5cd3be93c38bb5af31d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Nov 2018 19:52:23 -0500 Subject: [PATCH 2/5] update mod build config package --- SmartCursor/SmartCursor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartCursor/SmartCursor.csproj b/SmartCursor/SmartCursor.csproj index bfc6eab..6522383 100644 --- a/SmartCursor/SmartCursor.csproj +++ b/SmartCursor/SmartCursor.csproj @@ -49,7 +49,7 @@ true - + From a5d2ae363d172eaf680597d9c65fbf2b082ef719 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Nov 2018 19:55:01 -0500 Subject: [PATCH 3/5] remove code which has no effect --- SmartCursor/CursorPosition.cs | 27 --------------------------- SmartCursor/ModEntry.cs | 5 +---- SmartCursor/SmartCursor.csproj | 1 - 3 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 SmartCursor/CursorPosition.cs diff --git a/SmartCursor/CursorPosition.cs b/SmartCursor/CursorPosition.cs deleted file mode 100644 index 2e365c1..0000000 --- a/SmartCursor/CursorPosition.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.Xna.Framework; -using StardewModdingAPI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SmartCursor { - class CursorPosition : ICursorPosition { - public Vector2 AbsolutePixels { get; } - public Vector2 ScreenPixels { get; } - public Vector2 Tile { get; } - public Vector2 GrabTile { get; } - - public CursorPosition(Vector2 absolutePixels, Vector2 screenPixels, Vector2 tile, Vector2 grabTile) { - AbsolutePixels = absolutePixels; - ScreenPixels = screenPixels; - Tile = tile; - GrabTile = grabTile; - } - - public bool Equals(ICursorPosition other) { - throw new NotImplementedException(); - } - } -} diff --git a/SmartCursor/ModEntry.cs b/SmartCursor/ModEntry.cs index d503621..2762691 100644 --- a/SmartCursor/ModEntry.cs +++ b/SmartCursor/ModEntry.cs @@ -80,7 +80,6 @@ private double GetAngle(Vector2 screenPixels) { private int GetOctant(Vector2 screenPixels) { double angle = GetAngle(screenPixels); - Vector2 grabTile = Game1.player.getTileLocation(); angle += 22.5; if (angle < 45) { @@ -104,7 +103,7 @@ private int GetOctant(Vector2 screenPixels) { } private void InputEvents_ButtonPressed(object sender, EventArgsInput e) { - if (!Context.IsWorldReady || !Context.IsPlayerFree || !(e.Button == SButton.MouseLeft) || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool) { + if (!Context.IsWorldReady || !Context.IsPlayerFree || e.Button != SButton.MouseLeft || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool) { return; } @@ -145,10 +144,8 @@ private void InputEvents_ButtonPressed(object sender, EventArgsInput e) { dir = Game1.right; } - e = new EventArgsInput(SButton.MouseLeft, new CursorPosition(cursor.AbsolutePixels, cursor.ScreenPixels, grabTile, grabTile), null); Game1.player.lastClick = grabTile * 64 + new Vector2(32, 32); Game1.player.FacingDirection = dir; } - } } diff --git a/SmartCursor/SmartCursor.csproj b/SmartCursor/SmartCursor.csproj index 6522383..ac47d1e 100644 --- a/SmartCursor/SmartCursor.csproj +++ b/SmartCursor/SmartCursor.csproj @@ -62,7 +62,6 @@ - From a805da5fb175baefd16d782d51ed3a73a70d6a94 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Nov 2018 19:55:39 -0500 Subject: [PATCH 4/5] standardise version format --- SmartCursor/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartCursor/manifest.json b/SmartCursor/manifest.json index 10c9e42..86c27bc 100644 --- a/SmartCursor/manifest.json +++ b/SmartCursor/manifest.json @@ -1,7 +1,7 @@ { "Name": "SmartCursor", "Author": "stokastic", - "Version": "1.1", + "Version": "1.1.0", "Description": "Allows smart targeting of adjacent 8 tiles", "UniqueID": "stokastic.SmartCursor", "EntryDll": "SmartCursor.dll", From abf627218fe5aac796fbe35a292e04a9748fad64 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 14 Jan 2019 22:40:06 -0500 Subject: [PATCH 5/5] update for SMAPI 3.0 --- SmartCursor/ModEntry.cs | 19 +++++++++++++------ SmartCursor/manifest.json | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/SmartCursor/ModEntry.cs b/SmartCursor/ModEntry.cs index 2762691..2157387 100644 --- a/SmartCursor/ModEntry.cs +++ b/SmartCursor/ModEntry.cs @@ -7,13 +7,17 @@ namespace SmartCursor { public class ModEntry : Mod { - + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - InputEvents.ButtonPressed += InputEvents_ButtonPressed; - ControlEvents.MouseChanged += ControlEvents_MouseChanged; + helper.Events.Input.ButtonPressed += OnButtonPressed; + helper.Events.Input.CursorMoved += OnCursorMoved; } - private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChanged e) { + /// Raised after the player moves the in-game cursor. + /// The event sender. + /// The event data. + private void OnCursorMoved(object sender, CursorMovedEventArgs e) { if (!Context.IsWorldReady || !Context.IsPlayerFree || Game1.player.isMoving() || Game1.player.isCharging || Game1.player.isRafting || Game1.player.isRidingHorse() || Game1.player.UsingTool || Game1.player.IsEmoting || !Game1.player.CanMove) { return; } @@ -21,7 +25,7 @@ private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChange int dir = Game1.player.FacingDirection; Vector2 grabTile = new Vector2(1, 0); - switch(GetOctant(new Vector2(e.NewPosition.X, e.NewPosition.Y))) { + switch(GetOctant(new Vector2(e.NewPosition.ScreenPixels.X, e.NewPosition.ScreenPixels.Y))) { case 0: grabTile = new Vector2(1, 0); dir = Game1.right; @@ -102,7 +106,10 @@ private int GetOctant(Vector2 screenPixels) { return 0; } - private void InputEvents_ButtonPressed(object sender, EventArgsInput e) { + /// Raised after the player presses a button on the keyboard, controller, or mouse. + /// The event sender. + /// The event data. + private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady || !Context.IsPlayerFree || e.Button != SButton.MouseLeft || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool) { return; } diff --git a/SmartCursor/manifest.json b/SmartCursor/manifest.json index 86c27bc..dc2b892 100644 --- a/SmartCursor/manifest.json +++ b/SmartCursor/manifest.json @@ -1,10 +1,10 @@ { - "Name": "SmartCursor", + "Name": "Smart Cursor", "Author": "stokastic", "Version": "1.1.0", "Description": "Allows smart targeting of adjacent 8 tiles", "UniqueID": "stokastic.SmartCursor", "EntryDll": "SmartCursor.dll", - "MinimumApiVersion": "2.7", + "MinimumApiVersion": "2.10.1", "UpdateKeys": [ "Nexus:2458" ] } \ No newline at end of file