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

http://github.com/Asphyxia/Tukui · Lua · 45 lines · 39 code · 6 blank · 0 comment · 7 complexity · e2aa25c72514f22d506a9ac5b172c529 MD5 · raw file

  1. local parent, ns = ...
  2. local oUF = ns.oUF
  3. local Update = function(self, event)
  4. if(UnitAffectingCombat"player") then
  5. self.Combat:Show()
  6. else
  7. self.Combat:Hide()
  8. end
  9. end
  10. local Path = function(self, ...)
  11. return (self.Combat.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 combat = self.Combat
  18. if(combat and unit == 'player') then
  19. combat.__owner = self
  20. combat.ForceUpdate = ForceUpdate
  21. self:RegisterEvent("PLAYER_REGEN_DISABLED", Path)
  22. self:RegisterEvent("PLAYER_REGEN_ENABLED", Path)
  23. if(combat:IsObjectType"Texture" and not combat:GetTexture()) then
  24. combat:SetTexture[[Interface\CharacterFrame\UI-StateIcon]]
  25. combat:SetTexCoord(.5, 1, 0, .49)
  26. end
  27. return true
  28. end
  29. end
  30. local Disable = function(self)
  31. if(self.Combat) then
  32. self:UnregisterEvent("PLAYER_REGEN_DISABLED", Path)
  33. self:UnregisterEvent("PLAYER_REGEN_ENABLED", Path)
  34. end
  35. end
  36. oUF:AddElement('Combat', Path, Enable, Disable)