Screen.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. require "Polycode/EventDispatcher"
  2. class "Screen" (EventDispatcher)
  3. function Screen:__index__(name)
  4. if name == "enabled" then
  5. return Polycore.Screen_get_enabled(self.__ptr)
  6. end
  7. end
  8. function Screen:__set_callback(name,value)
  9. if name == "enabled" then
  10. Polycore.Screen_set_enabled(self.__ptr, value)
  11. return true
  12. end
  13. return false
  14. end
  15. function Screen:Screen(...)
  16. if type(arg[1]) == "table" and count(arg) == 1 then
  17. if ""..arg[1]:class() == "EventDispatcher" then
  18. self.__ptr = arg[1].__ptr
  19. return
  20. end
  21. end
  22. for k,v in pairs(arg) do
  23. if type(v) == "table" then
  24. if v.__ptr ~= nil then
  25. arg[k] = v.__ptr
  26. end
  27. end
  28. end
  29. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  30. self.__ptr = Polycore.Screen(unpack(arg))
  31. Polycore.__ptr_lookup[self.__ptr] = self
  32. end
  33. end
  34. function Screen:addChild(newEntity)
  35. local retVal = Polycore.Screen_addChild(self.__ptr, newEntity.__ptr)
  36. if Polycore.__ptr_lookup[retVal] ~= nil then
  37. return Polycore.__ptr_lookup[retVal]
  38. else
  39. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  40. Polycore.__ptr_lookup[retVal].__ptr = retVal
  41. return Polycore.__ptr_lookup[retVal]
  42. end
  43. end
  44. function Screen:removeChild(entityToRemove)
  45. local retVal = Polycore.Screen_removeChild(self.__ptr, entityToRemove.__ptr)
  46. if Polycore.__ptr_lookup[retVal] ~= nil then
  47. return Polycore.__ptr_lookup[retVal]
  48. else
  49. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  50. Polycore.__ptr_lookup[retVal].__ptr = retVal
  51. return Polycore.__ptr_lookup[retVal]
  52. end
  53. end
  54. function Screen:setScreenOffset(x, y)
  55. local retVal = Polycore.Screen_setScreenOffset(self.__ptr, x, y)
  56. end
  57. function Screen:getScreenOffset()
  58. local retVal = Polycore.Screen_getScreenOffset(self.__ptr)
  59. if Polycore.__ptr_lookup[retVal] ~= nil then
  60. return Polycore.__ptr_lookup[retVal]
  61. else
  62. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  63. Polycore.__ptr_lookup[retVal].__ptr = retVal
  64. return Polycore.__ptr_lookup[retVal]
  65. end
  66. end
  67. function Screen:Shutdown()
  68. local retVal = Polycore.Screen_Shutdown(self.__ptr)
  69. end
  70. function Screen:Update()
  71. local retVal = Polycore.Screen_Update(self.__ptr)
  72. end
  73. function Screen:getEntityAt(x, y)
  74. local retVal = Polycore.Screen_getEntityAt(self.__ptr, x, y)
  75. if Polycore.__ptr_lookup[retVal] ~= nil then
  76. return Polycore.__ptr_lookup[retVal]
  77. else
  78. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  79. Polycore.__ptr_lookup[retVal].__ptr = retVal
  80. return Polycore.__ptr_lookup[retVal]
  81. end
  82. end
  83. function Screen:Render()
  84. local retVal = Polycore.Screen_Render(self.__ptr)
  85. end
  86. function Screen:setRenderer(r_enderer)
  87. local retVal = Polycore.Screen_setRenderer(self.__ptr, r_enderer.__ptr)
  88. end
  89. function Screen:setNormalizedCoordinates(newVal, yCoordinateSize)
  90. local retVal = Polycore.Screen_setNormalizedCoordinates(self.__ptr, newVal, yCoordinateSize)
  91. end
  92. function Screen:setScreenShader(shaderName)
  93. local retVal = Polycore.Screen_setScreenShader(self.__ptr, shaderName)
  94. end
  95. function Screen:getHighestZIndex()
  96. local retVal = Polycore.Screen_getHighestZIndex(self.__ptr)
  97. return retVal
  98. end
  99. function Screen:sortChildren()
  100. local retVal = Polycore.Screen_sortChildren(self.__ptr)
  101. end
  102. function Screen:cmpZindex(left, right)
  103. local retVal = Polycore.Screen_cmpZindex(left.__ptr, right.__ptr)
  104. return retVal
  105. end
  106. function Screen:handleInputEvent(inputEvent)
  107. local retVal = Polycore.Screen_handleInputEvent(self.__ptr, inputEvent.__ptr)
  108. end
  109. function Screen:hasFilterShader()
  110. local retVal = Polycore.Screen_hasFilterShader(self.__ptr)
  111. return retVal
  112. end
  113. function Screen:drawFilter()
  114. local retVal = Polycore.Screen_drawFilter(self.__ptr)
  115. end
  116. function Screen:usesNormalizedCoordinates()
  117. local retVal = Polycore.Screen_usesNormalizedCoordinates(self.__ptr)
  118. return retVal
  119. end
  120. function Screen:getYCoordinateSize()
  121. local retVal = Polycore.Screen_getYCoordinateSize(self.__ptr)
  122. return retVal
  123. end
  124. function Screen:getRootEntity()
  125. local retVal = Polycore.Screen_getRootEntity(self.__ptr)
  126. if Polycore.__ptr_lookup[retVal] ~= nil then
  127. return Polycore.__ptr_lookup[retVal]
  128. else
  129. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  130. Polycore.__ptr_lookup[retVal].__ptr = retVal
  131. return Polycore.__ptr_lookup[retVal]
  132. end
  133. end
  134. function Screen:__delete()
  135. Polycore.__ptr_lookup[self.__ptr] = nil
  136. Polycore.delete_Screen(self.__ptr)
  137. end