private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); var shouldDisplay = newItemIndex == itemDef.itemIndex && newItemCount > 0; var fillIcon = self.GetComponent <MysticsItemsSuperIdolHUDIcon>(); if (shouldDisplay != fillIcon) { if (shouldDisplay) { var itemInventoryDisplay = self.GetComponentInParent <ItemInventoryDisplay>(); if (itemInventoryDisplay && itemInventoryDisplay.inventory) { var master = itemInventoryDisplay.inventory.GetComponent <CharacterMaster>(); if (master) { fillIcon = self.gameObject.AddComponent <MysticsItemsSuperIdolHUDIcon>(); fillIcon.master = master; fillIcon.fillAmount = CalculateIdolBonus(master, newItemCount); } } } else { UnityEngine.Object.Destroy(fillIcon); fillIcon = null; } } if (shouldDisplay && fillIcon) { fillIcon.itemCount = newItemCount; fillIcon.UpdateTransform(); } }
private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); var itemDef = ItemCatalog.GetItemDef(newItemIndex); if (self.tooltipProvider != null && itemDef != null) { var itemDescription = !Language.IsTokenInvalid(itemDef.descriptionToken) ? Language.GetString(itemDef.descriptionToken) : Language.GetString(itemDef.pickupToken); itemDescription += "\n\n" + PickupStatProvider.ProvideItemStats(newItemIndex, newItemCount); self.tooltipProvider.overrideBodyText = itemDescription; } }
private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); if (newItemIndex == itemDef.itemIndex) { Transform parent = self.transform.parent; if (parent) { RoR2.UI.ItemInventoryDisplay itemInventoryDisplay = parent.GetComponent <RoR2.UI.ItemInventoryDisplay>(); if (itemInventoryDisplay && itemInventoryDisplay.inventory) { MysticsItemsManuscript manuscript = itemInventoryDisplay.inventory.GetComponent <MysticsItemsManuscript>(); if (manuscript) { globalStringBuilder.Clear(); globalStringBuilder.Append(Language.GetString(self.tooltipProvider.bodyToken) + "\r\n"); globalStringBuilder.Append("\r\n"); globalStringBuilder.Append(Language.GetString("MYSTICSITEMS_STATCHANGE_LIST_HEADER")); foreach (var buffType in manuscript.buffOrder) { globalStringBuilder.Append("\r\n"); globalStringBuilder.Append( Language.GetStringFormatted( "MYSTICSITEMS_STATCHANGE_LIST_" + buffType.ToString().ToUpperInvariant(), "+" + (manuscript.buffStacks[buffType] * statBonus).ToString(System.Globalization.CultureInfo.InvariantCulture) ) ); } globalStringBuilder.Append(tooltipString); self.tooltipProvider.overrideBodyText = globalStringBuilder.ToString(); globalStringBuilder.Clear(); } } } } else { if (!string.IsNullOrEmpty(self.tooltipProvider.overrideBodyText) && self.tooltipProvider.overrideBodyText.Contains(tooltipString)) { self.tooltipProvider.overrideBodyText = ""; } } }
private static void ItemIconSetItemIndexHook(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, ItemIcon self, ItemIndex newIndex, int newCount) { orig(self, newIndex, newCount); var itemDef = ItemCatalog.GetItemDef(newIndex); if (self.tooltipProvider != null && itemDef != null) { var itemDescription = Language.GetString(itemDef.descriptionToken); IconToMasterRef.TryGetValue(self, out var master); // TODO: use a pool to reduce StatContext allocations itemDescription += ItemStatsMod.GetStatsForItem(newIndex, newCount, new StatContext(master)); self.tooltipProvider.overrideBodyText = itemDescription; } }
private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); if (newItemIndex == itemDef.itemIndex) { Transform parent = self.transform.parent; if (parent) { RoR2.UI.ItemInventoryDisplay itemInventoryDisplay = parent.GetComponent <RoR2.UI.ItemInventoryDisplay>(); if (itemInventoryDisplay && itemInventoryDisplay.inventory) { MysticsItemsMysticSwordBehaviour swordBehaviour = itemInventoryDisplay.inventory.GetComponent <MysticsItemsMysticSwordBehaviour>(); if (swordBehaviour) { globalStringBuilder.Clear(); globalStringBuilder.Append(Language.GetString(self.tooltipProvider.bodyToken) + "\r\n"); globalStringBuilder.Append("\r\n"); globalStringBuilder.Append(Language.GetString("MYSTICSITEMS_STATCHANGE_LIST_HEADER")); globalStringBuilder.Append("\r\n"); globalStringBuilder.Append( Language.GetStringFormatted( "MYSTICSITEMS_STATCHANGE_LIST_DAMAGE", "+" + (Mathf.RoundToInt(swordBehaviour.damageBonus * 100f)).ToString(System.Globalization.CultureInfo.InvariantCulture) ) ); globalStringBuilder.Append(tooltipString); self.tooltipProvider.overrideBodyText = globalStringBuilder.ToString(); globalStringBuilder.Clear(); } } } } else { if (!string.IsNullOrEmpty(self.tooltipProvider.overrideBodyText) && self.tooltipProvider.overrideBodyText.Contains(tooltipString)) { self.tooltipProvider.overrideBodyText = ""; } } }
internal void SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex itemIndex, int itemCount) { orig(self, itemIndex, itemCount); self.tooltipProvider.bodyToken = ItemCatalog.GetItemDef(itemIndex).descriptionToken; }
private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); UpdatePickupTooltip(self, newItemIndex, newItemCount); }