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

http://github.com/Asphyxia/Tukui · Lua · 46 lines · 39 code · 7 blank · 0 comment · 5 complexity · fbb049f86c66349172e0dcd5097d0549 MD5 · raw file

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