X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/922c2d739aa8ac8793961c0e3f562398e0654beb..4fb357642ebf6b8b7f103bf86e67a44de1dd00a7:/kehys/updater.lua?ds=sidebyside diff --git a/kehys/updater.lua b/kehys/updater.lua index be908d2..9a673ae 100644 --- a/kehys/updater.lua +++ b/kehys/updater.lua @@ -13,7 +13,7 @@ local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND; local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs; local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs; -local IsResting = IsResting; +local InCombatLockdown, IsResting = InCombatLockdown, IsResting; local dispelcolor = addon.Colors.OverlayColorDispel; local charmcolor = addon.Colors.OverlayColorCharm; @@ -24,6 +24,14 @@ local ignoredAuras = { [315176] = true, -- Grasping Tendrils }; +local powerColors = { + [Enum.PowerType.Mana] = {0.1, 0.5, 0.9}, + [Enum.PowerType.Rage] = {1, 0, 0}, + [Enum.PowerType.Focus] = {1, 0.5, 0}, + [Enum.PowerType.Energy] = {1, 0.8, 0}, + [Enum.PowerType.RunicPower] = {0.8, 0, 0.2}, +}; + function addon.FrameUpdate(frame) assert(type(frame) == "table", "FrameUpdate received invalid frame parameter!"); @@ -61,21 +69,45 @@ function addon.FrameUpdate(frame) frame.prev.hmax = nil; else if UnitIsAFK(unit) then + frame.text.status = true; frame.text:SetText("afk"); if not frame.text:IsShown() then frame.text:Show() end elseif UnitIsDND(unit) then + frame.text.status = true; 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 + frame.text.status = false; + if not (frame.nonraid and frame.unit == "target") and frame.text:IsShown() then + frame.text:Hide(); + end + end + if frame.nonraid and frame.unit == "player" then + if InCombatLockdown() then + frame.status:SetTexCoord(0.5, 1, 0, 0.484375); + frame.status:Show(); + elseif IsResting() then + frame.status:SetTexCoord(0, 0.5, 0, 0.421875); + frame.status:Show(); + elseif frame.status:IsShown() then + frame.status: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 + if frame.nonraid and frame.unit == "target" and frame.prev.htext ~= current then + frame.prev.htext = current; + if current > 1000000000 then -- 1.0B + frame.text:SetFormattedText("%.2fB", current / 1000000000); + elseif current > 1000000 then -- 1.0M + frame.text:SetFormattedText("%.2fM", current / 1000000); + elseif current > 1000 then -- 1.0K + frame.text:SetFormattedText("%.1fK", current / 1000); + end + if not frame.text:IsShown() then frame.text:Show() end + end frame.prev.health = current; frame.prev.hmax = hmax; if hmax < current or hmax <= 1 then @@ -135,12 +167,17 @@ function addon.FrameUpdate(frame) -- mana, if present if frame.mana ~= nil then local current, max = UnitPower(unit), UnitPowerMax(unit); + local ptype = UnitPowerType(unit); + if frame.mana.ptype ~= ptype then + frame.mana.ptype = ptype; + frame.mana:SetVertexColor(unpack(powerColors[ptype])); + end 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"); + frame.manatext: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 @@ -149,7 +186,7 @@ function addon.FrameUpdate(frame) else local percent = current/max; frame.mana:SetWidth(percent*width); - frame.manatext:SetText(format("%d", percent*100)); + frame.manatext:SetText(format("%d", percent*100+0.5)); if not frame.mana:IsShown() then frame.mana:Show() end if not frame.manatext:IsShown() then frame.manatext:Show() end end @@ -168,67 +205,75 @@ function addon.FrameUpdate(frame) frame.rounds = 0; end end - -- tank CD marker - if next(frame.tankcd) then - if not frame.defensive:IsShown() then frame.defensive:Show() end - elseif frame.defensive:IsShown() then - frame.defensive:Hide(); - end - -- aura stacks - if next(frame.stacks) then - local _, amount = next(frame.stacks); - frame.stack:SetText(amount); - if not frame.stack:IsShown() then frame.stack:Show() end - elseif frame.stack:IsShown() then - frame.stack:Hide(); - end - -- custom buff indicator 1 - if next(frame.buff1) then - if not frame.buffind1:IsShown() then frame.buffind1:Show() end - elseif frame.buffind1:IsShown() then - frame.buffind1:Hide(); - end - -- incoming ability - if next(frame.incoming) then - if not frame.glow:IsShown() then frame.glow:Show() end - elseif frame.glow:IsShown() then - frame.glow:Hide(); - end - -- overlays - if next(frame.alert) then - -- major - if frame.overlay.color ~= majorcolor then - frame.overlay:SetVertexColor(unpack(majorcolor)); - frame.overlay.color = majorcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end + if not frame.nonraid then + -- tank CD marker + if next(frame.tankcd) then + if not frame.defensive:IsShown() then frame.defensive:Show() end + elseif frame.defensive:IsShown() then + frame.defensive:Hide(); end - elseif frame.overlay ~= nil then - local _, _, _, _, _, _, _, _, _, spellid = UnitDebuff(unit, 1, "RAID"); - if UnitIsCharmed(unit) and frame.unit == frame.displayed then - -- charmed - if frame.overlay.color ~= charmcolor then - frame.overlay:SetVertexColor(unpack(charmcolor)); - frame.overlay.color = charmcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end - end - elseif spellid ~= nil and not ignoredAuras[spellid] then - -- dispellable - if frame.overlay.color ~= dispelcolor then - frame.overlay:SetVertexColor(unpack(dispelcolor)); - frame.overlay.color = dispelcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end - end - elseif next(frame.heal) then - -- major heals needed - if frame.overlay.color ~= healcolor then - frame.overlay:SetVertexColor(unpack(healcolor)); - frame.overlay.color = healcolor; + -- aura stacks + if next(frame.stacks) then + local _, amount = next(frame.stacks); + frame.stack:SetText(amount); + if not frame.stack:IsShown() then frame.stack:Show() end + elseif frame.stack:IsShown() then + frame.stack:Hide(); + end + -- custom buff indicator 1 + if next(frame.buff1) then + if not frame.buffind1:IsShown() then frame.buffind1:Show() end + elseif frame.buffind1:IsShown() then + frame.buffind1:Hide(); + end + -- custom buff indicator 2 + if next(frame.buff2) then + if not frame.buffind2:IsShown() then frame.buffind2:Show() end + elseif frame.buffind2:IsShown() then + frame.buffind2:Hide(); + end + -- incoming ability + if next(frame.incoming) then + if not frame.glow:IsShown() then frame.glow:Show() end + elseif frame.glow:IsShown() then + frame.glow:Hide(); + end + -- overlays + if next(frame.alert) then + -- major + if frame.overlay.color ~= majorcolor then + frame.overlay:SetVertexColor(unpack(majorcolor)); + frame.overlay.color = majorcolor; if not frame.overlay:IsShown() then frame.overlay:Show() end end else - if frame.overlay.color ~= nil then - frame.overlay.color = nil; - if frame.overlay:IsShown() then frame.overlay:Hide() end + local _, _, _, _, _, _, _, _, _, spellid = UnitDebuff(unit, 1, "RAID"); + if UnitIsCharmed(unit) and frame.unit == frame.displayed then + -- charmed + if frame.overlay.color ~= charmcolor then + frame.overlay:SetVertexColor(unpack(charmcolor)); + frame.overlay.color = charmcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + elseif spellid ~= nil and not ignoredAuras[spellid] then + -- dispellable + if frame.overlay.color ~= dispelcolor then + frame.overlay:SetVertexColor(unpack(dispelcolor)); + frame.overlay.color = dispelcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + elseif next(frame.heal) then + -- major heals needed + if frame.overlay.color ~= healcolor then + frame.overlay:SetVertexColor(unpack(healcolor)); + frame.overlay.color = healcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + else + if frame.overlay.color ~= nil then + frame.overlay.color = nil; + if frame.overlay:IsShown() then frame.overlay:Hide() end + end end end end