Mercurial > wow > reaction
diff modules/Bag.lua @ 221:bb13624de7e1
un-namespace Bag bar config
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sun, 21 Nov 2010 12:51:24 -0800 |
parents | e63aefb8a555 |
children | c4b134512c50 |
line wrap: on
line diff
--- 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