bug fix in snapping mouse to primary and secondary inventory slots

master
Mohammad Shoaib Khan 2023-03-07 22:57:15 +05:30
parent 6141447c13
commit 9096ce59b9
No known key found for this signature in database
GPG Key ID: D8040D966320B620
3 changed files with 20 additions and 20 deletions

View File

@ -43,20 +43,20 @@ namespace stardew_access.Patches
private static void handleKeyBinds(CraftingPage __instance, int ___currentCraftingPage) private static void handleKeyBinds(CraftingPage __instance, int ___currentCraftingPage)
{ {
if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.pagesOfCraftingRecipes[___currentCraftingPage].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)
{ {
// snap to first crafting recipe // snap to first crafting recipe
__instance.setCurrentlySnappedComponentTo(__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.myID); __instance.setCurrentlySnappedComponentTo(__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.myID);
__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.snapMouseCursorToCenter(); __instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.snapMouseCursorToCenter();
currentSelectedCraftingRecipe = 0; 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) else if (MainClass.Config.CraftingMenuCycleThroughRecipiesKey.JustPressed() && !isSelectingRecipe)
{ {
isSelectingRecipe = true; isSelectingRecipe = true;

View File

@ -14,16 +14,16 @@ namespace stardew_access.Patches
{ {
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin)
{
__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)
{ {
__instance.setCurrentlySnappedComponentTo(__instance.ItemsToGrabMenu.inventory[0].myID); __instance.setCurrentlySnappedComponentTo(__instance.ItemsToGrabMenu.inventory[0].myID);
__instance.ItemsToGrabMenu.inventory[0].snapMouseCursorToCenter(); __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 #region Narrate buttons in the menu
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))

View File

@ -14,16 +14,16 @@ namespace stardew_access.Patches
{ {
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.forSaleButtons.Count > 0)
{
__instance.inventory.inventory[0].snapMouseCursorToCenter();
__instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID);
}
else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.forSaleButtons.Count > 0)
{ {
__instance.forSaleButtons[0].snapMouseCursorToCenter(); __instance.forSaleButtons[0].snapMouseCursorToCenter();
__instance.setCurrentlySnappedComponentTo(__instance.forSaleButtons[0].myID); __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 #region Narrate buttons in the menu
if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y)) if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y))