public override void receiveRightClick(int x, int y, bool playSound = true) { //this prevents the standard inventory right-click action (removal of attachments) and prevents the slingshot to be sold with attachments if (SlingshotChanges && inventory.getItemAt(x, y) is Slingshot slingshot && HasAmmunition(slingshot)) { Game1.playSound("cancel"); Game1.showRedMessage(ModFeature.GetTrans("menu.slingshotempty")); return; } base.receiveRightClick(x, y, playSound); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { Item item = inventory.getItemAt(x, y); //prevents the slingshot to be sold with attachments if (SlingshotChanges && item is Slingshot slingshot && HasAmmunition(slingshot)) { Game1.playSound("cancel"); Game1.showRedMessage(ModFeature.GetTrans("menu.slingshotempty")); return; } base.receiveLeftClick(x, y, playSound); }
public override void performHoverAction(int x, int y) { base.performHoverAction(x, y); Item heldItem = Helper.Reflection.GetField <Item>(this, "heldItem").GetValue(); bool scrolling = Helper.Reflection.GetField <bool>(this, "scrolling").GetValue(); if (!scrolling && heldItem == null && inventory.getItemAt(x, y) is Item item && HighlightItemToSell(item)) { Helper.Reflection.GetField <string>(this, "boldTitleText").SetValue(item.DisplayName); Helper.Reflection.GetField <string>(this, "hoverText").SetValue(item.getDescription()); Helper.Reflection.GetField <Item>(this, "hoveredItem").SetValue(item); if (item is Slingshot slingshot) { if (HasAmmunition(slingshot)) { Helper.Reflection.GetField <string>(this, "hoverText").SetValue(ModFeature.GetTrans("menu.slingshotempty")); } float sellPercentage = Helper.Reflection.GetField <float>(this, "sellPercentage").GetValue(); int sellToStorePrice = (int)((float)(slingshot.salePrice() / 2) * sellPercentage * slingshot.Stack); //Helper.Reflection.GetField<Item>(this, "hoveredItem").SetValue(item); Helper.Reflection.GetField <int>(this, "hoverPrice").SetValue(sellToStorePrice); } } }