Mercurial > wow > reaction
changeset 221:bb13624de7e1
un-namespace Bag bar config
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sun, 21 Nov 2010 12:51:24 -0800 |
parents | a4e7475633b3 |
children | d08a74e86c96 |
files | Profile.lua classes/BagButton.lua modules/Bag.lua |
diffstat | 3 files changed, 22 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/Profile.lua Sun Nov 21 10:40:54 2010 -0800 +++ b/Profile.lua Sun Nov 21 12:51:24 2010 -0800 @@ -43,7 +43,7 @@ bf:ResetProfile() end - -- (4) Action is no longer a module, uses the bar config directly + -- (4) Action module uses the bar config directly local action = db:GetNamespace("Action",true) or db:RegisterNamespace("Action") if action then for name, ac in pairs(action.profile.bars) do @@ -57,6 +57,16 @@ action:ResetProfile() end + -- (5) Bags module uses the bar config directly + local bag = db:GetNamespace("Bag",true) or db:RegisterNamespace("Bag") + if bag then + for name, bc in pairs(bag.profile.buttons) do + local c = db.profile.bars[name] + c.buttons = bc + end + bag:ResetProfile() + end + db.profile.dbversion = 1 end
--- a/classes/BagButton.lua Sun Nov 21 10:40:54 2010 -0800 +++ b/classes/BagButton.lua Sun Nov 21 12:51:24 2010 -0800 @@ -25,7 +25,8 @@ btnHeight = 30, btnRows = 1, btnColumns = 6, - spacing = 4 + spacing = 4, + buttons = { } }, barType = L["Bag Bar"], @@ -42,20 +43,19 @@ -- Bag Button base class -- -function BagBase:New( idx, moduleConfig, bar, idHint ) +function BagBase:New( idx, btnCfg, bar, idHint ) local name = format("ReAction_%s_Bag_%d",bar:GetName(),idx) -- use a variable private leaf implementation class -- unlike traditional OO programming, we can initialize the leaf - -- class before initializing its derived class + -- class before initializing its parent local class = Bag if idx == 1 then class = Backpack elseif idx == 6 then class = Keyring end - self = class:New(name,moduleConfig.buttons[bar:GetName()][idx], bar, idx) - self.moduleConfig = moduleConfig + self = class:New(name, btnCfg, bar, idx) local f = self:GetFrame() local config = self:GetConfig() @@ -126,12 +126,6 @@ return self end -function BagBase:GetModuleConfig() - -- this is the Bag module config structure, - -- not the config structure of the bar itself - return self.moduleConfig -end - function BagBase:GetActionID() return self.config.bagID end
--- a/modules/Bag.lua Sun Nov 21 10:40:54 2010 -0800 +++ b/modules/Bag.lua Sun Nov 21 12:51:24 2010 -0800 @@ -20,21 +20,11 @@ -- handlers function module:OnInitialize() - self.db = ReAction.db:RegisterNamespace( moduleID, - { - profile = { - buttons = { } - } - } - ) - self.buttons = { } ReAction.RegisterCallback(self, "OnCreateBar", "OnRefreshBar") ReAction.RegisterCallback(self, "OnDestroyBar") ReAction.RegisterCallback(self, "OnRefreshBar") - ReAction.RegisterCallback(self, "OnEraseBar") - ReAction.RegisterCallback(self, "OnRenameBar") end function module:OnEnable() @@ -58,17 +48,17 @@ end function module:OnRefreshBar(event, bar, name) - if bar.config.type == moduleID then + local config = bar:GetConfig() + if config.type == moduleID then local btns = self.buttons[bar] if btns == nil then btns = { } self.buttons[bar] = btns end - local profile = self.db.profile - if profile.buttons[name] == nil then - profile.buttons[name] = {} + if not config.buttons then + config.buttons = { } end - local btnCfg = profile.buttons[name] + local btnCfg = config.buttons local r, c = bar:GetButtonGrid() local n = r*c @@ -77,7 +67,7 @@ btnCfg[i] = {} end if btns[i] == nil then - local success, r = pcall(Button.New,Button,i,profile,bar,i>1 and btnCfg[i-1].bagID) + local success, r = pcall(Button.New,Button,i,btnCfg[i],bar,i>1 and btnCfg[i-1].bagID) if success and r then btns[i] = r bar:AddButton(i,r) @@ -102,14 +92,6 @@ end -function module:OnEraseBar(event, bar, name) - self.db.profile.buttons[name] = nil -end - -function module:OnRenameBar(event, bar, oldName, newName) - local b = self.db.profile.buttons - b[newname], b[oldname] = b[oldname], nil -end -- hook some functions to propagate to our bag buttons