PageRenderTime 37ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Tukui/modules/unitframes/core/oUF/elements/resurrect.lua

http://github.com/Asphyxia/Tukui
Lua | 49 lines | 38 code | 11 blank | 0 comment | 6 complexity | ad2353e0938d8c730f2474eada794a0d MD5 | raw file
  1. local WoW42 = select(4, GetBuildInfo()) == 40200
  2. if(not WoW42) then return end
  3. local parent, ns = ...
  4. local oUF = ns.oUF
  5. local Update = function(self, event)
  6. local incomingResurrect = UnitHasIncomingResurrection(self.unit)
  7. local resurrect = self.ResurrectIcon
  8. if(incomingResurrect) and UnitIsDeadOrGhost(self.unit) and UnitIsConnected(self.unit) then
  9. resurrect:Show()
  10. else
  11. resurrect:Hide()
  12. end
  13. end
  14. local Path = function(self, ...)
  15. return (self.ResurrectIcon.Override or Update) (self, ...)
  16. end
  17. local ForceUpdate = function(element)
  18. return Path(element.__owner, 'ForceUpdate')
  19. end
  20. local Enable = function(self)
  21. local resurrect = self.ResurrectIcon
  22. if(resurrect) then
  23. resurrect.__owner = self
  24. resurrect.ForceUpdate = ForceUpdate
  25. self:RegisterEvent('INCOMING_RESURRECT_CHANGED', Path)
  26. if(resurrect:IsObjectType('Texture') and not resurrect:GetTexture()) then
  27. resurrect:SetTexture[[Interface\RaidFrame\Raid-Icon-Rez]]
  28. end
  29. return true
  30. end
  31. end
  32. local Disable = function(self)
  33. local resurrect = self.ResurrectIcon
  34. if(resurrect) then
  35. self:UnregisterEvent('INCOMING_RESURRECT_CHANGED', Path)
  36. end
  37. end
  38. oUF:AddElement('ResurrectIcon', Path, Enable, Disable)