mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-15 22:30:13 -05:00
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:
@ -17,6 +17,10 @@ function ComboPoints.prototype:init()
|
||||
end
|
||||
|
||||
|
||||
function ComboPoints.prototype:GetMaxComboPoints()
|
||||
return UnitPowerMax("player", SPELL_POWER_COMBO_POINTS)
|
||||
end
|
||||
|
||||
|
||||
-- 'Public' methods -----------------------------------------------------------
|
||||
|
||||
@ -149,6 +153,7 @@ function ComboPoints.prototype:GetOptions()
|
||||
order = 33.2
|
||||
}
|
||||
|
||||
if IceHUD.WowVer < 70000 then
|
||||
opts["anticipation"] = {
|
||||
type = "toggle",
|
||||
name = L["Show Anticipation"],
|
||||
@ -166,11 +171,12 @@ function ComboPoints.prototype:GetOptions()
|
||||
end,
|
||||
order = 33.3
|
||||
}
|
||||
end
|
||||
|
||||
opts["gradient"] = {
|
||||
type = "toggle",
|
||||
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()
|
||||
return self.moduleSettings.gradient
|
||||
end,
|
||||
@ -242,11 +248,14 @@ function ComboPoints.prototype:Enable(core)
|
||||
self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateComboPoints")
|
||||
else
|
||||
self:RegisterEvent("UNIT_POWER", "UpdateComboPoints")
|
||||
self:RegisterEvent("UNIT_MAXPOWER", "UpdateMaxComboPoints")
|
||||
end
|
||||
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "UpdateComboPoints")
|
||||
self:RegisterEvent("UNIT_EXITED_VEHICLE", "UpdateComboPoints")
|
||||
if IceHUD.WowVer < 70000 then
|
||||
self:RegisterEvent("PLAYER_TALENT_UPDATE", "AddAnticipation")
|
||||
self:AddAnticipation()
|
||||
end
|
||||
else
|
||||
self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateComboPoints")
|
||||
end
|
||||
@ -258,7 +267,15 @@ function ComboPoints.prototype:Enable(core)
|
||||
self:CreateComboFrame(true)
|
||||
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 --------------------------------------------------------
|
||||
|
||||
@ -268,11 +285,11 @@ function ComboPoints.prototype:CreateFrame()
|
||||
|
||||
self.frame:SetFrameStrata("BACKGROUND")
|
||||
if self.moduleSettings.graphicalLayout == "Horizontal" then
|
||||
self.frame:SetWidth(self.comboSize*5)
|
||||
self.frame:SetWidth((self.comboSize - 5)*self.GetMaxComboPoints())
|
||||
self.frame:SetHeight(1)
|
||||
else
|
||||
self.frame:SetWidth(1)
|
||||
self.frame:SetHeight(self.comboSize*5)
|
||||
self.frame:SetHeight(self.comboSize*self.GetMaxComboPoints())
|
||||
end
|
||||
self.frame:ClearAllPoints()
|
||||
self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos)
|
||||
@ -301,9 +318,10 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
|
||||
end
|
||||
|
||||
local i
|
||||
local maxComboPoints = self.GetMaxComboPoints()
|
||||
|
||||
-- create backgrounds
|
||||
for i = 1, 5 do
|
||||
for i = 1, maxComboPoints do
|
||||
if (not self.frame.graphicalBG[i]) then
|
||||
local frame = CreateFrame("Frame", nil, self.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]:SetHeight(self.comboSize)
|
||||
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
|
||||
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
|
||||
self.frame.graphicalBG[i]:SetAlpha(0.15)
|
||||
self.frame.graphicalBG[i].texture:SetVertexColor(self:GetColor("ComboPoints"))
|
||||
@ -338,7 +356,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
|
||||
end
|
||||
|
||||
-- create combo points
|
||||
for i = 1, 5 do
|
||||
for i = 1, maxComboPoints do
|
||||
if (not self.frame.graphical[i]) then
|
||||
local frame = CreateFrame("Frame", nil, self.frame)
|
||||
self.frame.graphical[i] = frame
|
||||
@ -363,7 +381,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
|
||||
|
||||
local r, g, b = self:GetColor("ComboPoints")
|
||||
if (self.moduleSettings.gradient) then
|
||||
g = g - (0.15*i)
|
||||
g = g - ((1 / maxComboPoints)*i)
|
||||
end
|
||||
self.frame.graphical[i].texture:SetVertexColor(r, g, b)
|
||||
|
||||
@ -371,6 +389,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
|
||||
end
|
||||
|
||||
-- create Anticipation points
|
||||
if IceHUD.WowVer < 70000 then
|
||||
for i = 1, 5 do
|
||||
if (not self.frame.graphicalAnt[i]) then
|
||||
local frame = CreateFrame("Frame", nil, self.frame)
|
||||
@ -406,7 +425,7 @@ function ComboPoints.prototype:CreateComboFrame(forceTextureUpdate)
|
||||
|
||||
self.frame.graphicalAnt[i]:Hide()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
@ -416,17 +435,22 @@ function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
|
||||
local points, anticipate, _
|
||||
if IceHUD.IceCore:IsInConfigMode() then
|
||||
points = 5
|
||||
points = self:GetMaxComboPoints()
|
||||
elseif IceHUD.WowVer >= 30000 then
|
||||
-- Parnic: apparently some fights have combo points while the player is in a vehicle?
|
||||
local isInVehicle = UnitHasVehicleUI("player")
|
||||
local checkUnit = isInVehicle and "vehicle" or "player"
|
||||
if IceHUD.WowVer >= 60000 then
|
||||
points = UnitPower(checkUnit, 4)
|
||||
points = UnitPower(checkUnit, SPELL_POWER_COMBO_POINTS)
|
||||
else
|
||||
points = GetComboPoints(checkUnit, "target")
|
||||
end
|
||||
|
||||
if IceHUD.WowVer < 70000 then
|
||||
_, _, _, anticipate = UnitAura("player", GetSpellInfo(AnticipationSpellId))
|
||||
else
|
||||
anticipate = 0
|
||||
end
|
||||
else
|
||||
points = GetComboPoints("target")
|
||||
end
|
||||
@ -437,7 +461,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
if (self.moduleSettings.comboMode == "Numeric") then
|
||||
local r, g, b = self:GetColor("ComboPoints")
|
||||
if (self.moduleSettings.gradient and points) then
|
||||
g = g - (0.15*points)
|
||||
g = g - ((1 / self:GetMaxComboPoints())*points)
|
||||
end
|
||||
self.frame.numeric:SetTextColor(r, g, b, 0.7)
|
||||
|
||||
@ -454,7 +478,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
else
|
||||
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
|
||||
|
||||
if ((points > 0) or (anticipate > 0)) and not hideIfNoTarget then
|
||||
@ -469,6 +493,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
self.frame.graphical[i]:Hide()
|
||||
end
|
||||
|
||||
if i <= #self.frame.graphicalAnt then
|
||||
if (i <= anticipate) and not hideIfNoTarget then
|
||||
self.frame.graphicalAnt[i]:Show()
|
||||
else
|
||||
@ -476,6 +501,7 @@ function ComboPoints.prototype:UpdateComboPoints(...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
|
Reference in New Issue
Block a user