comparison classes/ActionButton.lua @ 161:d0a41fc7b0d7

Totem bar support
author Flick <flickerstreak@gmail.com>
date Fri, 21 Aug 2009 04:15:09 +0000
parents 799c6ea9da7b
children 5257073138e8
comparison
equal deleted inserted replaced
160:caec78119a17 161:d0a41fc7b0d7
370 end 370 end
371 end 371 end
372 end 372 end
373 373
374 function Action:UpdateIcon() 374 function Action:UpdateIcon()
375 local action = self.actionID 375 local texture, tLeft, tRight, tTop, tBottom = self:GetIconTexture()
376 local texture = GetActionTexture(action)
377 local icon = self.frames.icon 376 local icon = self.frames.icon
378 local hotkey = self.frames.hotkey 377 local hotkey = self.frames.hotkey
379 local f = self:GetFrame() 378 local f = self:GetFrame()
380 379
381 if self.vehicleExitMode then 380 if self.vehicleExitMode then
386 icon:SetTexCoord(0,1,0,1) 385 icon:SetTexCoord(0,1,0,1)
387 end 386 end
388 387
389 if texture then 388 if texture then
390 icon:SetTexture(texture) 389 icon:SetTexture(texture)
390 if tLeft then
391 icon:SetTexCoord(tLeft,tRight,tTop,tBottom)
392 end
391 icon:Show() 393 icon:Show()
392 self.rangeTimer = -1 394 self.rangeTimer = -1
393 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2") 395 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
394 else 396 else
395 icon:Hide() 397 icon:Hide()
396 self.frames.cooldown:Hide() 398 self.frames.cooldown:Hide()
397 self.rangeTimer = nil 399 self.rangeTimer = nil
398 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot") 400 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
399 end 401 end
402 end
403
404 function Action:GetIconTexture()
405 return GetActionTexture(self.actionID)
400 end 406 end
401 407
402 function Action:UpdateBorder() 408 function Action:UpdateBorder()
403 local action = self.actionID 409 local action = self.actionID
404 if ReAction:GetKeybindMode() then 410 if ReAction:GetKeybindMode() then
454 self:GetFrame():SetChecked(0) 460 self:GetFrame():SetChecked(0)
455 end 461 end
456 end 462 end
457 463
458 function Action:UpdateUsable() 464 function Action:UpdateUsable()
459 local isUsable, notEnoughMana = IsUsableAction(self.actionID) 465 local isUsable, notEnoughMana = self:GetUsable()
460 local noRange = IsActionInRange(self.actionID) == 0 466 local noRange = self:GetInRange()
461 467
462 isUsable = self.vehicleExitMode or (isUsable and not noRange) 468 isUsable = self.vehicleExitMode or (isUsable and not noRange)
463 469
464 if isUsable then 470 if isUsable then
465 if self.usableStatus ~= "usable" then 471 if self.usableStatus ~= "usable" then
486 self.usableStatus = "unusable" 492 self.usableStatus = "unusable"
487 end 493 end
488 end 494 end
489 end 495 end
490 496
497 function Action:GetUsable()
498 return IsUsableAction(self.actionID)
499 end
500
501 function Action:GetInRange()
502 return IsActionInRange(self.actionID) == 0
503 end
504
491 function Action:UpdateCooldown() 505 function Action:UpdateCooldown()
492 CooldownFrame_SetTimer(self.frames.cooldown, GetActionCooldown(self.actionID)) 506 CooldownFrame_SetTimer(self.frames.cooldown, self:GetCooldown())
507 end
508
509 function Action:GetCooldown()
510 return GetActionCooldown(self.actionID)
493 end 511 end
494 512
495 function Action:UpdateFlash() 513 function Action:UpdateFlash()
496 local action = self.actionID 514 local action = self.actionID
497 self:SetFlash( (IsAttackAction(action) and IsCurrentAction(action)) or IsAutoRepeatAction(action) ) 515 self:SetFlash( (IsAttackAction(action) and IsCurrentAction(action)) or IsAutoRepeatAction(action) )
655 function Action:OnLeave( ) 673 function Action:OnLeave( )
656 GameTooltip:Hide() 674 GameTooltip:Hide()
657 end 675 end
658 676
659 function Action:OnAttributeChanged( attr, value ) 677 function Action:OnAttributeChanged( attr, value )
660 self:UpdateAction() 678 if attr ~= "statehidden" then
679 self:UpdateAction()
680 end
661 end 681 end
662 682
663 function Action:PostClick( ) 683 function Action:PostClick( )
664 self:UpdateCheckedState() 684 self:UpdateCheckedState()
665 end 685 end