From b85f04da4efe7d39665e94a1b97eff6255fa4707 Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 1 May 2020 20:23:20 +0200 Subject: [PATCH] unitframes: add option for timeleft on indicators --- api/config.lua | 1 + api/unitframes.lua | 15 ++++++++++++--- modules/gui.lua | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/api/config.lua b/api/config.lua index fae6fa15..782dc53f 100644 --- a/api/config.lua +++ b/api/config.lua @@ -205,6 +205,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "all_procs", "0") pfUI:UpdateConfig("unitframes", nil, "debuffs_class", "0") pfUI:UpdateConfig("unitframes", nil, "indicator_size", "10") + pfUI:UpdateConfig("unitframes", nil, "indicator_time", "1") pfUI:UpdateConfig("unitframes", nil, "clickcast", "") pfUI:UpdateConfig("unitframes", nil, "clickcast_shift", "") diff --git a/api/unitframes.lua b/api/unitframes.lua index 8e3df455..09b00791 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1689,8 +1689,10 @@ function pfUI.uf:ClickAction(button) end end -function pfUI.uf:AddIcon(frame, pos, icon, timeleft) +function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks) + local showtime = C.unitframes.indicator_time == "1" and true or nil local iconsize = tonumber(C.unitframes.indicator_size) + if not frame.hp then return end local frame = frame.hp.bar if pos > 6 or pos > ceil(frame:GetWidth() / iconsize) then return end @@ -1711,11 +1713,18 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft) frame.icon[i].cd = CreateFrame(COOLDOWN_FRAME_TYPE, nil, frame.icon[i]) frame.icon[i].cd.pfCooldownType = "ALL" frame.icon[i].cd:SetAlpha(0) + CreateBackdrop(frame.icon[i], nil, true) end end frame.icon[pos].tex:SetTexture(icon) - CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), (timeleft and timeleft < 100 and iconsize > 9 and timeleft or 0), 1) - pfUI.api.CreateBackdrop(frame.icon[pos], nil, true) + + -- show remaining time if config is set + if showtime and timeleft and timeleft < 100 and iconsize > 9 then + CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), timeleft, 1) + else + CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), 0, 1) + end + frame.icon[pos]:Show() end diff --git a/modules/gui.lua b/modules/gui.lua index 5a3e4a0b..4a2a0b7b 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1499,6 +1499,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(nil, T["Show Procs as Buff Indicators"], C.unitframes, "show_procs", "checkbox") CreateConfig(nil, T["Show Totems as Buff Indicators"], C.unitframes, "show_totems", "checkbox") CreateConfig(nil, T["Show Procs of all Classes"], C.unitframes, "all_procs", "checkbox") + CreateConfig(nil, T["Buff Indicator Show Time"], C.unitframes, "indicator_time", "checkbox") CreateConfig(nil, T["Buff Indicator Size"], C.unitframes, "indicator_size") CreateConfig(nil, T["Only Show Indicators for Dispellable Debuffs"], C.unitframes, "debuffs_class", "checkbox")