powerbar enable/disable

This commit is contained in:
Sumsebrum 2021-06-15 09:06:05 +02:00
parent 4f370f4e63
commit da5a8ea67d
7 changed files with 79 additions and 20 deletions

View File

@ -113,6 +113,7 @@ function Gladdy:UpdateFrame()
local teamSize = self.curBracket or 0 local teamSize = self.curBracket or 0
local highlightBorderSize = (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2) local highlightBorderSize = (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2)
local powerBarHeight = self.db.powerBarEnabled and (self.db.powerBarHeight + 1) or 0
local leftSize = 0 local leftSize = 0
local rightSize = 0 local rightSize = 0
--Trinket + Racial --Trinket + Racial
@ -140,9 +141,9 @@ function Gladdy:UpdateFrame()
rightSize = rightSize + self.db.highlightBorderSize rightSize = rightSize + self.db.highlightBorderSize
end end
local margin = self.db.powerBarHeight + 1 local margin = powerBarHeight
local width = self.db.barWidth + leftSize + rightSize local width = self.db.barWidth + leftSize + rightSize
local height = (self.db.healthBarHeight + self.db.powerBarHeight + 1) * teamSize local height = (self.db.healthBarHeight + powerBarHeight) * teamSize
+ (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2 * teamSize) + (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2 * teamSize)
+ self.db.bottomMargin * (teamSize - 1) + self.db.bottomMargin * (teamSize - 1)
@ -173,7 +174,7 @@ function Gladdy:UpdateFrame()
-- GrowDirection -- GrowDirection
if (self.db.growDirection == "LEFT" or self.db.growDirection == "RIGHT") then if (self.db.growDirection == "LEFT" or self.db.growDirection == "RIGHT") then
width = self.db.barWidth * teamSize + (leftSize + rightSize) * teamSize + self.db.bottomMargin * (teamSize - 1) width = self.db.barWidth * teamSize + (leftSize + rightSize) * teamSize + self.db.bottomMargin * (teamSize - 1)
height = self.db.healthBarHeight + self.db.powerBarHeight + 1 height = self.db.healthBarHeight + powerBarHeight
end end
self.frame:SetScale(self.db.frameScale) self.frame:SetScale(self.db.frameScale)
@ -214,13 +215,13 @@ function Gladdy:UpdateFrame()
button:SetWidth(self.db.barWidth) button:SetWidth(self.db.barWidth)
button:SetHeight(self.db.healthBarHeight) button:SetHeight(self.db.healthBarHeight)
button.secure:SetWidth(self.db.barWidth) button.secure:SetWidth(self.db.barWidth)
button.secure:SetHeight(self.db.healthBarHeight + self.db.powerBarHeight + 1) button.secure:SetHeight(self.db.healthBarHeight + powerBarHeight)
button:ClearAllPoints() button:ClearAllPoints()
button.secure:ClearAllPoints() button.secure:ClearAllPoints()
if (self.db.growDirection == "TOP") then if (self.db.growDirection == "TOP") then
if (i == 1) then if (i == 1) then
button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", leftSize, self.db.powerBarHeight + 1) button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", leftSize, powerBarHeight)
button.secure:SetPoint("TOPLEFT", button.powerBar, "TOPLEFT") button.secure:SetPoint("TOPLEFT", button.powerBar, "TOPLEFT")
else else
button:SetPoint("BOTTOMLEFT", self.buttons["arena" .. (i - 1)], "TOPLEFT", 0, margin + self.db.bottomMargin) button:SetPoint("BOTTOMLEFT", self.buttons["arena" .. (i - 1)], "TOPLEFT", 0, margin + self.db.bottomMargin)

View File

