diff modules/ReAction_Action/ReAction_Action.lua @ 48:7b7d178dec52

Implemented bar-type selection, extended CreateBar functionality
author Flick <flickerstreak@gmail.com>
date Sat, 12 Apr 2008 00:15:09 +0000
parents 0d95ce7a9ec2
children dcf8116560a1
line wrap: on
line diff
--- a/modules/ReAction_Action/ReAction_Action.lua	Fri Apr 11 22:21:28 2008 +0000
+++ b/modules/ReAction_Action/ReAction_Action.lua	Sat Apr 12 00:15:09 2008 +0000
@@ -31,43 +31,49 @@
 end
 
 function module:OnEnable()
+  ReAction:RegisterDefaultBarConfig(L["Action Bar"], { type = "actionbar" }, true)
 end
 
 function module:OnDisable()
+  ReAction:UnregisterDefaultBarConfig(L["Action Bar"])
 end
 
 function module:ApplyToBar(bar)
-  self:RefreshBar(bar)
+  if bar.config.type == "actionbar" then
+    self:RefreshBar(bar)
+  end
 end
 
 function module:RefreshBar(bar)
-  if self.buttons[bar] == nil then
-    self.buttons[bar] = { }
-  end
-  local btns = self.buttons[bar]
-  local profile = self.db.profile
-  local barName = bar:GetName()
-  if profile.buttons[barName] == nil then
-    profile.buttons[barName] = {}
-  end
-  local btnCfg = profile.buttons[barName]
+  if bar.config.type == "actionbar" then
+    if self.buttons[bar] == nil then
+      self.buttons[bar] = { }
+    end
+    local btns = self.buttons[bar]
+    local profile = self.db.profile
+    local barName = bar:GetName()
+    if profile.buttons[barName] == nil then
+      profile.buttons[barName] = {}
+    end
+    local btnCfg = profile.buttons[barName]
 
-  local r, c = bar:GetButtonGrid()
-  local n = r*c
-  for i = 1, n do
-    if btnCfg[i] == nil then
-      btnCfg[i] = {}
+    local r, c = bar:GetButtonGrid()
+    local n = r*c
+    for i = 1, n do
+      if btnCfg[i] == nil then
+        btnCfg[i] = {}
+      end
+      if btns[i] == nil then
+        btns[i] = self.BtnClass:new(bar,i,btnCfg[i])
+      else
+        btns[i]:Refresh(bar,i)
+      end
     end
-    if btns[i] == nil then
-      btns[i] = self.BtnClass:new(bar,i,btnCfg[i])
-    else
-      btns[i]:Refresh(bar,i)
-    end
-  end
-  for i = n+1, #btns do
-    btns[i] = btns[i]:Destroy()
-    if btnCfg[i] then
-      btnCfg[i] = nil
+    for i = n+1, #btns do
+      btns[i] = btns[i]:Destroy()
+      if btnCfg[i] then
+        btnCfg[i] = nil
+      end
     end
   end
 end
@@ -88,6 +94,11 @@
   self.db.profile.buttons[barName] = nil
 end
 
+function module:RenameBarConfig(oldname, newname)
+  local b = self.db.profile.buttons
+  b[newname], b[oldname] = b[oldname], nil
+end
+
 function module:ApplyConfigMode(mode,bars)
   for _, btns in pairs(self.buttons) do
     if btn then
@@ -113,41 +124,6 @@
   end
 end
 
-function module:GetGlobalBarOptions(opts)  
-  if self.globalBarOpts == nil then
-    self.globalBarOpts = {
-      newActionBar = {
-        type = "execute",
-        name = L["New Action Bar"],
-        desc = L["Create a new bar of standard action buttons"],
-        func = function()
-                 ReAction:CreateBar()
-               end,
-        disabled = InCombatLockdown,
-      }
-    }
-  end
-  return self.globalBarOpts
-end
-
-function module:GetBarMenuOptions(bar)
-  if not bar.modMenuOpts[moduleID] then
-    bar.modMenuOpts[moduleID] = {
-    }
-  end
-  return bar.modMenuOpts[moduleID]
-end
-
-function module:GetBarConfigOptions(bar)
-  if not bar.modConfigOpts[moduleID] then
-    bar.modConfigOpts[moduleID] = {
-    }
-  end
-  return bar.modConfigOpts[moduleID]
-end
-
-
-
 -- use-count of action IDs
 local ActionIDList = setmetatable( {}, {
   __index = function(self, idx)