diff --git a/ActionBars.lua b/ActionBars.lua index 4ba69f3..85c1b8e 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -10,7 +10,7 @@ local stancedefaults = { ROGUE = { stealth = 7 } } -local defaults = Bartender4:Merge({ +local abdefaults = Bartender4:Merge({ ['**'] = { Enabled = true, Buttons = 12, @@ -35,9 +35,17 @@ local defaults = Bartender4:Merge({ }, }, Bartender4.Bar.defaults) +local defaults = { + profile = { + OutOfRange = "button", + Colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } }, + ActionBars = abdefaults, + } +} + function BT4ActionBars:OnInitialize() - self.db = Bartender4.db - Bartender4:RegisterDefaultsKey("ActionBars", defaults) + self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults) + self:SetupOptions() @@ -101,14 +109,6 @@ function BT4ActionBars:ForAllButtons(...) self:ForAll("ForAll", ...) end -local getFunc -do - function getFunc(info) - local key = info.arg or info[#info] - return Bartender4.db.profile[key] - end -end - function BT4ActionBars:SetupOptions() self.options = { order = 20, @@ -129,9 +129,11 @@ function BT4ActionBars:SetupOptions() desc = "Configure how the Out of Range Indicator should display on the buttons.", type = "select", style = "dropdown", - arg = "OutOfRange", + get = function() + return BT4ActionBars.db.profile.OutOfRange + end, set = function(info, value) - Bartender4.db.profile.OutOfRange = value + BT4ActionBars.db.profile.OutOfRange = value BT4ActionBars:ForAllButtons("UpdateUsable") end, values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" }, @@ -142,11 +144,11 @@ function BT4ActionBars:SetupOptions() guiInline = true, name = "Colors", get = function(info) - local color = Bartender4.db.profile.Colors[info[#info]] + local color = BT4ActionBars.db.profile.Colors[info[#info]] return color.r, color.g, color.b end, set = function(info, r, g, b) - local color = Bartender4.db.profile.Colors[info[#info]] + local color = BT4ActionBars.db.profile.Colors[info[#info]] color.r, color.g, color.b = r, g, b BT4ActionBars:ForAllButtons("UpdateUsable") end, @@ -201,6 +203,7 @@ end function BT4ActionBars:Create(id, config) local id = tostring(id) local bar = setmetatable(Bartender4.Bar:Create(id, "SecureStateHeaderTemplate", config), ActionBar_MT) + bar.module = self self:CreateBarOption(id, self:GetOptionsTable()) diff --git a/Bartender4.lua b/Bartender4.lua index adcc867..b0e64f1 100644 --- a/Bartender4.lua +++ b/Bartender4.lua @@ -4,8 +4,7 @@ Bartender4 = AceAddon:NewAddon("Bartender4", "AceConsole-3.0", "AceEvent-3.0") local defaults = { profile = { - OutOfRange = "button", - Colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } }, + } } diff --git a/Button.lua b/Button.lua index 6dc6734..baca0e3 100644 --- a/Button.lua +++ b/Button.lua @@ -16,6 +16,7 @@ function Bartender4.Button:Create(id, parent) local name = ("BT4Button%d"):format(absid) local button = setmetatable(CreateFrame("CheckButton", name, parent, "SecureActionButtonTemplate, ActionButtonTemplate"), Button_MT) button.parent = parent + button.settings = parent.module.db button:SetScript("OnEvent", button.EventHandler) button:SetScript("OnUpdate", onUpdate) @@ -216,9 +217,9 @@ function Button:UpdateState() end function Button:UpdateUsable() - local oor = Bartender4.db.profile.OutOfRange + local oor = self.settings.profile.OutOfRange local isUsable, notEnoughMana = IsUsableAction(self.action) - local oorcolor, oomcolor = Bartender4.db.profile.Colors.range, Bartender4.db.profile.Colors.mana + local oorcolor, oomcolor = self.settings.profile.Colors.range, self.settings.profile.Colors.mana if ( oor ~= "button" or not self.outOfRange) then if ( oor == "none" or not self.outOfRange) then self.hotkey:SetVertexColor(1.0, 1.0, 1.0) diff --git a/Options.lua b/Options.lua index c595255..239a011 100644 --- a/Options.lua +++ b/Options.lua @@ -31,7 +31,7 @@ function Bartender4:SetupOptions() general = { order = 10, type = "group", - --cmdInline = true, + cmdInline = true, name = "General Settings", get = getFunc, set = setFunc,