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

http://github.com/Asphyxia/Tukui · Lua · 44 lines · 38 code · 6 blank · 0 comment · 7 complexity · 6d9905ec27fb1028269b0356786002fa MD5 · raw file

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