Skip to content

Commit

Permalink
refactor: cleanup code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Jun 11, 2022
1 parent 30d422a commit 6ee928c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
2 changes: 1 addition & 1 deletion gui/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ function GUI:SetupNameplateAuraFilter(parent)
StaticPopup_Show('FREEUI_RESET_NAMEPLATE_AURA_FILTER')
end)

for spellID, value in pairs(NAMEPLATE.NameplateFilter[index]) do
for spellID, value in pairs(NAMEPLATE.AuraFilterList[index]) do
if value then
createBar(scroll.child, index, spellID)
end
Expand Down
8 changes: 3 additions & 5 deletions modules/nameplate/nameplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1064,26 +1064,24 @@ function NAMEPLATE:CheckNameplateAuraFilters()
CheckNameplateAuraFilter(2)
end

NAMEPLATE.NameplateFilter = { [1] = {}, [2] = {} }

local function RefreshNameplateAuraFilter(index)
wipe(NAMEPLATE.NameplateFilter[index])
wipe(NAMEPLATE.AuraFilterList[index])

local VALUE = (index == 1 and C.NameplateAuraWhiteList) or (index == 2 and C.NameplateAuraBlackList)
if VALUE then
for spellID in pairs(VALUE) do
local name = GetSpellInfo(spellID)
if name then
if _G.FREE_ADB['NameplateAuraFilterList'][index][spellID] == nil then
NAMEPLATE.NameplateFilter[index][spellID] = true
NAMEPLATE.AuraFilterList[index][spellID] = true
end
end
end
end

for spellID, value in pairs(_G.FREE_ADB['NameplateAuraFilterList'][index]) do
if value then
NAMEPLATE.NameplateFilter[index][spellID] = true
NAMEPLATE.AuraFilterList[index][spellID] = true
end
end
end
Expand Down
75 changes: 41 additions & 34 deletions modules/unitframe/elements/auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ local isMine = {
['vehicle'] = true,
}

NAMEPLATE.AuraFilterList = {
[1] = {},
[2] = {},
}

function UNITFRAME.AuraFilter(
element,
unit,
Expand Down Expand Up @@ -274,16 +279,16 @@ function UNITFRAME.AuraFilter(
end
elseif style == 'nameplate' or style == 'boss' or style == 'arena' then
if element.__owner.plateType == 'NameOnly' then
return NAMEPLATE.NameplateFilter[1][spellID]
elseif NAMEPLATE.NameplateFilter[2][spellID] then
return NAMEPLATE.AuraFilterList[1][spellID]
elseif NAMEPLATE.AuraFilterList[2][spellID] then
return false
elseif
(element.showStealableBuffs and isStealable or element.alwaysShowStealable and dispellType[debuffType])
and not UnitIsPlayer(unit)
and not button.isDebuff
then
return true
elseif NAMEPLATE.NameplateFilter[1][spellID] then
elseif NAMEPLATE.AuraFilterList[1][spellID] then
return true
else
local auraFilter = C.DB.Nameplate.AuraFilterMode
Expand Down Expand Up @@ -489,6 +494,39 @@ function UNITFRAME:CreateAuras(self)
F:RegisterEvent('PLAYER_ENTERING_WORLD', UNITFRAME.PLAYER_ENTERING_WORLD)
end

function NAMEPLATE:CreateAuras(self)
local bu = CreateFrame('Frame', nil, self)
bu.gap = true
bu.spacing = 4
bu.numTotal = 32
bu.initialAnchor = 'BOTTOMLEFT'
bu:SetPoint('BOTTOM', self, 'TOP', 0, 16)
bu['growth-x'] = 'RIGHT'
bu['growth-y'] = 'UP'
bu.iconsPerRow = C.DB.Nameplate.AuraPerRow
bu.disableCooldown = true

UNITFRAME:UpdateAuraContainer(self, bu, bu.numTotal)

bu.onlyShowPlayer = C.DB.Nameplate.OnlyShowPlayer
bu.desaturateDebuff = C.DB.Nameplate.DesaturateIcon
bu.showDebuffType = C.DB.Nameplate.DebuffTypeColor
bu.showStealableBuffs = C.DB.Nameplate.StealableBuffs
bu.disableMouse = C.DB.Nameplate.DisableMouse

bu.showStealableBuffs = C.DB.Nameplate.DispellMode == 1
bu.alwaysShowStealable = C.DB.Nameplate.DispellMode == 2

bu.CustomFilter = UNITFRAME.AuraFilter
bu.PostCreateIcon = UNITFRAME.PostCreateIcon
bu.PostUpdateIcon = UNITFRAME.PostUpdateIcon
bu.PostUpdateGapIcon = UNITFRAME.PostUpdateGapIcon
bu.PreUpdate = BolsterPreUpdate
bu.PostUpdate = BolsterPostUpdate

self.Auras = bu
end

function UNITFRAME.PartyAuraFilter(_, _, _, _, _, _, _, _, _, _, _, _, spellID)
if C.PartyAurasList[spellID] then
return true
Expand Down Expand Up @@ -534,38 +572,7 @@ function UNITFRAME:CreatePartyAuras(self)
self.Auras = bu
end

function NAMEPLATE:CreateAuras(self)
local bu = CreateFrame('Frame', nil, self)
bu.gap = true
bu.spacing = 4
bu.numTotal = 32
bu.initialAnchor = 'BOTTOMLEFT'
bu:SetPoint('BOTTOM', self, 'TOP', 0, 16)
bu['growth-x'] = 'RIGHT'
bu['growth-y'] = 'UP'
bu.iconsPerRow = C.DB.Nameplate.AuraPerRow
bu.disableCooldown = true

UNITFRAME:UpdateAuraContainer(self, bu, bu.numTotal)

bu.onlyShowPlayer = C.DB.Nameplate.OnlyShowPlayer
bu.desaturateDebuff = C.DB.Nameplate.DesaturateIcon
bu.showDebuffType = C.DB.Nameplate.DebuffTypeColor
bu.showStealableBuffs = C.DB.Nameplate.StealableBuffs
bu.disableMouse = C.DB.Nameplate.DisableMouse

bu.showStealableBuffs = C.DB.Nameplate.DispellMode == 1
bu.alwaysShowStealable = C.DB.Nameplate.DispellMode == 2

bu.CustomFilter = UNITFRAME.AuraFilter
bu.PostCreateIcon = UNITFRAME.PostCreateIcon
bu.PostUpdateIcon = UNITFRAME.PostUpdateIcon
bu.PostUpdateGapIcon = UNITFRAME.PostUpdateGapIcon
bu.PreUpdate = BolsterPreUpdate
bu.PostUpdate = BolsterPostUpdate

self.Auras = bu
end

function UNITFRAME.GroupBuffFilter(_, _, _, _, _, _, _, _, _, caster, _, _, spellID, canApplyAura, isBossAura)
if isBossAura then
Expand Down

0 comments on commit 6ee928c

Please sign in to comment.