Mercurial > wow > reaction
changeset 222:d08a74e86c96
un-namespace totem, pet, stance, vehicle exit
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sun, 21 Nov 2010 14:42:38 -0800 |
parents | bb13624de7e1 |
children | c4b134512c50 |
files | Profile.lua classes/MultiCastButton.lua classes/PetActionButton.lua classes/StanceButton.lua classes/VehicleExitButton.lua modules/PetAction.lua modules/Stance.lua modules/Totem.lua modules/VehicleExit.lua |
diffstat | 9 files changed, 90 insertions(+), 125 deletions(-) [+] |
line wrap: on
line diff
--- a/Profile.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/Profile.lua Sun Nov 21 14:42:38 2010 -0800 @@ -46,11 +46,11 @@ -- (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 - local c = db.profile.bars[name] - if c then + for name, bar in pairs(db.profile.bars) do + local ac = action.profile.bars and action.profile.bars[name] + if ac then for key, value in pairs(ac) do - c[key] = value + bar[key] = value end end end @@ -60,13 +60,63 @@ -- (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 + for name, bar in pairs(db.profile.bars) do + local bc = bag.profile.buttons and bag.profile.buttons[name] + if bc then + bar.buttons = bc + end end bag:ResetProfile() end + -- (6) Pet module uses the bar config directly + local pet = db:GetNamespace("PetAction",true) or db:RegisterNamespace("PetAction") + if pet then + for name, bar in pairs(db.profile.bars) do + local pc = pet.profile.buttons and pet.profile.buttons[name] + if pc then + bar.buttons = pc + end + end + pet:ResetProfile() + end + + -- (7) Stance module uses the bar config directly + local stance = db:GetNamespace("Stance",true) or db:RegisterNamespace("Stance") + if stance then + for name, bar in pairs(db.profile.bars) do + local sc = stance.profile.buttons and stance.profile.buttons[name] + if sc then + bar.buttons = sc + end + end + stance:ResetProfile() + end + + -- (8) Totem module uses the bar config directly + local totem = db:GetNamespace("Totem",true) or db:RegisterNamespace("Totem") + if totem then + for name, bar in pairs(db.profile.bars) do + local tc = totem.profile.buttons and totem.profile.buttons[name] + if tc then + bar.buttons = tc + end + end + totem:ResetProfile() + end + + -- (9) Vehicle exit button uses the bar config directly + local vehicle = db:GetNamespace("VehicleExit",true) or db:RegisterNamespace("VehicleExit") + if vehicle then + for name, bar in pairs(db.profile.bars) do + local vc = vehicle.profile.buttons and vehicle.profile.buttons[name] + if vc then + bar.buttons = vc + end + end + vehicle:ResetProfile() + end + db.profile.dbversion = 1 end
--- a/classes/MultiCastButton.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/classes/MultiCastButton.lua Sun Nov 21 14:42:38 2010 -0800 @@ -311,7 +311,8 @@ btnHeight = 36, btnRows = 1, btnColumns = 6, - spacing = 3 + spacing = 3, + buttons = { } }, barType = L["Totem Bar"],
--- a/classes/PetActionButton.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/classes/PetActionButton.lua Sun Nov 21 14:42:38 2010 -0800 @@ -66,7 +66,8 @@ btnHeight = 30, btnRows = 1, btnColumns = 10, - spacing = 8 + spacing = 8, + buttons = { } }, barType = L["Pet Action Bar"],
--- a/classes/StanceButton.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/classes/StanceButton.lua Sun Nov 21 14:42:38 2010 -0800 @@ -49,11 +49,10 @@ { __index = Super } ) ReAction.Button.Stance = Stance -function Stance:New( idx, moduleConfig, bar, idHint ) +function Stance:New( idx, config, bar, idHint ) local name = format("ReAction_%s_Stance_%d",bar:GetName(),idx) - self = Super.New(self, name, moduleConfig.buttons[bar:GetName()][idx], bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) - self.moduleConfig = moduleConfig + self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) local f = self:GetFrame() local barFrame = bar:GetFrame()
--- a/classes/VehicleExitButton.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/classes/VehicleExitButton.lua Sun Nov 21 14:42:38 2010 -0800 @@ -16,7 +16,8 @@ btnHeight = 36, btnRows = 1, btnColumns = 1, - spacing = 3 + spacing = 3, + buttons = { } }, barType = L["Exit Vehicle Floater"],
--- a/modules/PetAction.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/modules/PetAction.lua Sun Nov 21 14:42:38 2010 -0800 @@ -35,13 +35,6 @@ -- module methods function module:OnInitialize() - self.db = ReAction.db:RegisterNamespace( moduleID, - { - profile = { - buttons = { } - } - } - ) self.buttons = { } ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") @@ -49,8 +42,6 @@ ReAction.RegisterCallback(self, "OnCreateBar") ReAction.RegisterCallback(self, "OnDestroyBar") ReAction.RegisterCallback(self, "OnRefreshBar") - ReAction.RegisterCallback(self, "OnEraseBar") - ReAction.RegisterCallback(self, "OnRenameBar") end function module:OnEnable() @@ -70,16 +61,16 @@ end function module:OnRefreshBar(event, bar, name) - if bar.config.type == moduleID then + local config = bar:GetConfig() + if config.type == moduleID then if self.buttons[bar] == nil then self.buttons[bar] = { } end local btns = self.buttons[bar] - 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 @@ -125,14 +116,6 @@ end 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 ---- Options ----
--- a/modules/Stance.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/modules/Stance.lua Sun Nov 21 14:42:38 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].stanceID) + local success, r = pcall(Button.New,Button,i,btnCfg,bar,i>1 and btnCfg[i-1].stanceID) if success and r then btns[i] = r bar:AddButton(i,r) @@ -102,18 +92,3 @@ 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 - -function module:RefreshAll() - for bar in pairs(self.buttons) do - self:OnRefreshBar(nil,bar,bar:GetName()) - end -end -
--- a/modules/Totem.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/modules/Totem.lua Sun Nov 21 14:42:38 2010 -0800 @@ -21,21 +21,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") self:RegisterEvent("UPDATE_MULTI_CAST_ACTIONBAR","PLAYER_ENTERING_WORLD") end @@ -61,17 +51,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 = min(r*c,6) @@ -111,21 +101,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 - -function module:RefreshAll() - for bar in pairs(self.buttons) do - self:OnRefreshBar(nil,bar,bar:GetName()) - end -end - function module:UPDATE_MULTI_CAST_ACTIONBAR() if not InCombatLockdown() then for bar in pairs(self.buttons) do
--- a/modules/VehicleExit.lua Sun Nov 21 12:51:24 2010 -0800 +++ b/modules/VehicleExit.lua Sun Nov 21 14:42:38 2010 -0800 @@ -21,13 +21,6 @@ -- module methods function module:OnInitialize() - self.db = ReAction.db:RegisterNamespace( moduleID, - { - profile = { - buttons = { } - } - } - ) self.registered = { } self.buttons = { } @@ -36,8 +29,6 @@ ReAction.RegisterCallback(self, "OnCreateBar") ReAction.RegisterCallback(self, "OnDestroyBar") ReAction.RegisterCallback(self, "OnRefreshBar") - ReAction.RegisterCallback(self, "OnEraseBar") - ReAction.RegisterCallback(self, "OnRenameBar") end function module:OnEnable() @@ -55,18 +46,16 @@ end function module:OnRefreshBar(event, bar, name) - if bar.config.type == moduleID then - local profile = self.db.profile - if profile.buttons[name] == nil then - profile.buttons[name] = {} + local config = bar:GetConfig() + if config.type == moduleID then + if not config.buttons then + config.buttons = { } end - local btnCfg = profile.buttons[name] + local btnCfg = config.buttons + btnCfg[1] = btnCfg[1] or { } - if profile.buttons[name] == nil then - profile.buttons[name] = { } - end if self.buttons[bar] == nil then - local success, r = pcall(Button.New, Button, 1, profile.buttons[name], bar) + local success, r = pcall(Button.New, Button, 1, btnCfg[1], bar) if success and r then self.buttons[bar] = r bar:AddButton(1,r) @@ -86,19 +75,10 @@ end 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 - function module:UpdateRegistration(bar) -- auto show/hide when on a vehicle - local config = self.db.profile.buttons[bar:GetName()] + local config = bar:GetConfig() local f = bar:GetFrame() if config.withControls then if bar.vehicleExitStateRegistered then @@ -128,7 +108,7 @@ end function Handler:GetConfig() - return module.db.profile.buttons[self.bar:GetName()] + return self.bar:GetConfig() end function Handler:GetPassengerOnly()