Modules/Auras: More fixes to aura filtering and nameplate auras

This commit is contained in:
andrew6180
2023-05-31 19:40:40 -07:00
parent ad3c7eaf28
commit 50e16a313b
8 changed files with 121 additions and 44 deletions
+65
View File
@@ -17,6 +17,71 @@ C.Values = {
}
}
do
C.StateSwitchGetText = function(_, TEXT)
local friend, enemy = strmatch(TEXT, '^Friendly:([^,]*)'), strmatch(TEXT, '^Enemy:([^,]*)')
local text, blockB, blockS, blockT = friend or enemy or TEXT
local SF, localized = E.global.unitframe.specialFilters[text], L[text]
if SF and localized and text:match('^block') then blockB, blockS, blockT = localized:match('^%[(.-)](%s?)(.+)') end
local filterText = (blockB and format('|cFF999999%s|r%s%s', blockB, blockS, blockT)) or localized or text
return (friend and format('|cFF33FF33%s|r %s', _G.FRIEND, filterText)) or (enemy and format('|cFFFF3333%s|r %s', _G.ENEMY, filterText)) or filterText
end
local function filterMatch(s,v)
local m1, m2, m3, m4 = '^'..v..'$', '^'..v..',', ','..v..'$', ','..v..','
return (strmatch(s, m1) and m1) or (strmatch(s, m2) and m2) or (strmatch(s, m3) and m3) or (strmatch(s, m4) and v..',')
end
C.SetFilterPriority = function(db, groupName, auraType, value, remove, movehere, friendState)
if not auraType or not value then return end
local filter = db[groupName] and db[groupName][auraType] and db[groupName][auraType].priority
if not filter then return end
local found = filterMatch(filter, E:EscapeString(value))
if found and movehere then
local tbl, sv, sm = {strsplit(',',filter)}
for i in ipairs(tbl) do
if tbl[i] == value then sv = i elseif tbl[i] == movehere then sm = i end
if sv and sm then break end
end
tremove(tbl, sm)
tinsert(tbl, sv, movehere)
db[groupName][auraType].priority = tconcat(tbl,',')
elseif found and friendState then
local realValue = strmatch(value, '^Friendly:([^,]*)') or strmatch(value, '^Enemy:([^,]*)') or value
local friend = filterMatch(filter, E:EscapeString('Friendly:'..realValue))
local enemy = filterMatch(filter, E:EscapeString('Enemy:'..realValue))
local default = filterMatch(filter, E:EscapeString(realValue))
local state =
(friend and (not enemy) and format('%s%s','Enemy:',realValue)) --[x] friend [ ] enemy: > enemy
or ((not enemy and not friend) and format('%s%s','Friendly:',realValue)) --[ ] friend [ ] enemy: > friendly
or (enemy and (not friend) and default and format('%s%s','Friendly:',realValue)) --[ ] friend [x] enemy: (default exists) > friendly
or (enemy and (not friend) and strmatch(value, '^Enemy:') and realValue) --[ ] friend [x] enemy: (no default) > realvalue
or (friend and enemy and realValue) --[x] friend [x] enemy: > default
if state then
local stateFound = filterMatch(filter, E:EscapeString(state))
if not stateFound then
local tbl, sv = {strsplit(',',filter)}
for i in ipairs(tbl) do
if tbl[i] == value then
sv = i
break
end
end
tinsert(tbl, sv, state)
tremove(tbl, sv+1)
db[groupName][auraType].priority = tconcat(tbl,',')
end
end
elseif found and remove then
db[groupName][auraType].priority = gsub(filter, found, '')
elseif not found and not remove then
db[groupName][auraType].priority = (filter == '' and value) or (filter..','..value)
end
end
end
E:AddLib("AceGUI", "AceGUI-3.0")
E:AddLib("AceConfig", "AceConfig-3.0-ElvUI")
E:AddLib("AceConfigDialog", "AceConfigDialog-3.0-ElvUI")