Mercurial > wow > reaction
comparison 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 |
comparison
equal
deleted
inserted
replaced
217:9c0691e91488 | 218:e63aefb8a555 |
---|---|
39 ) | 39 ) |
40 | 40 |
41 self:UpgradeProfile() | 41 self:UpgradeProfile() |
42 | 42 |
43 self.bars = { } | 43 self.bars = { } |
44 self.defaultBarConfig = { } | 44 self.barTypes = { } |
45 | 45 |
46 self.LBF = LibStub("LibButtonFacade",true) | 46 self.LBF = LibStub("LibButtonFacade",true) |
47 if self.LBF then | 47 if self.LBF then |
48 self.LBF:RegisterSkinCallback("ReAction", self.OnSkinChanged, self) | 48 self.LBF:RegisterSkinCallback("ReAction", self.OnSkinChanged, self) |
49 end | 49 end |
142 self:UserError(format(L["ReAction: name '%s' already in use"],name)) | 142 self:UserError(format(L["ReAction: name '%s' already in use"],name)) |
143 return nil | 143 return nil |
144 end | 144 end |
145 | 145 |
146 if type(config) == "string" then | 146 if type(config) == "string" then |
147 config = self.defaultBarConfig[config] | 147 local class = self.barTypes[config] |
148 if not config then | 148 if not class then |
149 error(("ReAction:CreateBar() - unknown bar type '%s'"):format(tostring(select(1,...)))) | 149 error(("ReAction:CreateBar() - unknown bar type '%s'"):format(config)) |
150 end | 150 end |
151 config = tcopy(config) | 151 config = tcopy(class:GetDefaultBarConfig()) |
152 config.btnRows = select(1,...) or config.btnRows or 1 | 152 config.btnRows = select(1,...) or config.btnRows |
153 config.btnColumns = select(2,...) or config.btnColumns or 12 | 153 config.btnColumns = select(2,...) or config.btnColumns |
154 config.btnWidth = select(3,...) or config.btnWidth or 36 | 154 config.btnWidth = select(3,...) or config.btnWidth |
155 config.btnHeight = select(3,...) or config.btnHeight or 36 | 155 config.btnHeight = select(3,...) or config.btnHeight |
156 config.spacing = select(4,...) or config.spacing or 3 | 156 config.spacing = select(4,...) or config.spacing |
157 config.width = config.width or config.btnColumns*(config.btnWidth + config.spacing) + 1 | 157 config.width = config.width or config.btnColumns*(config.btnWidth + config.spacing) + 1 |
158 config.height = config.height or config.btnRows*(config.btnHeight + config.spacing) + 1 | 158 config.height = config.height or config.btnRows*(config.btnHeight + config.spacing) + 1 |
159 config.anchor = config.anchor or "UIParent" | 159 config.anchor = config.anchor or "UIParent" |
160 config.point = config.point or "BOTTOM" | 160 config.point = config.point or "BOTTOM" |
161 config.relpoint = config.relpoint or "BOTTOM" | 161 config.relpoint = config.relpoint or "BOTTOM" |
282 ManageBlizzFrame(f, self.db.profile.options.hideBlizzardBars) | 282 ManageBlizzFrame(f, self.db.profile.options.hideBlizzardBars) |
283 end | 283 end |
284 ManageBlizzFrame(VehicleMenuBar, self.db.profile.options.hideBlizzardVehicleBar) | 284 ManageBlizzFrame(VehicleMenuBar, self.db.profile.options.hideBlizzardVehicleBar) |
285 end | 285 end |
286 | 286 |
287 function ReAction:RegisterBarType( name, config, isDefaultChoice ) | 287 function ReAction:RegisterBarType( class, isDefault ) |
288 self.defaultBarConfig[name] = config | 288 local name = class:GetBarType() |
289 if isDefaultChoice then | 289 self.barTypes[name] = class |
290 self.defaultBarConfigChoice = name | 290 if isDefault then |
291 self.defaultBarType = name | |
291 end | 292 end |
292 self:RefreshEditor() | 293 self:RefreshEditor() |
293 end | 294 end |
294 | 295 |
295 function ReAction:UnregisterBarType( name ) | 296 function ReAction:UnregisterBarType( class ) |
296 self.defaultBarConfig[name] = nil | 297 local name = class:GetBarType() |
297 if self.defaultBarConfigChoice == name then | 298 self.barTypes[name] = nil |
298 self.defaultBarConfigChoice = nil | 299 if self.defaultBarType == name then |
300 self.defaultBarType = nil | |
299 end | 301 end |
300 self:RefreshEditor() | 302 self:RefreshEditor() |
301 end | 303 end |
302 | 304 |
303 function ReAction:IterateBarTypes() | 305 function ReAction:IterateBarTypes() |
304 return pairs(self.defaultBarConfig) | 306 return pairs(self.barTypes) |
305 end | 307 end |
306 | 308 |
307 function ReAction:GetBarTypeConfig(name) | 309 function ReAction:GetDefaultBarConfig(barType) |
308 if name then | 310 if barType and self.barTypes[barType] then |
309 return self.defaultBarConfig[name] | 311 return self.barTypes[barType]:GetDefaultBarConfig() |
310 end | 312 end |
311 end | 313 end |
312 | 314 |
313 function ReAction:GetBarTypeOptions( fill ) | 315 function ReAction:GetBarTypeOptions( fill ) |
314 fill = fill or { } | 316 fill = fill or { } |
317 end | 319 end |
318 return fill | 320 return fill |
319 end | 321 end |
320 | 322 |
321 function ReAction:GetDefaultBarType() | 323 function ReAction:GetDefaultBarType() |
322 return self.defaultBarConfigChoice | 324 return self.defaultBarType |
323 end | 325 end |
324 | 326 |
325 function ReAction:SetConfigMode( mode ) | 327 function ReAction:SetConfigMode( mode ) |
326 if mode ~= self.configMode then | 328 if mode ~= self.configMode then |
327 if mode then | 329 if mode then |