diff --git a/modules/ComboPoints.lua b/modules/ComboPoints.lua index 70fbdf0..5409c1f 100644 --- a/modules/ComboPoints.lua +++ b/modules/ComboPoints.lua @@ -185,6 +185,23 @@ function ComboPoints.prototype:GetOptions() 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 end @@ -202,6 +219,7 @@ function ComboPoints.prototype:GetDefaultSettings() defaults["graphicalLayout"] = "Horizontal" defaults["comboGap"] = 0 defaults["showAnticipation"] = true + defaults["bShowWithNoTarget"] = true return defaults end @@ -395,7 +413,12 @@ function ComboPoints.prototype:UpdateComboPoints() elseif IceHUD.WowVer >= 30000 then -- Parnic: apparently some fights have combo points while the player is in a vehicle? 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) else points = GetComboPoints("target") @@ -416,7 +439,7 @@ function ComboPoints.prototype:UpdateComboPoints() pointsText = pointsText.."+"..tostring(anticipate) 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) else self.frame.numeric:SetText(pointsText) @@ -425,19 +448,21 @@ function ComboPoints.prototype:UpdateComboPoints() self.frame.numeric:SetText() 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() else self.frame.graphicalBG[i]:Hide() end - if (i <= points) then + if (i <= points) and not hideIfNoTarget then self.frame.graphical[i]:Show() else self.frame.graphical[i]:Hide() end - if (i <= anticipate) then + if (i <= anticipate) and not hideIfNoTarget then self.frame.graphicalAnt[i]:Show() else self.frame.graphicalAnt[i]:Hide() diff --git a/modules/ComboPointsBar.lua b/modules/ComboPointsBar.lua index c41d0d6..b0bc1b2 100644 --- a/modules/ComboPointsBar.lua +++ b/modules/ComboPointsBar.lua @@ -30,6 +30,23 @@ function ComboPointsBar.prototype:GetOptions() 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 end @@ -40,6 +57,7 @@ function ComboPointsBar.prototype:GetDefaultSettings() defaults.enabled = false defaults.alwaysDisplay = false defaults.desiredLerpTime = 0.05 + defaults.bShowWithNoTarget = true return defaults end @@ -69,7 +87,12 @@ function ComboPointsBar.prototype:UpdateComboPoints() elseif IceHUD.WowVer >= 30000 then -- Parnic: apparently some fights have combo points while the player is in a vehicle? 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 points = GetComboPoints("target") end @@ -78,7 +101,7 @@ function ComboPointsBar.prototype:UpdateComboPoints() points = nil 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:UpdateBar(0, "undef") else diff --git a/modules/SliceAndDice.lua b/modules/SliceAndDice.lua index 753de6a..b6e8293 100644 --- a/modules/SliceAndDice.lua +++ b/modules/SliceAndDice.lua @@ -50,7 +50,7 @@ function SliceAndDice.prototype:Enable(core) SliceAndDice.super.prototype.Enable(self, core) self:RegisterEvent("UNIT_AURA", "UpdateSliceAndDice") - self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateDurationBar") + self:RegisterEvent("UNIT_COMBO_POINTS", "ComboPointsChanged") if not self.moduleSettings.alwaysFullAlpha then self:Show(false) @@ -61,16 +61,15 @@ function SliceAndDice.prototype:Enable(core) self:SetBottomText1("") end -function SliceAndDice.prototype:TargetChanged() - SliceAndDice.super.prototype.TargetChanged(self) - self:UpdateDurationBar() - self:UpdateSliceAndDice() -end - function SliceAndDice.prototype:Disable(core) SliceAndDice.super.prototype.Disable(self, core) end +function SliceAndDice.prototype:ComboPointsChanged() + self:TargetChanged() + self:UpdateDurationBar() +end + -- OVERRIDE function SliceAndDice.prototype:GetDefaultSettings() local settings = SliceAndDice.super.prototype.GetDefaultSettings(self) @@ -90,6 +89,7 @@ function SliceAndDice.prototype:GetDefaultSettings() settings["lowerTextVisible"] = false settings["hideAnimationSettings"] = true settings["bAllowExpand"] = true + settings["bShowWithNoTarget"] = true return settings end @@ -137,6 +137,23 @@ function SliceAndDice.prototype:GetOptions() 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 end @@ -212,11 +229,21 @@ function SliceAndDice.prototype:MyOnUpdate() if self.bUpdateSnd then self:UpdateSliceAndDice(nil, self.unit, true) end - if self.target then + if self.target or self.moduleSettings.bShowWithNoTarget then self:UpdateDurationBar() 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) if unit and unit ~= self.unit then return @@ -249,7 +276,7 @@ function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate) else 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 self.bUpdateSnd = nil end @@ -267,18 +294,24 @@ function SliceAndDice.prototype:UpdateSliceAndDice(event, unit, fromUpdate) 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) if unit and unit ~= self.unit then return end - local points - if IceHUD.WowVer >= 30000 then - points = GetComboPoints(self.unit, "target") - else - points = GetComboPoints("target") - end - local scale + local points = SNDGetComboPoints(self.unit) -- first, set the cached upper limit of SnD duration CurrMaxSnDDuration = self:GetMaxBuffTime(maxComboPoints) @@ -295,7 +328,7 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit) 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 points > 0 and UnitExists("target") then + if points > 0 and (UnitExists("target") or self.moduleSettings.bShowWithNoTarget) then self:Show(true) end @@ -303,7 +336,7 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit) PotentialSnDDuration = self:GetMaxBuffTime(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 if (self.moduleSettings.reverse) then