From 42489e7118208f82214c8e5d0ee19ead27a6f89d Mon Sep 17 00:00:00 2001 From: d87 Date: Sat, 12 Sep 2020 21:48:21 +0700 Subject: [PATCH] Added AlternatePowerStatus --- Aptechka.lua | 17 +++++++++++++++-- Options/StatusConfig.lua | 1 + config.lua | 1 + frame.lua | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Aptechka.lua b/Aptechka.lua index e32c76d..e7aef34 100644 --- a/Aptechka.lua +++ b/Aptechka.lua @@ -1143,6 +1143,9 @@ end function Aptechka.UNIT_CONNECTION(self, event, unit) Aptechka:ForEachUnitFrame(unit, Aptechka.FrameUpdateConnection) end + +local Enum_RunicPower = Enum.PowerType.RunicPower +local Enum_Alternate = Enum.PowerType.Alternate function Aptechka.FrameUpdatePower(frame, unit, ptype) if ptype == "MANA" then-- not frame.power.disabled then local powerMax = UnitPowerMax(unit) @@ -1157,14 +1160,23 @@ function Aptechka.FrameUpdatePower(frame, unit, ptype) if not Aptechka:UnitIsTank(unit) then return FrameSetJob(frame, config.RunicPowerStatus, false) end - local powerMax = UnitPowerMax(unit) - local power = UnitPower(unit) + local powerMax = UnitPowerMax(unit, Enum_RunicPower) + local power = UnitPower(unit, Enum_RunicPower) if power > 40 then local p = power/powerMax FrameSetJob(frame, config.RunicPowerStatus, true, "PROGRESS", p) else FrameSetJob(frame, config.RunicPowerStatus, false) end + elseif ptype == "ALTERNATE" then + local powerMax = UnitPowerMax(unit, Enum_Alternate) + local power = UnitPower(unit, Enum_Alternate) + if power > 0 then + local p = power/powerMax + FrameSetJob(frame, config.AlternatePowerStatus, true, "PROGRESS", p) + else + FrameSetJob(frame, config.AlternatePowerStatus, false) + end end end function Aptechka.UNIT_POWER_UPDATE(self, event, unit, ptype) @@ -1718,6 +1730,7 @@ local function updateUnitButton(self, unit) Aptechka.FrameUpdateDisplayPower(self, unit) local ptype = select(2,UnitPowerType(owner)) Aptechka.FrameUpdatePower(self, unit, ptype) + Aptechka.FrameUpdatePower(self, unit, "ALTERNATE") end Aptechka.FrameUpdateThreat(self, unit) Aptechka.FrameUpdateMindControl(self, unit) diff --git a/Options/StatusConfig.lua b/Options/StatusConfig.lua index e28681b..b9ccf43 100644 --- a/Options/StatusConfig.lua +++ b/Options/StatusConfig.lua @@ -19,6 +19,7 @@ function ns.MakeStatusConfig() "MainTankStatus", "DispelStatus", "RunicPowerStatus", + "AlternatePowerStatus", } for i, status in ipairs(configurableWidgets) do diff --git a/config.lua b/config.lua index cb71fed..f1171cb 100644 --- a/config.lua +++ b/config.lua @@ -62,6 +62,7 @@ config.LOSStatus = { name = "OutOfSight", assignto = set("healfeedback"), scale config.DispelStatus = { name = "Dispel", assignto = set("raidbuff"), scale = 2, hscale = 2, spin = true, priority = 86 } config.StaggerStatus = { name = "Stagger", assignto = set("text2"), priority = 20 } config.RunicPowerStatus = { name = "RunicPower", assignto = set("mitigation"), priority = 10, color = { 0, 0.82, 1 } } +config.AlternatePowerStatus = { name = "AlternatePower", assignto = set("mitigation"), priority = 30, color = { 0.8, 0, 0.3 } } config.SummonPending = { name = "SUMMON_PENDING", set("text2"), color = {1,0.7,0}, text = "PENDING", priority = 50 } config.SummonAccepted = { name = "SUMMON_ACCEPTED", set("text2"), color = {0,1,0}, text = "ACCEPTED", priority = 51 } diff --git a/frame.lua b/frame.lua index b08b3ba..4eb6a08 100644 --- a/frame.lua +++ b/frame.lua @@ -1741,6 +1741,12 @@ local TextTypeHandlers = { self.text:SetTextColor(helpers.PercentColor(stagger)) self.text:SetFormattedText("%.0f%%", stagger*100) end, + ["PROGRESS"] = function(self, job, state, contentType, ...) + local perc = ... + self.text:SetTextColor(helpers.PercentColor(perc)) + -- self.text:SetTextColor(GetTextColor(job)) + self.text:SetFormattedText("%.0f%%", perc*100) + end, ["UnitName"] = function(self, job, state, contentType, ...) self.text:SetText(state.name) self:SetScript("OnUpdate", nil)