/Tukui/modules/unitframes/plugins/oUF_ClassIcons/oUF_ClassIcons.lua

http://github.com/Asphyxia/Tukui · Lua · 47 lines · 36 code · 10 blank · 1 comment · 4 complexity · b93beb8f4eb5c6ebb1b2a00076080e29 MD5 · raw file

  1. local _, ns = ...
  2. local oUF = ns.oUF or oUF
  3. local Update = function(self, event)
  4. local _, class = UnitClass(self.unit)
  5. local icon = self.ClassIcon
  6. if(class) then
  7. local left, right, top, bottom = unpack(CLASS_BUTTONS[class])
  8. -- zoom class icon
  9. left = left + (right - left) * 0.09
  10. right = right - (right - left) * 0.09
  11. top = top + (bottom - top) * 0.09
  12. bottom = bottom - (bottom - top) * 0.09
  13. icon:SetTexCoord(left, right, top, bottom)
  14. icon:Show()
  15. else
  16. icon:Hide()
  17. end
  18. end
  19. local Enable = function(self)
  20. local cicon = self.ClassIcon
  21. if(cicon) then
  22. self:RegisterEvent("PARTY_MEMBERS_CHANGED", Update)
  23. self:RegisterEvent("PLAYER_TARGET_CHANGED", Update)
  24. self:RegisterEvent("ARENA_OPPONENT_UPDATE", Update)
  25. cicon:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
  26. return true
  27. end
  28. end
  29. local Disable = function(self)
  30. local ricon = self.ClassIcon
  31. if(ricon) then
  32. self:UnregisterEvent("ARENA_OPPONENT_UPDATE", Update)
  33. self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Update)
  34. self:UnregisterEvent("PLAYER_TARGET_CHANGED", Update)
  35. end
  36. end
  37. oUF:AddElement('ClassIcon', Update, Enable, Disable)