From: Aleksi Blinnikka Date: Tue, 26 Dec 2017 19:12:21 +0000 (+0200) Subject: Redo config tables X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/bfc00e5a5dbe35130486f25d90ca65ec8f8f1924?ds=sidebyside Redo config tables --- diff --git a/Core.lua b/Core.lua new file mode 100644 index 0000000..09f61aa --- /dev/null +++ b/Core.lua @@ -0,0 +1,57 @@ +RaidFrameCustomization = LibStub("AceAddon-3.0"):NewAddon("RaidFrameCustomization", "AceTimer-3.0"); + +RaidFrameCustomization.normalBarColor = CreateColor(0.3, 0.3, 0.3); +RaidFrameCustomization.dispelBarColor = CreateColor(1, 0.5, 0); +RaidFrameCustomization.normalBackColor = {0.7, 0.7, 0.7}; +RaidFrameCustomization.dispelBackColor = {0.5, 0.2, 0}; + +RaidFrameCustomization.inits = {}; +RaidFrameCustomization.enables = {}; +RaidFrameCustomization.disables = {}; + +RaidFrameCustomization.frames = {}; +RaidFrameCustomization.positions = { + "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT" +}; + +local defaults = { + profile = { + indicatorFont = "Arial Narrow", + showIcons = true, + enabled = true, + indicators = { + ['**'] = { + textSize = 10, + color = {1, 1, 1, 1}, + mine = false, + stack = true, + showText = true, + showIcon = true, + useDefaultIcon = true, + iconSize = 10, + }, + }, + } +}; + +function RaidFrameCustomization:OnInitialize() + self.db = LibStub("AceDB-3.0"):New("RaidFrameCustomizationDB", defaults); + self:SetupOptions(); + self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig"); + self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig"); + self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig"); +end + +function RaidFrameCustomization:OnEnable() + self:RefreshConfig(); +end + +function RaidFrameCustomization:OnDisable() + self:CancelAllTimers(); + for _, frame in pairs(self.frames) do + for _, ind in pairs(frame) do + ind.text:SetText(""); + ind.icon:SetTexture(""); + end + end +end diff --git a/Globals.lua b/Globals.lua deleted file mode 100644 index 06407b3..0000000 --- a/Globals.lua +++ /dev/null @@ -1,6 +0,0 @@ -RaidFrameCustomization = {}; - -RaidFrameCustomization.normalBarColor = CreateColor(0.3, 0.3, 0.3); -RaidFrameCustomization.dispelBarColor = CreateColor(1, 0.5, 0); -RaidFrameCustomization.normalBackColor = {0.7, 0.7, 0.7}; -RaidFrameCustomization.dispelBackColor = {0.5, 0.2, 0}; diff --git a/Indicators.lua b/Indicators.lua new file mode 100644 index 0000000..7858b4b --- /dev/null +++ b/Indicators.lua @@ -0,0 +1,195 @@ +local media = LibStub:GetLibrary("LibSharedMedia-3.0"); +local f = RaidFrameCustomization.frames; +local positions = RaidFrameCustomization.positions; +local pad = 2; +local paddings = { + TOPLEFT = {pad, -pad}, + TOPRIGHT = {-pad, -pad}, + CENTER = {0, 0}, + BOTTOMLEFT = {pad, pad}, + BOTTOMRIGHT = {-pad, pad} +}; +local watchedAuras; -- all watched auras +local indicatorAuras; -- watched auras per indicator +local auraFilters = {"HELPFUL", "HARMFUL"}; +local DEFAULT_ICON = "Interface\\AddOns\\RaidFrameCustomization\\images\\rhomb"; +local _; + +-- global functions used every update +local GetTime = GetTime; +local UnitAura = UnitAura; +local UnitIsUnit = UnitIsUnit; +local UnitIsConnected = UnitIsConnected; +local UnitIsDeadOrGhost = UnitIsDeadOrGhost; +local CompactRaidFrameContainer_ApplyToFrames = CompactRaidFrameContainer_ApplyToFrames; + +-- list of important auras TODO try to use spellIDs +local centerAuras = { + "Power Word: Shield" +}; + +local function dPrint(s) + DEFAULT_CHAT_FRAME:AddMessage("Indicators: ".. tostring(s)); +end + +local function configureIndicators(frame) + local frameName = frame:GetName(); + if not f[frameName] then return end + + local config = RaidFrameCustomization.db.profile; + local font = media and media:Fetch('font', config.indicatorFont) or STANDARD_TEXT_FONT; + for pos, ind in pairs(f[frameName]) do + ind.text:SetFont(font, config[pos]["textSize"]); + ind.text:SetTextColor(unpack(config[pos]["color"])); + ind.icon:SetWidth(config[pos]["iconSize"]); + ind.icon:SetHeight(config[pos]["iconSize"]); + ind.icon:SetTexture(DEFAULT_ICON); + if config[pos]["showIcon"] then + ind.icon:Show(); + else + ind.icon:Hide(); + end + end +end + +-- Create the FontStrings used for indicators +local function setupCompactUnitFrame(frame) + local name = frame:GetName(); + f[name] = {}; + for _, pos in ipairs(positions) do + f[name][pos] = {}; + f[name][pos].text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall"); + f[name][pos].text:SetPoint(pos, frame, pos, paddings[pos][1], paddings[pos][2]); + f[name][pos].icon = frame:CreateTexture(nil, "OVERLAY"); + f[name][pos].icon:SetPoint(pos, frame, pos, paddings[pos][1], paddings[pos][2]); + end + configureIndicators(frame); +end + +-- Get all unit auras TODO change to event driven, only remaining updating with timer +local function getAuras(unit) + local unitAuras = {}; + local auraName, icon, count, expires, caster, debuffType, spellId; + local filter; + + for _, filter in ipairs(auraFilters) do + local i = 1; + while true do + auraName, _, icon, count, debuffType, _, expires, caster, _, _, spellId = UnitAura(unit, i, filter); + if not spellId then break end + if watchedAuras[auraName] or watchedAuras[spellId] or watchedAuras[debuffType] then + local aura = {}; + aura.auraName = auraName; + aura.spellId = spellId; + aura.count = count; + aura.expires = expires; + aura.mine = UnitIsUnit(caster, "player"); + aura.icon = icon; + aura.debuffType = debuffType; + table.insert(unitAuras, aura); + end + i = i + 1; + end + end + return unitAuras; +end + +-- Check the indicators on a frame and update the times on them +local function updateIndicators(frame) + if not frame.unit then return end + local unit = frame.unit; + local frameName = frame:GetName(); + + -- Check if the indicator object exists, else create it + if not f[frameName] then setupCompactUnitFrame(frame) end + -- Hide if unit is dead/disconnected + if (not UnitIsConnected(unit)) or UnitIsDeadOrGhost(frame.displayedUnit) then + for _, ind in pairs(f[frameName]) do + ind.text:SetText(""); + ind.icon:SetTexture(""); + end + return; + end + + local unitAuras = getAuras(unit); + for pos, ind in pairs(f[frameName]) do + -- try to find matching aura + local found, aura; + for _, aura in pairs(unitAuras) do + if indicatorAuras[pos][aura.auraName] or indicatorAuras[pos][aura.spellId] or + indicatorAuras[pos][aura.debuffType] then + found = aura; + -- break on first matching buff/debuff cast by me + -- otherwise continue through + if aura.mine then break end + end + end + + local config = RaidFrameCustomization.db.profile[pos]; + if found then + if config.mine and not found.mine then + -- don't show + ind.icon:SetTexture(""); + ind.text:SetText(""); + else + if config.showIcon and not config.useDefaultIcon then + -- show icon TODO coloring + ind.icon:SetTexture(found.icon); + end + -- TODO make show text into general setting + -- under which you can select what text to show + if config.showText then + -- show text + local text; + local remaining = found.expires - GetTime(); + if remaining > 60 then + text = string.format("%dm", ceil(remaining/60)); + else + text = string.format("%d", floor(remaining+0.5)); + end + + if config.stack and found.count > 0 then + if text then + text = found.count.."-"..text; + else + text = found.count; + end + end + + ind.text:SetText(text); + end + end + else + -- not found, show nothing + ind.icon:SetTexture(""); + ind.text:SetText(""); + end + end +end + +-- Update all indicators +function RaidFrameCustomization:UpdateAllIndicators() + CompactRaidFrameContainer_ApplyToFrames(CompactRaidFrameContainer, "normal", updateIndicators); +end + +-- Used to update everything that is affected by the configuration +function RaidFrameCustomization:RefreshConfig() + self:OnDisable(); -- clear everything + if self.db.profile.enabled then + CompactRaidFrameContainer_ApplyToFrames(CompactRaidFrameContainer, "normal", configureIndicators); + -- Format aura strings + watchedAuras = {}; + indicatorAuras = {}; + for _, pos in ipairs(positions) do + indicatorAuras[pos] = {}; + for _, aura in ipairs(self.db.profile[pos]["auras"]) do + watchedAuras[aura] = true; + indicatorAuras[pos][aura] = true; + end + end + + if next(watchedAuras) ~= nil then + self.updateTimer = self:ScheduleRepeatingTimer("UpdateAllIndicators", 0.15); + end + end +end diff --git a/IndicatorsConfig.lua b/IndicatorsConfig.lua new file mode 100644 index 0000000..958fa59 --- /dev/null +++ b/IndicatorsConfig.lua @@ -0,0 +1,118 @@ +local function createOptionsTable(self) + local options = { + type = "group", + get = function(item) return self.db.profile[item[#item]] end, + set = function(item, value) self.db.profile[item[#item]] = value; self:RefreshConfig() end, + args = { + enabled = { + type = "toggle", + name = "Enable", + }, + indicatorFont = { + type = "select", + dialogControl = "LSM30_Font", + name = "Indicator font", + values = AceGUIWidgetLSMlists.font, + }, + } + }; + + for _, pos in ipairs(self.positions) do + options.args[pos] = { + type = "group", + get = function(item) + return self.db.profile[pos][item[#item]]; + end, + set = function(item, value) + self.db.profile[pos][item[#item]] = value; + self:RefreshConfig(); + end, + args = { + auras = { + type = "input", + name = "Auras", + multiline = true, + width = "full", + get = function(item) + return table.concat(self.db.profile[pos]["auras"], "\n"); + end, + set = function(item, value) + local t = {}; + for aura in string.gmatch(value, "[^\n]+") do + aura = string.gsub(aura, "^%s*(.-)%s$", "%1"); + if tonumber(aura) then + table.insert(t, tonumber(aura)); + else + table.insert(t, aura); + end + end + self.db.profile[pos]["auras"] = t; + self:RefreshConfig(); + end, + }, + mine = { + type = "toggle", + name = "Only cast by me", + }, + showText = { + type = "toggle", + name = "Show remaining time", + }, + textSize = { + type = "range", + name = "Text size", + min = 1, + max = 30, + step = 1, + width = "full", + }, + color = { + type = "color", + name = "Text color", + get = function(item) + return unpack(self.db.profile[pos]["color"]); + end, + set = function(item, r, g, b, a) + self.db.profile[pos]["color"] = {r, g, b, a}; + self:RefreshConfig(); + end, + }, + stack = { + type = "toggle", + name = "Show stacks", + }, + showIcon = { + type = "toggle", + name = "Show icon", + }, + useDefaultIcon = { + type = "toggle", + name = "Use default icon", + disabled = function() return not self.db.profile[pos]["showIcon"] end, + }, + iconSize = { + type = "range", + name = "Icon size", + min = 1, + max = 30, + step = 1, + width = "full", + }, + } + }; + end + return options; +end + +function RaidFrameCustomization:SetupOptions() + local profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db); + local options = createOptionsTable(self); + local config = LibStub("AceConfig-3.0"); + config:RegisterOptionsTable("Indicators", options); + config:RegisterOptionsTable("Indicators Profiles", profiles); + + local dialog = LibStub("AceConfigDialog-3.0"); + self.optionsFrames = {}; + self.optionsFrames.Indicators = dialog:AddToBlizOptions("Indicators", "Indicators"); + self.optionsFrames.Profile = dialog:AddToBlizOptions("Indicators Profiles", "Profiles", "Indicators"); +end diff --git a/RaidFrameCustomization.toc b/RaidFrameCustomization.toc index 9797b47..a875949 100644 --- a/RaidFrameCustomization.toc +++ b/RaidFrameCustomization.toc @@ -1,16 +1,15 @@ ## Interface: 70300 ## Title: Raid Frame Customization - ## Version: 1.0 ## Author: schyrio ## Notes: Customization to the standard raid frames -## SavedVariables: IndicatorsDB +## SavedVariables: RaidFrameCustomizationDB embeds.xml -Globals.lua -RaidFrameIndicators.lua -RaidFrameIndicatorsConfig.lua +Core.lua +Indicators.lua +IndicatorsConfig.lua UnitFrameSetupHook.lua UpdateNameHook.lua UpdateStatusTextHook.lua diff --git a/RaidFrameIndicators.lua b/RaidFrameIndicators.lua deleted file mode 100644 index 8bb26ef..0000000 --- a/RaidFrameIndicators.lua +++ /dev/null @@ -1,251 +0,0 @@ -Indicators = LibStub("AceAddon-3.0"):NewAddon( "Indicators", "AceTimer-3.0"); -local media = LibStub:GetLibrary("LibSharedMedia-3.0"); -local f = {}; -- Indicator objects -local pad = 2; -local _; -local watchedAuras; -- all watched auras -local indicatorAuras; -- watched auras per indicator -local auraFilters = {"HELPFUL", "HARMFUL"}; -local DEFAULT_ICON = "Interface\\AddOns\\RaidFrameCustomization\\images\\rhomb"; - --- global functions used every update -local GetTime = GetTime; -local UnitAura = UnitAura; -local UnitIsUnit = UnitIsUnit; -local UnitIsConnected = UnitIsConnected; -local UnitIsDeadOrGhost = UnitIsDeadOrGhost; - --- list of important auras TODO try to use spellIDs -local centerAuras = { - "Power Word: Shield" -}; - -local function dPrint(s) - DEFAULT_CHAT_FRAME:AddMessage("Indicators: ".. tostring(s)); -end - --- Set the appearance of the FontStrings -local function setupIndicatorAppearance(frame) - local frameName = frame:GetName(); - if not f[frameName] then return end - local font = media and media:Fetch('font', Indicators.db.profile.indicatorFont) or STANDARD_TEXT_FONT; - - local i, ind; - for i, ind in ipairs(f[frameName]) do - ind.text:SetFont(font, Indicators.db.profile["textSize"..i], ""); - ind.icon:SetWidth(Indicators.db.profile["iconSize"..i]); - ind.icon:SetHeight(Indicators.db.profile["iconSize"..i]); - if Indicators.db.profile["showIcon"..i] then - ind.icon:Show(); - else - ind.icon:Hide(); - end - end -end - --- Create the FontStrings used for indicators -local function setupCompactUnitFrame(frame) - local frameName = frame:GetName(); - local i; - local positions = { - "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT" - }; - local paddings = { - {pad, -pad}, {-pad, -pad}, {0, 0}, {pad, pad}, {-pad, pad} - }; - - -- Create indicators - f[frameName] = {}; - for i = 1, 5 do - f[frameName][i] = {}; - f[frameName][i].text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall"); - f[frameName][i].text:SetPoint(positions[i], frame, positions[i], paddings[i][1], paddings[i][2]); - f[frameName][i].icon = frame:CreateTexture(nil, "OVERLAY"); - f[frameName][i].icon:SetPoint(positions[i], frame, positions[i], paddings[i][1], paddings[i][2]); - end - setupIndicatorAppearance(frame); -end - --- Get all unit auras -local function getAuras(unit) - local unitAuras = {}; - local auraName, icon, count, expires, caster, debuffType, spellId; - local filter; - - -- Get all unit auras - - for _, filter in ipairs(auraFilters) do - local i = 1; - while true do - auraName, _, icon, count, debuffType, _, expires, caster, _, _, spellId = UnitAura(unit, i, filter); - if not spellId then break end - if watchedAuras[auraName] or watchedAuras[spellId] or watchedAuras[debuffType] then - local aura = {}; - aura.auraName = auraName; - aura.spellId = spellId; - aura.count = count; - aura.expires = expires; - aura.mine = UnitIsUnit(caster, "player"); - aura.icon = icon; - aura.debuffType = debuffType; - table.insert(unitAuras, aura); - end - i = i + 1; - end - end - return unitAuras; -end - --- Check the indicators on a frame and update the times on them -local function updateIndicator(frame) - if not frame.unit then return end - local unit = frame.unit; - local frameName = frame:GetName(); - local i, ind; - - -- Check if the indicator object exists, else create it - if not f[frameName] then setupCompactUnitFrame(frame) end - -- Hide if unit is dead/disconnected - if (not UnitIsConnected(unit)) or UnitIsDeadOrGhost(frame.displayedUnit) then - for _, ind in pairs(f[frameName]) do - ind.text:SetText(""); - ind.icon:SetTexture(""); - end - return; - end - - local unitAuras = getAuras(unit); - for i, ind in ipairs(f[frameName]) do - -- try to find matching aura - local found, aura; - for _, aura in pairs(unitAuras) do - if indicatorAuras[i][aura.auraName] or indicatorAuras[i][aura.spellId] or - indicatorAuras[i][aura.debuffType] then - found = aura; - -- break on first matching buff/debuff cast by me - -- otherwise continue through - if aura.mine then break end - end - end - - if found then - if Indicators.db.profile["mine"..i] and not found.mine then - -- don't show - ind.icon:SetTexture(""); - ind.text:SetText(""); - else - if Indicators.db.profile["showIcon"..i] then - -- show icon TODO coloring - if Indicators.db.profile["useDefaultIcon"..i] then - ind.icon:SetTexture(DEFAULT_ICON); - else - ind.icon:SetTexture(found.icon); - end - end - -- TODO make show text into general setting - -- under which you can select what text to show - if Indicators.db.profile["showText"..i] then - -- show text - local text; - local remaining = found.expires - GetTime(); - if remaining > 60 then - text = string.format("%dm", ceil(remaining/60)); - else - text = string.format("%d", floor(remaining+0.5)); - end - - if Indicators.db.profile["stack"..i] and found.count > 0 then - if text then - text = found.count.."-"..text; - else - text = found.count; - end - end - - -- colors - ind.text:SetTextColor( - Indicators.db.profile["color"..i].r, - Indicators.db.profile["color"..i].g, - Indicators.db.profile["color"..i].b, - Indicators.db.profile["color"..i].a - ); - if Indicators.db.profile["debuffColor"..i] then - if found.debuffType then - if found.debuffType == "Curse" then - ind.text:SetTextColor(0.6,0,1,1); - elseif found.debuffType == "Disease" then - ind.text:SetTextColor(0.6,0.4,0,1); - elseif found.debuffType == "Magic" then - ind.text:SetTextColor(0.2,0.6,1,1); - elseif found.debuffType == "Poison" then - ind.text:SetTextColor(0,0.6,0,1); - end - end - end - - ind.text:SetText(text); - end - end - else - -- not found, show nothing - ind.icon:SetTexture(""); - ind.text:SetText(""); - end - end -end - --- Update all indicators -function Indicators:UpdateAllIndicators() - CompactRaidFrameContainer_ApplyToFrames(CompactRaidFrameContainer, "normal", updateIndicator); -end - --- Used to update everything that is affected by the configuration -function Indicators:RefreshConfig() - CompactRaidFrameContainer_ApplyToFrames(CompactRaidFrameContainer, "normal", setupIndicatorAppearance); - -- Format aura strings - watchedAuras = {}; - indicatorAuras = {}; - local auraName, i; - for i = 1, 5 do - indicatorAuras[i] = {}; - for auraName in string.gmatch(Indicators.db.profile["auras"..i], "[^\n]+") do -- Grab each line - auraName = string.gsub(auraName, "^%s*(.-)%s*$", "%1"); -- Strip any whitespaces - if tonumber(auraName) then - watchedAuras[tonumber(auraName)] = true; - indicatorAuras[i][tonumber(auraName)] = true; - else - watchedAuras[auraName] = true; - indicatorAuras[i][auraName] = true; - end - end - end - - self:CancelAllTimers(); - if next(watchedAuras) ~= nil then - self.updateTimer = self:ScheduleRepeatingTimer("UpdateAllIndicators", 0.15); - end -end - -function Indicators:OnInitialize() - self:SetupOptions(); - self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig"); - self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig"); - self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig"); -end - -function Indicators:OnEnable() - if self.db.profile.enabled then - Indicators:RefreshConfig(); - end -end - -function Indicators:OnDisable() - local frame, ind; - self:CancelAllTimers(); - for _, frame in pairs(f) do - for _, ind in pairs(frame) do - ind.text:SetText(""); - ind.icon:SetTexture(""); - end - end -end diff --git a/RaidFrameIndicatorsConfig.lua b/RaidFrameIndicatorsConfig.lua deleted file mode 100644 index 15f6080..0000000 --- a/RaidFrameIndicatorsConfig.lua +++ /dev/null @@ -1,218 +0,0 @@ -local Defaults = {} - -function CreateDefaults() - Defaults.profile = { - indicatorFont = "Arial Narrow", - showIcons = true, - enabled = true, - }; - for i = 1, 5 do - Defaults.profile["auras"..i] = ""; - Defaults.profile["textSize"..i] = 10; - Defaults.profile["color"..i] = {r = 1, g = 1, b = 1, a = 1,}; - Defaults.profile["mine"..i] = false; - Defaults.profile["stack"..i] = true; - Defaults.profile["debuffColor"..i] = false; - Defaults.profile["showText"..i] = true; - Defaults.profile["showIcon"..i] = true; - Defaults.profile["useDefaultIcon"..i] = true; - Defaults.profile["iconSize"..i] = 10; - end -end - -local Options = {} -function CreateOptions () - Options = { - type = 'group', - childGroups = 'tree', - get = function(item) return Indicators.db.profile[item[#item]] end, - set = function(item, value) Indicators.db.profile[item[#item]] = value; Indicators:RefreshConfig() end, - args = { - indicatorFont = { - type = 'select', - dialogControl = "LSM30_Font", - name = "Indicator Font", - desc = "Adjust the font used for the indicators", - values = AceGUIWidgetLSMlists.font, - order = 17, - }, - enabled = { - type = "toggle", - name = "Enabled", - desc = "Enable/Disable indicators", - order = 18, - set = function(item, value) - Indicators.db.profile[item[#item]] = value - if value == true then - Indicators:OnEnable() - else - Indicators:OnDisable() - end - end, - } - } - } - - --- Add options for each indicator - local indicatorNames = {"Top Left", "Top Right", "Center", "Bottom Left", "Bottom Right"} - for i = 1, 5 do - Options.args["i"..i] = {} - Options.args["i"..i].type = 'group' - Options.args["i"..i].name = indicatorNames[i] - Options.args["i"..i].order = i*10+10 - Options.args["i"..i].args = {} - Options.args["i"..i].args["auras"..i] = { - type = "input", - name = "Buffs/Debuffs", - desc = "The buffs/debuffs to show in this indicator. Put each buff/debuff on a separate line. You can use 'Magic/Poison/Curse/Disease' to show any debuff of that type.", - multiline = true, - order = 1, - width = "full", - } - Options.args["i"..i].args["mine"..i] = { - type = "toggle", - name = "Mine only", - desc = "Only show buffs/debuffs cast by me", - order = 10, - } - Options.args["i"..i].args.textHeader = { - type = "header", - name = "Text Counter", - order = 100, - } - Options.args["i"..i].args["showText"..i] = { - type = "toggle", - name = "Show text counter", - desc = "Show a text counter specifying the time left of the buff/debuff", - order = 110, - } - Options.args["i"..i].args["textSize"..i] = { - type = "range", - name = "Size", - desc = "Text size", - min = 1, - max = 30, - step = 1, - order = 120, - width = "full", - } - Options.args["i"..i].args.coloringHeader = { - type = "header", - name = "Color", - order = 150, - } - Options.args["i"..i].args["debuffColor"..i] = { - type = "toggle", - name = "Color by debuff type", - desc = "Color the text depending on the debuff type, will override any other coloring (poison = green, magic = blue etc)", - order = 165, - } - Options.args["i"..i].args["color"..i] = { - type = "color", - name = "Default color", - desc = "Default color of the indicator", - get = function(item) - local t = Indicators.db.profile[item[#item]] - return t.r, t.g, t.b, t.a - end, - set = function(item, r, g, b, a) - local t = Indicators.db.profile[item[#item]] - t.r, t.g, t.b, t.a = r, g, b, a - Indicators:RefreshConfig() - end, - order = 170, - } - Options.args["i"..i].args.stackHeader = { - type = "header", - name = "Stack Size", - order = 200, - } - Options.args["i"..i].args["stack"..i] = { - type = "toggle", - name = "Show stack size", - desc = "Show stack size for buffs/debuffs that stack", - order = 210, - } - Options.args["i"..i].args.iconHeader = { - type = "header", - name = "Icon", - order = 300, - } - Options.args["i"..i].args["showIcon"..i] = { - type = "toggle", - name = "Show icon", - desc = "Show an icon if the buff/debuff are on the unit", - order = 310, - } - Options.args["i"..i].args["useDefaultIcon"..i] = { - type = "toggle", - name = "Use default icon", - desc = "Show default icon instead of the ability's.", - disabled = function () return not Indicators.db.profile["showIcon"..i] end, - order = 315, - } - Options.args["i"..i].args["iconSize"..i] = { - type = "range", - name = "Icon size", - desc = "Icon size", - min = 1, - max = 30, - step = 1, - order = 320, - width = "full", - } - end -end - -local SlashCommands = { - type = "group", - args = { - enable = { - type = "execute", - name = "enable", - desc = "Enable indicators", - func = function() Indicators.db.profile.enabled = true; Indicators:OnEnable() end, - }, - disable = { - type = "execute", - name = "disable", - desc = "Disable indicators", - func = function() Indicators.db.profile.enabled = false; Indicators:OnDisable() end, - }, - config = { - type = "execute", - name = "config", - desc = "Show config", - func = function() Indicators:ShowConfig() end, - }, - } -} - -function Indicators:ShowConfig() - InterfaceOptionsFrame_OpenToCategory(self.optionsFrames.Profile) - InterfaceOptionsFrame_OpenToCategory(self.optionsFrames.Indicators) -end - -function Indicators:SetupOptions() - -- Set up defaults - CreateDefaults() - self.db = LibStub("AceDB-3.0"):New("IndicatorsDB", Defaults) - - -- Profile handling - local profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) - - -- Get the config up - CreateOptions() - local config = LibStub("AceConfig-3.0") - config:RegisterOptionsTable("Raid Frame Indicators", Options) - config:RegisterOptionsTable("Raid Frame Indicators Profiles", profiles) - - -- Register slash commands - config:RegisterOptionsTable("Raid Frame Indicators Options", SlashCommands, {"indicators", "raidframeindicators"}) - - -- Add to Blizz option pane - local dialog = LibStub("AceConfigDialog-3.0") - self.optionsFrames = {} - self.optionsFrames.Indicators = dialog:AddToBlizOptions("Raid Frame Indicators","Raid Frame Indicators") - self.optionsFrames.Profile = dialog:AddToBlizOptions("Raid Frame Indicators Profiles","Profiles", "Raid Frame Indicators") -end