Fix Charged point support in ComboPointsBar

This commit is contained in:
Parnic
2022-11-16 21:14:51 -06:00
parent 2a0db2eb01
commit 5712114eb8
3 changed files with 55 additions and 15 deletions

View File

@ -4,6 +4,7 @@ v1.14.5:
- Fix castbar flashing. There are controls on the player castbar module for flashing when a spell succeeds or fails, and separate controls for flashing when an instant cast completes. Those were broken, but now work again. - Fix castbar flashing. There are controls on the player castbar module for flashing when a spell succeeds or fails, and separate controls for flashing when an instant cast completes. Those were broken, but now work again.
- Add "@" after the number when the Combo Points module is in Numeric mode, "Show Charged points" is enabled, and the current combo point is charged. - Add "@" after the number when the Combo Points module is in Numeric mode, "Show Charged points" is enabled, and the current combo point is charged.
- Fix Charged point support in the ComboPointsBar module.
v1.14.4: v1.14.4:

View File

@ -11,6 +11,7 @@ function ComboPointsBar.prototype:init()
self:SetDefaultColor("ComboPointsBarMin", 1, 1, 0) self:SetDefaultColor("ComboPointsBarMin", 1, 1, 0)
self:SetDefaultColor("ComboPointsBarMax", 0, 1, 0) self:SetDefaultColor("ComboPointsBarMax", 0, 1, 0)
self:SetDefaultColor("ChargedComboPointBar", 0.3137254901960784, 0.3725490196078432, 1)
self.bTreatEmptyAsFull = true self.bTreatEmptyAsFull = true
end end
@ -52,6 +53,26 @@ function ComboPointsBar.prototype:GetOptions()
end, end,
} }
opts["bShowCharged"] = {
type = 'toggle',
width = 'double',
name = L["Show Charged points"],
desc = L["Whether or not to color a charged combo point a separate color and append an @ sign to the number. Set the ChargedComboPointBar color to the color you would like it to be."],
get = function()
return self.moduleSettings.bShowCharged
end,
set = function(info, v)
self.moduleSettings.bShowCharged = v
self:UpdateComboPoints()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
hidden = function()
return not GetUnitChargedPowerPoints
end,
}
return opts return opts
end end
@ -62,6 +83,7 @@ function ComboPointsBar.prototype:GetDefaultSettings()
defaults.alwaysDisplay = false defaults.alwaysDisplay = false
defaults.desiredLerpTime = 0.05 defaults.desiredLerpTime = 0.05
defaults.bShowWithNoTarget = true defaults.bShowWithNoTarget = true
defaults.bShowCharged = true
return defaults return defaults
end end
@ -84,17 +106,7 @@ function ComboPointsBar.prototype:Enable(core)
end end
if GetUnitChargedPowerPoints then if GetUnitChargedPowerPoints then
self:RegisterEvent("UNIT_POWER_POINT_CHARGE", "UpdateChargedComboPoints") self:RegisterEvent("UNIT_POWER_POINT_CHARGE", "UpdateComboPoints")
end
self:UpdateChargedComboPoints()
end
function ComboPointsBar.prototype:UpdateChargedComboPoints()
if GetUnitChargedPowerPoints then
local chargedPowerPoints = GetUnitChargedPowerPoints("player")
self.chargedPowerPointIndex = chargedPowerPoints and chargedPowerPoints[1]
self:UpdateComboPoints()
end end
end end
@ -131,20 +143,46 @@ function ComboPointsBar.prototype:UpdateComboPoints(...)
points = nil points = nil
end end
local isCharged = self:IsChargedPoint(points) and self.moduleSettings.bShowCharged
if points == nil or points == 0 or (not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget) then if points == nil or points == 0 or (not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget) then
self:Show(self.moduleSettings.alwaysDisplay) self:Show(self.moduleSettings.alwaysDisplay)
self:UpdateBar(0, "undef") self:UpdateBar(0, "undef")
else else
self:Show(true) self:Show(true)
self:SetScaledColor(color, (points - 1) / 4.0, self.settings.colors["ComboPointsBarMax"], self.settings.colors["ComboPointsBarMin"]) if isCharged then
color.r, color.g, color.b = self:GetColor("ChargedComboPointBar")
else
self:SetScaledColor(color, (points - 1) / 4.0, self.settings.colors["ComboPointsBarMax"], self.settings.colors["ComboPointsBarMin"])
end
self:UpdateBar(points / UnitPowerMax("player", SPELL_POWER_COMBO_POINTS), "undef") self:UpdateBar(points / UnitPowerMax("player", SPELL_POWER_COMBO_POINTS), "undef")
self.barFrame.bar:SetVertexColor(color.r, color.g, color.b, self.alpha) self.barFrame.bar:SetVertexColor(color.r, color.g, color.b, self.alpha)
end end
self:SetBottomText1(points or "0") local pointsText = tostring(points or 0)
if self.chargedPowerPointIndex then if isCharged then
self:SetBottomText2(self.chargedPowerPointIndex) pointsText = pointsText .. "@"
end end
self:SetBottomText1(pointsText or "0")
end
function ComboPointsBar.prototype:IsChargedPoint(point)
if not GetUnitChargedPowerPoints or not point then
return false
end
local chargedPoints = GetUnitChargedPowerPoints("player")
if not chargedPoints then
return false
end
for i=1, #chargedPoints do
if chargedPoints[i] == point then
return true
end
end
return false
end end
function ComboPointsBar.prototype:Update() function ComboPointsBar.prototype:Update()

View File

@ -4,6 +4,7 @@ v1.14.5:
- Fix castbar flashing. There are controls on the player castbar module for flashing when a spell succeeds or fails, and separate controls for flashing when an instant cast completes. Those were broken, but now work again. - Fix castbar flashing. There are controls on the player castbar module for flashing when a spell succeeds or fails, and separate controls for flashing when an instant cast completes. Those were broken, but now work again.
- Add "@" after the number when the Combo Points module is in Numeric mode, "Show Charged points" is enabled, and the current combo point is charged. - Add "@" after the number when the Combo Points module is in Numeric mode, "Show Charged points" is enabled, and the current combo point is charged.
- Fix Charged point support in the ComboPointsBar module.
v1.14.4: v1.14.4: