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

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

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