/// <summary> /// Shows a tooltip with the given item info. /// </summary> /// <param name="info">Info.</param> /// <param name="widget">Widget.</param> public static void ShowTooltip(UIItemInfo info, UIWidget widget) { if (info == null) { return; } // Set the title and description RnMUI_Tooltip.SetTitle(info.Name); RnMUI_Tooltip.SetDescription(info.Description); // Item types RnMUI_Tooltip.AddAttribute(info.Type, ""); RnMUI_Tooltip.AddAttribute(info.Subtype, ""); if (info.ItemType == 1) { RnMUI_Tooltip.AddAttribute(info.Damage.ToString(), " Damage"); RnMUI_Tooltip.AddAttribute(info.AttackSpeed.ToString("0.0"), " Attack speed"); RnMUI_Tooltip.AddAttribute_SingleColumn("(" + ((float)info.Damage / info.AttackSpeed).ToString("0.0") + " damage per second)", ""); } else { RnMUI_Tooltip.AddAttribute(info.Block.ToString(), " Block"); RnMUI_Tooltip.AddAttribute(info.Armor.ToString(), " Armor"); } RnMUI_Tooltip.AddAttribute_SingleColumn("", "+" + info.Stamina.ToString() + " Stamina", new RectOffset(0, 0, 7, 0)); RnMUI_Tooltip.AddAttribute_SingleColumn("", "+" + info.Strength.ToString() + " Strength"); // Set the tooltip position RnMUI_Tooltip.SetPosition(widget); // Show the tooltip RnMUI_Tooltip.Show(); }
/// <summary> /// Raises the tooltip event. /// </summary> /// <param name="show">If set to <c>true</c> show.</param> public override void OnTooltip(bool show) { if (show && this.IsAssigned()) { // Set the title and description RnMUI_Tooltip.SetTitle(this.spellInfo.Name); RnMUI_Tooltip.SetDescription(this.spellInfo.Description); if (this.spellInfo.Flags.Has(UISpellInfo_Flags.Passive)) { RnMUI_Tooltip.AddAttribute("Passive", ""); } else { // Power consumption if (this.spellInfo.PowerCost > 0f) { if (this.spellInfo.Flags.Has(UISpellInfo_Flags.PowerCostInPct)) { RnMUI_Tooltip.AddAttribute(this.spellInfo.PowerCost.ToString("0") + "%", " Energy"); } else { RnMUI_Tooltip.AddAttribute(this.spellInfo.PowerCost.ToString("0"), " Energy"); } } // Range if (this.spellInfo.Range > 0f) { if (this.spellInfo.Range == 1f) { RnMUI_Tooltip.AddAttribute("Melee range", ""); } else { RnMUI_Tooltip.AddAttribute(this.spellInfo.Range.ToString("0"), " yd range"); } } // Cast time if (this.spellInfo.CastTime == 0f) { RnMUI_Tooltip.AddAttribute("Instant", ""); } else { RnMUI_Tooltip.AddAttribute(this.spellInfo.CastTime.ToString("0.0"), " sec cast"); } // Cooldown if (this.spellInfo.Cooldown > 0f) { RnMUI_Tooltip.AddAttribute(this.spellInfo.Cooldown.ToString("0.0"), " sec cooldown"); } } // Set the tooltip position RnMUI_Tooltip.SetPosition(this.iconSprite as UIWidget); // Show the tooltip RnMUI_Tooltip.Show(); // Prevent hide return; } // Default hide RnMUI_Tooltip.Hide(); }