From 9096ce59b900ea460bcb482038000abae2f8187b Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Tue, 7 Mar 2023 22:57:15 +0530 Subject: [PATCH] bug fix in snapping mouse to primary and secondary inventory slots --- .../Patches/GameMenuPatches/CraftingPagePatch.cs | 16 ++++++++-------- stardew-access/Patches/ItemGrabMenuPatch.cs | 12 ++++++------ stardew-access/Patches/ShopMenuPatch.cs | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/stardew-access/Patches/GameMenuPatches/CraftingPagePatch.cs b/stardew-access/Patches/GameMenuPatches/CraftingPagePatch.cs index f9c5180..59e6140 100644 --- a/stardew-access/Patches/GameMenuPatches/CraftingPagePatch.cs +++ b/stardew-access/Patches/GameMenuPatches/CraftingPagePatch.cs @@ -43,20 +43,20 @@ namespace stardew_access.Patches private static void handleKeyBinds(CraftingPage __instance, int ___currentCraftingPage) { - if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) - { - // snap to first inventory slot - __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); - __instance.inventory.inventory[0].snapMouseCursorToCenter(); - currentSelectedCraftingRecipe = -1; - } - else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count > 0) + if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count > 0) { // snap to first crafting recipe __instance.setCurrentlySnappedComponentTo(__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.myID); __instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.snapMouseCursorToCenter(); currentSelectedCraftingRecipe = 0; } + else if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) + { + // snap to first inventory slot + __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); + __instance.inventory.inventory[0].snapMouseCursorToCenter(); + currentSelectedCraftingRecipe = -1; + } else if (MainClass.Config.CraftingMenuCycleThroughRecipiesKey.JustPressed() && !isSelectingRecipe) { isSelectingRecipe = true; diff --git a/stardew-access/Patches/ItemGrabMenuPatch.cs b/stardew-access/Patches/ItemGrabMenuPatch.cs index 664d810..1948491 100644 --- a/stardew-access/Patches/ItemGrabMenuPatch.cs +++ b/stardew-access/Patches/ItemGrabMenuPatch.cs @@ -14,16 +14,16 @@ namespace stardew_access.Patches { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) - { - __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); - __instance.inventory.inventory[0].snapMouseCursorToCenter(); - } - else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) + if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) { __instance.setCurrentlySnappedComponentTo(__instance.ItemsToGrabMenu.inventory[0].myID); __instance.ItemsToGrabMenu.inventory[0].snapMouseCursorToCenter(); } + else if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) + { + __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); + __instance.inventory.inventory[0].snapMouseCursorToCenter(); + } #region Narrate buttons in the menu if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) diff --git a/stardew-access/Patches/ShopMenuPatch.cs b/stardew-access/Patches/ShopMenuPatch.cs index 4f565a9..8da8b11 100644 --- a/stardew-access/Patches/ShopMenuPatch.cs +++ b/stardew-access/Patches/ShopMenuPatch.cs @@ -14,16 +14,16 @@ namespace stardew_access.Patches { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) - { - __instance.inventory.inventory[0].snapMouseCursorToCenter(); - __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); - } - else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.forSaleButtons.Count > 0) + if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.forSaleButtons.Count > 0) { __instance.forSaleButtons[0].snapMouseCursorToCenter(); __instance.setCurrentlySnappedComponentTo(__instance.forSaleButtons[0].myID); } + else if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) + { + __instance.inventory.inventory[0].snapMouseCursorToCenter(); + __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); + } #region Narrate buttons in the menu if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y))