@ -280,6 +280,7 @@ function BuffsDebuffs:UpdateFrame(unit)
self.frames[unit].debuffFrame:ClearAllPoints() self.frames[unit].debuffFrame:ClearAllPoints()
--DEBUFFS --DEBUFFS
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
local verticalMargin = -(Gladdy.db.powerBarHeight)/2 local verticalMargin = -(Gladdy.db.powerBarHeight)/2
if Gladdy.db.buffsCooldownPos == "TOP" then if Gladdy.db.buffsCooldownPos == "TOP" then
@ -298,9 +299,9 @@ function BuffsDebuffs:UpdateFrame(unit)
verticalMargin = verticalMargin + Gladdy.db.cooldownSize verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end end
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].debuffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].powerBar, "BOTTOMRIGHT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin) self.frames[unit].debuffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
else else
self.frames[unit].debuffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].powerBar, "BOTTOMLEFT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin) self.frames[unit].debuffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
end end
elseif Gladdy.db.buffsCooldownPos == "LEFT" then elseif Gladdy.db.buffsCooldownPos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
@ -342,9 +343,9 @@ function BuffsDebuffs:UpdateFrame(unit)
verticalMargin = verticalMargin + Gladdy.db.cooldownSize verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end end
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].buffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].powerBar, "BOTTOMRIGHT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin) self.frames[unit].buffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
else else
self.frames[unit].buffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].powerBar, "BOTTOMLEFT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin) self.frames[unit].buffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
end end
elseif Gladdy.db.buffsBuffsCooldownPos == "LEFT" then elseif Gladdy.db.buffsBuffsCooldownPos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
@ -662,6 +663,7 @@ function BuffsDebuffs:GetOptions()
min = 5, min = 5,
max = 50, max = 50,
step = 1, step = 1,
width = "full",
}), }),
buffsBuffsWidthFactor = Gladdy:option({ buffsBuffsWidthFactor = Gladdy:option({
type = "range", type = "range",
@ -671,6 +673,7 @@ function BuffsDebuffs:GetOptions()
min = 0.5, min = 0.5,
max = 2, max = 2,
step = 0.05, step = 0.05,
width = "full",
}), }),
buffsBuffsIconPadding = Gladdy:option({ buffsBuffsIconPadding = Gladdy:option({
type = "range", type = "range",
@ -680,6 +683,7 @@ function BuffsDebuffs:GetOptions()
min = 0, min = 0,
max = 10, max = 10,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },
@ -722,6 +726,7 @@ function BuffsDebuffs:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
buffsBuffsYOffset = Gladdy:option({ buffsBuffsYOffset = Gladdy:option({
type = "range", type = "range",
@ -730,6 +735,7 @@ function BuffsDebuffs:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },
@ -750,6 +756,7 @@ function BuffsDebuffs:GetOptions()
min = 0, min = 0,
max = 1, max = 1,
step = 0.05, step = 0.05,
width = "full",
}), }),
} }
} }
@ -778,6 +785,7 @@ function BuffsDebuffs:GetOptions()
min = 5, min = 5,
max = 50, max = 50,
step = 1, step = 1,
width = "full",
}), }),
buffsWidthFactor = Gladdy:option({ buffsWidthFactor = Gladdy:option({
type = "range", type = "range",
@ -787,6 +795,7 @@ function BuffsDebuffs:GetOptions()
min = 0.5, min = 0.5,
max = 2, max = 2,
step = 0.05, step = 0.05,
width = "full",
}), }),
buffsIconPadding = Gladdy:option({ buffsIconPadding = Gladdy:option({
type = "range", type = "range",
@ -796,6 +805,7 @@ function BuffsDebuffs:GetOptions()
min = 0, min = 0,
max = 10, max = 10,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },
@ -838,6 +848,7 @@ function BuffsDebuffs:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
buffsYOffset = Gladdy:option({ buffsYOffset = Gladdy:option({
type = "range", type = "range",
@ -846,6 +857,7 @@ function BuffsDebuffs:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },
@ -866,6 +878,7 @@ function BuffsDebuffs:GetOptions()
min = 0, min = 0,
max = 1, max = 1,
step = 0.05, step = 0.05,
width = "full",
}), }),
} }
} }
@ -894,6 +907,7 @@ function BuffsDebuffs:GetOptions()
max = 1, max = 1,
step = 0.1, step = 0.1,
order = 10, order = 10,
width = "full",
}), }),
}, },
}, },
@ -923,6 +937,7 @@ function BuffsDebuffs:GetOptions()
min = 0.1, min = 0.1,
max = 2, max = 2,
step = 0.1, step = 0.1,
width = "full",
}), }),
buffsDynamicColor = Gladdy:option({ buffsDynamicColor = Gladdy:option({
type = "toggle", type = "toggle",

View File

@ -215,6 +215,7 @@ function Classicon:GetOptions()
max = 100, max = 100,
step = 1, step = 1,
order = 3, order = 3,
width = "full",
}), }),
classIconWidthFactor = Gladdy:option({ classIconWidthFactor = Gladdy:option({
type = "range", type = "range",
@ -223,6 +224,7 @@ function Classicon:GetOptions()
max = 2, max = 2,
step = 0.05, step = 0.05,
order = 4, order = 4,
width = "full",
}), }),
}, },
}, },

