unitframes: add option for custom power colors

This commit is contained in:
shagu
2019-04-19 17:38:51 +02:00
parent 902f8430cd
commit 77460e0134
3 changed files with 85 additions and 12 deletions
+49
View File
@@ -170,6 +170,11 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", nil, "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", nil, "custombg", "0")
pfUI:UpdateConfig("unitframes", nil, "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", nil, "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", nil, "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", nil, "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", nil, "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5")
pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1")
pfUI:UpdateConfig("unitframes", nil, "always2dportrait", "0")
@@ -251,6 +256,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "player", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "player", "custombg", "0")
pfUI:UpdateConfig("unitframes", "player", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "player", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "player", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "player", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "player", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "target", "visible", "1")
pfUI:UpdateConfig("unitframes", "target", "showPVP", "0")
@@ -304,6 +313,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "target", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "target", "custombg", "0")
pfUI:UpdateConfig("unitframes", "target", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "target", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "target", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "target", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "target", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "focus", "visible", "1")
pfUI:UpdateConfig("unitframes", "focus", "showPVP", "0")
@@ -356,6 +369,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "focus", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "focus", "custombg", "0")
pfUI:UpdateConfig("unitframes", "focus", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "focus", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "focus", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "focus", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "focus", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "group", "visible", "1")
pfUI:UpdateConfig("unitframes", "group", "showPVP", "0")
@@ -409,6 +426,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "group", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "group", "custombg", "0")
pfUI:UpdateConfig("unitframes", "group", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "group", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "group", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "group", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "group", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "visible", "1")
pfUI:UpdateConfig("unitframes", "grouptarget", "showPVP", "0")
@@ -461,6 +482,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "grouptarget", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "custombg", "0")
pfUI:UpdateConfig("unitframes", "grouptarget", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "grouptarget", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "grouppet", "visible", "1")
pfUI:UpdateConfig("unitframes", "grouppet", "showPVP", "0")
@@ -513,6 +538,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "grouppet", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "grouppet", "custombg", "0")
pfUI:UpdateConfig("unitframes", "grouppet", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "grouppet", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "grouppet", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "grouppet", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "grouppet", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "raid", "visible", "1")
pfUI:UpdateConfig("unitframes", "raid", "showPVP", "0")
@@ -565,6 +594,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "raid", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "raid", "custombg", "0")
pfUI:UpdateConfig("unitframes", "raid", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "raid", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "raid", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "raid", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "raid", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "ttarget", "visible", "1")
pfUI:UpdateConfig("unitframes", "ttarget", "showPVP", "0")
@@ -617,6 +650,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "ttarget", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "ttarget", "custombg", "0")
pfUI:UpdateConfig("unitframes", "ttarget", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "ttarget", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "ttarget", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "ttarget", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "ttarget", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "pet", "visible", "1")
pfUI:UpdateConfig("unitframes", "pet", "showPVP", "0")
@@ -669,6 +706,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "pet", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "pet", "custombg", "0")
pfUI:UpdateConfig("unitframes", "pet", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "pet", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "pet", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "pet", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "pet", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "ptarget", "visible", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "showPVP", "0")
@@ -721,6 +762,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "ptarget", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "ptarget", "custombg", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "ptarget", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "ptarget", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "ptarget", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "ptarget", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("unitframes", "fallback", "visible", "1")
pfUI:UpdateConfig("unitframes", "fallback", "showPVP", "0")
@@ -773,6 +818,10 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "fallback", "customcolor", ".2,.2,.2,1")
pfUI:UpdateConfig("unitframes", "fallback", "custombg", "0")
pfUI:UpdateConfig("unitframes", "fallback", "custombgcolor", ".5,.2,.2,1")
pfUI:UpdateConfig("unitframes", "fallback", "manacolor", ".5,.5,1,1")
pfUI:UpdateConfig("unitframes", "fallback", "energycolor", "1,1,.5,1")
pfUI:UpdateConfig("unitframes", "fallback", "ragecolor", "1,.5,.5,1")
pfUI:UpdateConfig("unitframes", "fallback", "focuscolor", "1,1,.75,1")
pfUI:UpdateConfig("bars", "bar1", "pageable", "1")
pfUI:UpdateConfig("bars", "bar2", "pageable", "1")
+20 -6
View File
@@ -1495,13 +1495,13 @@ function pfUI.uf:RefreshUnit(unit, component)
end
end
local r, g, b, a = .2, .2, .2, 1
-- set healthbar color
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 custom = unit.config.defcolor == "0" and unit.config.custom or C.unitframes.custom
local r, g, b, a = .2, .2, .2, 1
if customfullhp == "1" and UnitHealth(unitstr) == UnitHealthMax(unitstr) then
r, g, b, a = pfUI.api.strsplit(",", customcolor)
custom_active = true
@@ -1540,10 +1540,24 @@ function pfUI.uf:RefreshUnit(unit, component)
unit.hp.bar:SetStatusBarColor(r, g, b, a)
local p = ManaBarColor[UnitPowerType(unitstr)]
local pr, pg, pb = 0, 0, 0
if p then pr, pg, pb = p.r + .5, p.g +.5, p.b +.5 end
unit.power.bar:SetStatusBarColor(pr, pg, pb)
-- set powerbar color
local mana = unit.config.defcolor == "0" and unit.config.manacolor or C.unitframes.manacolor
local rage = unit.config.defcolor == "0" and unit.config.ragecolor or C.unitframes.ragecolor
local energy = unit.config.defcolor == "0" and unit.config.energycolor or C.unitframes.energycolor
local focus = unit.config.defcolor == "0" and unit.config.focuscolor or C.unitframes.focuscolor
local r, g, b, a = .5, .5, .5, 1
local utype = UnitPowerType(unitstr)
if utype == 0 then
r, g, b, a = pfUI.api.strsplit(",", mana)
elseif utype == 1 then
r, g, b, a = pfUI.api.strsplit(",", rage)
elseif utype == 2 then
r, g, b, a = pfUI.api.strsplit(",", focus)
elseif utype == 3 then
r, g, b, a = pfUI.api.strsplit(",", energy)
end
unit.power.bar:SetStatusBarColor(r, g, b, a)
if UnitName(unitstr) then
unit.hpLeftText:SetText(pfUI.uf:GetStatusValue(unit, "hpleft"))
+16 -6
View File
@@ -1415,12 +1415,6 @@ pfUI:RegisterModule("gui", 20400, function ()
CreateGUIEntry(T["Unit Frames"], T["General"], function()
CreateConfig(nil, T["Disable pfUI Unit Frames"], C.unitframes, "disable", "checkbox")
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["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")
CreateConfig(nil, T["Healthbar Animation Speed"], C.unitframes, "animation_speed", "dropdown", pfUI.gui.dropdowns.uf_animationspeed)
CreateConfig(nil, T["Portrait Alpha"], C.unitframes, "portraitalpha")
CreateConfig(nil, T["Always Use 2D Portraits"], C.unitframes, "always2dportrait", "checkbox")
@@ -1432,6 +1426,18 @@ pfUI:RegisterModule("gui", 20400, function ()
CreateConfig(nil, T["Abbreviate Numbers (4200 -> 4.2k)"], C.unitframes, "abbrevnum", "checkbox")
CreateConfig(nil, T["Show Resting"], C.unitframes.player, "showRest", "checkbox")
CreateConfig(nil, T["Enable Energy Ticks"], C.unitframes.player, "energy", "checkbox")
CreateConfig(U[c], T["Colors"], nil, nil, "header")
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["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")
CreateConfig(nil, T["Mana Color"], C.unitframes, "manacolor", "color")
CreateConfig(nil, T["Rage Color"], C.unitframes, "ragecolor", "color")
CreateConfig(nil, T["Energy Color"], C.unitframes, "energycolor", "color")
CreateConfig(nil, T["Focus Color"], C.unitframes, "focuscolor", "color")
end)
CreateGUIEntry(T["Group Frames"], T["General"], function()
@@ -1554,6 +1560,10 @@ pfUI:RegisterModule("gui", 20400, function ()
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")
CreateConfig(U[c], T["Mana Color"], C.unitframes[c], "manacolor", "color")
CreateConfig(U[c], T["Rage Color"], C.unitframes[c], "ragecolor", "color")
CreateConfig(U[c], T["Energy Color"], C.unitframes[c], "energycolor", "color")
CreateConfig(U[c], T["Focus Color"], C.unitframes[c], "focuscolor", "color")
end)
end
end