Screen.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 retVal == nil then return nil end
  37. if Polycore.__ptr_lookup[retVal] ~= nil then
  38. return Polycore.__ptr_lookup[retVal]
  39. else
  40. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  41. Polycore.__ptr_lookup[retVal].__ptr = retVal
  42. return Polycore.__ptr_lookup[retVal]
  43. end
  44. end
  45. function Screen:removeChild(entityToRemove)
  46. local retVal = Polycore.Screen_removeChild(self.__ptr, entityToRemove.__ptr)
  47. if retVal == nil then return nil end
  48. if Polycore.__ptr_lookup[retVal] ~= nil then
  49. return Polycore.__ptr_lookup[retVal]
  50. else
  51. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  52. Polycore.__ptr_lookup[retVal].__ptr = retVal
  53. return Polycore.__ptr_lookup[retVal]
  54. end
  55. end
  56. function Screen:setScreenOffset(x, y)
  57. local retVal = Polycore.Screen_setScreenOffset(self.__ptr, x, y)
  58. end
  59. function Screen:getScreenOffset()
  60. local retVal = Polycore.Screen_getScreenOffset(self.__ptr)
  61. if retVal == nil then return nil end
  62. if Polycore.__ptr_lookup[retVal] ~= nil then
  63. return Polycore.__ptr_lookup[retVal]
  64. else
  65. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  66. Polycore.__ptr_lookup[retVal].__ptr = retVal
  67. return Polycore.__ptr_lookup[retVal]
  68. end
  69. end
  70. function Screen:Shutdown()
  71. local retVal = Polycore.Screen_Shutdown(self.__ptr)
  72. end
  73. function Screen:Update()
  74. local retVal = Polycore.Screen_Update(self.__ptr)
  75. end
  76. function Screen:getEntityAt(x, y)
  77. local retVal = Polycore.Screen_getEntityAt(self.__ptr, x, y)
  78. if retVal == nil then return nil end
  79. if Polycore.__ptr_lookup[retVal] ~= nil then
  80. return Polycore.__ptr_lookup[retVal]
  81. else
  82. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  83. Polycore.__ptr_lookup[retVal].__ptr = retVal
  84. return Polycore.__ptr_lookup[retVal]
  85. end
  86. end
  87. function Screen:Render()
  88. local retVal = Polycore.Screen_Render(self.__ptr)
  89. end
  90. function Screen:setRenderer(r_enderer)
  91. local retVal = Polycore.Screen_setRenderer(self.__ptr, r_enderer.__ptr)
  92. end
  93. function Screen:setNormalizedCoordinates(newVal, yCoordinateSize)
  94. local retVal = Polycore.Screen_setNormalizedCoordinates(self.__ptr, newVal, yCoordinateSize)
  95. end
  96. function Screen:setScreenShader(shaderName)
  97. local retVal = Polycore.Screen_setScreenShader(self.__ptr, shaderName.__ptr)
  98. end
  99. function Screen:clearScreenShader()
  100. local retVal = Polycore.Screen_clearScreenShader(self.__ptr)
  101. end
  102. function Screen:getHighestZIndex()
  103. local retVal = Polycore.Screen_getHighestZIndex(self.__ptr)
  104. return retVal
  105. end
  106. function Screen:sortChildren()
  107. local retVal = Polycore.Screen_sortChildren(self.__ptr)
  108. end
  109. function Screen:cmpZindex(left, right)
  110. local retVal = Polycore.Screen_cmpZindex(left.__ptr, right.__ptr)
  111. return retVal
  112. end
  113. function Screen:handleInputEvent(inputEvent)
  114. local retVal = Polycore.Screen_handleInputEvent(self.__ptr, inputEvent.__ptr)
  115. end
  116. function Screen:hasFilterShader()
  117. local retVal = Polycore.Screen_hasFilterShader(self.__ptr)
  118. return retVal
  119. end
  120. function Screen:drawFilter()
  121. local retVal = Polycore.Screen_drawFilter(self.__ptr)
  122. end
  123. function Screen:usesNormalizedCoordinates()
  124. local retVal = Polycore.Screen_usesNormalizedCoordinates(self.__ptr)
  125. return retVal
  126. end
  127. function Screen:getYCoordinateSize()
  128. local retVal = Polycore.Screen_getYCoordinateSize(self.__ptr)
  129. return retVal
  130. end
  131. function Screen:getRootEntity()
  132. local retVal = Polycore.Screen_getRootEntity(self.__ptr)
  133. if retVal == nil then return nil end
  134. if Polycore.__ptr_lookup[retVal] ~= nil then
  135. return Polycore.__ptr_lookup[retVal]
  136. else
  137. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  138. Polycore.__ptr_lookup[retVal].__ptr = retVal
  139. return Polycore.__ptr_lookup[retVal]
  140. end
  141. end
  142. function Screen:getScreenShaderMaterial()
  143. local retVal = Polycore.Screen_getScreenShaderMaterial(self.__ptr)
  144. if retVal == nil then return nil end
  145. if Polycore.__ptr_lookup[retVal] ~= nil then
  146. return Polycore.__ptr_lookup[retVal]
  147. else
  148. Polycore.__ptr_lookup[retVal] = Material("__skip_ptr__")
  149. Polycore.__ptr_lookup[retVal].__ptr = retVal
  150. return Polycore.__ptr_lookup[retVal]
  151. end
  152. end
  153. function Screen:__delete()
  154. Polycore.__ptr_lookup[self.__ptr] = nil
  155. Polycore.delete_Screen(self.__ptr)
  156. end