View File

@ -141,6 +141,7 @@ function CombatIndicator:GetOptions()
max = 100, max = 100,
step = 1, step = 1,
order = 2, order = 2,
width = "full",
}), }),
ciWidthFactor = Gladdy:option({ ciWidthFactor = Gladdy:option({
type = "range", type = "range",
@ -149,6 +150,7 @@ function CombatIndicator:GetOptions()
max = 2, max = 2,
step = 0.05, step = 0.05,
order = 3, order = 3,
width = "full",
}), }),
ciAlpha = Gladdy:option({ ciAlpha = Gladdy:option({
type = "range", type = "range",
@ -157,6 +159,7 @@ function CombatIndicator:GetOptions()
max = 1, max = 1,
step = 0.05, step = 0.05,
order = 4, order = 4,
width = "full",
}), }),
}, },
}, },
@ -201,6 +204,7 @@ function CombatIndicator:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
ciYOffset = Gladdy:option({ ciYOffset = Gladdy:option({
type = "range", type = "range",
@ -209,6 +213,7 @@ function CombatIndicator:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },

View File

@ -134,7 +134,7 @@ function Cooldowns:UpdateFrame(unit)
-- Cooldown frame -- Cooldown frame
if (Gladdy.db.cooldown) then if (Gladdy.db.cooldown) then
button.spellCooldownFrame:ClearAllPoints() button.spellCooldownFrame:ClearAllPoints()
local verticalMargin = -(Gladdy.db.powerBarHeight)/2 local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
if Gladdy.db.cooldownYPos == "TOP" then if Gladdy.db.cooldownYPos == "TOP" then
if Gladdy.db.cooldownXPos == "RIGHT" then if Gladdy.db.cooldownXPos == "RIGHT" then
@ -144,9 +144,9 @@ function Cooldowns:UpdateFrame(unit)
end end
elseif Gladdy.db.cooldownYPos == "BOTTOM" then elseif Gladdy.db.cooldownYPos == "BOTTOM" then
if Gladdy.db.cooldownXPos == "RIGHT" then if Gladdy.db.cooldownXPos == "RIGHT" then
button.spellCooldownFrame:SetPoint("TOPRIGHT", button.powerBar, "BOTTOMRIGHT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset) button.spellCooldownFrame:SetPoint("TOPRIGHT", button.healthBar, "BOTTOMRIGHT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
else else
button.spellCooldownFrame:SetPoint("TOPLEFT", button.powerBar, "BOTTOMLEFT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset) button.spellCooldownFrame:SetPoint("TOPLEFT", button.healthBar, "BOTTOMLEFT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
end end
elseif Gladdy.db.cooldownYPos == "LEFT" then elseif Gladdy.db.cooldownYPos == "LEFT" then
local anchor = Gladdy:GetAnchor(unit, "LEFT") local anchor = Gladdy:GetAnchor(unit, "LEFT")
@ -603,6 +603,7 @@ function Cooldowns:GetOptions()
order = 4, order = 4,
min = 5, min = 5,
max = 50, max = 50,
width = "full",
}), }),
cooldownWidthFactor = Gladdy:option({ cooldownWidthFactor = Gladdy:option({
type = "range", type = "range",
@ -612,6 +613,7 @@ function Cooldowns:GetOptions()
min = 0.5, min = 0.5,
max = 2, max = 2,
step = 0.05, step = 0.05,
width = "full",
}), }),
cooldownIconPadding = Gladdy:option({ cooldownIconPadding = Gladdy:option({
type = "range", type = "range",
@ -621,6 +623,7 @@ function Cooldowns:GetOptions()
min = 0, min = 0,
max = 10, max = 10,
step = 0.1, step = 0.1,
width = "full",
}), }),
cooldownMaxIconsPerLine = Gladdy:option({ cooldownMaxIconsPerLine = Gladdy:option({
type = "range", type = "range",
@ -629,6 +632,7 @@ function Cooldowns:GetOptions()
min = 3, min = 3,
max = 14, max = 14,
step = 1, step = 1,
width = "full",
}), }),
}, },
}, },
@ -655,6 +659,7 @@ function Cooldowns:GetOptions()
max = 1, max = 1,
step = 0.1, step = 0.1,
order = 9, order = 9,
width = "full",
}), }),
}, },
}, },
@ -684,6 +689,7 @@ function Cooldowns:GetOptions()
min = 0.1, min = 0.1,
max = 2, max = 2,
step = 0.1, step = 0.1,
width = "full",
}), }),
cooldownFontColor = Gladdy:colorOption({ cooldownFontColor = Gladdy:colorOption({
type = "color", type = "color",
@ -738,6 +744,7 @@ function Cooldowns:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
cooldownYOffset = Gladdy:option({ cooldownYOffset = Gladdy:option({
type = "range", type = "range",
@ -746,6 +753,7 @@ function Cooldowns:GetOptions()
min = -400, min = -400,
max = 400, max = 400,
step = 0.1, step = 0.1,
width = "full",
}), }),
}, },
}, },

