ScreenEvent.lua 723 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require "Polycode/Event"
  2. class "ScreenEvent" (Event)
  3. ENTITY_MOVE_TOP = 0
  4. ENTITY_MOVE_BOTTOM = 1
  5. ENTITY_MOVE_UP = 2
  6. ENTITY_MOVE_DOWN = 3
  7. function ScreenEvent:ScreenEvent(...)
  8. if type(arg[1]) == "table" and count(arg) == 1 then
  9. if ""..arg[1]:class() == "Event" then
  10. self.__ptr = arg[1].__ptr
  11. return
  12. end
  13. end
  14. for k,v in pairs(arg) do
  15. if type(v) == "table" then
  16. if v.__ptr ~= nil then
  17. arg[k] = v.__ptr
  18. end
  19. end
  20. end
  21. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  22. self.__ptr = Polycore.ScreenEvent(unpack(arg))
  23. Polycore.__ptr_lookup[self.__ptr] = self
  24. end
  25. end
  26. function ScreenEvent:__delete()
  27. Polycore.__ptr_lookup[self.__ptr] = nil
  28. Polycore.delete_ScreenEvent(self.__ptr)
  29. end