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

http://github.com/Asphyxia/Tukui · Lua · 62 lines · 55 code · 7 blank · 0 comment · 13 complexity · 0662f85991c4d4325201bdb860426fce MD5 · raw file

  1. local parent, ns = ...
  2. local oUF = ns.oUF
  3. local function Update(self, event)
  4. local unit
  5. local method, pid, rid = GetLootMethod()
  6. if(method == 'master') then
  7. if(pid) then
  8. if(pid == 0) then
  9. unit = 'player'
  10. else
  11. unit = 'party'..pid
  12. end
  13. elseif(rid) then
  14. unit = 'raid'..rid
  15. else
  16. return
  17. end
  18. if(UnitIsUnit(unit, self.unit)) then
  19. self.MasterLooter:Show()
  20. elseif(self.MasterLooter:IsShown()) then
  21. self.MasterLooter:Hide()
  22. end
  23. elseif(self.MasterLooter:IsShown()) then
  24. self.MasterLooter:Hide()
  25. end
  26. end
  27. local Path = function(self, ...)
  28. return (self.MasterLooter.Override or Update) (self, ...)
  29. end
  30. local ForceUpdate = function(element)
  31. return Path(element.__owner, 'ForceUpdate')
  32. end
  33. local function Enable(self, unit)
  34. local masterlooter = self.MasterLooter
  35. if(masterlooter) then
  36. masterlooter.__owner = self
  37. masterlooter.ForceUpdate = ForceUpdate
  38. self:RegisterEvent('PARTY_LOOT_METHOD_CHANGED', Path)
  39. self:RegisterEvent('PARTY_MEMBERS_CHANGED', Path)
  40. if(masterlooter:IsObjectType('Texture') and not masterlooter:GetTexture()) then
  41. masterlooter:SetTexture([[Interface\GroupFrame\UI-Group-MasterLooter]])
  42. end
  43. return true
  44. end
  45. end
  46. local function Disable(self)
  47. if(self.MasterLooter) then
  48. self:UnregisterEvent('PARTY_LOOT_METHOD_CHANGED', Path)
  49. self:UnregisterEvent('PARTY_MEMBERS_CHANGED', Path)
  50. end
  51. end
  52. oUF:AddElement('MasterLooter', Path, Enable, Disable)