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

http://github.com/Asphyxia/Tukui · Lua · 51 lines · 43 code · 8 blank · 0 comment · 6 complexity · b8d81f660606aa374c769b6c04e3c06a MD5 · raw file

  1. local parent, ns = ...
  2. local oUF = ns.oUF
  3. local GetRaidTargetIndex = GetRaidTargetIndex
  4. local SetRaidTargetIconTexture = SetRaidTargetIconTexture
  5. local Update = function(self, event)
  6. local index = GetRaidTargetIndex(self.unit)
  7. local icon = self.RaidIcon
  8. if(index) then
  9. SetRaidTargetIconTexture(icon, index)
  10. icon:Show()
  11. else
  12. icon:Hide()
  13. end
  14. end
  15. local Path = function(self, ...)
  16. return (self.RaidIcon.Override or Update) (self, ...)
  17. end
  18. local ForceUpdate = function(element)
  19. if(not element.__owner.unit) then return end
  20. return Path(element.__owner, 'ForceUpdate')
  21. end
  22. local Enable = function(self)
  23. local ricon = self.RaidIcon
  24. if(ricon) then
  25. ricon.__owner = self
  26. ricon.ForceUpdate = ForceUpdate
  27. self:RegisterEvent("RAID_TARGET_UPDATE", Path)
  28. if(ricon:IsObjectType"Texture" and not ricon:GetTexture()) then
  29. ricon:SetTexture[[Interface\TargetingFrame\UI-RaidTargetingIcons]]
  30. end
  31. return true
  32. end
  33. end
  34. local Disable = function(self)
  35. local ricon = self.RaidIcon
  36. if(ricon) then
  37. self:UnregisterEvent("RAID_TARGET_UPDATE", Path)
  38. end
  39. end
  40. oUF:AddElement('RaidIcon', Path, Enable, Disable)