local AceLocale = LibStub("AceLocale-3.0") local L = AceLocale:GetLocale( "Recount" ) local Epsilon=0.000000000000000001 local revision = tonumber(string.sub("$Revision: 1079 $", 12, -3)) local Recount = _G.Recount if Recount.Version < revision then Recount.Version = revision end local dbCombatants local pairs = pairs local math_floor = math.floor local table_sort = table.sort local tinsert = table.insert --.MainTitle = What you see on the window title --.TopNames = Names of the entries for the top data --.TopAmount = What we call the amount for the top --.BotNames = Names of the entries for the bottom --.BotMin = The minimum label for bottom --.BotAvg = The average label for bottom --.BotMax = The minimum label for bottom --.BotAmount = Label for what the amount is on the bottom local DetailTitles={} DetailTitles.Attacks={ TopNames = L["Ability Name"], TopCount = L["Count"], TopAmount = L["Damage"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.Resisted={ TopNames = L["Ability Name"], TopCount = L["Count"], TopAmount = L["Resisted"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.Blocked={ TopNames = L["Ability Name"], TopCount = "", TopAmount = L["Blocked"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.Absorbed={ TopNames = L["Ability Name"], TopCount = "", TopAmount = L["Absorbed"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.DamagedWho={ TopNames = L["Player/Mob Name"], TopCount = "", TopAmount = L["Damage"], BotNames = L["Attack Name"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Damage"] } DetailTitles.DamageTime={ TopNames = L["Player/Mob Name"], TopCount = "", TopAmount = L["Time (s)"], BotNames = L["Attack Name"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Time (s)"] } DetailTitles.Heals={ TopNames = L["Heal Name"], TopCount = L["Count"], TopAmount = L["Heal"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.HealedWho={ TopNames = L["Player/Mob Name"], TopCount = "", TopAmount = L["Healed"], BotNames = L["Heal Name"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Healed"] } DetailTitles.OverHeals={ TopNames = L["Heal Name"], TopCount = "", TopAmount = L["Overheal"], BotNames = L["Type"], BotMin = L["Min"], BotAvg = L["Avg"], BotMax = L["Max"], BotAmount = L["Count"] } DetailTitles.HealTime={ TopNames = L["Player/Mob Name"], TopCount = "", TopAmount = L["Time (s)"], BotNames = L["Heal Name"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Time (s)"] } DetailTitles.ActiveTime={ TopNames = L["Player/Mob Name"], TopCount = "", TopAmount = L["Time (s)"], BotNames = L["Ability"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Time (s)"] } DetailTitles.DOTs={ TopNames = L["Ability Name"], TopCount = "", TopAmount = L["DOT Time"], BotNames = L["Ticked on"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Duration"] } DetailTitles.HOTs={ TopNames = L["Ability Name"], TopCount = "", TopAmount = L["HOT Time"], BotNames = L["Ticked on"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Duration"] } DetailTitles.Network={ TopNames = L["Prefix"], TopCount = "", TopAmount = L["Messages"], BotNames = L["Distribution"], BotMin = "", BotAvg = "", BotMax = "", BotAmount = L["Messages"] } function Recount:MergedPetDamageDPS(data,fight) if not data or not data.Fights or not data.Fights[fight] then return 0,0 end local PetAmount=0 local PetTime=0 local Time=data.Fights[fight].ActiveTime or 0 if Recount.db.profile.MergePets and data.Pet then for v,k in pairs(data.Pet) do if dbCombatants[k] and dbCombatants[k].Fights and dbCombatants[k].Fights[fight] then if dbCombatants[k].Fights[fight].Damage and dbCombatants[k].Fights[fight].Damage > 0 then -- Ignore pets which didn't do any damage like non-damage totems or idle pets. PetAmount=PetAmount + (dbCombatants[k].Fights[fight].Damage or 0) if (dbCombatants[k].Fights[fight].ActiveTime or 0) > PetTime then PetTime = dbCombatants[k].Fights[fight].ActiveTime -- PetTime=PetTime + (dbCombatants[k].Fights[fight].ActiveTime or 0) end end end end if Time 0 then -- Ignore pets which didn't do any healing like non-healing totems or idle pets. PetAmount=PetAmount + (dbCombatants[k].Fights[fight].Healing or 0) if (dbCombatants[k].Fights[fight].ActiveTime or 0) > PetTime then PetTime = dbCombatants[k].Fights[fight].ActiveTime -- PetTime=PetTime + (dbCombatants[k].Fights[fight].ActiveTime or 0) end end end end if Timeb[2] then return true end return false end function Recount:AddSortedTooltipData(title,data,num) local SortedData=Recount:GetTable() GameTooltip:AddLine(title,1,0.82,0) local total=Epsilon local i=0 if data then for k,v in pairs(data) do if v.amount then i=i+1 if not SortedData[i] then SortedData[i]=Recount:GetTable() end SortedData[i][1]=k SortedData[i][2]=v.amount total=total+v.amount end end end if num>i then num=i end table_sort(SortedData,RecountSortFunc) for i=1,num do if SortedData[i] then GameTooltip:AddDoubleLine(i..". "..SortedData[i][1],SortedData[i][2].." ("..math_floor(100*SortedData[i][2]/total).."%)",1,1,1,1,1,1) end end Recount:FreeTableRecurse(SortedData) end --The various tooltip functions used for each of the main window data displays local TooltipFuncs={} function TooltipFuncs:Damage(name,data) if data then local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Damage Abilities"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].Attacks,3) GameTooltip:AddLine("") Recount:AddSortedTooltipData(L["Top 3"].." "..L["Attacked"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].DamagedWho,3) if Recount.db.profile.MergePets and data.Pet --[[and dbCombatants[data.Pet[table.getn(data.Pet)] ].Init]] then local petindex = #data.Pet local Damage while not Damage and petindex > 0 do Damage = data.Pet[petindex] and dbCombatants[data.Pet[petindex]] and dbCombatants[data.Pet[petindex]] and dbCombatants[data.Pet[petindex]].Fights and dbCombatants[data.Pet[petindex]].Fights[Recount.db.profile.CurDataSet] and dbCombatants[data.Pet[petindex]].Fights[Recount.db.profile.CurDataSet].Damage petindex = petindex - 1 end petindex = petindex + 1 if Damage then Damage=Damage/(Damage+(data.Fights[Recount.db.profile.CurDataSet].Damage or 0)) GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(L["Pet"]..":",data.Pet[petindex].." ("..math_floor(Damage*100+0.5).."%)",nil,nil,nil,1,1,1) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Pet Damage Abilities"],dbCombatants[data.Pet[petindex] ].Fights and dbCombatants[data.Pet[petindex] ].Fights[Recount.db.profile.CurDataSet].Attacks,3) GameTooltip:AddLine("") Recount:AddSortedTooltipData(L["Top 3"].." "..L["Pet Attacked"],dbCombatants[data.Pet[petindex] ].Fights and dbCombatants[data.Pet[petindex] ].Fights[Recount.db.profile.CurDataSet].DamagedWho,3) end end GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end end function TooltipFuncs:FDamage(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Friendly Attacks"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].FAttacks,3) GameTooltip:AddLine("") Recount:AddSortedTooltipData(L["Top 3"].." "..L["Friendly Fired On"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].FDamagedWho,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:DamageTaken(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Attacked by"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].WhoDamaged,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:Healing(name,data) if data then local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Heals"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].Heals,3) GameTooltip:AddLine("") Recount:AddSortedTooltipData(L["Top 3"].." "..L["Healed"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].HealedWho,3) if Recount.db.profile.MergePets and data.Pet --[[and dbCombatants[data.Pet[table.getn(data.Pet)] ].Init]] then local petindex = #data.Pet local Healing while not Healing and petindex > 0 do Healing = data.Pet[petindex] and dbCombatants[data.Pet[petindex]] and dbCombatants[data.Pet[petindex]] and dbCombatants[data.Pet[petindex]].Fights and dbCombatants[data.Pet[petindex]].Fights[Recount.db.profile.CurDataSet] and dbCombatants[data.Pet[petindex]].Fights[Recount.db.profile.CurDataSet].Healing petindex = petindex - 1 end petindex = petindex + 1 if Healing then Healing=Healing/(Healing+(data.Fights[Recount.db.profile.CurDataSet].Healing or 0)) GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(L["Pet"]..":",data.Pet[petindex].." ("..math_floor(Healing*100+0.5).."%)",nil,nil,nil,1,1,1) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Pet Healing Abilities"],dbCombatants[data.Pet[petindex] ].Fights and dbCombatants[data.Pet[petindex] ].Fights[Recount.db.profile.CurDataSet].Heals,3) GameTooltip:AddLine("") Recount:AddSortedTooltipData(L["Top 3"].." "..L["Pet Healed"],dbCombatants[data.Pet[petindex] ].Fights and dbCombatants[data.Pet[petindex] ].Fights[Recount.db.profile.CurDataSet].HealedWho,3) end end GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end end function TooltipFuncs:HealingTaken(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Healed By"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].WhoHealed,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:Overhealing(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Over Heals"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].OverHeals,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:DOTs(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["DOTs"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].DOTs,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:HOTs(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["HOTs"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].HOTs,3) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:ActiveTime(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) Recount:AddSortedTooltipData(L["Top 3"].." "..L["Attacked/Healed"],data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].TimeSpent,3) local Heal,Damage Heal=data and data.Fights[Recount.db.profile.CurDataSet].TimeHeal or 0 Damage=data and data.Fights[Recount.db.profile.CurDataSet].TimeDamage or 0 local Total=Heal+Damage+Epsilon Heal=100*Heal/Total Damage=100*Damage/Total GameTooltip:AddDoubleLine(L["Time Damaging"]..":",math_floor(Damage+0.5).."%",nil,nil,nil,1,1,1) GameTooltip:AddDoubleLine(L["Time Healing"]..":",math_floor(Heal+0.5).."%",nil,nil,nil,1,1,1) GameTooltip:AddLine("<"..L["Click for more Details"]..">",0,0.9,0) end function TooltipFuncs:DeathCounts(name,data) local SortedData,total GameTooltip:ClearLines() GameTooltip:AddLine(name) GameTooltip:Hide() end local MainWindowModes={ {L["Damage Done"],DataModes.DamageReturner,TooltipFuncs.Damage,nil,{"DAMAGE",L["'s DPS"]},nil,"Damage"}, {L["DPS"],DataModes.DPSReturner,TooltipFuncs.Damage,nil,{"DAMAGE","'s DPS"},nil,"Damage"}, {L["Friendly Fire"],DataModes.FriendlyDamageReturner,TooltipFuncs.FDamage}, {L["Damage Taken"],DataModes.DamageTakenReturner,TooltipFuncs.DamageTaken,nil,{"DAMAGETAKEN",L["'s DTPS"]},nil,"DamageTaken"}, {L["Healing Done"],DataModes.HealingReturner,TooltipFuncs.Healing,nil,{"HEALING",L["'s HPS"]},nil,"Healing"}, {L["Healing Taken"],DataModes.HealingTaken,TooltipFuncs.HealingTaken,nil,{"HEALINGTAKEN",L["'s HTPS"]},nil,"HealingTaken"}, {L["Overhealing Done"],DataModes.OverhealingReturner,TooltipFuncs.Overhealing}, {L["Deaths"],DataModes.DeathReturner,TooltipFuncs.DeathCounts}, {L["DOT Uptime"],DataModes.DOTReturner,TooltipFuncs.DOTs,nil,nil,nil,nil}, {L["HOT Uptime"],DataModes.HOTReturner,TooltipFuncs.HOTs,nil,nil,nil,nil}, {L["Activity"],DataModes.ActiveTime,TooltipFuncs.ActiveTime,nil,nil,nil,nil}, } function Recount:AddModeTooltip(lname,modefunc,toolfunc,...) tinsert(MainWindowModes,{lname,modefunc,toolfunc,...}) Recount:SetupMainWindow() end function Recount:SetupMainWindow() if Recount.LoadMainWindowData then -- If we add modes early no need to inform the main window, it will get set up later. Recount:LoadMainWindowData(MainWindowModes) end end function Recount:SetMainWindowModeByLabel(label) for k,v in pairs(Recount.MainWindowData) do if v[1] == L[label] then Recount:SetMainWindowMode(k) return end end end local oldlocalizer = Recount.LocalizeCombatants function Recount.LocalizeCombatants() dbCombatants = Recount.db2.combatants oldlocalizer() end