- Added support for ComboPoints, ComboPointsBar, and SliceAndDice to display with no target selected using UnitPower(unit, 4) which is apparently combo points now.

This commit is contained in:
Parnic
2014-10-21 23:36:46 -05:00
parent be6d1f6862
commit 996942ae0e
3 changed files with 106 additions and 25 deletions

View File

@ -185,6 +185,23 @@ function ComboPoints.prototype:GetOptions()
order = 34 order = 34
} }
opts["bShowWithNoTarget"] =
{
type = 'toggle',
name = L["Show with no target"],
desc = L["Whether or not to display when you have no target selected but have combo points available"],
get = function()
return self.moduleSettings.bShowWithNoTarget
end,
set = function(info, v)
self.moduleSettings.bShowWithNoTarget = v
self:UpdateComboPoints()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
}
return opts return opts
end end
@ -202,6 +219,7 @@ function ComboPoints.prototype:GetDefaultSettings()
defaults["graphicalLayout"] = "Horizontal" defaults["graphicalLayout"] = "Horizontal"
defaults["comboGap"] = 0 defaults["comboGap"] = 0
defaults["showAnticipation"] = true defaults["showAnticipation"] = true
defaults["bShowWithNoTarget"] = true
return defaults return defaults
end end
@ -395,7 +413,12 @@ function ComboPoints.prototype:UpdateComboPoints()
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")
points = GetComboPoints(isInVehicle and "vehicle" or "player", "target") local checkUnit = isInVehicle and "vehicle" or "player"
if IceHUD.WowVer >= 60000 then
points = UnitPower(checkUnit, 4)
else
points = GetComboPoints(checkUnit, "target")
end
_, _, _, anticipate = UnitAura("player", AnticipationAuraName) _, _, _, anticipate = UnitAura("player", AnticipationAuraName)
else else
points = GetComboPoints("target") points = GetComboPoints("target")
@ -416,7 +439,7 @@ function ComboPoints.prototype:UpdateComboPoints()
pointsText = pointsText.."+"..tostring(anticipate) pointsText = pointsText.."+"..tostring(anticipate)
end end
if points == 0 and anticipate == 0 then if (points == 0 and anticipate == 0) or (not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget) then
self.frame.numeric:SetText(nil) self.frame.numeric:SetText(nil)
else else
self.frame.numeric:SetText(pointsText) self.frame.numeric:SetText(pointsText)
@ -425,19 +448,21 @@ function ComboPoints.prototype:UpdateComboPoints()
self.frame.numeric:SetText() self.frame.numeric:SetText()
for i = 1, table.getn(self.frame.graphical) do for i = 1, table.getn(self.frame.graphical) do
if (points > 0) or (anticipate > 0) then local hideIfNoTarget = not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget
if ((points > 0) or (anticipate > 0)) and not hideIfNoTarget then
self.frame.graphicalBG[i]:Show() self.frame.graphicalBG[i]:Show()
else else
self.frame.graphicalBG[i]:Hide() self.frame.graphicalBG[i]:Hide()
end end
if (i <= points) then if (i <= points) and not hideIfNoTarget then
self.frame.graphical[i]:Show() self.frame.graphical[i]:Show()
else else
self.frame.graphical[i]:Hide() self.frame.graphical[i]:Hide()
end end
if (i <= anticipate) then if (i <= anticipate) and not hideIfNoTarget then
self.frame.graphicalAnt[i]:Show() self.frame.graphicalAnt[i]:Show()
else else
self.frame.graphicalAnt[i]:Hide() self.frame.graphicalAnt[i]:Hide()

View File

@ -30,6 +30,23 @@ function ComboPointsBar.prototype:GetOptions()
order = 31 order = 31
} }
opts["bShowWithNoTarget"] =
{
type = 'toggle',
name = L["Show with no target"],
desc = L["Whether or not to display when you have no target selected but have combo points available"],
get = function()
return self.moduleSettings.bShowWithNoTarget
end,
set = function(info, v)
self.moduleSettings.bShowWithNoTarget = v
self:UpdateComboPoints()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
}
return opts return opts
end end
@ -40,6 +57,7 @@ function ComboPointsBar.prototype:GetDefaultSettings()
defaults.enabled = false defaults.enabled = false
defaults.alwaysDisplay = false defaults.alwaysDisplay = false
defaults.desiredLerpTime = 0.05 defaults.desiredLerpTime = 0.05
defaults.bShowWithNoTarget = true
return defaults return defaults
end end
@ -69,7 +87,12 @@ function ComboPointsBar.prototype:UpdateComboPoints()
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")
points = GetComboPoints(isInVehicle and "vehicle" or "player", "target") local checkUnit = isInVehicle and "vehicle" or "player"
if IceHUD.WowVer >= 60000 then
points = UnitPower(checkUnit, 4)
else
points = GetComboPoints(checkUnit, "target")
end
else else
points = GetComboPoints("target") points = GetComboPoints("target")
end end
@ -78,7 +101,7 @@ function ComboPointsBar.prototype:UpdateComboPoints()
points = nil points = nil
end end
if points == nil or points == 0 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

View File

