diff --git a/ActionBars.lua b/ActionBars.lua index 9477dfa..ed3a786 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -8,33 +8,32 @@ local ActionBar = setmetatable({}, {__index = Bar}) local ActionBar_MT = {__index = ActionBar} local defaults = { - profile = { - Bars = { - ['**'] = { - Scale = 1, - Alpha = 1, - Buttons = 12, - Padding = 2, - } - } + ['**'] = { + Scale = 1, + Alpha = 1, + Buttons = 12, + Padding = 2, } } -local actionbars = {} function BT4ActionBars:OnInitialize() - self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults) + self.db = Bartender4.db + Bartender4:RegisterDefaultsKey("Bars", defaults) end +local first = true function BT4ActionBars:OnEnable() - for i=1,10 do - actionbars[i] = self:Create(i, self.db.profile.Bars[i]) + if first then + self.actionbars = {} + for i=1,10 do + self.actionbars[i] = self:Create(i, self.db.profile.Bars[i]) + end + first = nil end - self.db.RegisterCallback(self, "OnProfileChanged", "ApplyConfig") - self.db.RegisterCallback(self, "OnProfileCopied", "ApplyConfig") end function BT4ActionBars:ApplyConfig() - for i,v in ipairs(actionbars) do + for i,v in ipairs(self.actionbars) do v:ApplyConfig(self.db.profile.Bars[i]) v:Unlock() end @@ -79,10 +78,8 @@ function ActionBar:UpdateButtons(numbuttons) local buttons = self.buttons or {} -- create more buttons if needed - if #buttons < numbuttons then - for i = (#buttons+1), numbuttons do - buttons[i] = Bartender4.Button:Create(i, self) - end + for i = (#buttons+1), numbuttons do + buttons[i] = Bartender4.Button:Create(i, self) end -- show active buttons @@ -107,7 +104,7 @@ function ActionBar:UpdateButtonLayout() self:SetSize((36 + pad) * numbuttons + 8, 36 + 8) - buttons[1]:ClearSetPoint("TOPLEFT", self, "TOPLEFT", 5, -3) + buttons[1]:ClearSetPoint("TOPLEFT", self, "TOPLEFT", 6, -3) for i = 2, numbuttons do buttons[i]:ClearSetPoint("TOPLEFT", buttons[i-1], "TOPRIGHT", pad, 0) end diff --git a/Bartender4.lua b/Bartender4.lua index 922d617..8812393 100644 --- a/Bartender4.lua +++ b/Bartender4.lua @@ -1,6 +1,30 @@ --[[ $Id$ ]] -Bartender4 = LibStub("AceAddon-3.0"):NewAddon("Bartender4", "AceConsole-3.0", "AceEvent-3.0") +local AceAddon = LibStub("AceAddon-3.0") +Bartender4 = AceAddon:NewAddon("Bartender4", "AceConsole-3.0", "AceEvent-3.0") function Bartender4:OnInitialize() self.db = LibStub("AceDB-3.0"):New("Bartender4DB") + self.db.RegisterCallback(self, "OnProfileChanged", "UpdateModuleConfigs") + self.db.RegisterCallback(self, "OnProfileCopied", "UpdateModuleConfigs") +end + +local defaults = { + profile = { + + } +} + +function Bartender4:RegisterDefaultsKey(key, subdefaults) + defaults.profile[key] = subdefaults + + self.db:RegisterDefaults(defaults) +end + + +function Bartender4:UpdateModuleConfigs() + for k,v in AceAddon:IterateModulesOfAddon("Bartender4") do + if type(v.ApplyConfig) == "function" then + v:ApplyConfig() + end + end end diff --git a/Bartender4.toc b/Bartender4.toc index 0c98cfd..2afbc1f 100644 --- a/Bartender4.toc +++ b/Bartender4.toc @@ -1,13 +1,16 @@ -## Interface: 20200 +## Interface: 20300 ## Notes: Simple and Advanced combined - Bartender4 ActionBar AddOn ## Title: Bartender4 ## Author: Nevcairiel ## SavedVariables: Bartender4DB ## OptionalDeps: Ace3 +## X-Embeds: Ace3 ## X-Category: Action Bars ## X-License: BSD ## Version: 4.0 +embeds.xml + ## Core ## Bartender4.lua diff --git a/Button.lua b/Button.lua index db4a31d..b608bf8 100644 --- a/Button.lua +++ b/Button.lua @@ -11,7 +11,8 @@ Bartender4.Button = {} Bartender4.Button.prototype = Button function Bartender4.Button:Create(id, parent) local absid = (parent.id - 1) * 12 + id - local button = setmetatable(CreateFrame("CheckButton", ("BT4Button%d"):format(absid), parent, "ActionBarButtonTemplate"), Button_MT) + local name = ("BT4Button%d"):format(absid) + local button = setmetatable(CreateFrame("CheckButton", name, parent, "ActionBarButtonTemplate"), Button_MT) button:SetAttribute("type", "action") button:SetAttribute("useparent-unit", true) @@ -23,6 +24,8 @@ function Bartender4.Button:Create(id, parent) this = button ActionButton_UpdateAction() + _G[("%sNormalTexture"):format(name)]:Hide() + button:Show() return button diff --git a/embeds.xml b/embeds.xml new file mode 100644 index 0000000..0311c56 --- /dev/null +++ b/embeds.xml @@ -0,0 +1,11 @@ + +