diff classes/ActionButton.lua @ 124:0c5017f6062d

More fixes for new action button implementation
author Flick <flickerstreak@gmail.com>
date Tue, 03 Mar 2009 22:10:45 +0000
parents 943eed2c7def
children 729232aeeb5e
line wrap: on
line diff
--- a/classes/ActionButton.lua	Mon Feb 23 19:41:11 2009 +0000
+++ b/classes/ActionButton.lua	Tue Mar 03 22:10:45 2009 +0000
@@ -71,7 +71,7 @@
 local _childupdate_vehicleExit =  -- function(self, snippetid, message)
 [[
   local show = (mcVehicleState == "vehicle")
-  if show then
+  if show and doVehicle then
     self:SetAttribute("type","macro")
     self:SetAttribute("macrotext","/run VehicleExit()")
     self:Show()
@@ -157,7 +157,7 @@
 function Action:New( idx, config, bar, idHint )
   local name = format("ReAction_%s_Action_%d",bar:GetName(),idx)
  
-  self = Super.New(self, name, config, bar, idx, "ActionButtonTemplate, SecureActionButtonTemplate" )
+  self = Super.New(self, name, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
 
   local f = self:GetFrame()
   local barFrame = bar:GetFrame()
@@ -181,7 +181,6 @@
   -- set up the base action ID
   self:SetActionIDPool("action",120)
   config.actionID = self:AcquireActionID(config.actionID, idHint)
-  self.actionID = config.actionID
   self.nPages = 1
 
   -- attribute setup
@@ -210,16 +209,9 @@
   f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid)
   barFrame:WrapScript(f, "OnDragStart", _onDragStart)
   barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag)
-  if idx == 7 then
-    -- install vehicle-exit button on 7th button (only)
-    f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
-    local button = self
-    function barFrame:ShowVehicleExit(show)
-      button:ShowVehicleExit(show)
-    end
-  end
 
   -- event registration
+  f:EnableMouse(true)
   f:RegisterForDrag("LeftButton", "RightButton")
   f:RegisterForClicks("AnyUp")
   for _, evt in pairs(eventList) do
@@ -262,9 +254,22 @@
 function Action:Refresh()
   self.bar:PlaceButton(self, 36, 36)
   self:RefreshPages()
+  self:InstallVehicle()
   self:UpdateAction()
 end
 
+function Action:InstallVehicle()
+  if self.idx == 7 and self.bar:GetConfig().vehicle then
+    -- install vehicle-exit button on 7th button (only)
+    f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
+    barFrame.ShowVehicleExit = function(bar,show)
+      self:ShowVehicleExit(show)
+    end
+  else
+    f:SetAttribute("_childupdate-vehicle",nil)
+  end
+end
+
 function Action:UpdateAll()
   self:UpdateActionIDLabel(ReAction:GetConfigMode())
   self:UpdateHotkey()
@@ -567,7 +572,7 @@
 function Action:ShowVehicleExit(show)
   local f = self:GetFrame()
   local tx = f.vehicleExitTexture
-  if show then
+  if show and self.bar:GetConfig().vehicle then
     if not tx then
       tx = f:CreateTexture(nil,"ARTWORK")
       tx:SetAllPoints()
@@ -651,8 +656,11 @@
 function Action:ACTIONBAR_UPDATE_STATE()
   self:UpdateCheckedState()
 end
-Action.TRADE_SKILL_SHOW = Action.ACTIONBAR_UPDATE_STATE
-Action.TRADE_SKILL_CLOSE = Action.ACTIONBAR_UPDATE_STATE
+
+function Action:TRADE_SKILL_SHOW()
+  self:UpdateCheckedState()
+end
+Action.TRADE_SKILL_CLOSE = Action.TRADE_SKILL_CLOSE
 
 function Action:UNIT_ENTERED_VEHICLE(event,unit)
   if unit == "player" then