Mercurial > wow > reaction
diff ReAction.lua @ 218:e63aefb8a555
Demodularization of buttons
- register class instead of config
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 19 Nov 2010 23:06:24 -0800 |
parents | 9c0691e91488 |
children | c4b134512c50 |
line wrap: on
line diff
--- a/ReAction.lua Fri Nov 19 15:27:23 2010 -0800 +++ b/ReAction.lua Fri Nov 19 23:06:24 2010 -0800 @@ -41,7 +41,7 @@ self:UpgradeProfile() self.bars = { } - self.defaultBarConfig = { } + self.barTypes = { } self.LBF = LibStub("LibButtonFacade",true) if self.LBF then @@ -144,16 +144,16 @@ end if type(config) == "string" then - config = self.defaultBarConfig[config] - if not config then - error(("ReAction:CreateBar() - unknown bar type '%s'"):format(tostring(select(1,...)))) + local class = self.barTypes[config] + if not class then + error(("ReAction:CreateBar() - unknown bar type '%s'"):format(config)) end - config = tcopy(config) - config.btnRows = select(1,...) or config.btnRows or 1 - config.btnColumns = select(2,...) or config.btnColumns or 12 - config.btnWidth = select(3,...) or config.btnWidth or 36 - config.btnHeight = select(3,...) or config.btnHeight or 36 - config.spacing = select(4,...) or config.spacing or 3 + config = tcopy(class:GetDefaultBarConfig()) + config.btnRows = select(1,...) or config.btnRows + config.btnColumns = select(2,...) or config.btnColumns + config.btnWidth = select(3,...) or config.btnWidth + config.btnHeight = select(3,...) or config.btnHeight + config.spacing = select(4,...) or config.spacing config.width = config.width or config.btnColumns*(config.btnWidth + config.spacing) + 1 config.height = config.height or config.btnRows*(config.btnHeight + config.spacing) + 1 config.anchor = config.anchor or "UIParent" @@ -284,29 +284,31 @@ ManageBlizzFrame(VehicleMenuBar, self.db.profile.options.hideBlizzardVehicleBar) end -function ReAction:RegisterBarType( name, config, isDefaultChoice ) - self.defaultBarConfig[name] = config - if isDefaultChoice then - self.defaultBarConfigChoice = name +function ReAction:RegisterBarType( class, isDefault ) + local name = class:GetBarType() + self.barTypes[name] = class + if isDefault then + self.defaultBarType = name end self:RefreshEditor() end -function ReAction:UnregisterBarType( name ) - self.defaultBarConfig[name] = nil - if self.defaultBarConfigChoice == name then - self.defaultBarConfigChoice = nil +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.defaultBarConfig) + return pairs(self.barTypes) end -function ReAction:GetBarTypeConfig(name) - if name then - return self.defaultBarConfig[name] +function ReAction:GetDefaultBarConfig(barType) + if barType and self.barTypes[barType] then + return self.barTypes[barType]:GetDefaultBarConfig() end end @@ -319,7 +321,7 @@ end function ReAction:GetDefaultBarType() - return self.defaultBarConfigChoice + return self.defaultBarType end function ReAction:SetConfigMode( mode )