View File

@ -89,18 +89,19 @@ function Highlight:UpdateFrame(unit)
return return
end end
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local borderSize = Gladdy.db.highlightBorderSize local borderSize = Gladdy.db.highlightBorderSize
local borderOffset = borderSize local borderOffset = borderSize
local iconSize = Gladdy.db.healthBarHeight + Gladdy.db.powerBarHeight + 1 local hpAndPowerHeight = Gladdy.db.healthBarHeight + powerBarHeight
local width = Gladdy.db.barWidth + (Gladdy.db.highlightInset and 0 or borderSize * 2) local width = Gladdy.db.barWidth + (Gladdy.db.highlightInset and 0 or borderSize * 2)
local height = iconSize + (Gladdy.db.highlightInset and 0 or borderSize * 2) local height = hpAndPowerHeight + (Gladdy.db.highlightInset and 0 or borderSize * 2)
button.targetBorder:SetWidth(width) button.targetBorder:SetWidth(width)
button.targetBorder:SetHeight(height) button.targetBorder:SetHeight(height)
button.targetBorder:ClearAllPoints() button.targetBorder:ClearAllPoints()
if Gladdy.db.highlightInset then if Gladdy.db.highlightInset then
button.targetBorder:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", -(borderOffset/Gladdy.db.statusbarBorderOffset), (borderOffset/Gladdy.db.statusbarBorderOffset)) button.targetBorder:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", -(borderOffset/Gladdy.db.statusbarBorderOffset), (borderOffset/Gladdy.db.statusbarBorderOffset))
button.targetBorder:SetPoint("BOTTOMRIGHT", button.powerBar, "BOTTOMRIGHT", (borderOffset/Gladdy.db.statusbarBorderOffset), -(borderOffset/Gladdy.db.statusbarBorderOffset)) button.targetBorder:SetPoint("BOTTOMRIGHT", Gladdy.db.powerBarEnabled and button.powerBar or button.healthBar, "BOTTOMRIGHT", (borderOffset/Gladdy.db.statusbarBorderOffset), -(borderOffset/Gladdy.db.statusbarBorderOffset))
else else
button.targetBorder:SetPoint("TOP", button.healthBar, "TOP", 0, (Gladdy.db.highlightInset and 0 or borderSize)) button.targetBorder:SetPoint("TOP", button.healthBar, "TOP", 0, (Gladdy.db.highlightInset and 0 or borderSize))
end end
@ -113,7 +114,7 @@ function Highlight:UpdateFrame(unit)
button.focusBorder:ClearAllPoints() button.focusBorder:ClearAllPoints()
if Gladdy.db.highlightInset then if Gladdy.db.highlightInset then
button.focusBorder:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", -(borderOffset/Gladdy.db.statusbarBorderOffset), (borderOffset/Gladdy.db.statusbarBorderOffset)) button.focusBorder:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", -(borderOffset/Gladdy.db.statusbarBorderOffset), (borderOffset/Gladdy.db.statusbarBorderOffset))
button.focusBorder:SetPoint("BOTTOMRIGHT", button.powerBar, "BOTTOMRIGHT", (borderOffset/Gladdy.db.statusbarBorderOffset), -(borderOffset/Gladdy.db.statusbarBorderOffset)) button.focusBorder:SetPoint("BOTTOMRIGHT", Gladdy.db.powerBarEnabled and button.powerBar or button.healthBar, "BOTTOMRIGHT", (borderOffset/Gladdy.db.statusbarBorderOffset), -(borderOffset/Gladdy.db.statusbarBorderOffset))
else else
button.focusBorder:SetPoint("TOP", button.healthBar, "TOP", 0, (Gladdy.db.highlightInset and 0 or borderSize)) button.focusBorder:SetPoint("TOP", button.healthBar, "TOP", 0, (Gladdy.db.highlightInset and 0 or borderSize))
end end
@ -214,6 +215,7 @@ function Highlight:GetOptions()
min = 1, min = 1,
max = 20, max = 20,
step = 1, step = 1,
width = "full",
}), }),
highlightBorderStyle = Gladdy:option({ highlightBorderStyle = Gladdy:option({
type = "select", type = "select",

View File

@ -7,6 +7,7 @@ local Gladdy = LibStub("Gladdy")
local L = Gladdy.L local L = Gladdy.L
local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists
local Powerbar = Gladdy:NewModule("Power Bar", 90, { local Powerbar = Gladdy:NewModule("Power Bar", 90, {
powerBarEnabled = true,
powerBarFont = "DorisPP", powerBarFont = "DorisPP",
powerBarHeight = 20, powerBarHeight = 20,
powerBarTexture = "Smooth", powerBarTexture = "Smooth",
@ -113,17 +114,24 @@ function Powerbar:SetPower(powerBar, power, powerMax, powerType)
end end
end end
if (powerType == 1) then if (powerType == 1 and powerBar.powerType ~= powerType) then
powerBar.energy:SetStatusBarColor(1, 0, 0, 1) powerBar.energy:SetStatusBarColor(1, 0, 0, 1)
elseif (powerType == 3) then powerBar.powerColor = {r = 1, g = 0, b = 0}
powerBar.powerType = powerType
elseif (powerType == 3 and powerBar.powerType ~= powerType) then
powerBar.energy:SetStatusBarColor(1, 1, 0, 1) powerBar.energy:SetStatusBarColor(1, 1, 0, 1)
else powerBar.powerColor = {r = 1, g = 1, b = 0}
powerBar.powerType = powerType
elseif powerBar.powerType ~= powerType then
powerBar.energy:SetStatusBarColor(.18, .44, .75, 1) powerBar.energy:SetStatusBarColor(.18, .44, .75, 1)
powerBar.powerColor = {r = .18, g = .44, b = .75}
powerBar.powerType = powerType
end end
powerBar.powerText:SetText(powerText) powerBar.powerText:SetText(powerText)
powerBar.energy:SetMinMaxValues(0, powerMax) powerBar.energy:SetMinMaxValues(0, powerMax)
powerBar.energy:SetValue(power) powerBar.energy:SetValue(power)
end end
function Powerbar:UpdateFrame(unit) function Powerbar:UpdateFrame(unit)
@ -135,6 +143,12 @@ function Powerbar:UpdateFrame(unit)
local healthBar = Gladdy.modules["Health Bar"].frames[unit] local healthBar = Gladdy.modules["Health Bar"].frames[unit]
if not Gladdy.db.powerBarEnabled then
powerBar:Hide()
return
else
powerBar:Show()
end
powerBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture)) powerBar.bg:SetTexture(Gladdy.LSM:Fetch("statusbar", Gladdy.db.powerBarTexture))
powerBar.bg:SetVertexColor(Gladdy.db.powerBarBgColor.r, Gladdy.db.powerBarBgColor.g, Gladdy.db.powerBarBgColor.b, Gladdy.db.powerBarBgColor.a) powerBar.bg:SetVertexColor(Gladdy.db.powerBarBgColor.r, Gladdy.db.powerBarBgColor.g, Gladdy.db.powerBarBgColor.b, Gladdy.db.powerBarBgColor.a)
@ -169,6 +183,7 @@ function Powerbar:ResetUnit(unit)
powerBar.raceText:SetText("") powerBar.raceText:SetText("")
powerBar.powerText:SetText("") powerBar.powerText:SetText("")
powerBar.energy:SetValue(0) powerBar.energy:SetValue(0)
powerBar.powerColor = {r = 1, g = 1, b = 1}
end end
function Powerbar:Test(unit) function Powerbar:Test(unit)
@ -252,10 +267,13 @@ function Powerbar:UNIT_POWER(unit, power, powerMax, powerType)
if (powerType == 1) then if (powerType == 1) then
powerBar.energy:SetStatusBarColor(1, 0, 0, 1) powerBar.energy:SetStatusBarColor(1, 0, 0, 1)
powerBar.powerColor = {r = 1, g = 0, b = 0}
elseif (powerType == 3) then elseif (powerType == 3) then
powerBar.energy:SetStatusBarColor(1, 1, 0, 1) powerBar.energy:SetStatusBarColor(1, 1, 0, 1)
powerBar.powerColor = {r = 1, g = 1, b = 0}
else else
powerBar.energy:SetStatusBarColor(.18, .44, .75, 1) powerBar.energy:SetStatusBarColor(.18, .44, .75, 1)
powerBar.powerColor = {r = .18, g = .44, b = .75}
end end
powerBar.powerText:SetText(powerText) powerBar.powerText:SetText(powerText)
@ -315,11 +333,16 @@ function Powerbar:GetOptions()
name = L["Power Bar"], name = L["Power Bar"],
order = 2, order = 2,
}, },
powerBarEnabled = Gladdy:option({
type = "toggle",
name = L["Enabled"],
order = 3,
}),
group = { group = {
type = "group", type = "group",
childGroups = "tree", childGroups = "tree",
name = L["Frame"], name = L["Frame"],
order = 3, order = 4,
args = { args = {
general = { general = {
type = "group", type = "group",
@ -339,6 +362,7 @@ function Powerbar:GetOptions()
min = 0, min = 0,
max = 50, max = 50,
step = 1, step = 1,
width = "full",
}), }),
powerBarTexture = option({ powerBarTexture = option({
type = "select", type = "select",
@ -390,6 +414,7 @@ function Powerbar:GetOptions()
step = 0.1, step = 0.1,
min = 1, min = 1,
max = 20, max = 20,
width = "full",
}), }),
}, },
}, },
@ -418,6 +443,7 @@ function Powerbar:GetOptions()
min = 0.5, min = 0.5,
max = Gladdy.db.powerBarHeight/2, max = Gladdy.db.powerBarHeight/2,
step = 0.5, step = 0.5,
width = "full",
}), }),
powerBarBorderColor = Gladdy:colorOption({ powerBarBorderColor = Gladdy:colorOption({
type = "color", type = "color",