Mercurial > wow > reaction
changeset 223:c4b134512c50
Move RegisterBarType from modules to button classes
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Mon, 22 Nov 2010 10:25:18 -0800 |
parents | d08a74e86c96 |
children | 82757c2c1ea5 |
files | ReAction.lua classes/ActionButton.lua classes/BagButton.lua classes/MultiCastButton.lua classes/PetActionButton.lua classes/StanceButton.lua classes/VehicleExitButton.lua modules/Action.lua modules/Bag.lua modules/PetAction.lua modules/Stance.lua modules/Totem.lua modules/VehicleExit.lua |
diffstat | 13 files changed, 21 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/ReAction.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/ReAction.lua Mon Nov 22 10:25:18 2010 -0800 @@ -31,6 +31,8 @@ ReAction.LKB = LKB +ReAction.barTypes = { } + ------ Handlers ------ function ReAction:OnInitialize() self.db = LibStub("AceDB-3.0"):New("ReAction_DB", @@ -41,7 +43,6 @@ self:UpgradeProfile() self.bars = { } - self.barTypes = { } self.LBF = LibStub("LibButtonFacade",true) if self.LBF then @@ -143,8 +144,9 @@ return nil end + local class if type(config) == "string" then - local class = self.barTypes[config] + class = self.barTypes[config] if not class then error(("ReAction:CreateBar() - unknown bar type '%s'"):format(config)) end @@ -161,8 +163,13 @@ config.relpoint = config.relpoint or "BOTTOM" config.y = config.y or 200 config.x = config.x or 0 + else + config = config or profile.bars[name] or { } + if not config or not config.type or not self.barTypes[config.type] then + error(("ReAction: Unable to construct/fetch config table for bar '%s'"):format(name)) + end + class = self.barTypes[config.type] end - config = config or profile.bars[name] or { } profile.bars[name] = config local bar = self.Bar:New( name, config ) -- ReAction.Bar defined in Bar.lua @@ -293,15 +300,6 @@ self:RefreshEditor() end -function ReAction:UnregisterBarType( class ) - local name = class:GetBarType() - self.barTypes[name] = nil - if self.defaultBarType == name then - self.defaultBarType = nil - end - self:RefreshEditor() -end - function ReAction:IterateBarTypes() return pairs(self.barTypes) end
--- a/classes/ActionButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/ActionButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -187,7 +187,9 @@ barType = L["Action Bar"] }, { __index = Super } ) + ReAction.Button.Action = Action +ReAction:RegisterBarType(Action, true) function Action:New( idx, barConfig, bar, idHint ) local name = format("ReAction_%s_Action_%d",bar:GetName(),idx)
--- a/classes/BagButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/BagButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -38,6 +38,7 @@ local Keyring = setmetatable( { }, { __index = BagBase } ) ReAction.Button.Bag = BagBase +ReAction:RegisterBarType(BagBase) -- -- Bag Button base class
--- a/classes/MultiCastButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/MultiCastButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -318,7 +318,9 @@ barType = L["Totem Bar"], }, { __index = Action } ) + ReAction.Button.MultiCast = MultiCast +ReAction:RegisterBarType(MultiCast) function MultiCast:New( idx, btnConfig, bar ) local maxIndex = bar.nTotemSlots or 0
--- a/classes/PetActionButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/PetActionButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -73,7 +73,9 @@ barType = L["Pet Action Bar"], }, { __index = Super } ) + ReAction.Button.PetAction = Pet +ReAction:RegisterBarType(Pet) function Pet:New( idx, config, bar, idHint ) local name = format("ReAction_%s_PetAction_%d",bar:GetName(),idx)
--- a/classes/StanceButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/StanceButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -47,7 +47,9 @@ barType = L["Stance Bar"], }, { __index = Super } ) + ReAction.Button.Stance = Stance +ReAction:RegisterBarType(Stance) function Stance:New( idx, config, bar, idHint ) local name = format("ReAction_%s_Stance_%d",bar:GetName(),idx)
--- a/classes/VehicleExitButton.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/classes/VehicleExitButton.lua Mon Nov 22 10:25:18 2010 -0800 @@ -23,7 +23,9 @@ barType = L["Exit Vehicle Floater"], }, { __index = Super } ) + ReAction.Button.VehicleExit = VExitButton +ReAction:RegisterBarType(VExitButton) function VExitButton:New( idx, config, bar ) local name = format("ReAction_%s_VehicleExit_%d",bar:GetName(),idx)
--- a/modules/Action.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/Action.lua Mon Nov 22 10:25:18 2010 -0800 @@ -29,12 +29,10 @@ end function module:OnEnable() - ReAction:RegisterBarType(Button, true) ReAction:GetModule("State"):RegisterStateProperty("page", nil, PropHandler.GetOptions(), PropHandler) end function module:OnDisable() - ReAction:UnregisterBarType(Button) ReAction:GetModule("State"):UnregisterStateProperty("page") end
--- a/modules/Bag.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/Bag.lua Mon Nov 22 10:25:18 2010 -0800 @@ -27,14 +27,6 @@ ReAction.RegisterCallback(self, "OnRefreshBar") end -function module:OnEnable() - ReAction:RegisterBarType(Button) -end - -function module:OnDisable() - ReAction:UnregisterBarType(Button) -end - function module:OnDestroyBar(event, bar, name) local btns = self.buttons[bar] if btns then
--- a/modules/PetAction.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/PetAction.lua Mon Nov 22 10:25:18 2010 -0800 @@ -44,14 +44,6 @@ ReAction.RegisterCallback(self, "OnRefreshBar") end -function module:OnEnable() - ReAction:RegisterBarType(Button) -end - -function module:OnDisable() - ReAction:UnregisterBarType(Button) -end - function module:OnCreateBar(event, bar, name) if bar.config.type == moduleID then -- auto show/hide when pet exists
--- a/modules/Stance.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/Stance.lua Mon Nov 22 10:25:18 2010 -0800 @@ -27,14 +27,6 @@ ReAction.RegisterCallback(self, "OnRefreshBar") end -function module:OnEnable() - ReAction:RegisterBarType(Button) -end - -function module:OnDisable() - ReAction:UnregisterBarType(Button) -end - function module:OnDestroyBar(event, bar, name) local btns = self.buttons[bar] if btns then
--- a/modules/Totem.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/Totem.lua Mon Nov 22 10:25:18 2010 -0800 @@ -30,14 +30,6 @@ self:RegisterEvent("UPDATE_MULTI_CAST_ACTIONBAR","PLAYER_ENTERING_WORLD") end -function module:OnEnable() - ReAction:RegisterBarType(Button) -end - -function module:OnDisable() - ReAction:UnregisterBarType(Button) -end - function module:OnDestroyBar(event, bar, name) local btns = self.buttons[bar] if btns then
--- a/modules/VehicleExit.lua Sun Nov 21 14:42:38 2010 -0800 +++ b/modules/VehicleExit.lua Mon Nov 22 10:25:18 2010 -0800 @@ -31,14 +31,6 @@ ReAction.RegisterCallback(self, "OnRefreshBar") end -function module:OnEnable() - ReAction:RegisterBarType(Button) -end - -function module:OnDisable() - ReAction:UnregisterBarType(Button) -end - function module:OnCreateBar(event, bar, name) if bar.config.type == moduleID then self:OnRefreshBar(event, bar, name)