public override bool ShiftClickSlot(Item[] inventory, int context, int slot) { if ((context != ItemSlot.Context.InventoryItem && context != ItemSlot.Context.InventoryCoin && context != ItemSlot.Context.InventoryAmmo) || slot == 58) { return(false); } if (GenericBagUI.visible) { GenericHoldingBag bag = GenericBagUI.openBag; if (bag != null) { Item selected = inventory[slot]; int oldStack = selected.stack; bag.addItem(selected); if (selected.stack <= 0) { inventory[slot] = new Item(); } if (oldStack != selected.stack) { GenericBagUI.buildItem(); } return(true); } } return(base.ShiftClickSlot(inventory, context, slot)); }
private void ItemSlotHandle(Item itm, ref bool rebuild) { string itmTag = GenericHoldingBag.ItemToTag(itm); if (Main.mouseLeftRelease && Main.mouseLeft) { if (Main.mouseItem != null && Main.mouseItem.type != 0) { Item t = Main.mouseItem; openBag.addItem(t); if (t.stack == 0) { Main.mouseItem = new Item(); } rebuild = true; } else { if (itm != null && itm.type != 0 && openBag.items.ContainsKey(itmTag)) { if (ItemSlot.ShiftInUse) { if (withdrawItem(itm, ref rebuild)) { Recipe.FindRecipes(); } } else { int total = (int)Math.Min((long)(openBag.items[itmTag]), itm.maxStack); Main.mouseItem = itm.Clone(); Main.mouseItem.stack = total; long l = (long)(openBag.items[itmTag]) - total; openBag.items.Remove(itmTag); if (l > 0) { openBag.items[itmTag] = l; } else { openBag.items[itmTag] = 0L; itm.SetDefaults(0); rebuild = true; } } } } } else if (Main.stackSplit <= 1 && Main.mouseRight && (itm != null && itm.type != 0 && openBag.items.ContainsKey(itmTag))) { if (itm.maxStack >= 1 && (Main.mouseItem.IsTheSameAs(itm) || Main.mouseItem.type == 0) && (Main.mouseItem.stack < Main.mouseItem.maxStack || Main.mouseItem.type == 0)) { if (Main.mouseItem.type == 0) { Main.mouseItem = itm.Clone(); Main.mouseItem.stack = 0; } Main.mouseItem.stack++; long l = (long)(openBag.items[itmTag]) - 1; openBag.items.Remove(itmTag); if (l > 0) { openBag.items[itmTag] = l; } else { openBag.items[itmTag] = 0L; itm.SetDefaults(0); rebuild = true; } Recipe.FindRecipes(); Main.soundInstanceMenuTick.Stop(); Main.soundInstanceMenuTick = Main.soundMenuTick.CreateInstance(); Main.PlaySound(12, -1, -1, 1, 1f, 0f); if (Main.stackSplit == 0) { Main.stackSplit = 15; } else { Main.stackSplit = Main.stackDelay; } } } if (itm != null && itm.type != 0 && openBag.items.ContainsKey(itmTag)) { Main.hoverItemName = itm.HoverName; object hoverItemName = Main.hoverItemName; Main.hoverItemName = string.Concat(new object[] { hoverItemName, " (", "" + (openBag.items[itmTag]) + " left in the bag", ")" }); } else { } }