WIP Legion combo points updates

Adds support for the new 6/8 (without/with Anticipation) combo points instead of hardcoding to 5. This same treatment will need to be done to the other combo point-centric modules (SnD, ComboPointsBar).
Moved the old Anticipation extra-combo-point support to pre-Legion only. Anticipation doesn't work the same way now.
This commit is contained in:
Parnic
2016-05-24 02:05:12 -05:00
parent 5fbf85811e
commit e54c645b99

View File

@ -17,6 +17,10 @@ function ComboPoints.prototype:init()
end end
function ComboPoints.prototype:GetMaxComboPoints()
return UnitPowerMax("player", SPELL_POWER_COMBO_POINTS)
end
-- 'Public' methods ----------------------------------------------------------- -- 'Public' methods -----------------------------------------------------------
@ -149,28 +153,30 @@ function ComboPoints.prototype:GetOptions()
order = 33.2 order = 33.2
} }
opts["anticipation"] = { if IceHUD.WowVer < 70000 then
type = "toggle", opts["anticipation"] = {
name = L["Show Anticipation"], type = "toggle",
desc = L["Show points stored by the Anticipation talent"], name = L["Show Anticipation"],
get = function() desc = L["Show points stored by the Anticipation talent"],
return self.moduleSettings.showAnticipation get = function()
end, return self.moduleSettings.showAnticipation
set = function(info, v) end,
self.moduleSettings.showAnticipation = v set = function(info, v)
self:AddAnticipation() -- This will activate or deactivate as needed self.moduleSettings.showAnticipation = v
self:Redraw() self:AddAnticipation() -- This will activate or deactivate as needed
end, self:Redraw()
disabled = function() end,
return not self.moduleSettings.enabled disabled = function()
end, return not self.moduleSettings.enabled
order = 33.3 end,
} order = 33.3
}
end
opts["gradient"] = { opts["gradient"] = {
type = "toggle", type = "toggle",
name = L["Change color"], name = L["Change color"],
desc = L["1 combo point: yellow, 5 combo points: red"], desc = L["1 combo point: yellow, max combo points: red"],
get = function() get = function()
return self.moduleSettings.gradient return self.moduleSettings.gradient
end, end,
@ -242,11 +248,14 @@ function ComboPoints.prototype:Enable(core)
self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateComboPoints") self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateComboPoints")
else else
self:RegisterEvent("UNIT_POWER", "UpdateComboPoints") self:RegisterEvent("UNIT_POWER", "UpdateComboPoints")
self:RegisterEvent("UNIT_MAXPOWER", "UpdateMaxComboPoints")
end end
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "UpdateComboPoints") self:RegisterEvent("UNIT_ENTERED_VEHICLE", "UpdateComboPoints")
self:RegisterEvent("UNIT_EXITED_VEHICLE", "UpdateComboPoints") self:RegisterEvent("UNIT_EXITED_VEHICLE", "UpdateComboPoints")
self:RegisterEvent("PLAYER_TALENT_UPDATE", "AddAnticipation") if IceHUD.WowVer < 70000 then
self:AddAnticipation() self:RegisterEvent("PLAYER_TALENT_UPDATE", "AddAnticipation")
self:AddAnticipation()
end
else else
self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateComboPoints") self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateComboPoints")
end end
@ -258,7 +267,15 @@ function ComboPoints.prototype:Enable(core)
self:CreateComboFrame(true) self:CreateComboFrame(true)
end end
function ComboPoints.prototype:UpdateMaxComboPoints(event, unit, powerType)
if unit == "player" and powerType == "COMBO_POINTS" then
for i = 1, #self.frame.graphical do
self.frame.graphicalBG[i]:Hide()
self.frame.graphical[i]:Hide()
end
self:Redraw()
end
end
-- 'Protected' methods -------------------------------------------------------- -- 'Protected' methods --------------------------------------------------------
@ -268,11 +285,11 @@ function ComboPoints.prototype:CreateFrame()
self.frame:SetFrameStrata("BACKGROUND") self.frame:SetFrameStrata("BACKGROUND")
if self.moduleSettings.graphicalLayout == "Horizontal" then if self.moduleSettings.graphicalLayout == "Horizontal" then
self.frame:SetWidth(self.comboSize*5) self.frame:SetWidth((self.comboSize - 5)*self.GetMaxComboPoints())
self.frame:SetHeight(1) self.frame:SetHeight(1)
else else
self.frame:SetWidth(1) self.frame:SetWidth(1)
self.frame:SetHeight(self.comboSize*5) self.frame:SetHeight(self.comboSize*self.GetMaxComboPoints())
end end
self.frame:ClearAllPoints() self.frame:ClearAllPoints()
self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos) self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos)
@ -301,9 +318,10 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
end end
local i local i
local maxComboPoints = self.GetMaxComboPoints()
-- create backgrounds -- create backgrounds
for i = 1, 5 do for i = 1, maxComboPoints do
if (not self.frame.graphicalBG[i]) then if (not self.frame.graphicalBG[i]) then
local frame = CreateFrame("Frame", nil, self.frame) local frame = CreateFrame("Frame", nil, self.frame)
self.frame.graphicalBG[i] = frame self.frame.graphicalBG[i] = frame
@ -327,9 +345,9 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
self.frame.graphicalBG[i]:SetWidth(self.comboSize) self.frame.graphicalBG[i]:SetWidth(self.comboSize)
self.frame.graphicalBG[i]:SetHeight(self.comboSize) self.frame.graphicalBG[i]:SetHeight(self.comboSize)
if self.moduleSettings.graphicalLayout == "Horizontal" then if self.moduleSettings.graphicalLayout == "Horizontal" then
self.frame.graphicalBG[i]:SetPoint("TOPLEFT", ((i-1) * (self.comboSize-5)) + (i-1) + ((i-1) * self.moduleSettings.comboGap), 0) self.frame.graphicalBG[i]:SetPoint("TOPLEFT", ((i-1) * (self.comboSize-5)) - 2.5 + ((i-1) * self.moduleSettings.comboGap), 0)
else else
self.frame.graphicalBG[i]:SetPoint("TOPLEFT", 0, -1 * (((i-1) * (self.comboSize-5)) + (i-1) + ((i-1) * self.moduleSettings.comboGap))) self.frame.graphicalBG[i]:SetPoint("TOPLEFT", 0, -1 * (((i-1) * (self.comboSize-5)) - 2.5 + ((i-1) * self.moduleSettings.comboGap)))
end end
self.frame.graphicalBG[i]:SetAlpha(0.15) self.frame.graphicalBG[i]:SetAlpha(0.15)
self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("ComboPoints")) self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("ComboPoints"))
@ -338,7 +356,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
end end
-- create combo points -- create combo points
for i = 1, 5 do for i = 1, maxComboPoints do
if (not self.frame.graphical[i]) then if (not self.frame.graphical[i]) then
local frame = CreateFrame("Frame", nil, self.frame) local frame = CreateFrame("Frame", nil, self.frame)
self.frame.graphical[i] = frame self.frame.graphical[i] = frame
@ -363,7 +381,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
local r, g, b = self:GetColor("ComboPoints") local r, g, b = self:GetColor("ComboPoints")
if (self.moduleSettings.gradient) then if (self.moduleSettings.gradient) then
g = g - (0.15*i) g = g - ((1 / maxComboPoints)*i)
end end
self.frame.graphical[i].texture:SetVertexColor(r, g, b) self.frame.graphical[i].texture:SetVertexColor(r, g, b)
@ -371,42 +389,43 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
end end
-- create Anticipation points -- create Anticipation points
for i = 1, 5 do if IceHUD.WowVer < 70000 then
if (not self.frame.graphicalAnt[i]) then for i = 1, 5 do
local frame = CreateFrame("Frame", nil, self.frame) if (not self.frame.graphicalAnt[i]) then
self.frame.graphicalAnt[i] = frame local frame = CreateFrame("Frame", nil, self.frame)
frame.texture = frame:CreateTexture() self.frame.graphicalAnt[i] = frame
frame.texture:SetAllPoints(frame) frame.texture = frame:CreateTexture()
end frame.texture:SetAllPoints(frame)
if forceTextureUpdate then
if self.moduleSettings.comboMode == "Graphical Bar" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "Combo")
elseif self.moduleSettings.comboMode == "Graphical Circle" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboRound")
elseif self.moduleSettings.comboMode == "Graphical Glow" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlow")
elseif self.moduleSettings.comboMode == "Graphical Clean Circle" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurves")
end end
if forceTextureUpdate then
if self.moduleSettings.comboMode == "Graphical Bar" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "Combo")
elseif self.moduleSettings.comboMode == "Graphical Circle" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboRound")
elseif self.moduleSettings.comboMode == "Graphical Glow" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboGlow")
elseif self.moduleSettings.comboMode == "Graphical Clean Circle" then
self.frame.graphicalAnt[i].texture:SetTexture(IceElement.TexturePath .. "ComboCleanCurves")
end
end
self.frame.graphicalAnt[i]:SetFrameStrata("LOW")
self.frame.graphicalAnt[i]:SetFrameLevel(self.frame.graphical[i]:GetFrameLevel() + 1)
self.frame.graphicalAnt[i]:SetWidth(math.floor(self.comboSize / 2))
self.frame.graphicalAnt[i]:SetHeight(math.floor(self.comboSize / 2))
self.frame.graphicalAnt[i]:SetPoint("CENTER", self.frame.graphical[i], "CENTER")
local r, g, b = self:GetColor("AnticipationPoints")
if (self.moduleSettings.gradient) then
r = r - 0.25 * (i - 1) -- Go to straight blue, which is most visible against the redorange
end
self.frame.graphicalAnt[i].texture:SetVertexColor(r, g, b)
self.frame.graphicalAnt[i]:Hide()
end end
self.frame.graphicalAnt[i]:SetFrameStrata("LOW")
self.frame.graphicalAnt[i]:SetFrameLevel(self.frame.graphical[i]:GetFrameLevel() + 1)
self.frame.graphicalAnt[i]:SetWidth(math.floor(self.comboSize / 2))
self.frame.graphicalAnt[i]:SetHeight(math.floor(self.comboSize / 2))
self.frame.graphicalAnt[i]:SetPoint("CENTER", self.frame.graphical[i], "CENTER")
local r, g, b = self:GetColor("AnticipationPoints")
if (self.moduleSettings.gradient) then
r = r - 0.25 * (i - 1) -- Go to straight blue, which is most visible against the redorange
end
self.frame.graphicalAnt[i].texture:SetVertexColor(r, g, b)
self.frame.graphicalAnt[i]:Hide()
end end
end end
function ComboPoints.prototype:UpdateComboPoints(...) function ComboPoints.prototype:UpdateComboPoints(...)
@ -416,17 +435,22 @@ function ComboPoints.prototype:UpdateComboPoints(...)
local points, anticipate, _ local points, anticipate, _
if IceHUD.IceCore:IsInConfigMode() then if IceHUD.IceCore:IsInConfigMode() then
points = 5 points = self:GetMaxComboPoints()
elseif IceHUD.WowVer >= 30000 then elseif IceHUD.WowVer >= 30000 then
-- Parnic: apparently some fights have combo points while the player is in a vehicle? -- Parnic: apparently some fights have combo points while the player is in a vehicle?
local isInVehicle = UnitHasVehicleUI("player") local isInVehicle = UnitHasVehicleUI("player")
local checkUnit = isInVehicle and "vehicle" or "player" local checkUnit = isInVehicle and "vehicle" or "player"
if IceHUD.WowVer >= 60000 then if IceHUD.WowVer >= 60000 then
points = UnitPower(checkUnit, 4) points = UnitPower(checkUnit, SPELL_POWER_COMBO_POINTS)
else else
points = GetComboPoints(checkUnit, "target") points = GetComboPoints(checkUnit, "target")
end end
_, _, _, anticipate = UnitAura("player", GetSpellInfo(AnticipationSpellId))
if IceHUD.WowVer < 70000 then
_, _, _, anticipate = UnitAura("player", GetSpellInfo(AnticipationSpellId))
else
anticipate = 0
end
else else
points = GetComboPoints("target") points = GetComboPoints("target")
end end
@ -437,7 +461,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
if (self.moduleSettings.comboMode == "Numeric") then if (self.moduleSettings.comboMode == "Numeric") then
local r, g, b = self:GetColor("ComboPoints") local r, g, b = self:GetColor("ComboPoints")
if (self.moduleSettings.gradient and points) then if (self.moduleSettings.gradient and points) then
g = g - (0.15*points) g = g - ((1 / self:GetMaxComboPoints())*points)
end end
self.frame.numeric:SetTextColor(r, g, b, 0.7) self.frame.numeric:SetTextColor(r, g, b, 0.7)
@ -454,7 +478,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
else else
self.frame.numeric:SetText() self.frame.numeric:SetText()
for i = 1, table.getn(self.frame.graphical) do for i = 1, self:GetMaxComboPoints() do
local hideIfNoTarget = not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget local hideIfNoTarget = not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget
if ((points > 0) or (anticipate > 0)) and not hideIfNoTarget then if ((points > 0) or (anticipate > 0)) and not hideIfNoTarget then
@ -469,10 +493,12 @@ function ComboPoints.prototype:UpdateComboPoints(...)
self.frame.graphical[i]:Hide() self.frame.graphical[i]:Hide()
end end
if (i <= anticipate) and not hideIfNoTarget then if i <= #self.frame.graphicalAnt then
self.frame.graphicalAnt[i]:Show() if (i <= anticipate) and not hideIfNoTarget then
else self.frame.graphicalAnt[i]:Show()
self.frame.graphicalAnt[i]:Hide() else
self.frame.graphicalAnt[i]:Hide()
end
end end
end end
end end