Skip to content

Commit

Permalink
Buff filtering import from SUI 6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wutname1 committed Dec 8, 2022
1 parent 810dd20 commit f774d2a
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 62 deletions.
79 changes: 49 additions & 30 deletions Modules/UnitFrames/Elements/Buffs.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
local UF = SUI.UF

---@param element any
---@param unit? UnitId
---@param isFullUpdate? boolean
local function updateSettings(element, unit, isFullUpdate)
local DB = element.DB
element.size = DB.size or 20
element.initialAnchor = DB.position.anchor
element['growth-x'] = DB.growthx
element['growth-y'] = DB.growthy
-- Buffs.spacing = DB.spacing
element.showType = DB.showType
element.num = DB.number or 10
element.onlyShowPlayer = DB.onlyShowPlayer
end

---@param element any
local function SizeChange(element)
local DB = element.DB
local w = (DB.number / DB.rows)
if w < 1.5 then
w = 1.5
end
element:SetSize((DB.size + DB.spacing) * w, (DB.spacing + DB.size) * DB.rows)
end

---@param frame table
---@param DB table
local function Build(frame, DB)
--Buff Icons
local Buffs = CreateFrame('Frame', frame.unitOnCreate .. 'Buffs', frame)
Buffs.PostCreateButton = function(self, button)
local element = CreateFrame('Frame', frame.unitOnCreate .. 'Buffs', frame.raised)
element.PostCreateButton = function(self, button)
UF.Auras:PostCreateButton('Buffs', button)
end

---@param unit UnitId
local CustomFilter = function(
element,
unit,
Expand Down Expand Up @@ -48,38 +72,35 @@ local function Build(frame, DB)
canApplyAura = canApplyAura,
sourceUnit = source
}
button.data = data
button.unit = unit

return UF.Auras:Filter(element, unit, data, element.DB.rules)
end
Buffs.CustomFilter = CustomFilter
frame.Buffs = Buffs
local PreUpdate = function(self)
updateSettings(element)
end

element.displayReasons = {}
element.CustomFilter = CustomFilter
element.PreUpdate = PreUpdate
element.SizeChange = SizeChange
frame.Buffs = element
end

---@param frame table
local function Update(frame)
local DB = frame.Buffs.DB
---@param settings? table
local function Update(frame, settings)
local element = frame.Buffs
local DB = settings or element.DB

if (DB.enabled) then
frame.Buffs:Show()
element:Show()
else
frame.Buffs:Hide()
element:Hide()
end

local Buffs = frame.Buffs
Buffs.size = DB.auraSize
Buffs.initialAnchor = DB.initialAnchor
Buffs['growth-x'] = DB.growthx
Buffs['growth-y'] = DB.growthy
Buffs.spacing = DB.spacing
Buffs.showType = DB.showType
Buffs.num = DB.number
Buffs.onlyShowPlayer = DB.onlyShowPlayer
Buffs.PostCreateIcon = UF.Auras.PostCreateAura
Buffs.PostUpdateIcon = UF.Auras.PostUpdateAura
Buffs:SetPoint(SUI:InverseAnchor(DB.position.anchor), frame, DB.position.anchor, DB.position.x, DB.position.y)
local w = (DB.number / DB.rows)
if w < 1.5 then
w = 1.5
end
Buffs:SetSize((DB.auraSize + DB.spacing) * w, (DB.spacing + DB.auraSize) * DB.rows)
updateSettings(element)
end

