diff modules/ReAction_Action/ReAction_Action.lua @ 102:ad49739d110d

Added feature to lock buttons (per-bar), with optional only-in-combat selector.
author Flick <flickerstreak@gmail.com>
date Sun, 26 Oct 2008 02:26:31 +0000
parents 567a885cdfad
children b2fb8f7dc780
line wrap: on
line diff
--- a/modules/ReAction_Action/ReAction_Action.lua	Sat Oct 25 18:49:18 2008 +0000
+++ b/modules/ReAction_Action/ReAction_Action.lua	Sun Oct 26 02:26:31 2008 +0000
@@ -150,10 +150,28 @@
       get  = "GetHideEmpty",
       set  = "SetHideEmpty",
     },
+    lockButtons = {
+      name = L["Lock Buttons"],
+      desc = L["Prevents picking up/dragging actions.|nNOTE: This setting is overridden by the global setting in Blizzard's Action Buttons tab"],
+      order = 2,
+      type = "toggle",
+      disabled = "LockButtonsDisabled",
+      get = "GetLockButtons",
+      set = "SetLockButtons",
+    },
+    lockOnlyCombat = {
+      name = L["Only in Combat"],
+      desc = L["Only lock the buttons when in combat"],
+      order = 3,
+      type = "toggle",
+      disabled = "LockButtonsCombatDisabled",
+      get = "GetLockButtonsCombat",
+      set = "SetLockButtonsCombat",
+    },
     pages = {
       name  = L["# Pages"],
       desc  = L["Use the Dynamic State tab to specify page transitions"],
-      order = 2,
+      order = 4,
       type  = "range",
       min   = 1,
       max   = 10,
@@ -164,7 +182,7 @@
     mindcontrol = {
       name = L["Mind Control Support"],
       desc = L["When possessing a target (e.g. via Mind Control), map the first 12 buttons of this bar to the possessed target's actions."],
-      order = 3,
+      order = 5,
       type = "toggle",
       width = "double",
       set = "SetMindControl",
@@ -172,7 +190,7 @@
     },
     actions = {
       name   = L["Edit Action IDs"],
-      order  = 4,
+      order  = 6,
       type   = "group",
       inline = true,
       args   = {
@@ -290,10 +308,10 @@
         end
       end
     end
+    local f = self.bar:GetFrame()
     for _, b in ipairs(self.btns) do
       b:Refresh()
     end
-    local f = self.bar:GetFrame()
     f:SetAttribute("mindcontrol",self.config.mindcontrol)
     f:Execute(
       [[
@@ -307,6 +325,7 @@
         control:ChildUpdate()
       ]])
     RegisterStateDriver(f, "mindcontrol", "[bonusbar:5] mc; none")
+    self:UpdateButtonLock()
   end
 
   function Handle:Destroy()
@@ -330,6 +349,17 @@
     end
   end
 
+  function Handle:UpdateButtonLock()
+    local f = self.bar:GetFrame()
+    f:SetAttribute("lockbuttons",self.config.lockButtons)
+    f:SetAttribute("lockbuttonscombat",self.config.lockButtonsCombat)
+    f:Execute(
+      [[
+        lockButtons = self:GetAttribute("lockbuttons")
+        lockButtonsCombat = self:GetAttribute("lockbuttonscombat")
+      ]])
+  end
+
   function Handle:SetKeybindMode(mode)
     for _, b in pairs(self.btns) do
       if mode then
@@ -360,10 +390,8 @@
 
   function Handle:SetHideEmpty(info, value)
     if value ~= self.config.hideEmpty then
-      for b in self.bar:IterateButtons() do
-        b:ShowGrid(not value)
-      end
       self.config.hideEmpty = value
+      self:ShowGrid(not value)
     end
   end
 
@@ -371,6 +399,32 @@
     return self.config.hideEmpty
   end
 
+  function Handle:GetLockButtons()
+    return LOCK_ACTIONBAR == "1" or self.config.lockButtons
+  end
+
+  function Handle:SetLockButtons(info, value)
+    self.config.lockButtons = value
+    self:UpdateButtonLock()
+  end
+
+  function Handle:LockButtonsDisabled()
+    return LOCK_ACTIONBAR == "1"
+  end
+
+  function Handle:GetLockButtonsCombat()
+    return self.config.lockButtonsCombat
+  end
+
+  function Handle:SetLockButtonsCombat(info, value)
+    self.config.lockButtonsCombat = value
+    self:UpdateButtonLock()
+  end
+
+  function Handle:LockButtonsCombatDisabled()
+    return LOCK_ACTIONBAR == "1" or not self.config.lockButtons
+  end
+
   function Handle:GetNumPages()
     return self.config.nPages
   end
@@ -898,6 +952,15 @@
         self:SetAttribute("action",value)
       ]])
 
+    -- install drag wrappers to lock buttons 
+    bar:GetFrame():WrapScript(f, "OnDragStart",
+      -- OnDragStart(self, button, kind, value, ...)
+      [[
+        if lockButtons and (PlayerInCombat() or not lockButtonsCombat) and not IsModifiedClick("PICKUPACTION") then
+          return "clear"
+        end
+      ]])
+
     self.frame = f
     self.normalTexture = getglobal(format("%sNormalTexture",f:GetName()))