From 3e7c0b0640691897126b97a9fc4fbf7c1a7621ea Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 1 May 2020 20:42:49 +0200 Subject: [PATCH] unitframes: add option to show indicator stacks --- api/config.lua | 3 ++- api/unitframes.lua | 19 ++++++++++++++++--- modules/gui.lua | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/api/config.lua b/api/config.lua index 782dc53f..df78547a 100644 --- a/api/config.lua +++ b/api/config.lua @@ -204,8 +204,9 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "show_totems", "0") 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, "indicator_stacks", "1") + pfUI:UpdateConfig("unitframes", nil, "indicator_size", "10") pfUI:UpdateConfig("unitframes", nil, "clickcast", "") pfUI:UpdateConfig("unitframes", nil, "clickcast_shift", "") diff --git a/api/unitframes.lua b/api/unitframes.lua index 09b00791..f50ae781 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1421,7 +1421,7 @@ function pfUI.uf:RefreshUnit(unit, component) local active = {} for i=1,32 do - local texture = UnitBuff(unitstr, i) + local texture, count = UnitBuff(unitstr, i) local timeleft, _ if pfUI.client > 11200 then _, _, texture, _, _, timeleft = _G.UnitBuff(unitstr, i) @@ -1431,7 +1431,7 @@ function pfUI.uf:RefreshUnit(unit, component) -- match filter for _, filter in pairs(pfUI.uf.buffs) do if filter == string.lower(texture) then - table.insert(active, { texture, timeleft }) + table.insert(active, { texture, timeleft, count }) break end end @@ -1440,7 +1440,7 @@ function pfUI.uf:RefreshUnit(unit, component) -- add icons for every found buff for pos, data in pairs(active) do - pfUI.uf:AddIcon(unit, pos, data[1], data[2]) + pfUI.uf:AddIcon(unit, pos, data[1], data[2], data[3]) end -- hide unused icon slots @@ -1691,6 +1691,7 @@ end function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks) local showtime = C.unitframes.indicator_time == "1" and true or nil + local showstacks = C.unitframes.indicator_stacks == "1" and true or nil local iconsize = tonumber(C.unitframes.indicator_size) if not frame.hp then return end @@ -1710,6 +1711,11 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks) frame.icon[i].tex:SetAllPoints(frame.icon[i]) frame.icon[i].tex:SetTexCoord(.08, .92, .08, .92) frame.icon[i].tex:SetAlpha(.7) + frame.icon[i].stacks = frame.icon[i]:CreateFontString(nil, "OVERLAY") + frame.icon[i].stacks:SetFont(pfUI.font_unit, math.max(iconsize/3, 10), "OUTLINE") + frame.icon[i].stacks:SetPoint("BOTTOMRIGHT", 0, 0) + frame.icon[i].stacks:SetJustifyH("RIGHT") + frame.icon[i].stacks:SetJustifyV("BOTTOM") frame.icon[i].cd = CreateFrame(COOLDOWN_FRAME_TYPE, nil, frame.icon[i]) frame.icon[i].cd.pfCooldownType = "ALL" frame.icon[i].cd:SetAlpha(0) @@ -1725,6 +1731,13 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks) CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), 0, 1) end + -- show stacks if config is set + if showstacks and stacks and stacks > 1 and iconsize > 9 then + frame.icon[pos].stacks:SetText(stacks) + else + frame.icon[pos].stacks:SetText("") + end + frame.icon[pos]:Show() end diff --git a/modules/gui.lua b/modules/gui.lua index 4a2a0b7b..bb9b2cd7 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1500,6 +1500,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () 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 Show Stacks"], C.unitframes, "indicator_stacks", "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")