Quantcast
--[[
##########################################################
S V U I   By: Failcoder
##########################################################
LOCALIZED LUA FUNCTIONS
##########################################################
GET ADDON DATA
##########################################################
]]--
local _G = _G;
local select            = _G.select;
local assert            = _G.assert;
local type              = _G.type;
local error             = _G.error;
local print             = _G.print;
local ipairs            = _G.ipairs;
local pairs             = _G.pairs;
local tostring          = _G.tostring;
local tonumber          = _G.tonumber;
local GetSpellInfo      = _G.GetSpellInfo;
local SV = select(2, ...)

local playerClass = select(2, UnitClass("player"));
local filterClass = playerClass or "NONE";

local function safename(id)
    local n = GetSpellInfo(id)
    if not n then
        return false
    end
    return n
end

--[[ FILTER DATA ]]--
local FilterIDs = {
    ["BlackList"] = [[36900,36901,36893,114216,97821,36032,8733,57724,25771,57723,36032,58539,26013,6788,71041,41425,55711,8326,23445,24755,25163,80354,95223,124275,124274,124273,117870,123981,15007,113942,89140]],

    ["WhiteList"] = [[31821,2825,32182,80353,90355,47788,33206,116849,22812,123059,136431,137332,137375,144351,142863,142864,142865,143198,162264]],

    ["CC"] = [[47476,91800,91807,91797,108194,115001,33786,339,78675,22570,5211,102359,99,127797,45334,114238,3355,24394,64803,19386,117405,128405,31661,118,122,82691,44572,33395,102051,20066,10326,853,105593,31935,105421,605,64044,8122,9484,15487,114404,88625,87194,2094,1776,6770,1833,1330,408,88611,51514,64695,63685,118905,118345,710,6789,118699,5484,6358,30283,115268,89766,137143,7922,105771,107566,132168,107570,118895,18498,116706,115078,119392,119381,120086,140023,25046,20549,107079]],

    ["Defense"] = [[17,45438,115610,48797,48792,49039,87256,55233,50461,33206,47788,62618,47585,104773,110913,108359,22812,102342,61336,19263,53480,1966,31224,74001,5277,45182,98007,30823,108271,1022,6940,114039,31821,498,642,86659,31850,118038,55694,97463,12975,114029,871,114030,120954,122783,122278,116849,20594,218256]],

    ["Player"] = [[45438,115610,110909,12051,12472,80353,12042,32612,110960,108839,111264,108843,48797,48792,49039,87256,49222,55233,50461,51271,96268,33206,47788,62618,47585,6346,10060,114239,119032,27827,104773,110913,108359,113860,113861,113858,88448,22812,102342,61336,117679,102543,102558,102560,132158,106898,1850,106951,52610,69369,112071,124974,19263,53480,51755,54216,3045,3584,131894,90355,90361,31224,74001,5277,45182,51713,114018,2983,11327,108212,57933,79140,13750,98007,30823,108271,16188,2825,79206,8178,58875,108281,108271,16166,114896,1044,1022,1038,6940,114039,31821,498,642,86659,20925,31850,31884,53563,31842,105809,85499,118038,55694,97463,12975,114029,871,114030,18499,1719,23920,114028,46924,3411,107574,120954,122783,122278,116849,125174,116841,20594,59545,20572,26297,68992,191428,191427,187827,162264,218256,178740]],

    ["Raid"] = [[175601,175599,172069,172066,166779,56037,175654,166185,166175,174404,173763,174500,174939,172115,166200,174473,158986,159113,159178,159213,159410,160521,159386,159188,162497,159202,156152,156151,156143,163046,159220,163242,163590,163241,160179,159972,162346,162892,162475,155569,158241,158026,167200,159709,167179,163374,158200,163472,172895,162185,162184,161242,161358,156803,164004,164005,164006,158619,164176,164178,164191,157349,164232,164235,164240,158553,165102,157801,156096,156743,156047,156401,156404,158054,156888,157000,156999,155365,155061,155030,155236,159044,162276,155657,155222,155399,154989,155499,155318,155277,154952,155074,163284,162293,155493,163633,155921,165195,155701,156310,164380,155240,155242,176133,156934,175104,176121,158702,155225,157139,161570,157853,155080,143962,155078,36240,155326,165300,157060,156766,161839,156844,156309,156203,173471,164271,158315,156601,170395,170405,158692,158702,158686,158683,159585,156112,184369,180079,179897,185978,182373,182280,182074,182001,187819,181345,184360,184449,185065,184450,185066,184676,184652,181488,188929,180389,179867,181295,179977,179864,179909,179908,181957,182200,182178,182325,185239,185510,182600,179219,181753,182038,188666,189627,180415,185237,185238,185241,180526,181508,181653,179428,182008,179407,188208,186073,186407,186500,186063,186333,181275,181099,181597,182006,181841,182088,184964,186123,185014,186952,186961,189891,183634,189895,190049]]
};

local InitAuraBars = [[2825,32182,80353,90355,86659,162264]]

SV.defaults.Filters["BlackList"] = {};
SV.defaults.Filters["WhiteList"] = {};
SV.defaults.Filters["Defense"] = {};
SV.defaults.Filters["Player"] = {};
SV.defaults.Filters["AuraBars"] = {};
SV.defaults.Filters["CC"] = {};
SV.defaults.Filters["Raid"] = {};
SV.defaults.Filters["Custom"] = {};

for k, x in pairs(FilterIDs) do
    local src = {};
    for id in x:gmatch("([^,]+)") do
        if(id) then
            local spellID = tonumber(id);
            local n = safename(spellID);
            if(n) then
                src[id] = {['enable'] = true, ['id'] = spellID, ['priority'] = 0, ['isDefault'] = true}
            end
        end
    end
    SV.defaults.Filters[k] = src
end

for id in InitAuraBars:gmatch("([^,]+)") do
    if(id) then
        local spellID = tonumber(id);
        if(safename(spellID)) then
            SV.defaults.Filters["AuraBars"][id] = {0.98, 0.57, 0.11}
        end
    end
end

local function SanitizeFilters()
    for filterType, filterData in pairs(SV.db.Filters) do
        if(filterType == 'AuraBars') then
          for id, params in pairs(SV.db.Filters[filterType]) do
            if(type(id) ~= 'string') then
                SV.db.Filters.AuraBars[id] = nil;
                local newID = tostring(id);
                if(newID) then
                    SV.db.Filters.AuraBars[newID] = {0.98, 0.57, 0.11}
                end
            end
          end
        elseif(filterType == 'Custom') then
          for customType, customData in pairs(SV.db.Filters.Custom) do
            for id, params in pairs(customData) do
                if((not params.id) or (tonumber(id) ~= params.id)) then
                    SV.db.Filters.Custom[customType][id] = nil;
                end
            end
          end
        else
          for id, params in pairs(SV.db.Filters[filterType]) do
              if((not params.id) or (tonumber(id) ~= params.id)) then
                  SV.db.Filters[filterType][id] = nil;
              end
          end
        end
    end
end

SV:NewScript(SanitizeFilters);