@ -50,7 +50,7 @@ function SliceAndDice.prototype:Enable(core)
SliceAndDice.super.prototype.Enable(self, core) SliceAndDice.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_AURA", "UpdateSliceAndDice") self:RegisterEvent("UNIT_AURA", "UpdateSliceAndDice")
self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateDurationBar") self:RegisterEvent("UNIT_COMBO_POINTS", "ComboPointsChanged")
if not self.moduleSettings.alwaysFullAlpha then if not self.moduleSettings.alwaysFullAlpha then
self:Show(false) self:Show(false)
@ -61,16 +61,15 @@ function SliceAndDice.prototype:Enable(core)
self:SetBottomText1("") self:SetBottomText1("")
end end
function SliceAndDice.prototype:TargetChanged()
SliceAndDice.super.prototype.TargetChanged(self)
self:UpdateDurationBar()
self:UpdateSliceAndDice()
end
function SliceAndDice.prototype:Disable(core) function SliceAndDice.prototype:Disable(core)
SliceAndDice.super.prototype.Disable(self, core) SliceAndDice.super.prototype.Disable(self, core)
end end
function SliceAndDice.prototype:ComboPointsChanged()
self:TargetChanged()
self:UpdateDurationBar()
end
-- OVERRIDE -- OVERRIDE
function SliceAndDice.prototype:GetDefaultSettings() function SliceAndDice.prototype:GetDefaultSettings()
local settings = SliceAndDice.super.prototype.GetDefaultSettings(self) local settings = SliceAndDice.super.prototype.GetDefaultSettings(self)
@ -90,6 +89,7 @@ function SliceAndDice.prototype:GetDefaultSettings()
settings["lowerTextVisible"] = false settings["lowerTextVisible"] = false
settings["hideAnimationSettings"] = true settings["hideAnimationSettings"] = true
settings["bAllowExpand"] = true settings["bAllowExpand"] = true
settings["bShowWithNoTarget"] = true
return settings return settings
end end
@ -137,6 +137,23 @@ function SliceAndDice.prototype:GetOptions()
end end
} }
opts["bShowWithNoTarget"] =
{
type = 'toggle',
name = L["Show with no target"],
desc = L["Whether or not to display when you have no target selected but have combo points available"],
get = function()
return self.moduleSettings.bShowWithNoTarget
end,
set = function(info, v)
self.moduleSettings.bShowWithNoTarget = v
self:ComboPointsChanged()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
}
return opts return opts
end end
@ -212,11 +229,21 @@ function SliceAndDice.prototype:MyOnUpdate()
if self.bUpdateSnd then if self.bUpdateSnd then
self:UpdateSliceAndDice(nil, self.unit, true) self:UpdateSliceAndDice(nil, self.unit, true)
end end
if self.target then if self.target or self.moduleSettings.bShowWithNoTarget then
self:UpdateDurationBar() self:UpdateDurationBar()
end end
end end
local function SNDGetComboPoints(unit)
if IceHUD.WowVer >= 60000 then
return UnitPower(unit, 4)
elseif IceHUD.WowVer >= 30000 then
return GetComboPoints(unit, "target")
else
return GetComboPoints()
end
end
function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate) function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate)
if unit and unit ~= self.unit then if unit and unit ~= self.unit then
return return
@ -249,7 +276,7 @@ function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate)
else else
self:UpdateBar(0, "SliceAndDice") self:UpdateBar(0, "SliceAndDice")
if ((IceHUD.WowVer >= 30000 and GetComboPoints(self.unit, "target") == 0) or (IceHUD.WowVer < 30000 and GetComboPoints() == 0)) or not UnitExists("target") then if SNDGetComboPoints(self.unit) == 0 or (not UnitExists("target") and not self.moduleSettings.bShowWithNoTarget) then
if self.bIsVisible then if self.bIsVisible then
self.bUpdateSnd = nil self.bUpdateSnd = nil
end end
@ -267,18 +294,24 @@ function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate)
end end
end end
function SliceAndDice.prototype:TargetChanged()
if self.moduleSettings.bShowWithNoTarget and SNDGetComboPoints(self.unit) > 0 then
self.target = true
else
self.target = UnitExists("target")
end
self:Update(self.unit)
self:UpdateDurationBar()
self:UpdateSliceAndDice()
end
function SliceAndDice.prototype:UpdateDurationBar(event, unit) function SliceAndDice.prototype:UpdateDurationBar(event, unit)
if unit and unit ~= self.unit then if unit and unit ~= self.unit then
return return
end end
local points local points = SNDGetComboPoints(self.unit)
if IceHUD.WowVer >= 30000 then
points = GetComboPoints(self.unit, "target")
else
points = GetComboPoints("target")
end
local scale
-- first, set the cached upper limit of SnD duration -- first, set the cached upper limit of SnD duration
CurrMaxSnDDuration = self:GetMaxBuffTime(maxComboPoints) CurrMaxSnDDuration = self:GetMaxBuffTime(maxComboPoints)
@ -295,7 +328,7 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit)
self.durationFrame:Show() self.durationFrame:Show()
-- if we have combo points and a target selected, go ahead and show the bar so the duration bar can be seen -- if we have combo points and a target selected, go ahead and show the bar so the duration bar can be seen
if points > 0 and UnitExists("target") then if points > 0 and (UnitExists("target") or self.moduleSettings.bShowWithNoTarget) then
self:Show(true) self:Show(true)
end end
@ -303,7 +336,7 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit)
PotentialSnDDuration = self:GetMaxBuffTime(points) PotentialSnDDuration = self:GetMaxBuffTime(points)
-- compute the scale from the current number of combo points -- compute the scale from the current number of combo points
scale = IceHUD:Clamp(PotentialSnDDuration / CurrMaxSnDDuration, 0, 1) local scale = IceHUD:Clamp(PotentialSnDDuration / CurrMaxSnDDuration, 0, 1)
-- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element -- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element
if (self.moduleSettings.reverse) then if (self.moduleSettings.reverse) then