comparison 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
comparison
equal deleted inserted replaced
144:e5b5f2aa48e2 145:42cade25d40d
44 [[ 44 [[
45 local action = nil 45 local action = nil
46 if (doVehicle and mcVehicleState == "vehicle") or 46 if (doVehicle and mcVehicleState == "vehicle") or
47 (doMindControl and mcVehicleState == "mc") then 47 (doMindControl and mcVehicleState == "mc") then
48 local idx = self:GetAttribute("bar-idx") 48 local idx = self:GetAttribute("bar-idx")
49 if idx and idx <= 12 then 49 local maxN = (doVehicle and mcVehicleState == "vehicle") and 7 or 12
50 if idx and idx <= maxN then
50 action = 120 + idx 51 action = 120 + idx
51 else 52 else
52 action = 0 53 action = 0
53 end 54 end
54 elseif page and state and page[state] then 55 elseif page and state and page[state] then
78 local _childupdate_vehicleExit = -- function(self, snippetid, message) 79 local _childupdate_vehicleExit = -- function(self, snippetid, message)
79 [[ 80 [[
80 local show = (mcVehicleState == "vehicle") 81 local show = (mcVehicleState == "vehicle")
81 if show and doVehicle then 82 if show and doVehicle then
82 self:SetAttribute("type","macro") 83 self:SetAttribute("type","macro")
83 self:SetAttribute("macrotext","/run VehicleExit()")
84 self:Show() 84 self:Show()
85 else 85 else
86 self:SetAttribute("type","action") 86 self:SetAttribute("type","action")
87 end 87 end
88 control:CallMethod("ShowVehicleExit",show) 88 control:CallMethod("ShowVehicleExit",show)
227 function Action:Destroy() 227 function Action:Destroy()
228 local f = self:GetFrame() 228 local f = self:GetFrame()
229 local c = self:GetConfig() 229 local c = self:GetConfig()
230 230
231 f:SetAttribute("_childupdate-vehicle",nil) 231 f:SetAttribute("_childupdate-vehicle",nil)
232 f:SetAttribute("action",c.actionID) -- so that Destroy releases the right one 232 f:SetAttribute("action",c.actionID) -- so that Super.Destroy releases the right one
233 233
234 if c.pageactions and #c.pageactions > 1 then 234 if c.pageactions and #c.pageactions > 1 then
235 for i = 2, #c.pageactions do 235 for i = 2, #c.pageactions do
236 self:ReleaseActionID(c.pageactions[i]) 236 self:ReleaseActionID(c.pageactions[i])
237 self:ReleaseActionID(id) 237 self:ReleaseActionID(id)
255 self:ShowGrid(not self:GetBarConfig().hideEmpty) 255 self:ShowGrid(not self:GetBarConfig().hideEmpty)
256 self:UpdateAction() 256 self:UpdateAction()
257 end 257 end
258 258
259 function Action:InstallVehicle() 259 function Action:InstallVehicle()
260 local f = self:GetFrame()
260 if self.idx == 7 and self:GetBarConfig().vehicle then 261 if self.idx == 7 and self:GetBarConfig().vehicle then
261 -- install vehicle-exit button on 7th button (only) 262 -- install vehicle-exit button on 7th button (only)
262 self:GetFrame():SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit) 263 f:SetAttribute("_childupdate-vehicle", _childupdate_vehicleExit)
264 f:SetAttribute("macrotext","/run VehicleExit()")
263 self:GetBar():GetFrame().ShowVehicleExit = function(bar,show) 265 self:GetBar():GetFrame().ShowVehicleExit = function(bar,show)
264 self:ShowVehicleExit(show) 266 self:ShowVehicleExit(show)
265 end 267 end
266 else 268 else
267 self:GetFrame():SetAttribute("_childupdate-vehicle",nil) 269 f:SetAttribute("_childupdate-vehicle",nil)
270 f:SetAttribute("macrotext",nil)
268 end 271 end
269 end 272 end
270 273
271 function Action:ShowGrid( show ) 274 function Action:ShowGrid( show )
272 if not InCombatLockdown() then 275 if not InCombatLockdown() then
366 local action = self.actionID 369 local action = self.actionID
367 local texture = GetActionTexture(action) 370 local texture = GetActionTexture(action)
368 local icon = self.frames.icon 371 local icon = self.frames.icon
369 local hotkey = self.frames.hotkey 372 local hotkey = self.frames.hotkey
370 local f = self:GetFrame() 373 local f = self:GetFrame()
374
375 if self.vehicleExitMode then
376 texture = "Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up"
377 icon:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
378 icon:SetVertexColor(1,0,0)
379 else
380 icon:SetTexCoord(0,1,0,1)
381 end
382
371 if texture then 383 if texture then
372 icon:SetTexture(texture) 384 icon:SetTexture(texture)
373 icon:Show() 385 icon:Show()
374 self.rangeTimer = -1 386 self.rangeTimer = -1
375 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2") 387 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
376 else 388 else
377 icon:Hide() 389 icon:Hide()
378 self.frames.cooldown:Hide() 390 self.frames.cooldown:Hide()
379 self.rangeTimer = nil 391 self.rangeTimer = nil
380 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot") 392 if self.vehicleExitMode then
393 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
394 else
395 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
396 end
381 end 397 end
382 end 398 end
383 399
384 function Action:UpdateBorder() 400 function Action:UpdateBorder()
385 local action = self.actionID 401 local action = self.actionID
437 end 453 end
438 end 454 end
439 455
440 function Action:UpdateUsable() 456 function Action:UpdateUsable()
441 local isUsable, notEnoughMana = IsUsableAction(self.actionID) 457 local isUsable, notEnoughMana = IsUsableAction(self.actionID)
442 if isUsable then 458 if isUsable or self.vehicleExitMode then
443 self.frames.icon:SetVertexColor(1.0, 1.0, 1.0) 459 self.frames.icon:SetVertexColor(1.0, 1.0, 1.0)
444 self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0) 460 self.frames.normalTexture:SetVertexColor(1.0, 1.0, 1.0)
445 elseif notEnoughMana then 461 elseif notEnoughMana then
446 self.frames.icon:SetVertexColor(0.5, 0.5, 1.0) 462 self.frames.icon:SetVertexColor(0.5, 0.5, 1.0)
447 self.frames.normalTexture:SetVertexColor(0.5, 0.5, 1.0) 463 self.frames.normalTexture:SetVertexColor(0.5, 0.5, 1.0)
495 local rangeTimer = self.rangeTimer 511 local rangeTimer = self.rangeTimer
496 if rangeTimer then 512 if rangeTimer then
497 rangeTimer = rangeTimer - elapsed 513 rangeTimer = rangeTimer - elapsed
498 self.rangeTimer = rangeTimer 514 self.rangeTimer = rangeTimer
499 if rangeTimer <= 0 then 515 if rangeTimer <= 0 then
500 if IsActionInRange(self.actionID) == 0 then 516 if self.vehicleExitMode then
517 self.frames.icon:SetVertexColor(1,1,1)
518 elseif IsActionInRange(self.actionID) == 0 then
501 self.frames.icon:SetVertexColor(1.0,0.1,0.1) 519 self.frames.icon:SetVertexColor(1.0,0.1,0.1)
502 else 520 else
503 self:UpdateUsable() 521 self:UpdateUsable()
504 end 522 end
505 self.rangeTimer = TOOLTIP_UPDATE_TIME 523 self.rangeTimer = TOOLTIP_UPDATE_TIME
584 doVehicle = self:GetAttribute("vehicle") 602 doVehicle = self:GetAttribute("vehicle")
585 control:ChildUpdate() 603 control:ChildUpdate()
586 ]]) 604 ]])
587 605
588 f:SetAttribute("_onstate-mc", _onstate_mc) 606 f:SetAttribute("_onstate-mc", _onstate_mc)
589 RegisterStateDriver(f, "mc", "[target=vehicle,exists] vehicle; [bonusbar:5] mc; none") 607 RegisterStateDriver(f, "mc", "[target=vehicle,exists,bonusbar:5] vehicle; [bonusbar:5] mc; none")
590 608
591 f:SetAttribute("lockbuttons",config.lockButtons) 609 f:SetAttribute("lockbuttons",config.lockButtons)
592 f:SetAttribute("lockbuttonscombat",config.lockButtonsCombat) 610 f:SetAttribute("lockbuttonscombat",config.lockButtonsCombat)
593 f:Execute( 611 f:Execute(
594 [[ 612 [[
609 ]]) 627 ]])
610 end 628 end
611 629
612 630
613 function Action:ShowVehicleExit(show) 631 function Action:ShowVehicleExit(show)
614 local f = self:GetFrame() 632 self.vehicleExitMode = show and self:GetBarConfig().vehicle
615 local tx = f.vehicleExitTexture 633 self:UpdateIcon()
616 if show and self:GetBarConfig().vehicle then
617 if not tx then
618 tx = f:CreateTexture(nil,"ARTWORK")
619 tx:SetAllPoints()
620 -- copied from Blizzard/VehicleMenuBar.lua SkinsData
621 tx:SetTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
622 tx:SetTexCoord(0.140625, 0.859375, 0.140625, 0.859375)
623 f.vehicleExitTexture = tx
624 end
625 tx:Show()
626 f.vehicleExitMode = true
627 elseif tx then
628 tx:SetTexCoord(0,1,0,1)
629 tx:Hide()
630 f.vehicleExitMode = false
631 end
632 end 634 end
633 635
634 function Action:OnEnter( ) 636 function Action:OnEnter( )
635 self:SetTooltip() 637 self:SetTooltip()
636 end 638 end