diff classes/ActionButton.lua @ 159:799c6ea9da7b

added vehicle exit floater some fixes for vehicle exit button on main bars still some lingering settexcoords issues on the vehicle exit icon
author Flick <flickerstreak@gmail.com>
date Mon, 29 Jun 2009 17:43:16 +0000
parents 806a61b331a0
children d0a41fc7b0d7
line wrap: on
line diff
--- a/classes/ActionButton.lua	Sat Jun 13 00:13:52 2009 +0000
+++ b/classes/ActionButton.lua	Mon Jun 29 17:43:16 2009 +0000
@@ -259,13 +259,19 @@
 function Action:InstallVehicle()
   local f = self:GetFrame()
   if self.idx == 7 and self:GetBarConfig().vehicle then
-    -- install vehicle-exit button on 7th button (only)
-    f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
-    f:SetAttribute("macrotext","/run VehicleExit()")
-    self:GetBar():GetFrame().ShowVehicleExit = function(bar,show)
-      self:ShowVehicleExit(show)
+    if not self.vehicleInstalled then
+      self.vehicleInstalled = true
+      -- install vehicle-exit button on 7th button (only)
+      f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
+      f:SetAttribute("macrotext","/run VehicleExit()")
+      self:GetBar():GetFrame().ShowVehicleExit = function(bar,show)
+        self:ShowVehicleExit(show)
+      end
     end
-  else
+    -- setscale blows away tex coords
+    self:UpdateIcon()
+  elseif self.vehicleInstalled then
+    self.vehicleInstalled = false
     f:SetAttribute("_childupdate-vehicle",nil)
     f:SetAttribute("macrotext",nil)
   end
@@ -375,7 +381,7 @@
   if self.vehicleExitMode then
     texture = "Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up"
     icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
-    icon:SetVertexColor(1,0,0)
+    icon:SetVertexColor(1,1,1)
   else
     icon:SetTexCoord(0,1,0,1)
   end
@@ -389,11 +395,7 @@
     icon:Hide()
     self.frames.cooldown:Hide()
     self.rangeTimer = nil
-    if self.vehicleExitMode then
-      f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
-    else
-      f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
-    end
+    f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
   end
 end
 
@@ -455,15 +457,34 @@
 
 function Action:UpdateUsable()
   local isUsable, notEnoughMana = IsUsableAction(self.actionID)
-  if isUsable or self.vehicleExitMode then
-    self.frames.icon:SetVertexColor(1.0, 1.0, 1.0)
-    self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
+  local noRange = IsActionInRange(self.actionID) == 0
+
+  isUsable = self.vehicleExitMode or (isUsable and not noRange)
+
+  if isUsable then
+    if self.usableStatus ~= "usable" then
+      self.frames.icon:SetVertexColor(1.0, 1.0, 1.0)
+      self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
+      self.usableStatus = "usable"
+    end
+  elseif noRange then
+    if self.usableStatus ~= "norange" then
+      self.frames.icon:SetVertexColor(1.0,0.1,0.1)
+      self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
+      self.usableStatus = "norange"
+    end
   elseif notEnoughMana then
-    self.frames.icon:SetVertexColor(0.5, 0.5, 1.0)
-    self.frames.normalTexture:SetVertexColor(0.5, 0.5, 1.0)
+    if self.usableStatus ~= "oom" then
+      self.frames.icon:SetVertexColor(0.5, 0.5, 1.0)
+      self.frames.normalTexture:SetVertexColor(0.5, 0.5, 1.0)
+      self.usableStatus = "oom"
+    end
   else
-    self.frames.icon:SetVertexColor(0.4, 0.4, 0.4)
-    self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
+    if self.usableStatus ~= "unusable" then
+      self.frames.icon:SetVertexColor(0.4, 0.4, 0.4)
+      self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
+      self.usableStatus = "unusable"
+    end
   end
 end
 
@@ -513,13 +534,7 @@
     rangeTimer = rangeTimer - elapsed
     self.rangeTimer = rangeTimer
     if rangeTimer <= 0 then
-      if self.vehicleExitMode then
-        self.frames.icon:SetVertexColor(1,1,1)
-      elseif IsActionInRange(self.actionID) == 0 then
-        self.frames.icon:SetVertexColor(1.0,0.1,0.1)
-      else
-        self:UpdateUsable()
-      end
+      self:UpdateUsable()
       self.rangeTimer = TOOLTIP_UPDATE_TIME
     end
   end