public override void receiveLeftClick(int x, int y, bool playSound = true) { if (isWithinBounds(x, y)) { Item clicked_item2 = inventory.getItemAt(x, y); if (clicked_item2 != null) { int clicked_index2 = inventory.getInventoryPositionOfClick(x, y); inventory.actualInventory[clicked_index2] = TryToPlace(clicked_item2, clicked_item2.Stack); } } if (ItemsToGrabMenu.isWithinBounds(x, y)) { Item clicked_item = ItemsToGrabMenu.getItemAt(x, y); if (clicked_item != null) { int clicked_index = ItemsToGrabMenu.getInventoryPositionOfClick(x, y); ItemsToGrabMenu.actualInventory[clicked_index] = TryToGrab(clicked_item, clicked_item.Stack); } } if (okButton.containsPoint(x, y) && readyToClose()) { exitThisMenu(); } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { Item old = heldItem; int oldStack = old?.Stack ?? (-1); if (isWithinBounds(x, y)) { base.receiveLeftClick(x, y, playSound: false); if (itemChangeBehavior == null && old == null && heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { heldItem = ItemsToGrabMenu.tryToAddItem(heldItem, "Ship"); } } bool sound = true; if (ItemsToGrabMenu.isWithinBounds(x, y)) { heldItem = ItemsToGrabMenu.leftClick(x, y, heldItem, playSound: false); if ((heldItem != null && old == null) || (heldItem != null && old != null && !heldItem.Equals(old))) { if (itemChangeBehavior != null) { sound = itemChangeBehavior(heldItem, ItemsToGrabMenu.getInventoryPositionOfClick(x, y), old, this, onRemoval: true); } if (sound) { Game1.playSound("dwop"); } } if ((heldItem == null && old != null) || (heldItem != null && old != null && !heldItem.Equals(old))) { Item tmp = heldItem; if (heldItem == null && ItemsToGrabMenu.getItemAt(x, y) != null && oldStack < ItemsToGrabMenu.getItemAt(x, y).Stack) { tmp = old.getOne(); tmp.Stack = oldStack; } if (itemChangeBehavior != null) { sound = itemChangeBehavior(old, ItemsToGrabMenu.getInventoryPositionOfClick(x, y), tmp, this); } if (sound) { Game1.playSound("Ship"); } } if (heldItem is Object && (bool)(heldItem as Object).isRecipe) { string recipeName = heldItem.Name.Substring(0, heldItem.Name.IndexOf("Recipe") - 1); try { if ((heldItem as Object).Category == -7) { Game1.player.cookingRecipes.Add(recipeName, 0); } else { Game1.player.craftingRecipes.Add(recipeName, 0); } poof = new TemporaryAnimatedSprite("TileSheets\\animations", new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2(x - x % 64 + 16, y - y % 64 + 16), flicker: false, flipped: false); Game1.playSound("newRecipe"); } catch (Exception) { } heldItem = null; } else if (Game1.oldKBState.IsKeyDown(Keys.LeftShift) && Game1.player.addItemToInventoryBool(heldItem)) { heldItem = null; if (itemChangeBehavior != null) { sound = itemChangeBehavior(heldItem, ItemsToGrabMenu.getInventoryPositionOfClick(x, y), old, this, onRemoval: true); } if (sound) { Game1.playSound("coin"); } } } if (okButton.containsPoint(x, y) && readyToClose()) { Game1.playSound("bigDeSelect"); Game1.exitActiveMenu(); } if (trashCan.containsPoint(x, y) && heldItem != null && heldItem.canBeTrashed()) { Utility.trashItem(heldItem); heldItem = null; } }