diff --git a/ElvUI/Core/install.lua b/ElvUI/Core/install.lua index 9b36938..93cf099 100644 --- a/ElvUI/Core/install.lua +++ b/ElvUI/Core/install.lua @@ -558,7 +558,7 @@ function E:SetupLayout(layout, noDataReset) E.db.unitframe.units.arena.castbar.width = 200 end - if(layout == "dpsCaster" or layout == "healer" or (layout == "dpsMelee" and E.myclass == "HUNTER")) then + if layout == "dpsCaster" or layout == "healer" or (layout == "dpsMelee" and E.myclass == "HUNTER") then if not E.db.movers then E.db.movers = {} end E.db.unitframe.units.player.castbar.width = E.PixelMode and 406 or 436 E.db.unitframe.units.player.castbar.height = 28 @@ -664,18 +664,6 @@ local function SetupAuras(style) UF:Configure_AuraBars(frame) end - frame = UF["focus"] - E:CopyTable(E.db.unitframe.units.focus.buffs, P.unitframe.units.focus.buffs) - E:CopyTable(E.db.unitframe.units.focus.debuffs, P.unitframe.units.focus.debuffs) - E:CopyTable(E.db.unitframe.units.focus.aurabar, P.unitframe.units.focus.aurabar) - E.db.unitframe.units.focus.smartAuraDisplay = P.unitframe.units.focus.smartAuraDisplay - - if frame then - UF:Configure_Auras(frame, "Buffs") - UF:Configure_Auras(frame, "Debuffs") - UF:Configure_AuraBars(frame) - end - if not style then E.db.unitframe.units.player.buffs.enable = true E.db.unitframe.units.player.buffs.attachTo = "FRAME" @@ -690,7 +678,7 @@ local function SetupAuras(style) E:GetModule("UnitFrames"):CreateAndUpdateUF("target") end - if(InstallStepComplete) then + if InstallStepComplete then InstallStepComplete.message = L["Auras Set"] InstallStepComplete:Show() end diff --git a/ElvUI/Libraries/Load_Libraries.xml b/ElvUI/Libraries/Load_Libraries.xml index 4b9c2ae..ea430d1 100644 --- a/ElvUI/Libraries/Load_Libraries.xml +++ b/ElvUI/Libraries/Load_Libraries.xml @@ -17,6 +17,7 @@ + diff --git a/ElvUI/Libraries/oUF/elements/auras.lua b/ElvUI/Libraries/oUF/elements/auras.lua index e8f834b..9a2db4e 100644 --- a/ElvUI/Libraries/oUF/elements/auras.lua +++ b/ElvUI/Libraries/oUF/elements/auras.lua @@ -64,18 +64,25 @@ button.isDebuff - indicates if the button holds a debuff (boolean) local ns = oUF local oUF = ns.oUF -local tinsert = table.insert -local floor = math.floor +local tinsert, getn = table.insert, table.getn +local floor, min, mod = math.floor, math.min, math.mod local CreateFrame = CreateFrame local GetTime = GetTime local UnitAura = UnitAura +local GetPlayerBuff = GetPlayerBuff +local GetPlayerBuffTexture = GetPlayerBuffTexture +local GetPlayerBuffApplications = GetPlayerBuffApplications +local GetPlayerBuffDispelType = GetPlayerBuffDispelType +local GetPlayerBuffTimeLeft = GetPlayerBuffTimeLeft local VISIBLE = 1 local HIDDEN = 0 local function UpdateTooltip(self) - if self.filter == 'HELPFUL' then + if self:GetParent().__owner.unit == "player" then + GameTooltip:SetPlayerBuff(self:GetID()) + elseif self.filter == 'HELPFUL' then GameTooltip:SetUnitBuff(self:GetParent().__owner.unit, self:GetID(), self.filter) else GameTooltip:SetUnitDebuff(self:GetParent().__owner.unit, self:GetID(), self.filter) @@ -83,7 +90,7 @@ local function UpdateTooltip(self) end local function onEnter(self) - if(not self:IsVisible()) then return end + if not self:IsVisible() then return end GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT') self:UpdateTooltip() @@ -97,7 +104,7 @@ local function createAuraIcon(element, index) local button = CreateFrame('Button', '$parentButton' .. index, element) button:RegisterForClicks('RightButtonUp') - local cd = CreateFrame('Cooldown', '$parentCooldown', button, 'oUF_CooldownFrameTemplate') + local cd = CreateFrame('Frame', '$parentCooldown', button, 'oUF_CooldownFrameTemplate') cd:SetAllPoints() local icon = button:CreateTexture(nil, 'BORDER') @@ -126,117 +133,124 @@ local function createAuraIcon(element, index) * self - the widget holding the aura buttons * button - the newly created aura button (Button) --]] - if(element.PostCreateIcon) then element:PostCreateIcon(button) end + if element.PostCreateIcon then element:PostCreateIcon(button) end return button end local function customFilter(element, unit, button, name) - if(name) then - return true - end + if name then return true end end local function updateIcon(element, unit, index, offset, filter, isDebuff, visible) local name, rank, texture, count, dispelType, duration, expiration = UnitAura(unit, index, filter) + if unit == "player" then + local idx = GetPlayerBuff(index - 1, filter) + if idx < 0 then return end + index = idx + texture = GetPlayerBuffTexture(idx) + count = GetPlayerBuffApplications(idx) + dispelType = GetPlayerBuffDispelType(idx) + duration = GetPlayerBuffTimeLeft(idx) + end + if element.forceShow then name, rank, texture = GetSpellInfo(26993) count, dispelType, duration, expiration = 5, 'Magic', 0, 60 end - if(name) then - local position = visible + offset + 1 - local button = element[position] - if(not button) then - --[[ Override: Auras:CreateIcon(position) - Used to create the aura button at a given position. + if not name then return end - * self - the widget holding the aura buttons - * position - the position at which the aura button is to be created (number) + local position = visible + offset + 1 + local button = element[position] + if not button then + --[[ Override: Auras:CreateIcon(position) + Used to create the aura button at a given position. - ## Returns - - * button - the button used to represent the aura (Button) - --]] - button = (element.CreateIcon or createAuraIcon) (element, position) - - tinsert(element, button) - element.createdIcons = element.createdIcons + 1 - end - - button.filter = filter - button.isDebuff = isDebuff - - --[[ Override: Auras:CustomFilter(unit, button, ...) - Defines a custom filter that controls if the aura button should be shown. - - * self - the widget holding the aura buttons - * unit - the unit on which the aura is cast (string) - * button - the button displaying the aura (Button) - * ... - the return values from [UnitAura](http://wowprogramming.com/docs/api/UnitAura) + * self - the widget holding the aura buttons + * position - the position at which the aura button is to be created (number) ## Returns - * show - indicates whether the aura button should be shown (boolean) + * button - the button used to represent the aura (Button) --]] - local show = true - if not element.forceShow then - show = (element.CustomFilter or customFilter) (element, unit, button, name, rank, texture, count, dispelType, duration, expiration) - end + button = (element.CreateIcon or createAuraIcon) (element, position) - if(show) then - -- We might want to consider delaying the creation of an actual cooldown - -- object to this point, but I think that will just make things needlessly - -- complicated. - if(button.cd and not element.disableCooldown) then - if(duration and duration > 0) then - button.cd:SetCooldown(GetTime() - (duration - expiration), duration) - button.cd:Show() - else - button.cd:Hide() - end - end + tinsert(element, button) + element.createdIcons = element.createdIcons + 1 + end - if(button.overlay) then - if((isDebuff and element.showDebuffType) or (not isDebuff and element.showBuffType) or element.showType) then - local color = DebuffTypeColor[dispelType] or DebuffTypeColor.none + button.filter = filter + button.isDebuff = isDebuff - button.overlay:SetVertexColor(color.r, color.g, color.b) - button.overlay:Show() - else - button.overlay:Hide() - end - end + --[[ Override: Auras:CustomFilter(unit, button, ...) + Defines a custom filter that controls if the aura button should be shown. - if(button.icon) then button.icon:SetTexture(texture) end - if(button.count) then button.count:SetText(count > 1 and count) end + * self - the widget holding the aura buttons + * unit - the unit on which the aura is cast (string) + * button - the button displaying the aura (Button) + * ... - the return values from [UnitAura](http://wowprogramming.com/docs/api/UnitAura) - local size = element.size or 16 - button:SetSize(size, size) + ## Returns - button:EnableMouse(not element.disableMouse) - button:SetID(index) - button:Show() + * show - indicates whether the aura button should be shown (boolean) + --]] + local show = true + if not element.forceShow then + show = (element.CustomFilter or customFilter) (element, unit, button, name, rank, texture, count, dispelType, duration, expiration) + end - --[[ Callback: Auras:PostUpdateIcon(unit, button, index, position) - Called after the aura button has been updated. + if not show then return HIDDEN end - * self - the widget holding the aura buttons - * unit - the unit on which the aura is cast (string) - * button - the updated aura button (Button) - * index - the index of the aura (number) - * position - the actual position of the aura button (number) - --]] - if(element.PostUpdateIcon) then - element:PostUpdateIcon(unit, button, index, position) - end - - return VISIBLE + -- We might want to consider delaying the creation of an actual cooldown + -- object to this point, but I think that will just make things needlessly + -- complicated. + if button.cd and not element.disableCooldown then + if duration and duration > 0 then + -- button.cd:SetCooldown(GetTime() - (duration - expiration), duration) + button.cd:Show() else - return HIDDEN + button.cd:Hide() end end + + if button.overlay then + if (isDebuff and element.showDebuffType) or (not isDebuff and element.showBuffType) or element.showType then + local color = DebuffTypeColor[dispelType] or DebuffTypeColor.none + + button.overlay:SetVertexColor(color.r, color.g, color.b) + button.overlay:Show() + else + button.overlay:Hide() + end + end + + if button.icon then button.icon:SetTexture(texture) end + if button.count then button.count:SetText(count > 1 and count) end + + local size = element.size or 16 + button:SetWidth(size) + button:SetHeight(size) + + button:EnableMouse(not element.disableMouse) + button:SetID(index) + button:Show() + + --[[ Callback: Auras:PostUpdateIcon(unit, button, index, position) + Called after the aura button has been updated. + + * self - the widget holding the aura buttons + * unit - the unit on which the aura is cast (string) + * button - the updated aura button (Button) + * index - the index of the aura (number) + * position - the actual position of the aura button (number) + --]] + if element.PostUpdateIcon then + element:PostUpdateIcon(unit, button, index, position) + end + + return VISIBLE end local function SetPosition(element, from, to) @@ -252,7 +266,7 @@ local function SetPosition(element, from, to) -- Bail out if the to range is out of scope. if(not button) then break end - local col = (i - 1) % cols + local col = mod((i - 1), cols) local row = floor((i - 1) / cols) button:ClearAllPoints() @@ -261,25 +275,25 @@ local function SetPosition(element, from, to) end local function filterIcons(element, unit, filter, limit, isDebuff, offset, dontHide) - if(not offset) then offset = 0 end + if not offset then offset = 0 end local index = 1 local visible = 0 local hidden = 0 - while(visible < limit) do + while visible < limit do local result = updateIcon(element, unit, index, offset, filter, isDebuff, visible) - if(not result) then + if not result then break - elseif(result == VISIBLE) then + elseif result == VISIBLE then visible = visible + 1 - elseif(result == HIDDEN) then + elseif result == HIDDEN then hidden = hidden + 1 end index = index + 1 end - if(not dontHide) then - for i = visible + offset + 1, #element do + if not dontHide then + for i = visible + offset + 1, getn(element) do element[i]:Hide() end end @@ -288,42 +302,42 @@ local function filterIcons(element, unit, filter, limit, isDebuff, offset, dontH end local function UpdateAuras(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then return end local auras = self.Auras - if(auras) then + if auras then --[[ Callback: Auras:PreUpdate(unit) Called before the element has been updated. * self - the widget holding the aura buttons * unit - the unit for which the update has been triggered (string) --]] - if(auras.PreUpdate) then auras:PreUpdate(unit) end + if auras.PreUpdate then auras:PreUpdate(unit) end local numBuffs = auras.numBuffs or 32 local numDebuffs = auras.numDebuffs or 40 local max = auras.numTotal or numBuffs + numDebuffs - local visibleBuffs, hiddenBuffs = filterIcons(auras, unit, auras.buffFilter or auras.filter or 'HELPFUL', math.min(numBuffs, max), nil, 0, true) + local visibleBuffs, hiddenBuffs = filterIcons(auras, unit, auras.buffFilter or auras.filter or 'HELPFUL', min(numBuffs, max), nil, 0, true) local hasGap - if(visibleBuffs ~= 0 and auras.gap) then + if visibleBuffs ~= 0 and auras.gap then hasGap = true visibleBuffs = visibleBuffs + 1 local button = auras[visibleBuffs] - if(not button) then + if not button then button = (auras.CreateIcon or createAuraIcon) (auras, visibleBuffs) tinsert(auras, button) auras.createdIcons = auras.createdIcons + 1 end -- Prevent the button from displaying anything. - if(button.cd) then button.cd:Hide() end - if(button.icon) then button.icon:SetTexture() end - if(button.overlay) then button.overlay:Hide() end - if(button.stealable) then button.stealable:Hide() end - if(button.count) then button.count:SetText() end + if button.cd then button.cd:Hide() end + if button.icon then button.icon:SetTexture() end + if button.overlay then button.overlay:Hide() end + if button.stealable then button.stealable:Hide() end + if button.count then button.count:SetText() end button:EnableMouse(false) button:Show() @@ -341,10 +355,10 @@ local function UpdateAuras(self, event, unit) end end - local visibleDebuffs, hiddenDebuffs = filterIcons(auras, unit, auras.debuffFilter or auras.filter or 'HARMFUL', math.min(numDebuffs, max - visibleBuffs), true, visibleBuffs) + local visibleDebuffs, hiddenDebuffs = filterIcons(auras, unit, auras.debuffFilter or auras.filter or 'HARMFUL', min(numDebuffs, max - visibleBuffs), true, visibleBuffs) auras.visibleDebuffs = visibleDebuffs - if(hasGap and visibleDebuffs == 0) then + if hasGap and visibleDebuffs == 0 then auras[visibleBuffs]:Hide() visibleBuffs = visibleBuffs - 1 end @@ -364,11 +378,11 @@ local function UpdateAuras(self, event, unit) * from - the offset of the first aura button to be (re-)anchored (number) * to - the offset of the last aura button to be (re-)anchored (number) --]] - if(auras.PreSetPosition) then + if auras.PreSetPosition then fromRange, toRange = auras:PreSetPosition(max) end - if(fromRange or auras.createdIcons > auras.anchoredIcons) then + if fromRange or auras.createdIcons > auras.anchoredIcons then --[[ Override: Auras:SetPosition(from, to) Used to (re-)anchor the aura buttons. Called when new aura buttons have been created or if :PreSetPosition is defined. @@ -387,72 +401,72 @@ local function UpdateAuras(self, event, unit) * self - the widget holding the aura buttons * unit - the unit for which the update has been triggered (string) --]] - if(auras.PostUpdate) then auras:PostUpdate(unit) end + if auras.PostUpdate then auras:PostUpdate(unit) end end local buffs = self.Buffs - if(buffs) then - if(buffs.PreUpdate) then buffs:PreUpdate(unit) end + if buffs then + if buffs.PreUpdate then buffs:PreUpdate(unit) end local numBuffs = buffs.num or 32 local visibleBuffs, hiddenBuffs = filterIcons(buffs, unit, buffs.filter or 'HELPFUL', numBuffs) buffs.visibleBuffs = visibleBuffs local fromRange, toRange - if(buffs.PreSetPosition) then + if buffs.PreSetPosition then fromRange, toRange = buffs:PreSetPosition(numBuffs) end - if(fromRange or buffs.createdIcons > buffs.anchoredIcons) then + if fromRange or buffs.createdIcons > buffs.anchoredIcons then (buffs.SetPosition or SetPosition) (buffs, fromRange or buffs.anchoredIcons + 1, toRange or buffs.createdIcons) buffs.anchoredIcons = buffs.createdIcons end - if(buffs.PostUpdate) then buffs:PostUpdate(unit) end + if buffs.PostUpdate then buffs:PostUpdate(unit) end end local debuffs = self.Debuffs - if(debuffs) then - if(debuffs.PreUpdate) then debuffs:PreUpdate(unit) end + if debuffs then + if debuffs.PreUpdate then debuffs:PreUpdate(unit) end local numDebuffs = debuffs.num or 40 local visibleDebuffs, hiddenDebuffs = filterIcons(debuffs, unit, debuffs.filter or 'HARMFUL', numDebuffs, true) debuffs.visibleDebuffs = visibleDebuffs local fromRange, toRange - if(debuffs.PreSetPosition) then + if debuffs.PreSetPosition then fromRange, toRange = debuffs:PreSetPosition(numDebuffs) end - if(fromRange or debuffs.createdIcons > debuffs.anchoredIcons) then + if fromRange or debuffs.createdIcons > debuffs.anchoredIcons then (debuffs.SetPosition or SetPosition) (debuffs, fromRange or debuffs.anchoredIcons + 1, toRange or debuffs.createdIcons) debuffs.anchoredIcons = debuffs.createdIcons end - if(debuffs.PostUpdate) then debuffs:PostUpdate(unit) end + if debuffs.PostUpdate then debuffs:PostUpdate(unit) end end end local function Update(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then return end UpdateAuras(self, event, unit) -- Assume no event means someone wants to re-anchor things. This is usually -- done by UpdateAllElements and :ForceUpdate. - if(event == 'ForceUpdate' or not event) then + if event == 'ForceUpdate' or not event then local buffs = self.Buffs - if(buffs) then + if buffs then (buffs.SetPosition or SetPosition) (buffs, 1, buffs.createdIcons) end local debuffs = self.Debuffs - if(debuffs) then + if debuffs then (debuffs.SetPosition or SetPosition) (debuffs, 1, debuffs.createdIcons) end local auras = self.Auras - if(auras) then + if auras then (auras.SetPosition or SetPosition) (auras, 1, auras.createdIcons) end end @@ -463,11 +477,11 @@ local function ForceUpdate(element) end local function Enable(self) - if(self.Buffs or self.Debuffs or self.Auras) then - self:RegisterEvent('UNIT_AURA', UpdateAuras) + if self.Buffs or self.Debuffs or self.Auras then + self:RegisterEvent('PLAYER_AURAS_CHANGED', UpdateAuras) local buffs = self.Buffs - if(buffs) then + if buffs then buffs.__owner = self buffs.ForceUpdate = ForceUpdate @@ -478,7 +492,7 @@ local function Enable(self) end local debuffs = self.Debuffs - if(debuffs) then + if debuffs then debuffs.__owner = self debuffs.ForceUpdate = ForceUpdate @@ -489,7 +503,7 @@ local function Enable(self) end local auras = self.Auras - if(auras) then + if auras then auras.__owner = self auras.ForceUpdate = ForceUpdate @@ -504,13 +518,13 @@ local function Enable(self) end local function Disable(self) - if(self.Buffs or self.Debuffs or self.Auras) then - self:UnregisterEvent('UNIT_AURA', UpdateAuras) + if self.Buffs or self.Debuffs or self.Auras then + self:UnregisterEvent('PLAYER_AURAS_CHANGED', UpdateAuras) - if(self.Buffs) then self.Buffs:Hide() end - if(self.Debuffs) then self.Debuffs:Hide() end - if(self.Auras) then self.Auras:Hide() end + if self.Buffs then self.Buffs:Hide() end + if self.Debuffs then self.Debuffs:Hide() end + if self.Auras then self.Auras:Hide() end end end -oUF:AddElement('Auras', Update, Enable, Disable) \ No newline at end of file +oUF:AddElement('Auras', Update, Enable, Disable) diff --git a/ElvUI/Libraries/oUF/elements/elements.xml b/ElvUI/Libraries/oUF/elements/elements.xml index 91f969b..d3455b9 100644 --- a/ElvUI/Libraries/oUF/elements/elements.xml +++ b/ElvUI/Libraries/oUF/elements/elements.xml @@ -1,6 +1,6 @@