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

http://github.com/Asphyxia/Tukui · Lua · 53 lines · 45 code · 8 blank · 0 comment · 12 complexity · a93e7baf2acf9b53c01a5bcb10e5ec44 MD5 · raw file

  1. local parent, ns = ...
  2. local oUF = ns.oUF
  3. local Update = function(self, event)
  4. local lfdrole = self.LFDRole
  5. local role = UnitGroupRolesAssigned(self.unit)
  6. if(role == 'TANK' or role == 'HEALER' or role == 'DAMAGER') then
  7. lfdrole:SetTexCoord(GetTexCoordsForRoleSmallCircle(role))
  8. lfdrole:Show()
  9. else
  10. lfdrole:Hide()
  11. end
  12. end
  13. local Path = function(self, ...)
  14. return (self.LFDRole.Override or Update) (self, ...)
  15. end
  16. local ForceUpdate = function(element)
  17. return Path(element.__owner, 'ForceUpdate')
  18. end
  19. local Enable = function(self)
  20. local lfdrole = self.LFDRole
  21. if(lfdrole) then
  22. lfdrole.__owner = self
  23. lfdrole.ForceUpdate = ForceUpdate
  24. if(self.unit == "player") then
  25. self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Path)
  26. else
  27. self:RegisterEvent("PARTY_MEMBERS_CHANGED", Path)
  28. end
  29. if(lfdrole:IsObjectType"Texture" and not lfdrole:GetTexture()) then
  30. lfdrole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]
  31. end
  32. return true
  33. end
  34. end
  35. local Disable = function(self)
  36. local lfdrole = self.LFDRole
  37. if(lfdrole) then
  38. self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Path)
  39. self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Path)
  40. end
  41. end
  42. oUF:AddElement('LFDRole', Path, Enable, Disable)