local SPELL_POWER_HOLY_POWER = SPELL_POWER_HOLY_POWER
--update holy power
local updateHolyPower = function(self, event, unit, powerType)
if(self.unit ~= unit or (powerType and powerType ~= "HOLY_POWER")) then return end
local bar = self.HolyPowerBar
local num = UnitPower("player", SPELL_POWER_HOLY_POWER)
local maxHolyPower = UnitPowerMax("player", SPELL_POWER_HOLY_POWER)
if num < 1 then
if bar:IsShown() then bar:Hide() end
return
else
if not bar:IsShown() then bar:Show() end
end
--adjust the width of the holy power frame
local w = 64*(maxHolyPower+2)
bar:SetWidth(w)
for i = 1, bar.maxOrbs do
local orb = self.HolyPower[i]
if i > maxHolyPower then
if orb:IsShown() then orb:Hide() end
else
if not orb:IsShown() then orb:Show() end
end
end
for i = 1, maxHolyPower do
local orb = self.HolyPower[i]
local full = num/maxHolyPower
if(i <= num) then
if full == 1 then
orb.fill:SetVertexColor(1,0,0)
orb.glow:SetVertexColor(1,0,0)
else
orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
end
orb.fill:Show()
orb.glow:Show()
orb.highlight:Show()
else
orb.fill:Hide()
orb.glow:Hide()
orb.highlight:Hide()
end
end
end
--create holy power bar
local createHolyPowerBar = function(self)
self.HolyPower = {}
local t
local bar = CreateFrame("Frame","oUF_DiabloHolyPower",self)
bar.maxOrbs = 5
local w = 64*(bar.maxOrbs+2) --create the bar for
local h = 64
--bar:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
bar:SetPoint(self.cfg.holypower.pos.a1,self.cfg.holypower.pos.af,self.cfg.holypower.pos.a2,self.cfg.holypower.pos.x,self.cfg.holypower.pos.y)
bar:SetWidth(w)
bar:SetHeight(h)
--color
bar.color = self.cfg.holypower.color
--left edge
t = bar:CreateTexture(nil,"BACKGROUND",nil,-8)
t:SetSize(64,64)
t:SetPoint("LEFT",0,0)
t:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_left")
bar.leftEdge = t
--right edge
t = bar:CreateTexture(nil,"BACKGROUND",nil,-8)
t:SetSize(64,64)
t:SetPoint("RIGHT",0,0)
t:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_right")
bar.rightEdge = t
for i = 1, bar.maxOrbs do
local orb = CreateFrame("Frame",nil,bar)
self.HolyPower[i] = orb
orb:SetSize(64,64)
orb:SetPoint("LEFT",i*64,0)
local orbSizeMultiplier = 0.85
--bar background
orb.barBg = orb:CreateTexture(nil,"BACKGROUND",nil,-8)
orb.barBg:SetSize(64,64)
orb.barBg:SetPoint("CENTER")
orb.barBg:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_bar_bg")
--orb background
orb.bg = orb:CreateTexture(nil,"BACKGROUND",nil,-7)
orb.bg:SetSize(128*orbSizeMultiplier,128*orbSizeMultiplier)
orb.bg:SetPoint("CENTER")
orb.bg:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_orb_bg")
--orb filling
orb.fill = orb:CreateTexture(nil,"BACKGROUND",nil,-6)
orb.fill:SetSize(128*orbSizeMultiplier,128*orbSizeMultiplier)
orb.fill:SetPoint("CENTER")
orb.fill:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_orb_fill1")
orb.fill:SetVertexColor(self.cfg.holypower.color.r,self.cfg.holypower.color.g,self.cfg.holypower.color.b)
--orb.fill:SetBlendMode("ADD")
--orb border
orb.border = orb:CreateTexture(nil,"BACKGROUND",nil,-5)
orb.border:SetSize(128*orbSizeMultiplier,128*orbSizeMultiplier)
orb.border:SetPoint("CENTER")
orb.border:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_orb_border")
--orb glow
orb.glow = orb:CreateTexture(nil,"BACKGROUND",nil,-4)
orb.glow:SetSize(128*orbSizeMultiplier,128*orbSizeMultiplier)
orb.glow:SetPoint("CENTER")
orb.glow:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_orb_glow")
orb.glow:SetVertexColor(self.cfg.holypower.color.r,self.cfg.holypower.color.g,self.cfg.holypower.color.b)
orb.glow:SetBlendMode("BLEND")
--orb highlight
orb.highlight = orb:CreateTexture(nil,"BACKGROUND",nil,-3)
orb.highlight:SetSize(128*orbSizeMultiplier,128*orbSizeMultiplier)
orb.highlight:SetPoint("CENTER")
orb.highlight:SetTexture("Interface\\AddOns\\oUF_Diablo\\media\\combo_orb_highlight")
end
bar:SetScale(self.cfg.holypower.scale)
func.applyDragFunctionality(bar)
self.HolyPowerBar = bar
end
--holypower
if cfg.playerclass == "PALADIN" and self.cfg.holypower.show then
createHolyPowerBar(self)
self.HolyPower.Override = updateHolyPower
end