---@param unitName string
Expand All @@ -99,18 +120,16 @@ end
---@type SUI.UF.Elements.Settings
local Settings = {
number = 10,
auraSize = 20,
size = 20,
spacing = 1,
showType = true,
width = false,
initialAnchor = 'BOTTOMLEFT',
growthx = 'RIGHT',
growthy = 'DOWN',
rows = 2,
position = {
anchor = 'TOPLEFT',
relativePoint = 'BOTTOMLEFT',
y = -10
relativePoint = 'BOTTOMLEFT'
},
config = {
type = 'Auras'
Expand Down
82 changes: 50 additions & 32 deletions Modules/UnitFrames/Elements/Debuffs.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
local UF = SUI.UF

---@param element any
---@param unit? UnitId
---@param isFullUpdate? boolean
local function updateSettings(element, unit, isFullUpdate)
local DB = element.DB
element.size = DB.size or 20
element.initialAnchor = DB.position.anchor
element['growth-x'] = DB.growthx
element['growth-y'] = DB.growthy
-- Buffs.spacing = DB.spacing
element.showType = DB.showType
element.num = DB.number or 10
element.onlyShowPlayer = DB.onlyShowPlayer
end

---@param element any
local function SizeChange(element)
local DB = element.DB
local w = (DB.number / DB.rows)
if w < 1.5 then
w = 1.5
end
element:SetSize((DB.size + DB.spacing) * w, (DB.spacing + DB.size) * DB.rows)
end

---@param frame table
---@param DB table
local function Build(frame, DB)
--Debuff Icons
local Debuffs = CreateFrame('Frame', frame.unitOnCreate .. 'Debuffs', frame)
Debuffs.PostCreateButton = function(self, button)
local element = CreateFrame('Frame', frame.unitOnCreate .. 'Debuffs', frame.raised)
element.PostCreateButton = function(self, button)
UF.Auras:PostCreateButton('Debuffs', button)
end

---@param unit UnitId
local CustomFilter = function(
element,
unit,
Expand Down Expand Up @@ -48,39 +72,36 @@ local function Build(frame, DB)
canApplyAura = canApplyAura,
sourceUnit = source
}
button.data = data
button.unit = unit

return UF.Auras:Filter(element, unit, data, element.DB.rules)
end
Debuffs.CustomFilter = CustomFilter
local PreUpdate = function(self)
updateSettings(element)
end

frame.Debuffs = Debuffs
element.displayReasons = {}
element.CustomFilter = CustomFilter
element.PreUpdate = PreUpdate
element.SizeChange = SizeChange

frame.Debuffs = element
end

---@param frame table
local function Update(frame)
local DB = frame.Debuffs.DB
---@param settings? table
local function Update(frame, settings)
local element = frame.Debuffs
local DB = settings or element.DB

if (DB.enabled) then
frame.Debuffs:Show()
element:Show()
else
frame.Debuffs:Hide()
element:Hide()
end

local Debuffs = frame.Debuffs
Debuffs.size = DB.auraSize
Debuffs.initialAnchor = DB.initialAnchor
Debuffs['growth-x'] = DB.growthx
Debuffs['growth-y'] = DB.growthy
Debuffs.spacing = DB.spacing
Debuffs.showType = DB.showType
Debuffs.num = DB.number
Debuffs.onlyShowPlayer = DB.onlyShowPlayer
Debuffs.PostCreateIcon = UF.Auras.PostCreateAura
Debuffs.PostUpdateIcon = UF.Auras.PostUpdateAura
Debuffs:SetPoint(SUI:InverseAnchor(DB.position.anchor), frame, DB.position.anchor, DB.position.x, DB.position.y)
local w = (DB.number / DB.rows)
if w < 1.5 then
w = 1.5
end
Debuffs:SetSize((DB.auraSize + DB.spacing) * w, (DB.spacing + DB.auraSize) * DB.rows)
updateSettings(element)
end

---@param unitName string
Expand All @@ -100,28 +121,25 @@ end
---@type SUI.UF.Elements.Settings
local Settings = {
number = 10,
auraSize = 20,
size = 20,
spacing = 1,
width = false,
ShowBoss = true,
showType = true,
initialAnchor = 'BOTTOMRIGHT',
growthx = 'LEFT',
growthy = 'UP',
rows = 2,
position = {
anchor = 'TOPRIGHT',
relativePoint = 'BOTTOMRIGHT',
y = -10
relativePoint = 'BOTTOMRIGHT'
},
rules = {
duration = {
enabled = true,
maxTime = 180,
minTime = 1
},
isBossAura = true,
isFromPlayerOrPlayerPet = true
isBossAura = true
},
config = {
type = 'Auras'
Expand Down

0 comments on commit f774d2a

Please sign in to comment.