diff --git a/Interface/AddOns/SVUI/SVUI.toc b/Interface/AddOns/SVUI/SVUI.toc index a867494..f404ada 100644 --- a/Interface/AddOns/SVUI/SVUI.toc +++ b/Interface/AddOns/SVUI/SVUI.toc @@ -3,8 +3,8 @@ ## Version: @project-version@ ## Title: |cffFF9900SVUI|r ## Notes: Supervillain UI [|cff9911FFCore Framework|r]. -## SavedVariables: SVUI_Global -## SavedVariablesPerCharacter: SVUI_Profile, SVUI_Filters, SVUI_Cache +## SavedVariables: SVUI_Global, SVUI_AuraFilters +## SavedVariablesPerCharacter: SVUI_Profile, SVUI_Cache ## OptionalDeps: Blizzard_DebugTools, Blizzard_PetJournal, SharedMedia ## X-oUF: oUF_SuperVillain ## X-Notes: Special thanks to Elv and Tukz for their incredible work. diff --git a/Interface/AddOns/SVUI/packages/bag/SVBag.lua b/Interface/AddOns/SVUI/packages/bag/SVBag.lua index 4555663..2469785 100644 --- a/Interface/AddOns/SVUI/packages/bag/SVBag.lua +++ b/Interface/AddOns/SVUI/packages/bag/SVBag.lua @@ -350,7 +350,7 @@ function MOD:Layout(isBank) if not f then return; end; local buttonSize = isBank and MOD.db.bankSize or MOD.db.bagSize; local buttonSpacing = 8; - local containerWidth = (MOD.db.alignToChat == true and (SuperVillain.db.SVDock.dockWidth - 14)) or (isBank and MOD.db.bankWidth) or MOD.db.bagWidth + local containerWidth = (MOD.db.alignToChat == true and (isBank and (SuperVillain.db.SVDock.dockLeftWidth - 14) or (SuperVillain.db.SVDock.dockRightWidth - 14))) or (isBank and MOD.db.bankWidth) or MOD.db.bagWidth local numContainerColumns = floor(containerWidth / (buttonSize + buttonSpacing)); local holderWidth = ((buttonSize + buttonSpacing) * numContainerColumns) - buttonSpacing; local numContainerRows = 0; diff --git a/Interface/AddOns/SVUI/packages/unit/common/auras.lua b/Interface/AddOns/SVUI/packages/unit/common/auras.lua index 1103db7..c66dd0f 100644 --- a/Interface/AddOns/SVUI/packages/unit/common/auras.lua +++ b/Interface/AddOns/SVUI/packages/unit/common/auras.lua @@ -310,10 +310,9 @@ end function MOD:AuraFilter(unit, icon, name, _, _, _, dtype, duration, _, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossAura) if spellID == 65148 then return false end local isPlayer,friendly; - local db = self:GetParent().db; local auraType = self.type; - if not db or not auraType or not db[auraType] then return true end - db = db[auraType] + local db = MOD.db[unit][auraType]; + if not db then return true end local filtered=true; local allowed=true; local pass=false; @@ -381,7 +380,7 @@ function MOD:AuraFilter(unit, icon, name, _, _, _, dtype, duration, _, caster, i end elseif spellDB[name] and spellDB[name].enable then filtered=false - end + end end return filtered end diff --git a/Interface/AddOns/SVUI/packages/unit/frames/basic/tot.lua b/Interface/AddOns/SVUI/packages/unit/frames/basic/tot.lua index 8552ab3..24dbd53 100644 --- a/Interface/AddOns/SVUI/packages/unit/frames/basic/tot.lua +++ b/Interface/AddOns/SVUI/packages/unit/frames/basic/tot.lua @@ -39,7 +39,7 @@ function MOD.Construct:targettarget(frame) frame.RaidIcon = MOD:CreateRaidIcon(frame) frame.Debuffs = MOD:CreateDebuffs(frame) frame.Range = { insideAlpha = 1, outsideAlpha = 1 } - frame:Point("BOTTOM", SuperVillain.UIParent, "BOTTOM", 0, 226) + frame:Point("BOTTOM", SuperVillain.UIParent, "BOTTOM", 0, 213) SuperVillain:SetSVMovable(frame, frame:GetName().."_MOVE", L["TargetTarget Frame"], nil, nil, nil, "ALL, SOLO") end --[[ diff --git a/Interface/AddOns/SVUI/system/classes/Database.lua b/Interface/AddOns/SVUI/system/classes/Database.lua index 9d0572b..441e940 100644 --- a/Interface/AddOns/SVUI/system/classes/Database.lua +++ b/Interface/AddOns/SVUI/system/classes/Database.lua @@ -860,8 +860,8 @@ local DatabaseDefaults = { ["xrayFocus"] = true, ["player"] = { ["enable"] = true, - ["width"] = 235, - ["height"] = 70, + ["width"] = 215, + ["height"] = 60, ["lowmana"] = 30, ["combatfade"] = false, ["predict"] = true, @@ -902,7 +902,7 @@ local DatabaseDefaults = { { ["enable"] = true, ["tags"] = "", - ["height"] = 15, + ["height"] = 10, ["position"] = "INNERLEFT", ["hideonnpc"] = false, ["xOffset"] = 0, @@ -1057,8 +1057,8 @@ local DatabaseDefaults = { }, ["target"] = { ["enable"] = true, - ["width"] = 235, - ["height"] = 70, + ["width"] = 215, + ["height"] = 60, ["threatEnabled"] = true, ["rangeCheck"] = true, ["predict"] = true, @@ -1098,7 +1098,7 @@ local DatabaseDefaults = { { ["enable"] = true, ["tags"] = "", - ["height"] = 13, + ["height"] = 10, ["position"] = "CENTER", ["hideonnpc"] = true, ["xOffset"] = 0, @@ -3352,6 +3352,12 @@ local DatabaseDefaults = { } }, } + +local GlobalDefaults = { + ["Accountant"] = {}, + ["profiles"] = {}, + ["profileKeys"] = {}, +} --[[ ########################################################## CREATE DB @@ -3391,8 +3397,8 @@ local function importdata(s, d) end local function setdefaults(t, key, sub, sub2) - local sv = _G["SVUI_Profile"] - local src = DatabaseDefaults + local sv = rawget(t, "profile") + local src = rawget(t, "defaults") local savedProfile = sv[key] if(sub2 and sv[key] and sv[key][sub]) then savedProfile = sv[key][sub][sub2] @@ -3412,7 +3418,8 @@ local function setdefaults(t, key, sub, sub2) end local function getdefaults(t, key) - return DatabaseDefaults[key] or {} + local src = rawget(t, "defaults") + return src[key] or {} end local function removedefaults(db, src, nometa) @@ -3438,7 +3445,7 @@ end local function resetprofile(t) local sv = rawget(t, "profile") - local src = DatabaseDefaults + local src = rawget(t, "defaults") for k,v in pairs(sv) do if(k ~= "SAFEDATA") then sv[k] = nil @@ -3448,27 +3455,10 @@ local function resetprofile(t) ReloadUI() end -local function listprofiles(t) - local list = {[" SELECT ONE"] = " SELECT ONE"} - local globals = rawget(t, "global") - for key,_ in pairs(globals.profiles) do - list[key] = key - end - return list -end - -local function firstprofile(t) - local globals = rawget(t, "global") - for key,_ in pairs(globals.profiles) do - return key - end -end - local function importprofile(t, key) - if(key == " SELECT ONE") then return end local sv = rawget(t, "profile") local dv = rawget(t, "defaults") - local globals = rawget(t, "global") + local globals = SuperVillain.global local src = globals.profiles[key] if(not src) then return end for k,v in pairs(sv) do @@ -3482,29 +3472,29 @@ local function importprofile(t, key) end local function exportprofile(t, key) - if(key == " SELECT ONE") then return end local sv = rawget(t, "profile") - local globals = rawget(t, "global") - local dv = DatabaseDefaults + local dv = rawget(t, "defaults") + local globals = SuperVillain.global if(not globals.profiles[key]) then globals.profiles[key] = {} end local saved = globals.profiles[key] tablecopy(saved, sv) for k,v in pairs(saved) do removedefaults(saved[k], dv[k]) end + globals.profileKeys[key] = key SuperVillain:SavedPopup() end local function removeprofile(t, key) - if(key == " SELECT ONE") then return end - local globals = rawget(t, "global") + local globals = SuperVillain.global if(globals.profiles[key]) then globals.profiles[key] = nil end + if(globals.profileKeys[key]) then globals.profileKeys[key] = nil end collectgarbage("collect") end local function initializedata(t) local sv = rawget(t, "profile") - local dv = DatabaseDefaults + local dv = rawget(t, "defaults") for k,v in pairs(sv) do if(k ~= "SAFEDATA" and dv[k]) then removedefaults(sv[k], dv[k]) @@ -3541,18 +3531,15 @@ local metadatabase = { end } -local METAPROFILE = function(sv, gv) +local METAPROFILE = function(sv) local db = setmetatable({}, metadatabase) db.profile = sv - db.global = gv db.defaults = DatabaseDefaults db.Init = initializedata db.Reset = resetprofile db.SetDefault = setdefaults db.GetDefault = getdefaults - db.GetAll = listprofiles - db.GetFirst = firstprofile db.Import = importprofile db.Export = exportprofile db.Remove = removeprofile @@ -3564,6 +3551,58 @@ local METAPROFILE = function(sv, gv) return db end +local function listprofiles(t) + local globals = t.globals + local list = globals.profileKeys or {} + return list +end + +local function checkprofiles(t) + local hasProfile = false + local globals = rawget(t, "globals") + local list = globals.profileKeys or {} + for key,_ in pairs(list) do + hasProfile = true + end + return hasProfile +end + +local function initializeglobals(t) + local sv = _G["SVUI_Global"] + local dv = GlobalDefaults + local keys = {} + for k,v in pairs(sv.profiles) do + keys[k] = k + end + sv.profileKeys = keys +end + +local metaglobals = { + __index = function(t, k) + local sv = rawget(t, "globals") + local dv = rawget(t, "defaults") + local src = dv and dv[k] + if(not sv[k]) then sv[k] = {} end + if(src) then + tablecopy(sv[k], src) + end + rawset(t, k, sv[k]) + return rawget(t, k) + end +} + +local METAGLOBAL = function(sv) + local db = setmetatable({}, metaglobals) + + db.globals = sv + db.defaults = GlobalDefaults + db.GetProfiles = listprofiles + db.CheckProfiles = checkprofiles + db.Init = initializeglobals + + return db +end + function SuperVillain:HexColor(arg1,arg2,arg3) local r,g,b; if arg1 and type(arg1) == "string" then @@ -3592,13 +3631,19 @@ end function SuperVillain:SetDatabaseObjects(init) if(init) then + self.global = tcopy(GlobalDefaults, true) self.db = tcopy(DatabaseDefaults, true) else local sv = _G["SVUI_Profile"] local gv = _G["SVUI_Global"] + twipe(self.global) twipe(self.db) - self.db = METAPROFILE(sv, gv) + + self.global = METAGLOBAL(gv) + self.global:Init() + + self.db = METAPROFILE(sv) self.db:Init() self.db.profileKey = pkey end diff --git a/Interface/AddOns/SVUI/system/classes/Filters.lua b/Interface/AddOns/SVUI/system/classes/Filters.lua index 5d14c8a..0815dc2 100644 --- a/Interface/AddOns/SVUI/system/classes/Filters.lua +++ b/Interface/AddOns/SVUI/system/classes/Filters.lua @@ -628,9 +628,48 @@ local function tablecopy(d, s) end end +do + for k, x in pairs(FilterIDs) do + local src = {}; + for id in gmatch(x, '([^,]+)') do + if(id) then + local saved + local n = safename(id); + local p = FilterOverrides[tostring(id)] or 0; + if k == "Strict" then + saved = {['enable'] = true, ['spellID'] = id, ['priority'] = p} + else + saved = {['enable'] = true, ['priority'] = p} + end + src[n] = saved + end + end + FilterDefaults[k] = src + end +end + +local function removedefaults(db, src, nometa) + if(type(src) ~= "table") then return end + if(not nometa) then + setmetatable(db, nil) + end + for k,v in pairs(src) do + if type(v) == "table" and type(db[k]) == "table" then + removedefaults(db[k], v, nometa) + if next(db[k]) == nil then + db[k] = nil + end + else + if db[k] == src[k] then + db[k] = nil + end + end + end +end + local function setdefaults(t, key) - local sv = _G["SVUI_Filters"] - local src = FilterDefaults + local sv = rawget(t, "filters") + local src = rawget(t, "defaults") local dest = sv[key] if(dest) then for k,v in pairs(dest) do @@ -647,8 +686,8 @@ local function getdefaults(t, key) end local function resetfilters(t) - local sv = _G["SVUI_Filters"] - local src = FilterDefaults + local sv = rawget(t, "filters") + local src = rawget(t, "defaults") for k,v in pairs(sv) do sv[k] = nil end @@ -656,12 +695,32 @@ local function resetfilters(t) end local function changefilter(t, k, id, v) - local sv = _G["SVUI_Filters"] + local sv = rawget(t, "filters") local name = safename(id) rawset(sv[k], name, v) end -local metadatabase = { +local function initializedata(t) + local sv = rawget(t, "filters") + local dv = rawget(t, "defaults") + for k,v in pairs(sv) do + if(dv[k]) then + removedefaults(sv[k], dv[k]) + end + end +end + +local SanitizeDatabase = function(self, event) + if event == "PLAYER_LOGOUT" then + local db = SuperVillain.Filters.filters + local src = FilterDefaults + for k,v in pairs(db) do + removedefaults(db[k], src[k]) + end + end +end + +local metadatabase = { __index = function(t, k) local sv = rawget(t, "filters") local dv = rawget(t, "defaults") @@ -672,48 +731,37 @@ local metadatabase = { end rawset(t, k, sv[k]) return rawget(t, k) - end + end, } local METAFILTERS = function(sv) - local db = setmetatable({}, metadatabase) + local methods = { + filters = sv, + defaults = FilterDefaults, + Init = initializedata, + Reset = resetprofile, + SetDefault = setdefaults, + Change = changefilter + } - db.filters = sv - db.defaults = FilterDefaults - db.Reset = resetprofile - db.SetDefault = setdefaults - db.Change = changefilter + local db = setmetatable(methods, metadatabase) - for k, x in pairs(FilterIDs) do - local src = {}; - for id in gmatch(x, '([^,]+)') do - if(id) then - local saved - local n = safename(id); - local p = FilterOverrides[tostring(id)] or 0; - if k == "Strict" then - saved = {['enable'] = true, ['spellID'] = id, ['priority'] = p} - else - saved = {['enable'] = true, ['priority'] = p} - end - src[n] = saved - end - end - tablecopy(db[k], src) - end + local logout = CreateFrame("Frame",nil) + logout:RegisterEvent("PLAYER_LOGOUT") + logout:SetScript("OnEvent", SanitizeDatabase) return db end function SuperVillain:SetFilterObjects(init) if(init) then - self.Filters = FilterDefaults + self.Filters = tcopy(FilterDefaults, true) else - local sv = _G["SVUI_Filters"] - twipe(self.Filters) - + --self.Filters = tcopy(FilterDefaults, true) + local sv = _G["SVUI_AuraFilters"] self.Filters = METAFILTERS(sv) + self.Filters:Init() end end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/system/system.lua b/Interface/AddOns/SVUI/system/system.lua index caf7bfb..d58597f 100644 --- a/Interface/AddOns/SVUI/system/system.lua +++ b/Interface/AddOns/SVUI/system/system.lua @@ -343,7 +343,7 @@ function SuperVillain:RefreshEverything(bypass) collectgarbage("collect"); if not bypass then - if(SVUI_Profile.SAFEDATA.install_complete == nil or (SVUI_Profile.SAFEDATA.install_complete and type(SVUI_Profile.SAFEDATA.install_complete) == 'boolean') or (SVUI_Profile.SAFEDATA.install_complete and type(tonumber(SVUI_Profile.SAFEDATA.install_complete)) == 'number' and tonumber(SVUI_Profile.SAFEDATA.install_complete) < tonumber(self.version))) then + if(SVUI_Profile.SAFEDATA.install_complete == nil or (SVUI_Profile.SAFEDATA.install_complete and type(SVUI_Profile.SAFEDATA.install_complete) == 'boolean') or (SVUI_Profile.SAFEDATA.install_complete and type(tonumber(SVUI_Profile.SAFEDATA.install_complete)) == 'number' and tonumber(SVUI_Profile.SAFEDATA.install_complete) < 4.04)) then self:Install(); end end @@ -375,7 +375,8 @@ local function PreLoad(self) if not SVUI_Profile then SVUI_Profile = {} end if not SVUI_Profile.SAFEDATA then SVUI_Profile.SAFEDATA = {} end - if not SVUI_Filters then SVUI_Filters = {} end + if SVUI_Filters then SVUI_Filters = nil end + if not SVUI_AuraFilters then SVUI_AuraFilters = {} end if not SVUI_Cache then SVUI_Cache = {} end if not SVUI_Cache["Dock"] then SVUI_Cache["Dock"] = {} end @@ -411,7 +412,7 @@ local function FullLoad(self) self:SetSVMovablesPositions(); self.CoreEnabled = true; - if (SVUI_Profile.SAFEDATA.install_complete == nil or not SVUI_Profile.install_version or SVUI_Profile.install_version ~= self.version) then + if (SVUI_Profile.SAFEDATA.install_complete == nil or not SVUI_Profile.install_version or tonumber(SVUI_Profile.install_version) < 4.04) then self:Install() SVUI_Profile.install_version = self.version end diff --git a/Interface/AddOns/SVUI_ConfigOMatic/modules/filter.lua b/Interface/AddOns/SVUI_ConfigOMatic/modules/filter.lua index eb46d42..997283c 100644 --- a/Interface/AddOns/SVUI_ConfigOMatic/modules/filter.lua +++ b/Interface/AddOns/SVUI_ConfigOMatic/modules/filter.lua @@ -226,7 +226,7 @@ local function generateFilterOptions() type = "select", order = 3, values = function() - local values = {} + local v = {} watchedBuffs = {} for o, f in pairs(SuperVillain.Filters["PetBuffWatch"])do tinsert(watchedBuffs, f) @@ -234,10 +234,10 @@ local function generateFilterOptions() for o, l in pairs(watchedBuffs)do if l.id then local name = GetSpellInfo(l.id) - values[l.id] = name + v[l.id] = name end end; - return values + return v end, get = function(e)return selectedSpell end, set = function(e, arg)selectedSpell = arg; generateFilterOptions()end @@ -440,7 +440,7 @@ local function generateFilterOptions() type = "select", order = 3, values = function() - local values = {} + local v = {} watchedBuffs = {} for o, f in pairs(SuperVillain.Filters["BuffWatch"])do tinsert(watchedBuffs, f) @@ -448,10 +448,10 @@ local function generateFilterOptions() for o, l in pairs(watchedBuffs)do if l.id then local name = GetSpellInfo(l.id) - values[l.id] = name + v[l.id] = name end end; - return values + return v end, get = function(e)return selectedSpell end, set = function(e, arg)selectedSpell = arg;generateFilterOptions()end @@ -635,7 +635,7 @@ local function generateFilterOptions() } } - if not selectedSpell or not SuperVillain.Filters[filterType][selectedSpell]then + if not selectedSpell or not SuperVillain.Filters[filterType][selectedSpell] then SuperVillain.Options.args.filters.args.spellGroup = nil; return end; @@ -686,6 +686,7 @@ local function generateFilterOptions() } end; MOD:RefreshUnitFrames() + collectgarbage("collect") end; SuperVillain.Options.args.filters = { type = "group", @@ -722,10 +723,8 @@ SuperVillain.Options.args.filters = { values = function() filters = {} filters[""] = NONE; - for g in pairs(SuperVillain.Filters) do - if(g ~= "defaults" and g ~= "filters" and SuperVillain.Filters[g] and type(SuperVillain.Filters[g]) == "table") then - filters[g] = g - end + for g in pairs(SuperVillain.Filters.defaults) do + filters[g] = g end; return filters end @@ -747,10 +746,8 @@ SuperVillain.Options.args.filters = { values = function() filters = {} filters[""] = NONE; - for g in pairs(SuperVillain.Filters) do - if(g ~= "defaults" and g ~= "filters" and SuperVillain.Filters[g] and type(SuperVillain.Filters[g]) == "table") then - filters[g] = g - end + for g in pairs(SuperVillain.Filters.defaults) do + filters[g] = g end; filters["Buff Indicator"] = "Buff Indicator" filters["Buff Indicator (Pet)"] = "Buff Indicator (Pet)" diff --git a/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua b/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua index 5a40f60..67f7379 100644 --- a/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua +++ b/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua @@ -76,7 +76,8 @@ SuperVillain.Options.args.profiles = { order = 6, get = function() return " SELECT ONE" end, set = function(key, value) SuperVillain.db:Import(value) end, - values = SuperVillain.db:GetAll(), + disabled = function() local t = SuperVillain.global:CheckProfiles() return (not t) end, + values = SuperVillain.global:GetProfiles(), }, spacer2 = { order = 7, @@ -96,8 +97,8 @@ SuperVillain.Options.args.profiles = { desc = L["delete_sub"], get = function() return " SELECT ONE" end, set = function(key, value) SuperVillain.db:Remove(value) end, - values = SuperVillain.db:GetAll(), - disabled = function() local t = SuperVillain.db:GetAll() return (not t) end, + values = SuperVillain.global:GetProfiles(), + disabled = function() local t = SuperVillain.global:CheckProfiles() return (not t) end, confirm = true, confirmText = L["delete_confirm"], },