diff ReAction.lua @ 223:c4b134512c50

Move RegisterBarType from modules to button classes
author Flick <flickerstreak@gmail.com>
date Mon, 22 Nov 2010 10:25:18 -0800
parents e63aefb8a555
children 19fd228d9241
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