changeset 170:0030201b5fc2

use secure HasAction() (drycoded)
author Flick <flickerstreak@gmail.com>
date Tue, 19 Oct 2010 20:07:55 +0000
parents 8cc187143acd
children fe0c7be6f6ef
files classes/ActionButton.lua
diffstat 1 files changed, 5 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/classes/ActionButton.lua	Tue Oct 19 17:20:16 2010 +0000
+++ b/classes/ActionButton.lua	Tue Oct 19 20:07:55 2010 +0000
@@ -60,13 +60,12 @@
   self:SetAttribute("action",action)
 
   if not self:GetAttribute("showgrid") then
-    local hasaction = (action > 120) or self:GetAttribute("hasaction-"..action)
     local tempShow = self:GetAttribute("showgrid-temp")
     local evtShow = self:GetAttribute("showgrid-event")
     if tempShow then tempShow = (tempShow > 0) end
     if evtShow then evtShow = (evtShow > 0) end
 
-    if tempShow or evtShow or hasaction then
+    if tempShow or evtShow or HasAction(action) then
       self:Show()
     else
       self:Hide()
@@ -93,8 +92,7 @@
     local count = message + (self:GetAttribute("showgrid-temp") or 0)
     if count <= 0 then
       local action = self:GetAttribute("action")
-      local hasaction = (action > 120) or self:GetAttribute("hasaction-"..action)
-      if hasaction then
+      if HasAction(action) then
         self:Show()
       else
         self:Hide()
@@ -110,8 +108,6 @@
   if lockButtons and (PlayerInCombat() or not lockButtonsCombat) and not IsModifiedClick("PICKUPACTION") then
     return kind, value, ...
   else
-    -- don't make any assumptions about hiding on grid show here, as we don't know if the 
-    -- drag gets cancelled later. 
     return "action", self:GetAttribute("action")
   end
 ]]
@@ -120,16 +116,15 @@
 [[
   if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then
     return kind, value, ...
+  else
+    return "action", self:GetAttribute("action")
   end
-  self:SetAttribute("hasaction-"..self:GetAttribute("action"),true)
-  return "action", self:GetAttribute("action")
 ]]
 
 --
 -- private
 --
 local eventList = {
-  "PLAYER_REGEN_ENABLED",
   "PLAYER_ENTERING_WORLD",
   "ACTIONBAR_PAGE_CHANGED",
   "ACTIONBAR_SLOT_CHANGED",
@@ -249,7 +244,6 @@
 
 function Action:Refresh()
   Super.Refresh(self)
-  self:RefreshHasActionAttributes()
   self:RefreshPages()
   self:InstallVehicle()
   self:ShowGrid(not self:GetBarConfig().hideEmpty)
@@ -325,37 +319,8 @@
   end
 end
 
-function Action:RefreshHasActionAttributes()
-  -- check if each action has an action or not, and flag an attribute
-  -- so that the showgrid secure handler can make decisions accordingly
-  local f = self:GetFrame()
-  local attr = "hasaction-"..self.config.actionID
-  local hasAction = HasAction(self.config.actionID)
-  if f:GetAttribute(attr) ~= hasAction then
-    f:SetAttribute(attr,hasAction) -- avoid setting attribute and triggering script handler unnecessarily
-  end
-  if self.config.pageactions then
-    for i = 1, self.nPages do
-      attr = "hasaction-"..self.config.pageactions[i]
-      hasAction = HasAction(self.config.pageactions[i])
-      if f:GetAttribute(attr) ~= hasAction then
-        f:SetAttribute(attr,hasAction)
-      end
-    end
-  end
-end
-
 function Action:UpdateShowGrid()
-  -- this is a little bit complicated because there's no
-  -- secure access to HasAction.
-  if InCombatLockdown() then
-    self.showgridPending = true  -- handle after combat
-  else
-    self.showgridPending = false
-    self:RefreshHasActionAttributes()
-
-    -- the following is an out-of-combat show/hide to supplement the secure
-    -- handling and clean up after it when it guesses
+  if not InCombatLockdown() then
     local f = self:GetFrame()
     local count = (f:GetAttribute("showgrid-event") or 0) +
                   (self.showGridTempCount or 0) +
@@ -785,12 +750,6 @@
   end
 end
 
-function Action:PLAYER_REGEN_ENABLED()
-  if self.showgridPending then
-    self:UpdateShowGrid()
-  end
-end
-
 function Action:UNIT_INVENTORY_CHANGED(unit)
   if unit == "player" then
     self:UpdateTooltip()