Skip to content

Commit 9906655

Browse files
committed
Add Death list to skull mouseover (will very likely be gone on midnight)
1 parent 51ec898 commit 9906655

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Display.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,24 @@ function MPT:UpdateKeyInfo(Full, Deaths, preview)
228228
F.KeyInfo.Icon:SetScript("OnEnter", function(Frame)
229229
local timelost = self:FormatTime(select(2,C_ChallengeMode.GetDeathCount())) or "0:00"
230230
local text = "Time lost: "..timelost
231+
local list = {}
232+
self.PlayerDeaths = self.PlayerDeaths or {}
233+
for unit, deaths in pairs(self.PlayerDeaths) do
234+
local color = GetClassColorObj(select(2, UnitClass(unit)))
235+
local name = NSAPI and NSAPI:Shorten(unit, 8) or color:WrapTextInColorCode(UnitName(unit))
236+
table.insert(list, {name, deaths})
237+
end
238+
table.sort(list,
239+
function(a, b)
240+
if a[2] == b[2] then -- sort by name if deathcount is equal
241+
return a[1] > b[1]
242+
else -- otherwise sort by death count
243+
return a[2] > b[2]
244+
end
245+
end)
246+
for _, v in ipairs(list) do
247+
text = text.."\n"..v[1].." "..v[2]
248+
end
231249
GameTooltip:SetOwner(Frame, "ANCHOR_CURSOR")
232250
GameTooltip:SetText(text)
233251
GameTooltip:Show()

EventHandler.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function MPT:EventHandler(e, ...) -- internal checks whether the event comes fro
107107
elseif e == "CHALLENGE_MODE_DEATH_COUNT_UPDATED" then
108108
self:UpdateKeyInfo(false, true)
109109
elseif e == "CHALLENGE_MODE_START" then
110+
self.PlayerDeaths = {}
110111
self:Init()
111112
self:ToggleEventRegister(true)
112113
elseif e == "CHALLENGE_MODE_COMPLETED" then
@@ -150,12 +151,19 @@ function MPT:EventHandler(e, ...) -- internal checks whether the event comes fro
150151
self:CreateMiniMapButton()
151152
elseif e == "COMBAT_LOG_EVENT_UNFILTERED" and C_ChallengeMode.IsChallengeModeActive() then
152153
if GetRestrictedActionStatus then return end -- disable for midnight. Edit this later when I know how the API works
153-
local _, se, _, _, _, _, _, destGUID = CombatLogGetCurrentEventInfo()
154+
local _, se, _, _, _, _, _, destGUID, destName = CombatLogGetCurrentEventInfo()
154155
if (se == "UNIT_DIED" or se == "UNIT_DESTROYED" or se == "UNIT_DISSIPATES") and destGUID then
155156
if self.CurrentPull and self.CurrentPull[destGUID] then
156157
self.CurrentPull[destGUID] = "DEAD"
157158
if not self.done then self:UpdateCurrentPull() end
158159
end
160+
if se == "UNIT_DIED" and destName and UnitIsPlayer(destName) then
161+
self.PlayerDeaths = self.PlayerDeaths or {}
162+
num = self.PlayerDeaths and self.PlayerDeaths[destName] or 0
163+
if UnitHealth(destName) == 0 then
164+
self.PlayerDeaths[destName] = num and num+1 or 1
165+
end
166+
end
159167
end
160168
elseif e == "UNIT_THREAT_LIST_UPDATE" and C_ChallengeMode.IsChallengeModeActive() and InCombatLockdown() then
161169
if GetRestrictedActionStatus then return end -- disable for midnight. Edit this later when I know how the API works

0 commit comments

Comments
 (0)