Mercurial > wow > reaction
diff classes/ActionButton.lua @ 145:42cade25d40d
Fixed display bugs with vehicle support
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Mon, 27 Apr 2009 18:10:04 +0000 |
parents | 0de0e64a970f |
children | 806a61b331a0 |
line wrap: on
line diff
--- a/classes/ActionButton.lua Sun Apr 19 20:40:55 2009 +0000 +++ b/classes/ActionButton.lua Mon Apr 27 18:10:04 2009 +0000 @@ -46,7 +46,8 @@ if (doVehicle and mcVehicleState == "vehicle") or (doMindControl and mcVehicleState == "mc") then local idx = self:GetAttribute("bar-idx") - if idx and idx <= 12 then + local maxN = (doVehicle and mcVehicleState == "vehicle") and 7 or 12 + if idx and idx <= maxN then action = 120 + idx else action = 0 @@ -80,7 +81,6 @@ local show = (mcVehicleState == "vehicle") if show and doVehicle then self:SetAttribute("type","macro") - self:SetAttribute("macrotext","/run VehicleExit()") self:Show() else self:SetAttribute("type","action") @@ -229,7 +229,7 @@ local c = self:GetConfig() f:SetAttribute("_childupdate-vehicle",nil) - f:SetAttribute("action",c.actionID) -- so that Destroy releases the right one + f:SetAttribute("action",c.actionID) -- so that Super.Destroy releases the right one if c.pageactions and #c.pageactions > 1 then for i = 2, #c.pageactions do @@ -257,14 +257,17 @@ end function Action:InstallVehicle() + local f = self:GetFrame() if self.idx == 7 and self:GetBarConfig().vehicle then -- install vehicle-exit button on 7th button (only) - self:GetFrame():SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit) + f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit) + f:SetAttribute("macrotext","/run VehicleExit()") self:GetBar():GetFrame().ShowVehicleExit = function(bar,show) self:ShowVehicleExit(show) end else - self:GetFrame():SetAttribute("_childupdate-vehicle",nil) + f:SetAttribute("_childupdate-vehicle",nil) + f:SetAttribute("macrotext",nil) end end @@ -368,6 +371,15 @@ local icon = self.frames.icon local hotkey = self.frames.hotkey local f = self:GetFrame() + + 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) + else + icon:SetTexCoord(0,1,0,1) + end + if texture then icon:SetTexture(texture) icon:Show() @@ -377,7 +389,11 @@ icon:Hide() self.frames.cooldown:Hide() self.rangeTimer = nil - f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot") + if self.vehicleExitMode then + f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2") + else + f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot") + end end end @@ -439,7 +455,7 @@ function Action:UpdateUsable() local isUsable, notEnoughMana = IsUsableAction(self.actionID) - if isUsable then + 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) elseif notEnoughMana then @@ -497,7 +513,9 @@ rangeTimer = rangeTimer - elapsed self.rangeTimer = rangeTimer if rangeTimer <= 0 then - if IsActionInRange(self.actionID) == 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() @@ -586,7 +604,7 @@ ]]) f:SetAttribute("_onstate-mc", _onstate_mc) - RegisterStateDriver(f, "mc", "[target=vehicle,exists] vehicle; [bonusbar:5] mc; none") + RegisterStateDriver(f, "mc", "[target=vehicle,exists,bonusbar:5] vehicle; [bonusbar:5] mc; none") f:SetAttribute("lockbuttons",config.lockButtons) f:SetAttribute("lockbuttonscombat",config.lockButtonsCombat) @@ -611,24 +629,8 @@ function Action:ShowVehicleExit(show) - local f = self:GetFrame() - local tx = f.vehicleExitTexture - if show and self:GetBarConfig().vehicle then - if not tx then - tx = f:CreateTexture(nil,"ARTWORK") - tx:SetAllPoints() - -- copied from Blizzard/VehicleMenuBar.lua SkinsData - tx:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up") - tx:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375) - f.vehicleExitTexture = tx - end - tx:Show() - f.vehicleExitMode = true - elseif tx then - tx:SetTexCoord(0,1,0,1) - tx:Hide() - f.vehicleExitMode = false - end + self.vehicleExitMode = show and self:GetBarConfig().vehicle + self:UpdateIcon() end function Action:OnEnter( )