/Tukui/modules/unitframes/core/oUF/factory.lua

http://github.com/Asphyxia/Tukui · Lua · 33 lines · 25 code · 8 blank · 0 comment · 2 complexity · 204788c46677169f7fc14cb3d2e84d37 MD5 · raw file

  1. local parent, ns = ...
  2. local oUF = ns.oUF
  3. local Private = oUF.Private
  4. local argcheck = Private.argcheck
  5. local _QUEUE = {}
  6. local _FACTORY = CreateFrame'Frame'
  7. _FACTORY:SetScript('OnEvent', Private.OnEvent)
  8. _FACTORY:RegisterEvent'PLAYER_LOGIN'
  9. _FACTORY.active = true
  10. function _FACTORY:PLAYER_LOGIN()
  11. if(not self.active) then return end
  12. for _, func in next, _QUEUE do
  13. func(oUF)
  14. end
  15. end
  16. function oUF:Factory(func)
  17. argcheck(func, 2, 'function')
  18. table.insert(_QUEUE, func)
  19. end
  20. function oUF:EnableFactory()
  21. _FACTORY.active = true
  22. end
  23. function oUF:DisableFactory()
  24. _FACTORY.active = nil
  25. end