diff --git a/api/config.lua b/api/config.lua index d4285e19..7e959a01 100644 --- a/api/config.lua +++ b/api/config.lua @@ -69,6 +69,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("buffbar", "pbuff", "dtypebg", "1") pfUI:UpdateConfig("buffbar", "pbuff", "dtypeborder", "0") pfUI:UpdateConfig("buffbar", "pbuff", "dtypetext", "0") + pfUI:UpdateConfig("buffbar", "pbuff", "colorstacks", "0") pfUI:UpdateConfig("buffbar", "pbuff", "width", "-1") pfUI:UpdateConfig("buffbar", "pbuff", "height", "20") pfUI:UpdateConfig("buffbar", "pbuff", "filter", "blacklist") @@ -85,6 +86,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("buffbar", "pdebuff", "dtypebg", "0") pfUI:UpdateConfig("buffbar", "pdebuff", "dtypeborder", "1") pfUI:UpdateConfig("buffbar", "pdebuff", "dtypetext", "0") + pfUI:UpdateConfig("buffbar", "pdebuff", "colorstacks", "0") pfUI:UpdateConfig("buffbar", "pdebuff", "width", "-1") pfUI:UpdateConfig("buffbar", "pdebuff", "height", "20") pfUI:UpdateConfig("buffbar", "pdebuff", "filter", "blacklist") @@ -101,6 +103,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("buffbar", "tdebuff", "dtypebg", "0") pfUI:UpdateConfig("buffbar", "tdebuff", "dtypeborder", "1") pfUI:UpdateConfig("buffbar", "tdebuff", "dtypetext", "0") + pfUI:UpdateConfig("buffbar", "tdebuff", "colorstacks", "0") pfUI:UpdateConfig("buffbar", "tdebuff", "width", "-1") pfUI:UpdateConfig("buffbar", "tdebuff", "height", "20") pfUI:UpdateConfig("buffbar", "tdebuff", "filter", "blacklist") diff --git a/modules/buffwatch.lua b/modules/buffwatch.lua index 17d00fa9..89eb808e 100644 --- a/modules/buffwatch.lua +++ b/modules/buffwatch.lua @@ -236,6 +236,8 @@ pfUI:RegisterModule("buffwatch", function () and data[3] and data[3] ~= "" -- buff has a name and data[4] and data[4] ~= "" -- buff has a texture then + local uuid = data[4] .. data[3] -- we use that to cache some values for buffs + -- update bar data frame.bars[bar] = frame.bars[bar] or CreateStatusBar(bar, frame) frame.bars[bar].id = data[2] @@ -245,11 +247,16 @@ pfUI:RegisterModule("buffwatch", function () -- update max duration the cached remaining values is less than -- the real one, indicates a buff renewal - frame.durations[data[4]] = frame.durations[data[4]] or {} - if not frame.durations[data[4]][1] or frame.durations[data[4]][1] < data[1] then - frame.durations[data[4]][2] = data[1] -- max + frame.durations[uuid] = frame.durations[uuid] or {} + if not frame.durations[uuid][1] or frame.durations[uuid][1] < data[1] then + frame.durations[uuid][2] = data[1] -- max + end + frame.durations[uuid][1] = data[1] -- current + + -- cache max stacks for the buff + if not frame.charges[uuid] or frame.charges[uuid] < data[5] then + frame.charges[uuid] = data[5] end - frame.durations[data[4]][1] = data[1] -- current -- set name if frame.bars[bar].cacheName ~= data[3] then @@ -291,13 +298,26 @@ pfUI:RegisterModule("buffwatch", function () end -- cache maxduration - if frame.bars[bar].cacheMaxDuration ~= frame.durations[data[4]][2] then - frame.bars[bar].cacheMaxDuration = frame.durations[data[4]][2] - frame.bars[bar].bar:SetMinMaxValues(0, frame.durations[data[4]][2]) + if frame.bars[bar].cacheMaxDuration ~= frame.durations[uuid][2] then + frame.bars[bar].cacheMaxDuration = frame.durations[uuid][2] + frame.bars[bar].bar:SetMinMaxValues(0, frame.durations[uuid][2]) end + -- set stacks if data[5] > 1 then - frame.bars[bar].stacks:SetText(data[5]) + local stacks_percentage = data[5] / (frame.charges[uuid] * .01) + if stacks_percentage >= 90 then + sr, sg, sb, sa = .3, 1, .3, 1 + elseif stacks_percentage >= 60 then + sr, sg, sb, sa = 1, 1, .3, 1 + elseif stacks_percentage >= 0 then + sr, sg, sb, sa = 1, .3, .3, 1 + end + if frame.config.colorstacks == "1" then + frame.bars[bar].stacks:SetText("|cff" .. string.format("%02x%02x%02x", sr*255, sg*255, sb*255) .. data[5]) + else + frame.bars[bar].stacks:SetText(data[5]) + end else frame.bars[bar].stacks:SetText("") end @@ -345,6 +365,7 @@ pfUI:RegisterModule("buffwatch", function () frame.type = type frame.bars = { } frame.durations = { } + frame.charges = { } frame.buffs = { } for i=1,32 do frame.buffs[i] = { } diff --git a/modules/gui.lua b/modules/gui.lua index 00183106..b7a6ed00 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1174,6 +1174,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, T["Automatic Background Color"], C.buffbar.pbuff, "dtypebg", "checkbox") CreateConfig(nil, this, T["Automatic Border Color"], C.buffbar.pbuff, "dtypeborder", "checkbox") CreateConfig(nil, this, T["Automatic Text Color"], C.buffbar.pbuff, "dtypetext", "checkbox") + CreateConfig(nil, this, T["Color Buff Stacks"], C.buffbar.pbuff, "colorstacks", "checkbox") CreateConfig(nil, this, T["Buffbar Width"], C.buffbar.pbuff, "width") CreateConfig(nil, this, T["Buffbar Height"], C.buffbar.pbuff, "height") CreateConfig(nil, this, T["Filter Mode"], C.buffbar.pbuff, "filter", "dropdown", pfUI.gui.dropdowns.buffbarfilter) @@ -1191,6 +1192,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, T["Automatic Background Color"], C.buffbar.pdebuff, "dtypebg", "checkbox") CreateConfig(nil, this, T["Automatic Border Color"], C.buffbar.pdebuff, "dtypeborder", "checkbox") CreateConfig(nil, this, T["Automatic Text Color"], C.buffbar.pdebuff, "dtypetext", "checkbox") + CreateConfig(nil, this, T["Color Debuff Stacks"], C.buffbar.pdebuff, "colorstacks", "checkbox") CreateConfig(nil, this, T["Buffbar Width"], C.buffbar.pdebuff, "width") CreateConfig(nil, this, T["Buffbar Height"], C.buffbar.pdebuff, "height") CreateConfig(nil, this, T["Filter Mode"], C.buffbar.pdebuff, "filter", "dropdown", pfUI.gui.dropdowns.buffbarfilter) @@ -1208,6 +1210,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, T["Automatic Background Color"], C.buffbar.tdebuff, "dtypebg", "checkbox") CreateConfig(nil, this, T["Automatic Border Color"], C.buffbar.tdebuff, "dtypeborder", "checkbox") CreateConfig(nil, this, T["Automatic Text Color"], C.buffbar.tdebuff, "dtypetext", "checkbox") + CreateConfig(nil, this, T["Color Debuff Stacks"], C.buffbar.tdebuff, "colorstacks", "checkbox") CreateConfig(nil, this, T["Buffbar Width"], C.buffbar.tdebuff, "width") CreateConfig(nil, this, T["Buffbar Height"], C.buffbar.tdebuff, "height") CreateConfig(nil, this, T["Filter Mode"], C.buffbar.tdebuff, "filter", "dropdown", pfUI.gui.dropdowns.buffbarfilter)