X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/9fb47ba879ec613725953c2044ce7e6419af2e3f..922c2d739aa8ac8793961c0e3f562398e0654beb:/kehys/updater.lua diff --git a/kehys/updater.lua b/kehys/updater.lua index a3bd53c..be908d2 100644 --- a/kehys/updater.lua +++ b/kehys/updater.lua @@ -5,12 +5,15 @@ local _, addon = ...; local unpack = unpack; local min = math.min; +local format = string.format; local UnitDebuff, UnitIsCharmed = UnitDebuff, UnitIsCharmed; local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax; +local UnitPower, UnitPowerMax = UnitPower, UnitPowerMax; local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND; local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs; local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs; +local IsResting = IsResting; local dispelcolor = addon.Colors.OverlayColorDispel; local charmcolor = addon.Colors.OverlayColorCharm; @@ -26,12 +29,14 @@ function addon.FrameUpdate(frame) local unit = frame.displayed; local width = frame.barwidth; - -- range check (doesn't have an event) - local inrange, checked = UnitInRange(unit); - if checked and not inrange then - frame:SetAlpha(0.55); - else - frame:SetAlpha(1); + -- range check (doesn't have an event) frames can be marked constantly visible + if not frame.constant then + local inrange, checked = UnitInRange(unit); + if checked and not inrange then + frame:SetAlpha(0.55); + else + frame:SetAlpha(1); + end end -- states if UnitIsDeadOrGhost(unit) then @@ -61,9 +66,13 @@ function addon.FrameUpdate(frame) elseif UnitIsDND(unit) then frame.text:SetText("dnd"); if not frame.text:IsShown() then frame.text:Show() end + elseif frame.nonraid and frame.unit == "player" and IsResting() then + frame.text:SetText("zzz"); + if not frame.text:IsShown() then frame.text:Show() end else if frame.text:IsShown() then frame.text:Hide() end end + -- TODO incoming res, maybe just with events? -- health local current, hmax = UnitHealth(unit), UnitHealthMax(unit); if frame.prev.health ~= current or frame.prev.hmax ~= hmax then @@ -123,15 +132,41 @@ function addon.FrameUpdate(frame) elseif frame.healpred:IsShown() then frame.healpred:Hide(); end - frame.rounds = frame.rounds + 1; - if (frame.rounds > 7) then - frame.tankcd = {}; - frame.alert = {}; - frame.stacks = {}; - frame.heal = {}; - frame.buff1 = {}; - addon.SetAuras(frame.unit, frame.guid); - frame.rounds = 0; + -- mana, if present + if frame.mana ~= nil then + local current, max = UnitPower(unit), UnitPowerMax(unit); + if frame.prev.mana ~= current or frame.prev.mmax ~= max then + frame.prev.mana = current; + frame.prev.mmax = max; + if max < current or max <= 1 then + frame.mana:SetWidth(width); + frame.mana:SetText("100"); + if not frame.mana:IsShown() then frame.mana:Show() end + if not frame.manatext:IsShown() then frame.manatext:Show() end + elseif current <= 0 then + if frame.mana:IsShown() then frame.mana:Hide() end + if frame.manatext:IsShown() then frame.manatext:Hide() end + else + local percent = current/max; + frame.mana:SetWidth(percent*width); + frame.manatext:SetText(format("%d", percent*100)); + if not frame.mana:IsShown() then frame.mana:Show() end + if not frame.manatext:IsShown() then frame.manatext:Show() end + end + end + end + -- forced aura updates + if frame.rounds ~= nil then + frame.rounds = frame.rounds + 1; + if (frame.rounds > 7) then + frame.tankcd = {}; + frame.alert = {}; + frame.stacks = {}; + frame.heal = {}; + frame.buff1 = {}; + addon.SetAuras(frame.unit, frame.guid); + frame.rounds = 0; + end end -- tank CD marker if next(frame.tankcd) then @@ -167,7 +202,7 @@ function addon.FrameUpdate(frame) frame.overlay.color = majorcolor; if not frame.overlay:IsShown() then frame.overlay:Show() end end - else + elseif frame.overlay ~= nil then local _, _, _, _, _, _, _, _, _, spellid = UnitDebuff(unit, 1, "RAID"); if UnitIsCharmed(unit) and frame.unit == frame.displayed then -- charmed