Screen.lua 4.0 KB

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