This commit is contained in:
Bunny67
2018-06-02 10:55:43 +03:00
parent 3578bd7521
commit f0547dbe52
2 changed files with 88 additions and 82 deletions
+84 -78
View File
@@ -81,7 +81,7 @@ local HIDDEN = 0
local function UpdateTooltip(self) local function UpdateTooltip(self)
if self:GetParent().__owner.unit == "player" then if self:GetParent().__owner.unit == "player" then
GameTooltip:SetPlayerBuff(self:GetID()) GameTooltip:SetPlayerBuff(self:GetID() - 1)
elseif self.filter == 'HELPFUL' then elseif self.filter == 'HELPFUL' then
GameTooltip:SetUnitBuff(self:GetParent().__owner.unit, self:GetID(), self.filter) GameTooltip:SetUnitBuff(self:GetParent().__owner.unit, self:GetID(), self.filter)
else else
@@ -143,16 +143,18 @@ local function customFilter(element, unit, button, texture)
end end
local function updateIcon(element, unit, index, offset, filter, isDebuff, visible) local function updateIcon(element, unit, index, offset, filter, isDebuff, visible)
local texture, count, dispelType, duration, expiration = UnitAura(unit, index, filter) local texture, count, dispelType, duration, expiration
if unit == "player" then if unit == "player" then
local idx = GetPlayerBuff(index - 1, filter) local idx = GetPlayerBuff(index - 1, filter)
if idx < 0 then return end --if idx < 0 then return end
index = idx --index = idx
texture = GetPlayerBuffTexture(idx) texture = GetPlayerBuffTexture(idx)
count = GetPlayerBuffApplications(idx) count = GetPlayerBuffApplications(idx)
dispelType = GetPlayerBuffDispelType(idx) dispelType = GetPlayerBuffDispelType(idx)
duration = GetPlayerBuffTimeLeft(idx) duration = GetPlayerBuffTimeLeft(idx)
else
texture, count, dispelType, duration, expiration = UnitAura(unit, index, filter)
end end
if element.forceShow then if element.forceShow then
@@ -160,97 +162,99 @@ local function updateIcon(element, unit, index, offset, filter, isDebuff, visibl
count, dispelType, duration, expiration = 5, 'Magic', 0, 60 count, dispelType, duration, expiration = 5, 'Magic', 0, 60
end end
if not texture then return end if texture 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.
local position = visible + offset + 1 * self - the widget holding the aura buttons
local button = element[position] * position - the position at which the aura button is to be created (number)
if not button then
--[[ Override: Auras:CreateIcon(position)
Used to create the aura button at a given position.
* self - the widget holding the aura buttons ## Returns
* position - the position at which the aura button is to be created (number)
* 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)
## Returns ## Returns
* button - the button used to represent the aura (Button) * show - indicates whether the aura button should be shown (boolean)
--]] --]]
button = (element.CreateIcon or createAuraIcon) (element, position) local show = true
if not element.forceShow then
show = (element.CustomFilter or customFilter) (element, unit, button, texture, count, dispelType, duration, expiration)
end
tinsert(element, button) if show then
element.createdIcons = element.createdIcons + 1 -- We might want to consider delaying the creation of an actual cooldown
end -- 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
button.filter = filter if button.overlay then
button.isDebuff = isDebuff if (isDebuff and element.showDebuffType) or (not isDebuff and element.showBuffType) or element.showType then
local color = DebuffTypeColor[dispelType] or DebuffTypeColor.none
--[[ Override: Auras:CustomFilter(unit, button, ...) button.overlay:SetVertexColor(color.r, color.g, color.b)
Defines a custom filter that controls if the aura button should be shown. button.overlay:Show()
else
button.overlay:Hide()
end
end
* self - the widget holding the aura buttons if button.icon then button.icon:SetTexture(texture) end
* unit - the unit on which the aura is cast (string) -- if button.count then button.count:SetText(count > 1 and count) end
* button - the button displaying the aura (Button)
* ... - the return values from [UnitAura](http://wowprogramming.com/docs/api/UnitAura)
## Returns local size = element.size or 16
button:SetWidth(size)
button:SetHeight(size)
* show - indicates whether the aura button should be shown (boolean) button:EnableMouse(not element.disableMouse)
--]] button:SetID(index)
local show = true button:Show()
if not element.forceShow then
show = (element.CustomFilter or customFilter) (element, unit, button, texture, count, dispelType, duration, expiration)
end
if not show then return HIDDEN end --[[ Callback: Auras:PostUpdateIcon(unit, button, index, position)
Called after the aura button has been updated.
-- We might want to consider delaying the creation of an actual cooldown * self - the widget holding the aura buttons
-- object to this point, but I think that will just make things needlessly * unit - the unit on which the aura is cast (string)
-- complicated. * button - the updated aura button (Button)
if button.cd and not element.disableCooldown then * index - the index of the aura (number)
if duration and duration > 0 then * position - the actual position of the aura button (number)
-- button.cd:SetCooldown(GetTime() - (duration - expiration), duration) --]]
button.cd:Show() if element.PostUpdateIcon then
element:PostUpdateIcon(unit, button, index, position)
end
return VISIBLE
else else
button.cd:Hide() return HIDDEN
end end
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 end
local function SetPosition(element, from, to) local function SetPosition(element, from, to)
@@ -302,6 +306,8 @@ local function filterIcons(element, unit, filter, limit, isDebuff, offset, dontH
end end
local function UpdateAuras(self, event, unit) local function UpdateAuras(self, event, unit)
if event == "PLAYER_AURAS_CHANGED" then unit = "player" end
if self.unit ~= unit then return end if self.unit ~= unit then return end
local auras = self.Auras local auras = self.Auras
+4 -4
View File
@@ -22,7 +22,7 @@ local UnitIsUnit = UnitIsUnit
function UF:Construct_Buffs(frame) function UF:Construct_Buffs(frame)
local buffs = CreateFrame("Frame", frame:GetName().."Buffs", frame) local buffs = CreateFrame("Frame", frame:GetName().."Buffs", frame)
buffs.spacing = E.Spacing buffs.spacing = E.Spacing
--buffs.PreSetPosition = (not frame:GetScript("OnUpdate")) and self.SortAuras or nil buffs.PreSetPosition = (not frame:GetScript("OnUpdate")) and self.SortAuras or nil
buffs.PostCreateIcon = self.Construct_AuraIcon buffs.PostCreateIcon = self.Construct_AuraIcon
buffs.PostUpdateIcon = self.PostUpdateAura buffs.PostUpdateIcon = self.PostUpdateAura
--buffs.CustomFilter = self.AuraFilter --buffs.CustomFilter = self.AuraFilter
@@ -37,7 +37,7 @@ end
function UF:Construct_Debuffs(frame) function UF:Construct_Debuffs(frame)
local debuffs = CreateFrame("Frame", frame:GetName().."Debuffs", frame) local debuffs = CreateFrame("Frame", frame:GetName().."Debuffs", frame)
debuffs.spacing = E.Spacing debuffs.spacing = E.Spacing
--debuffs.PreSetPosition = (not frame:GetScript("OnUpdate")) and self.SortAuras or nil debuffs.PreSetPosition = (not frame:GetScript("OnUpdate")) and self.SortAuras or nil
debuffs.PostCreateIcon = self.Construct_AuraIcon debuffs.PostCreateIcon = self.Construct_AuraIcon
debuffs.PostUpdateIcon = self.PostUpdateAura debuffs.PostUpdateIcon = self.PostUpdateAura
--debuffs.CustomFilter = self.AuraFilter --debuffs.CustomFilter = self.AuraFilter
@@ -298,7 +298,7 @@ local function SortAurasByCaster(a, b)
end end
function UF:SortAuras() function UF:SortAuras()
if not self.db then return end --[[if not self.db then return end
--Sorting by Index is Default --Sorting by Index is Default
if self.db.sortMethod == "TIME_REMAINING" then if self.db.sortMethod == "TIME_REMAINING" then
@@ -309,7 +309,7 @@ function UF:SortAuras()
tsort(self, SortAurasByDuration) tsort(self, SortAurasByDuration)
elseif self.db.sortMethod == "PLAYER" then elseif self.db.sortMethod == "PLAYER" then
tsort(self, SortAurasByCaster) tsort(self, SortAurasByCaster)
end end]]
--Look into possibly applying filter priorities for auras here. --Look into possibly applying filter priorities for auras here.