70 lines
2.3 KiB
Lua
70 lines
2.3 KiB
Lua
local NanamiDPS = NanamiDPS
|
|
local DataStore = NanamiDPS.DataStore
|
|
local L = NanamiDPS.L
|
|
|
|
local Tooltip = {}
|
|
NanamiDPS.Tooltip = Tooltip
|
|
|
|
function Tooltip:ShowBar(bar, window)
|
|
if not bar or not bar.barData then return end
|
|
local data = bar.barData
|
|
local moduleName = window.activeModuleName
|
|
local mod = NanamiDPS.modules[moduleName]
|
|
|
|
GameTooltip:SetOwner(bar, "ANCHOR_RIGHT")
|
|
|
|
if mod and mod.GetTooltip then
|
|
local seg = DataStore:GetSegment(window.segmentIndex or 1)
|
|
mod:GetTooltip(data.id or data.name, seg, GameTooltip)
|
|
else
|
|
GameTooltip:AddLine(data.name or L["Unknown"])
|
|
if data.value then
|
|
GameTooltip:AddDoubleLine("|cffffffff" .. L["Total Amount"], "|cffffffff" .. NanamiDPS.formatNumber(data.value))
|
|
end
|
|
if data.perSecond then
|
|
GameTooltip:AddDoubleLine("|cffffffff" .. L["Per Second"], "|cffffffff" .. NanamiDPS.round(data.perSecond, 1))
|
|
end
|
|
end
|
|
|
|
GameTooltip:AddLine(" ")
|
|
GameTooltip:AddLine("|cff888888" .. L["Click to view details"])
|
|
GameTooltip:Show()
|
|
end
|
|
|
|
function Tooltip:Hide()
|
|
GameTooltip:Hide()
|
|
end
|
|
|
|
function Tooltip:ShowSpellDetail(playerName, spells, effectiveSpells, totalSum, effectiveSum, tooltip)
|
|
tooltip = tooltip or GameTooltip
|
|
|
|
if not spells then return end
|
|
|
|
tooltip:AddLine(" ")
|
|
tooltip:AddLine("|cffffd100" .. L["Details"] .. ":")
|
|
|
|
local sorted = {}
|
|
for spell, amount in pairs(spells) do
|
|
table.insert(sorted, { spell = spell, amount = amount })
|
|
end
|
|
table.sort(sorted, function(a, b) return a.amount > b.amount end)
|
|
|
|
for _, entry in ipairs(sorted) do
|
|
local pct = totalSum > 0 and NanamiDPS.round(entry.amount / totalSum * 100, 1) or 0
|
|
local rightStr
|
|
|
|
if effectiveSpells and effectiveSpells[entry.spell] then
|
|
local eff = effectiveSpells[entry.spell]
|
|
local overheal = entry.amount - eff
|
|
rightStr = string.format("|cffcc8888+%s |cffffffff%s (%.1f%%)",
|
|
NanamiDPS.formatNumber(overheal),
|
|
NanamiDPS.formatNumber(eff), pct)
|
|
else
|
|
rightStr = string.format("|cffffffff%s (%.1f%%)",
|
|
NanamiDPS.formatNumber(entry.amount), pct)
|
|
end
|
|
|
|
tooltip:AddDoubleLine("|cffffffff" .. entry.spell, rightStr)
|
|
end
|
|
end
|