Compare with Previous | Blame | View Log
if not CompactBars then error("CompactBars has to be loaded first") end local L = LibStub("AceLocale-3.0"):GetLocale("CompactBars", true) local newList, del, deepDel, deepCopy = CompactBars.sb:GetRecyclingFunctions() local config = CompactBars:NewModule("config") local aceconfig = LibStub:GetLibrary("AceConfig-3.0") local acedialog = LibStub:GetLibrary("AceConfigDialog-3.0") local acedboptions = LibStub:GetLibrary("AceDBOptions-3.0") local tmp = newList() local lsm = LibStub:GetLibrary("LibSharedMedia-3.0") CompactBars.sp = CompactBars:GetModule("spells") local function refreshScale() CompactBars.sb:RedrawScale(CompactBars.db.profile.width, CompactBars.db.profile.maxtime, CompactBars.db.profile.steps, CompactBars.db.profile.maxneg, CompactBars.db.profile.position,CompactBars.db.profile.horizontal, CompactBars.db.profile.loflag, CompactBars.db.profile.scaletexture, CompactBars.db.profile.locked, CompactBars.db.profile.scale, CompactBars.db.profile.height, CompactBars.db.profile.fonts, CompactBars.db.profile.scaletext, CompactBars.db.profile.amaxtimes, CompactBars.db.profile.ehidescale, CompactBars.db.profile.eiconpos, CompactBars.db.profile.nevershowscale) end local function isSpell(id) if GetSpellInfo(id) then return true end end local function isAV(id, typ) if CompactBars.db.profile.spells[id..typ] then return true end end local function insertDefaultSpell(info, db) db.defaults.profile.spells[info.spellid..info.typ] = deepCopy(info) end function config:insertSpell(info, db) if not info then return end if not GetSpellInfo(info.spellid) then return end if info and info.typ then if not (info.typ == "Dots" or info.typ == "Shortbuffs" or info.typ == "Debuffs" or info.typ == "CCs" or info.typ == "Cooldowns" or info.typ == "ItemCooldowns" or info.typ == "SharedDebuffs" or info.typ == "InternalCooldowns") then return end else return end db.profile.spells[info.spellid..info.typ] = deepCopy(info) if not CompactBarsConfig.args.spells.args[info.typ].args then CompactBarsConfig.args.spells.args[info.typ].args = {} end CompactBarsConfig.args.spells.args[info.typ].args[tostring(info.spellid)] = { name = function() if select(2, GetSpellInfo(info.spellid)) then if select(2, GetSpellInfo(info.spellid)) ~= "" then return GetSpellInfo(info.spellid) .. " (" .. select(2, GetSpellInfo(info.spellid)) .. ")" else return GetSpellInfo(info.spellid) end else return GetSpellInfo(info.spellid) end end, type = "group" } CompactBarsConfig.args.spells.args[info.typ].args[tostring(info.spellid)].args = { duration = { name = L["Duration"], desc = L["This should return the time. For example if you want that this spell is 10 seconds then type: return 10 (you can use any lua code here)"], multiline = true, type = "input", get = function() return tostring(CompactBars.db.profile.spells[info.spellid..info.typ].duration or "") end, set = function(self, inp) if tonumber(inp) then CompactBars.db.profile.spells[info.spellid..info.typ].duration = tonumber(inp) else CompactBars.db.profile.spells[info.spellid..info.typ].duration = inp end end, }, disabled = { name = "Disabled", type = "toggle", get = function() return CompactBars.db.profile.spells[info.spellid..info.typ].disabled end, set = function(self, inp) CompactBars.db.profile.spells[info.spellid..info.typ].disabled = inp end, }, applications = { name = L["Applications"], desc = L["The maximum number of applications that are possible for this spell. This leads to a changing alpha value. If you want that your spell always uses the alpha value (instead of actual_applications/maxapplications) from the color input then leave this at one."], type = "range", min = 1, max = 10, step = 1, get = function() return CompactBars.db.profile.spells[info.spellid..info.typ].applications or 1 end, set = function(self, inp) if inp == 0 then inp = 1 end CompactBars.db.profile.spells[info.spellid..info.typ].applications = tonumber(inp) end, }, color = { name = L["Positive color"], desc = L["This value overrides the default values for this spell. For the default values see the color dialogue."], type = "color", hasAlpha = true, get = function() if CompactBars.db.profile.spells[info.spellid..info.typ].color then return CompactBars.db.profile.spells[info.spellid..info.typ].color.r, CompactBars.db.profile.spells[info.spellid..info.typ].color.g, CompactBars.db.profile.spells[info.spellid..info.typ].color.b, CompactBars.db.profile.spells[info.spellid..info.typ].color.a end end, set = function(self, r, g, b, a) CompactBars.db.profile.spells[info.spellid..info.typ].color = {r = r, g = g, b = b, a = a} end, }, colorzero = { name = L["Negative color"], desc = L["This value overrides the default values for this spell. For the default values see the color dialogue."], type = "color", hasAlpha = true, get = function() if CompactBars.db.profile.spells[info.spellid..info.typ].colorzero then return CompactBars.db.profile.spells[info.spellid..info.typ].colorzero.r, CompactBars.db.profile.spells[info.spellid..info.typ].colorzero.g, CompactBars.db.profile.spells[info.spellid..info.typ].colorzero.b, CompactBars.db.profile.spells[info.spellid..info.typ].colorzero.a end end, set = function(self, rc, gc, bc, ac) CompactBars.db.profile.spells[info.spellid..info.typ].colorzero = {r = rc, g = gc, b = bc, a = ac} end, }, typ = { name = L["Type"], desc = L["The type of the spell"], type = "select", values = {Dots = L["Dots"], Shortbuffs = L["Short buffs"], Debuffs = L["Debuffs"], SharedDebuffs = L["Shared debuffs"], InternalCooldowns = L["Internal cooldowns"], CCs = L["CCs"], Cooldowns = L["Spell cooldowns"], ItemCooldowns = L["Item cooldowns"]}, get = function() return CompactBars.db.profile.spells[info.spellid..info.typ].typ end, set = function(self, inp) CompactBars.db.profile.spells[info.spellid..info.typ].typ = inp end, }, class = { name = L["Class"], desc = L["The class which belongs to the spell"], type = "select", values = {["DEATHKNIGHT"] = L["Death Knight"], ["DRUID"] = L["Druid"], ["HUNTER"] = L["Hunter"], ["MAGE"] = L["Mage"], ["PALADIN"] = L["Paladin"],["PRIEST"] = L["Priest"], ["ROGUE"] = L["Rogue"], ["SHAMAN"] = L["Shaman"], ["WARLOCK"] = L["Warlock"], ["WARRIOR"] = L["Warrior"] , ["GENERAL"] = L["General"]}, get = function() if not CompactBars.db.profile.spells[info.spellid..info.typ].class then CompactBars.db.profile.spells[info.spellid..info.typ].class = select(2, UnitClass("player")) end return CompactBars.db.profile.spells[info.spellid..info.typ].class end, set = function(self, inp) CompactBars.db.profile.spells[info.spellid..info.typ].class = inp end, }, } if info.typ == "Dots" then -- add the ticker things CompactBarsConfig.args.spells.args[info.typ].args[tostring(info.spellid)].args.tickerenabled = { name = L["Enable Ticks"], type = "toggle", get = function(self) return CompactBars.db.profile.spells[info.spellid..info.typ].eticks end, set = function(self, val) CompactBars.db.profile.spells[info.spellid..info.typ].eticks = val end, order = -2, } CompactBarsConfig.args.spells.args[info.typ].args[tostring(info.spellid)].args.tickertime = { name = L["Tick time"], type = "range", min = 1, max = 10, step = 1, get = function(self) return CompactBars.db.profile.spells[info.spellid..info.typ].ticktimer end, set = function(self, val) CompactBars.db.profile.spells[info.spellid..info.typ].ticktimer = val end, order = -1, } end end function config:insertConfigSpell() if isSpell(tmp.spellid) and not isAV(tmp.spellid, tmp.typ) then if not tmp.spellid or tmp.spellid == "" then error("Insert a spell ID!") end if not GetSpellInfo(tmp.spellid) then error("Invalid spell ID!") end if not tmp.duration or tmp.duration == "" then error("Insert a duration!") end if type(tmp.duration) == "number" then tmp.duration = CompactBars.db.profile.spells[tmp.typ..tmp.duration] end loadstring(tmp.duration) config:insertSpell(deepCopy(tmp), CompactBars.db) end deepDel(tmp) tmp = newList() end CompactBarsConfig = { type = "group", args = { general = { name = L["General"], desc = L["General options"], type = "group", get = function(info) local leaf = info[#info] if leaf ~= "owndots" then leaf = "e"..leaf end return CompactBars.db.profile[leaf] end, set = function(info, inp) local leaf = info[#info] if leaf ~= "owndots" then leaf = "e"..leaf end CompactBars.db.profile[leaf] = inp if leaf == "iconpos" then CompactBars.sb:SetIcon(inp) end refreshScale() end, args = { locked = { name = L["Locked"], desc = L["Locks or unlocks the bar (use ALT+Click to drag when unlocked!)"], type = "toggle", get = function() return CompactBars.db.profile.locked end, set = function(self, lock) CompactBars.db.profile.locked = lock CompactBars.sb:SetLock(lock) end, order = 0, }, owndots = { name = L["Only debuffs from Target"], desc = L["Shows only the dots for your current target"], type = "toggle", }, iconpos = { name = L["Icon out of the bar"], desc = L["As soon as the icon reaches zero the bar will fade"], type = "toggle", }, hidescale = { name = L["Hide the scale"], desc = L["... if there is nothing to track"], type = "toggle", }, hidetext = { name = L["Hide target text"], desc = L["This is not needed if you run the addon only with your own dots"], type = "toggle", }, removedots = { name = L["Remove debuffs on target change"], desc = L["Removes all the debuff bars that do not belong to your current target"], type = "toggle", get = function() return CompactBars.db.profile.removedots end, set = function(info, inp) CompactBars.db.profile.removedots = inp if inp then CompactBars:RegisterEvent("UNIT_TARGET", "TargetChanged") else CompactBars:UnregisterEvent("UNIT_TARGET") end end, }, dots = { name = L["Enable dots"], type = "toggle", }, cooldowns = { name = L["Enable cooldowns"], type = "toggle", }, debuffs = { name = L["Enable debuffs"], type = "toggle", }, ccs = { name = L["Enable ccs"], type = "toggle", }, shortbuffs = { name = L["Enable short buffs"], type = "toggle", }, internalcooldowns = { name = L["Enable internal cooldowns"], desc = L["Mainly like the shortbuffs category but the bar will not be removed when the buff fades"], type = "toggle", }, shareddebuffs = { name = L["Enable shared debuffs"], desc = L["Shared debuffs are things that can be refreshed from other people (eg Sunder Armor)"], type = "toggle", }, bossmods = { name = L["Enable bossmods"], type = "toggle", set = function(info, val) CompactBars.db.profile.ebossmods = val if not val then CompactBarsConfig.args.bossmods.args.hidebossmod.disabled = true BigWigs:ToggleModuleActive("Bars", true) else CompactBarsConfig.args.bossmods.args.hidebossmod.disabled = false end end, get = function(info) return CompactBars.db.profile.ebossmods end, }, }, }, bossmods = { name = L["Bossmods"], type = "group", order = 9999, args = { bossmods = { name = L["Enable bossmods"], type = "toggle", set = function(info, val) CompactBars.db.profile.ebossmods = val if not val then CompactBarsConfig.args.bossmods.args.hidebossmod.disabled = true if BigWigs and IsAddOnLoaded("BigWigs_Plugins") then BigWigs:ToggleModuleActive("Bars", true) end else CompactBarsConfig.args.bossmods.args.hidebossmod.disabled = false if CompactBars.db.profile.hidebossmod then if BigWigs and IsAddOnLoaded("BigWigs_Plugins") then BigWigs:ToggleModuleActive("Bars", false) end end end end, get = function(info) return CompactBars.db.profile.ebossmods end, }, hidebossmod = { name = L["Hide bossmod bars"], type = "toggle", set = function(info, val) CompactBars.db.profile.hidebossmod = val if not val then if BigWigs and IsAddOnLoaded("BigWigs_Plugins") then BigWigs:ToggleModuleActive("Bars", true) end else if BigWigs and IsAddOnLoaded("BigWigs_Plugins") then BigWigs:ToggleModuleActive("Bars", false) end end end, get = function(info) return CompactBars.db.profile.hidebossmod end, }, hidebartext = { name = L["Hide bar text"], type = "toggle", set = function(info, val) CompactBars.db.profile.bossmodbartext = val end, get = function() return CompactBars.db.profile.bossmodbartext end, } }, }, additionalscale = { name = L["Logarithmic scale"], type = "group", args = { segments = { name = L["Input segments"], desc = L["Every segement is seperated by a comma"], type = "input", multiline = true, get = function(info) if not CompactBars.db.profile.amaxtimes then return "" end local ret = "" for k, v in pairs(CompactBars.db.profile.amaxtimes) do ret = ret .. v .. ", " end if ret then ret = string.sub(ret, 1, string.len(ret) - 2) end return ret end, set = function(info, inp) deepDel(CompactBars.db.profile.amaxtimes) CompactBars.db.profile.amaxtimes = nil CompactBars.db.profile.amaxtimes = newList() if inp and inp ~= "" then for _, v in pairs({strsplit(",", inp)}) do tinsert(CompactBars.db.profile.amaxtimes, tonumber(strtrim(v))) end end refreshScale() end, }, }, }, view = { name = L["View"], type = "group", args = { scaletext = { name = L["Scale text"], desc = L["Hides or shows the text on the scale"], type = "toggle", order = 0, get = function() return CompactBars.db.profile.scaletext end, set = function(self, inp) CompactBars.db.profile.scaletext = inp refreshScale() end, }, nevershowscale = { name = L["Never show scale"], type = "toggle", get = function() return CompactBars.db.profile.nevershowscale end, set = function(self, inp) CompactBars.db.profile.nevershowscale = inp refreshScale() end, }, textures = { type = "group", name = L["Textures"], get = function(info) for k, v in pairs(lsm:HashTable("statusbar")) do if v == CompactBars.db.profile[info[#info]] then return k end end end, set = function(info, inp) CompactBars.db.profile[info[#info]] = lsm:Fetch("statusbar",inp) refreshScale() end, args = { scaletexture = { order = 1, name = L["Scaletexture"], desc = L["The texture of the scale"], type = "select", dialogControl = 'LSM30_Statusbar', values = AceGUIWidgetLSMlists.statusbar , }, bartexture = { order = 2, name = L["Bartexture"], desc = L["The texture of the bar"], type = "select", dialogControl = 'LSM30_Statusbar', values = AceGUIWidgetLSMlists.statusbar, }, }, }, markers = { type = "group", name = L["Markers"], desc = L["Used to create lines at special destinations"], args = { times = { name = L["Points of time"], type = "input", multiline = true, get = function() return CompactBars.db.profile.markers end, set = function(self, inp) CompactBars.sb:ResetMarkers() CompactBars.db.profile.markers = inp for k, v in pairs({strsplit(",", inp)}) do CompactBars.sb:CreateMarker(tonumber(strtrim(v))) end end, }, }, }, position = { type = "group", name = L["Position"], desc = L["The Position on the screen (bottom left corner)"], args = { x = { name = L["X"], type = "input", validate = function(self, inp) if tonumber(inp) then return true end return L["Only numbers are a valid input"] end, get = function() return tostring(CompactBars.db.profile.position.x) end, set = function(self, inp) CompactBars.db.profile.position.x = tonumber(inp) CompactBars.sb:SetPosition(CompactBars.db.profile.position.x, CompactBars.db.profile.position.y) end, }, y = { name = L["Y"], type = "input", validate = function(self, inp) if tonumber(inp) then return true end return L["Only numbers are a valid input"] end, get = function() return tostring(CompactBars.db.profile.position.y) end, set = function(self, inp) CompactBars.db.profile.position.y = tonumber(inp) CompactBars.sb:SetPosition(CompactBars.db.profile.position.x, CompactBars.db.profile.position.y) end, }, }, }, width = { order = 3, name = L["Scalesize"], desc = L["The size of the scale."], type = "range", min = 10, max = 1000, step = 1, get = function() return CompactBars.db.profile.width end, set = function(self, inp) CompactBars.db.profile.width = inp refreshScale() end, }, height = { order = 4, name = L["Barsize"], desc = L["The size of the bars."], type = "range", min = 10, max = 100, step = 1, get = function() return CompactBars.db.profile.height end, set = function(self, inp) CompactBars.db.profile.height = inp refreshScale() end, }, scale = { order = 5, name = L["Scale"], desc = L["Scales everything."], type = "range", min = 0.5, max = 3.0, step = 0.1, isPercent = true, get = function() return CompactBars.db.profile.scale end, set = function(self, inp) CompactBars.db.profile.scale = inp CompactBars.sb:SetScale(inp) end, }, maxtime = { order = 6, name = L["Maximum time"], type = "range", min = 5, max = 100, step = 1, get = function() return CompactBars.db.profile.maxtime end, set = function(self, inp) CompactBars.db.profile.maxtime = inp refreshScale() end, }, steps = { order = 7, name = L["Steps"], desc = L["In how many steps the bar should be devided (if you have a 10 second bar and want a mark every second then you should input 10 here"], type = "range", min = 1, max = 20, step = 1, get = function() return CompactBars.db.profile.steps end, set = function(self, inp) CompactBars.db.profile.steps = inp refreshScale() end, }, maxneg = { order = 8, name = L["Maximum negative time"], desc = L["Time limit where the bar should be truncated (If you want standard bars that do not show negative values use 0 here)"], type = "range", min = -10, max = 0, step = 1, get = function() return CompactBars.db.profile.maxneg end, set = function(self, inp) CompactBars.db.profile.maxneg = inp refreshScale() end, }, horizontal = { order = 1, name = L["Horizontal"], desc = L["If we use a horizontal (true) or vertical (false) scale and bars."], type = "toggle", get = function() return CompactBars.db.profile.horizontal end, set = function(self, inp) CompactBars.db.profile.horizontal = inp refreshScale() end, }, loflag = { order = 2, name = L["Left/above Flag"], desc = L["If this is true the scale will be above or on the left side of the bars."], type = "toggle", get = function() return CompactBars.db.profile.loflag end, set = function(self, inp) CompactBars.db.profile.loflag = inp refreshScale() end, }, barodering = { name = L["Bar order"], type = "group", args = { barordering = { name = L["Bar order"], type = "input", multiline = true, validate = function(info, inp) if not string.match(inp, "%a*,.?%a*,.?%a*,.?%a*") then return L["Invalid input!"] end if string.find(inp, "Debuffs") and string.find(inp, "Shortbuffs") and string.find(inp, "Bossmods") and string.find(inp, "Cooldowns") then return true end return L["Invalid input!"] end, get = function() return CompactBars.db.profile.barorder end, set = function(info, inp) CompactBars.db.profile.barorder = inp end, } } }, barcolors = { order = 7, name = L["Barcolors"], desc = L["Sets the colors for the bars."], type = "group", get = function(info) local l1, l2 = _, info[#info] if info[#info-1] == "positive" then l1 = "barcolor" else l1 = "barcolorzero" end return CompactBars.db.profile[l1][l2].r, CompactBars.db.profile[l1][l2].g, CompactBars.db.profile[l1][l2].b, CompactBars.db.profile[l1][l2].a end, set = function(info, r, g, b, a) local l1, l2 = _, info[#info] if info[#info-1] == "positive" then l1 = "barcolor" else l1 = "barcolorzero" end CompactBars.db.profile[l1][l2].r = r CompactBars.db.profile[l1][l2].g = g CompactBars.db.profile[l1][l2].b = b CompactBars.db.profile[l1][l2].a = a end, args = { positive = { order = 120, name = L["Positive Barcolor"], desc = L["The color of the positive area of the bar."], type = "group", args = { arcane = { name = L["Arcane"], type = "color", hasAlpha = true, }, fire = { name = L["Fire"], type = "color", hasAlpha = true, }, nature = { name = L["Nature"], type = "color", hasAlpha = true, }, frost = { name = L["Frost"], type = "color", hasAlpha = true, }, shadow = { name = L["Shadow"], type = "color", hasAlpha = true, }, holy = { name = L["Holy"], type = "color", hasAlpha = true, }, physical = { name = L["Physical"], type = "color", hasAlpha = true, }, }, }, negative = { order = 121, name = L["Negative Barcolor"], desc = L["The color of the negative area of the bar."], type = "group", args = { arcane = { name = L["Arcane"], type = "color", hasAlpha = true, }, fire = { name = L["Fire"], type = "color", hasAlpha = true, }, nature = { name = L["Nature"], type = "color", hasAlpha = true, }, frost = { name = L["Frost"], type = "color", hasAlpha = true, }, shadow = { name = L["Shadow"], type = "color", hasAlpha = true, }, holy = { name = L["Holy"], type = "color", hasAlpha = true, }, physical = { name = L["Physical"], type = "color", hasAlpha = true, }, }, }, }, }, fonts = { order = 200, name = L["Fonts"], type = "group", get = function(info) local l1, l2 = info[#info-1], info[#info] return CompactBars.db.profile.fonts[l1][l2] end, set = function(info, inp) local l1, l2 = info[#info-1], info[#info] CompactBars.db.profile.fonts[l1][l2] = inp refreshScale() end, args = { bar = { name = L["Font of the bar"], type = "group", args = { font = { order = 1, name = L["Font"], type = "select", dialogControl = 'LSM30_Font', values = AceGUIWidgetLSMlists.font, get = function() for k, v in pairs(lsm:HashTable("font")) do if v == CompactBars.db.profile.fonts.bar.font then return k end end end, set = function(info, inp) CompactBars.db.profile.fonts.bar.font = lsm:Fetch("font",inp) end, }, size = { order = 2, name = L["Size"], type = "range", min = 10, max = 30, }, monochrome = { order = 3, name = L["Monochrome"], type = "toggle", }, outline = { order = 4, name = L["Outline"], type = "toggle", }, thickoutline = { order = 5, name = L["Thick Outline"], type = "toggle", }, }, }, scale = { name = L["Font of the scale"], type = "group", args = { font = { order = 1, name = L["Font"], type = "select", dialogControl = 'LSM30_Font', values = AceGUIWidgetLSMlists.font, get = function() for k, v in pairs(lsm:HashTable("font")) do if v == CompactBars.db.profile.fonts.scale.font then return k end end end, set = function(info, inp) CompactBars.db.profile.fonts.scale.font = lsm:Fetch("font",inp) end, }, size = { order = 2, name = L["Size"], type = "range", min = 10, max = 30, }, monochrome = { order = 3, name = L["Monochrome"], type = "toggle", }, outline = { order = 4, name = L["Outline"], type = "toggle", }, thickoutline = { order = 5, name = L["Thick Outline"], type = "toggle", }, }, }, }, }, }, }, spells = { order = 999, name = L["Spells"], type = "group", args = { Insert = { order = 0, name = L["Insert new Spell"], type = "group", args = { spellid = { name = L["Spell Id"], type = "input", get = function() return tostring(tmp.spellid or "") end, set = function(self, inp) if not tonumber(inp) then -- inp is a link local temp = string.match(inp, "Hspell:(%d+)") if temp and GetSpellInfo(temp) then tmp.spellid = tonumber(temp) return end temp = string.match(GetSpellLink(inp), "Hspell:(%d+)") if temp and GetSpellInfo(temp) then tmp.spellid = tonumber(temp) return end error(L["Input has to be a number, a spell link or a spell name (last two options are only possible for spells in your spellbook!)"]) else tmp.spellid = tonumber(inp) end end, }, duration = { name = L["Duration"], desc = L["This should return the time. For example if you want that this spell is 10 seconds then type: return 10 (you can use any lua code here)"], multiline = true, type = "input", get = function() return tostring(tmp.duration or "") end, set = function(self, inp) if tonumber(inp) then tmp.duration = tonumber(inp) else tmp.duration = inp end end, }, applications = { name = L["Applications"], desc = L["The maximum number of applications that are possible for this spell. This leads to a changing alpha value. If you want that your spell always uses the alpha value (instead of actual_applications/maxapplications) from the color input then leave this at one."], type = "range", min = 1, max = 10, step = 1, get = function() return tmp.applications or 1 end, set = function(self, inp) if inp == 0 then inp = 1 end tmp.applications = inp end, }, color = { name = L["Positive color"], desc = L["This value overrides the default values for this spell. For the default values see the color dialogue."], type = "color", hasAlpha = true, get = function() if tmp.color then return tmp.color.r, tmp.color.g, tmp.color.b, tmp.color.a end end, set = function(self, rc, gc, bc, ac) tmp.color = {r = rc, g = gc, b = bc, a = ac} end, }, colorzero = { name = L["Negative color"], desc = L["This value overrides the default values for this spell. For the default values see the color dialogue."], type = "color", hasAlpha = true, get = function() if tmp.colorzero then return tmp.colorzero.r, tmp.colorzero.g, tmp.colorzero.b, tmp.colorzero.a end end, set = function(self, rc, gc, bc, ac) tmp.colorzero = {r = rc, g = gc, b = bc, a = ac} end, }, typ = { name = L["Type"], desc = L["The type of the spell"], type = "select", values = {Dots = L["Dots"], Shortbuffs = L["Short buffs"], SharedDebuffs = L["Shared debuffs"], InternalCooldowns = L["Internal cooldowns"], Debuffs = L["Debuffs"], CCs = L["CCs"], Cooldowns = L["Spell cooldowns"], ItemCooldowns = L["Item cooldowns"]}, get = function() return tmp.typ end, set = function(self, inp) tmp.typ = inp end, }, class = { name = L["Class"], desc = L["The class which uses the spell"], type = "select", values = {["DEATHKNIGHT"] = L["Death Knight"], ["DRUID"] = L["Druid"], ["HUNTER"] = L["Hunter"], ["MAGE"] = L["Mage"], ["PALADIN"] = L["Paladin"], ["PRIEST"] = L["Priest"], ["ROGUE"] = L["Rogue"], ["SHAMAN"] = L["Shaman"], ["WARLOCK"] = L["Warlock"], ["WARRIOR"] = L["Warrior"], ["GENERAL"] = L["General"]}, get = function() if not tmp.class then tmp.class = select(2, UnitClass("player")) end return tmp.class end, set = function(self, inp) tmp.class = inp end, }, exec = { order = -1, name = L["Insert"], desc = L["Insert the details you entered."], type = "execute", func = function() config:insertConfigSpell() end, }, }, }, ["Dots"] = { name = L["Dots"], type = "group", args = {}, }, ["Shortbuffs"] = { name = L["Short buffs"], desc = L["Important buffs"], type = "group", args = {}, }, ["Debuffs"] = { name = L["Debuffs"], desc = L["Effects that don't belong to the other categories"], type = "group", args = {}, }, ["CCs"] = { name = L["CCs"], desc = L["CCs and Silences"], type = "group", args = {}, }, ["Cooldowns"] = { name = L["Spell cooldowns"], type = "group", args = {}, }, ["ItemCooldowns"] = { name = L["Item cooldowns"], type = "group", args = {}, }, ["InternalCooldowns"] = { name = L["Internal cooldowns"], type = "group", args = {}, }, ["SharedDebuffs"] = { name = L["Shared debuffs"], desc = L["Debuffs which can be refreshed from other people"], type = "group", args = {}, }, }, }, }, } local function initSpells(db) for id, info in pairs(db.profile.spells) do if type(info) == "number" then info = nil else config:insertSpell(info, db) end end end local function initDefaultSpells(data) -- class local db = CompactBars.Spells[select(2, UnitClass("player"))] local info = newList() info.class = select(2, UnitClass("player")) for k, tab in pairs(db) do info.typ = k for id, val in pairs(tab) do info.spellid = id if type(val) == "number" then val = tab[tab[id]] end info.duration = val -- duration, applications, color, colorzero if not val then insertDefaultSpell(deepCopy(info), data) else local func = loadstring(val) if func then _, info.applications, info.color, info.colorzero = func(sp) if not info.applications then info.applications = 1 end insertDefaultSpell(deepCopy(info), data) end end end end -- important for everyone del(info) db = CompactBars.Spells["GENERAL"] info = newList() info.class = "GENERAL" for k, tab in pairs(db) do info.typ = k for id, val in pairs(tab) do info.spellid = id if type(val) == "number" then val = tab[tab[id]] end info.duration = val -- duration, applications, color, colorzero if not val then insertDefaultSpell(deepCopy(info), data) else local func = loadstring(val) if func then _, info.applications, info.color, info.colorzero = func() if not info.applications then info.applications = 1 end insertDefaultSpell(deepCopy(info), data) end end end end end -- duration, applications, color, colorzero function CompactBars:GetSpellInfo(typ, id) if not CompactBars.db.profile["e"..string.lower(typ)] then return false end if CompactBars.db.profile.spells[id..typ] and CompactBars.db.profile.spells[id..typ].typ == typ and not CompactBars.db.profile.spells[id..typ].disabled then local dur if CompactBars.db.profile.spells[id..typ].duration == "" then CompactBars.db.profile.spells[id..typ].duration = nil end if CompactBars.db.profile.spells[id..typ].duration then if type(CompactBars.db.profile.spells[id..typ].duration) == "number" then dur = CompactBars.db.profile.spells[CompactBars.db.profile.spells[id..typ].duration].duration else dur = CompactBars.db.profile.spells[id..typ].duration end else dur = nil end if dur then dur = loadstring(dur) dur = dur() else dur = 0 end return dur, CompactBars.db.profile.spells[id..typ].applications, deepCopy(CompactBars.db.profile.spells[id..typ].color), deepCopy(CompactBars.db.profile.spells[id..typ].colorzero) end return false end function config:OnInitialize() self = CompactBars local db = newList() db.defaults = newList() db.defaults.profile = { barorder = "Shortbuffs, Cooldowns, Bossmods, Debuffs", ebossmods = true, amaxtimes = {}, eiconpos = true, ehidescale = false, owndots = false, scaletext = true, edots = true, edebuffs = true, eccs = true, eshortbuffs = true, spells = {}, scale = 1.0, height = 20, fonts = {scale = {font = "Fonts\\FRIZQT__.TTF", size = 11, outline = true, thickoutline = false, monochrome = true}, bar = {font = "Fonts\\FRIZQT__.TTF", size = 11, outline = true, thickoutline = false, monochrome = true} }, position = {x = 600, y = 400}, width = 200, maxtime = 30, steps = 5, maxneg = -1, horizontal = true, loflag = false, barcolor = { physical = {r = 0, g = 0, b = 0, a = 1.0}, nature = {r = 34/255, g = 139/255, b = 34/255, a = 1.0}, shadow = {r = 148/255, g = 0, b = 211/255, a = 1.0}, fire = {r = 1, g = 0, b = 0, a = 1.0}, frost = {r = 0, g = 0, b = 1, a = 1.0}, arcane = {r = 216/255, g = 191/255, b = 216/255, a = 1.0}, holy = {r = 1.0, g = 215/255, b = 0, a = 1.0}}, barcolorzero = { physical = {r = 0, g = 0, b = 0, a = 0.2}, nature = {r = 34/255, g = 139/255, b = 34/255, a = 0.2}, shadow = {r = 148/255, g = 0, b = 211/255, a = 0.2}, fire = {r = 1, g = 0, b = 0, a = 0.2}, frost = {r = 0, g = 0, b = 1, a = 0.2}, arcane = {r = 216/255, g = 191/255, b = 216/255, a = 0.2}, holy = {r = 1.0, g = 215/255, b = 0, a = 0.2}}, scaletexture = nil, bartexture = nil, locked = false } lsm:Register("statusbar", "CompactBars - Default", "Interface\\ChatFrame\\ChatFrameBackground") --]] initDefaultSpells(db) db = LibStub:GetLibrary("AceDB-3.0"):New("CompactBarsDB", db.defaults) CompactBars.db = db if CompactBars.db.profile.removedots then self:RegisterEvent("UNIT_TARGET", "TargetChanged") end initSpells(db) CompactBarsConfig.args.profile = acedboptions:GetOptionsTable(CompactBars.db) CompactBarsConfig.args.profile.order = -1 aceconfig:RegisterOptionsTable("CompactBars", CompactBarsConfig) acedialog:AddToBlizOptions("CompactBars") acedialog:SetDefaultSize("CompactBars", 900, 600) InterfaceOptionsFrame:SetWidth(900) end