public static void Prefix(SpriteBatch b, ref string hoverText, ref string hoverTitle, Item hoveredItem, ref int healAmountToDisplay, ref int currencySymbol, ref int moneyAmountToShowAtBottom) { ItemTooltipEvent theEvent = new ItemTooltipEvent(b, hoveredItem, hoverTitle, hoverText, healAmountToDisplay, currencySymbol, moneyAmountToShowAtBottom); BookcaseEvents.OnItemTooltip.Post(theEvent); hoverTitle = theEvent.Title; hoverText = theEvent.Description; healAmountToDisplay = theEvent.HealAmount; currencySymbol = theEvent.CurrencySymbol; moneyAmountToShowAtBottom = theEvent.MoneyToShow; }
// This method is an event listener. It will be called when an item tooltip is rendered. // The ItemTooltipEvent parameter contains the original tooltip data. public void OnItemTooltip(ItemTooltipEvent evt) { // Check if the item is not null. Also checks if the tooltip already has price info. // In this case, -1 means there is no price data in the tooltip. if (evt.Item != null && evt.MoneyToShow == -1) { // Uses bookcase's ItemUtils to get the price of the item. int price = ItemUtils.GetSellPrice(evt.Item, true); // Checks if the item actually has a sell value. if (price > 0) { // Changes the amount of money shown on the tooltip to reflect the price. // The money symbol graphic is already part of the vanilla tooltip. It's normally just disabled (-1). // By changing this value to something greater than 0, the info becomes visible. evt.MoneyToShow = price; } } }