Screen.lua 4.1 KB

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