unitframes: option to fade health to custom color

This commit is contained in:
shagu
2021-12-13 03:20:28 +01:00
parent c38a55a89e
commit a4796e6c85
3 changed files with 15 additions and 0 deletions
+2
View File
@@ -191,6 +191,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", nil, "pastel", "1")
pfUI:UpdateConfig("unitframes", nil, "custom", "0")
pfUI:UpdateConfig("unitframes", nil, "customfullhp", "0")
pfUI:UpdateConfig("unitframes", nil, "customfade", "0")
pfUI:UpdateConfig("unitframes", nil, "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", nil, "custombg", "0")
pfUI:UpdateConfig("unitframes", nil, "custombgcolor", ".5,.2,.2,1")
@@ -451,6 +452,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", unit, "defcolor", "1")
pfUI:UpdateConfig("unitframes", unit, "custom", "0")
pfUI:UpdateConfig("unitframes", unit, "customfullhp", "0")
pfUI:UpdateConfig("unitframes", unit, "customfade", "0")
pfUI:UpdateConfig("unitframes", unit, "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", unit, "custombg", "0")
pfUI:UpdateConfig("unitframes", unit, "custombgcolor", ".5,.2,.2,1")
+11
View File
@@ -1800,6 +1800,7 @@ function pfUI.uf:RefreshUnit(unit, component)
local custom_active = nil
local customfullhp = unit.config.defcolor == "0" and unit.config.customfullhp or C.unitframes.customfullhp
local customcolor = unit.config.defcolor == "0" and unit.config.customcolor or C.unitframes.customcolor
local customfade = unit.config.defcolor == "0" and unit.config.customfade or C.unitframes.customfade
local custom = unit.config.defcolor == "0" and unit.config.custom or C.unitframes.custom
local r, g, b, a = .2, .2, .2, 1
@@ -1839,6 +1840,16 @@ function pfUI.uf:RefreshUnit(unit, component)
r, g, b = (r + .5) * .5, (g + .5) * .5, (b + .5) * .5
end
if customfade == "1" then
-- fade custom color into default color
local perc = UnitHealth(unitstr) / UnitHealthMax(unitstr) * 2 - 1
local cr, cg, cb, ca = pfUI.api.strsplit(",", customcolor)
r = (cr*perc) + (r*(1-perc))
g = (cr*perc) + (g*(1-perc))
b = (cr*perc) + (b*(1-perc))
end
unit.hp.bar:SetStatusBarColor(r, g, b, a)
-- set powerbar color
+2
View File
@@ -1607,6 +1607,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(nil, T["Enable Pastel Colors"], C.unitframes, "pastel", "checkbox")
CreateConfig(nil, T["Health Bar Color"], C.unitframes, "custom", "dropdown", pfUI.gui.dropdowns.uf_color)
CreateConfig(nil, T["Custom Health Bar Color"], C.unitframes, "customcolor", "color")
CreateConfig(nil, T["Fade To Custom Color"], C.unitframes, "customfade", "checkbox")
CreateConfig(nil, T["Use Custom Color On Full Health"], C.unitframes, "customfullhp", "checkbox")
CreateConfig(nil, T["Enable Custom Color Health Bar Background"], C.unitframes, "custombg", "checkbox")
CreateConfig(nil, T["Custom Health Bar Background Color"], C.unitframes, "custombgcolor", "color")
@@ -1797,6 +1798,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(U[c], T["Inherit Default Colors"], C.unitframes[c], "defcolor", "checkbox")
CreateConfig(U[c], T["Health Bar Color"], C.unitframes[c], "custom", "dropdown", pfUI.gui.dropdowns.uf_color)
CreateConfig(U[c], T["Custom Health Bar Color"], C.unitframes[c], "customcolor", "color")
CreateConfig(U[c], T["Fade To Custom Color"], C.unitframes[c], "customfade", "checkbox")
CreateConfig(U[c], T["Use Custom Color On Full Health"], C.unitframes[c], "customfullhp", "checkbox")
CreateConfig(U[c], T["Custom Health Bar Background Color"], C.unitframes[c], "custombgcolor", "color")
CreateConfig(U[c], T["Use Custom Color Health Bar Background"], C.unitframes[c], "custombg", "checkbox")