Core.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. require "Polycode/EventDispatcher"
  2. class "Core" (EventDispatcher)
  3. Core.EVENTBASE_CORE = 0x200
  4. Core.EVENT_CORE_RESIZE = Core.EVENTBASE_CORE + 0
  5. Core.EVENT_LOST_FOCUS = Core.EVENTBASE_CORE + 1
  6. Core.EVENT_GAINED_FOCUS = Core.EVENTBASE_CORE + 2
  7. Core.EVENT_UNDO = Core.EVENTBASE_CORE + 3
  8. Core.EVENT_REDO = Core.EVENTBASE_CORE + 4
  9. Core.EVENT_COPY = Core.EVENTBASE_CORE + 5
  10. Core.EVENT_CUT = Core.EVENTBASE_CORE + 6
  11. Core.EVENT_SELECT_ALL = Core.EVENTBASE_CORE + 7
  12. Core.EVENT_PASTE = Core.EVENTBASE_CORE + 8
  13. Core.EVENT_GYRO_ROTATION = Core.EVENTBASE_CORE + 9
  14. Core.EVENT_ACCELEROMETER_MOTION = Core.EVENTBASE_CORE + 10
  15. Core.CURSOR_ARROW = 0
  16. Core.CURSOR_TEXT = 1
  17. Core.CURSOR_POINTER = 2
  18. Core.CURSOR_CROSSHAIR = 3
  19. Core.CURSOR_RESIZE_LEFT_RIGHT = 4
  20. Core.CURSOR_RESIZE_UP_DOWN = 5
  21. Core.CURSOR_OPEN_HAND = 6
  22. function Core:__getvar(name)
  23. if name == "eventMutex" then
  24. local retVal = Polycore.Core_get_eventMutex(self.__ptr)
  25. if retVal == nil then return nil end
  26. local __c = _G["CoreMutex"]("__skip_ptr__")
  27. __c.__ptr = retVal
  28. return __c
  29. elseif name == "paused" then
  30. return Polycore.Core_get_paused(self.__ptr)
  31. elseif name == "pauseOnLoseFocus" then
  32. return Polycore.Core_get_pauseOnLoseFocus(self.__ptr)
  33. elseif name == "defaultScreenWidth" then
  34. return Polycore.Core_get_defaultScreenWidth(self.__ptr)
  35. elseif name == "defaultScreenHeight" then
  36. return Polycore.Core_get_defaultScreenHeight(self.__ptr)
  37. elseif name == "deviceAttitude" then
  38. local retVal = Polycore.Core_get_deviceAttitude(self.__ptr)
  39. if retVal == nil then return nil end
  40. local __c = _G["Quaternion"]("__skip_ptr__")
  41. __c.__ptr = retVal
  42. return __c
  43. end
  44. if EventDispatcher["__getvar"] ~= nil then
  45. return EventDispatcher.__getvar(self, name)
  46. end
  47. end
  48. function Core:__setvar(name,value)
  49. if name == "paused" then
  50. Polycore.Core_set_paused(self.__ptr, value)
  51. return true
  52. elseif name == "pauseOnLoseFocus" then
  53. Polycore.Core_set_pauseOnLoseFocus(self.__ptr, value)
  54. return true
  55. elseif name == "defaultScreenWidth" then
  56. Polycore.Core_set_defaultScreenWidth(self.__ptr, value)
  57. return true
  58. elseif name == "defaultScreenHeight" then
  59. Polycore.Core_set_defaultScreenHeight(self.__ptr, value)
  60. return true
  61. elseif name == "deviceAttitude" then
  62. Polycore.Core_set_deviceAttitude(self.__ptr, value.__ptr)
  63. return true
  64. end
  65. if EventDispatcher["__setvar"] ~= nil then
  66. return EventDispatcher.__setvar(self, name, value)
  67. else
  68. return false
  69. end
  70. end
  71. function Core:Update()
  72. local retVal = Polycore.Core_Update(self.__ptr)
  73. return retVal
  74. end
  75. function Core:Render()
  76. local retVal = Polycore.Core_Render(self.__ptr)
  77. end
  78. function Core:fixedUpdate()
  79. local retVal = Polycore.Core_fixedUpdate(self.__ptr)
  80. return retVal
  81. end
  82. function Core:systemUpdate()
  83. local retVal = Polycore.Core_systemUpdate(self.__ptr)
  84. return retVal
  85. end
  86. function Core:updateAndRender()
  87. local retVal = Polycore.Core_updateAndRender(self.__ptr)
  88. return retVal
  89. end
  90. function Core:enableMouse(newval)
  91. local retVal = Polycore.Core_enableMouse(self.__ptr, newval)
  92. end
  93. function Core:captureMouse(newval)
  94. local retVal = Polycore.Core_captureMouse(self.__ptr, newval)
  95. end
  96. function Core:setCursor(cursorType)
  97. local retVal = Polycore.Core_setCursor(self.__ptr, cursorType)
  98. end
  99. function Core:warpCursor(x, y)
  100. local retVal = Polycore.Core_warpCursor(self.__ptr, x, y)
  101. end
  102. function Core:createThread(target)
  103. local retVal = Polycore.Core_createThread(self.__ptr, target.__ptr)
  104. end
  105. function Core:lockMutex(mutex)
  106. local retVal = Polycore.Core_lockMutex(self.__ptr, mutex.__ptr)
  107. end
  108. function Core:unlockMutex(mutex)
  109. local retVal = Polycore.Core_unlockMutex(self.__ptr, mutex.__ptr)
  110. end
  111. function Core:createMutex()
  112. local retVal = Polycore.Core_createMutex(self.__ptr)
  113. if retVal == nil then return nil end
  114. local __c = _G["CoreMutex"]("__skip_ptr__")
  115. __c.__ptr = retVal
  116. return __c
  117. end
  118. function Core:copyStringToClipboard(str)
  119. local retVal = Polycore.Core_copyStringToClipboard(self.__ptr, str)
  120. end
  121. function Core:getClipboardString()
  122. local retVal = Polycore.Core_getClipboardString(self.__ptr)
  123. return retVal
  124. end
  125. function Core:getServices()
  126. local retVal = Polycore.Core_getServices(self.__ptr)
  127. if retVal == nil then return nil end
  128. local __c = _G["CoreServices"]("__skip_ptr__")
  129. __c.__ptr = retVal
  130. return __c
  131. end
  132. function Core:getFPS()
  133. local retVal = Polycore.Core_getFPS(self.__ptr)
  134. return retVal
  135. end
  136. function Core:Shutdown()
  137. local retVal = Polycore.Core_Shutdown(self.__ptr)
  138. end
  139. function Core:isFullscreen()
  140. local retVal = Polycore.Core_isFullscreen(self.__ptr)
  141. return retVal
  142. end
  143. function Core:getAALevel()
  144. local retVal = Polycore.Core_getAALevel(self.__ptr)
  145. return retVal
  146. end
  147. function Core:getInput()
  148. local retVal = Polycore.Core_getInput(self.__ptr)
  149. if retVal == nil then return nil end
  150. local __c = _G["CoreInput"]("__skip_ptr__")
  151. __c.__ptr = retVal
  152. return __c
  153. end
  154. function Core:getXRes()
  155. local retVal = Polycore.Core_getXRes(self.__ptr)
  156. return retVal
  157. end
  158. function Core:getYRes()
  159. local retVal = Polycore.Core_getYRes(self.__ptr)
  160. return retVal
  161. end
  162. function Core:getBackingXRes()
  163. local retVal = Polycore.Core_getBackingXRes(self.__ptr)
  164. return retVal
  165. end
  166. function Core:getBackingYRes()
  167. local retVal = Polycore.Core_getBackingYRes(self.__ptr)
  168. return retVal
  169. end
  170. function Core.getScreenInfo(width, height, hz)
  171. local retVal = Polycore.Core_getScreenInfo(width.__ptr, height.__ptr, hz.__ptr)
  172. end
  173. function Core:getScreenWidth()
  174. local retVal = Polycore.Core_getScreenWidth(self.__ptr)
  175. return retVal
  176. end
  177. function Core:getScreenHeight()
  178. local retVal = Polycore.Core_getScreenHeight(self.__ptr)
  179. return retVal
  180. end
  181. function Core:createFolder(folderPath)
  182. local retVal = Polycore.Core_createFolder(self.__ptr, folderPath)
  183. end
  184. function Core:copyDiskItem(itemPath, destItemPath)
  185. local retVal = Polycore.Core_copyDiskItem(self.__ptr, itemPath, destItemPath)
  186. end
  187. function Core:moveDiskItem(itemPath, destItemPath)
  188. local retVal = Polycore.Core_moveDiskItem(self.__ptr, itemPath, destItemPath)
  189. end
  190. function Core:removeDiskItem(itemPath)
  191. local retVal = Polycore.Core_removeDiskItem(self.__ptr, itemPath)
  192. end
  193. function Core:openFolderPicker()
  194. local retVal = Polycore.Core_openFolderPicker(self.__ptr)
  195. return retVal
  196. end
  197. function Core:setFramerate(frameRate, maxFixedCycles)
  198. local retVal = Polycore.Core_setFramerate(self.__ptr, frameRate, maxFixedCycles)
  199. end
  200. function Core:openFilePicker(extensions, allowMultiple)
  201. local retVal = Polycore.Core_openFilePicker(self.__ptr, extensions.__ptr, allowMultiple)
  202. if retVal == nil then return nil end
  203. local __c = _G["std::vector<String>"]("__skip_ptr__")
  204. __c.__ptr = retVal
  205. return __c
  206. end
  207. function Core:saveFilePicker(extensions)
  208. local retVal = Polycore.Core_saveFilePicker(self.__ptr, extensions.__ptr)
  209. return retVal
  210. end
  211. function Core:handleVideoModeChange(modeInfo)
  212. local retVal = Polycore.Core_handleVideoModeChange(self.__ptr, modeInfo.__ptr)
  213. end
  214. function Core:flushRenderContext()
  215. local retVal = Polycore.Core_flushRenderContext(self.__ptr)
  216. end
  217. function Core:prepareRenderContext()
  218. local retVal = Polycore.Core_prepareRenderContext(self.__ptr)
  219. end
  220. function Core:openFile(fileName, opts)
  221. local retVal = Polycore.Core_openFile(self.__ptr, fileName, opts)
  222. if retVal == nil then return nil end
  223. local __c = _G["CoreFile"]("__skip_ptr__")
  224. __c.__ptr = retVal
  225. return __c
  226. end
  227. function Core:closeFile(file)
  228. local retVal = Polycore.Core_closeFile(self.__ptr, file.__ptr)
  229. end
  230. function Core:addFileSource(type, source)
  231. local retVal = Polycore.Core_addFileSource(self.__ptr, type, source)
  232. end
  233. function Core:removeFileSource(type, source)
  234. local retVal = Polycore.Core_removeFileSource(self.__ptr, type, source)
  235. end
  236. function Core:parseFolder(pathString, showHidden)
  237. local retVal = Polycore.Core_parseFolder(self.__ptr, pathString, showHidden)
  238. if retVal == nil then return nil end
  239. local __c = _G["std::vector<OSFileEntry>"]("__skip_ptr__")
  240. __c.__ptr = retVal
  241. return __c
  242. end
  243. function Core:systemParseFolder(pathString, showHidden, targetVector)
  244. local retVal = Polycore.Core_systemParseFolder(self.__ptr, pathString, showHidden, targetVector.__ptr)
  245. return retVal
  246. end
  247. function Core:getResourcePathForFile(fileName)
  248. local retVal = Polycore.Core_getResourcePathForFile(self.__ptr, fileName)
  249. return retVal
  250. end
  251. function Core:setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport)
  252. local retVal = Polycore.Core_setVideoMode(self.__ptr, xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport)
  253. end
  254. function Core:resizeTo(xRes, yRes)
  255. local retVal = Polycore.Core_resizeTo(self.__ptr, xRes, yRes)
  256. end
  257. function Core:doSleep()
  258. local retVal = Polycore.Core_doSleep(self.__ptr)
  259. end
  260. function Core:openURL(url)
  261. local retVal = Polycore.Core_openURL(self.__ptr, url)
  262. end
  263. function Core:getElapsed()
  264. local retVal = Polycore.Core_getElapsed(self.__ptr)
  265. return retVal
  266. end
  267. function Core:getTicks()
  268. local retVal = Polycore.Core_getTicks(self.__ptr)
  269. return retVal
  270. end
  271. function Core:getRefreshIntervalMs()
  272. local retVal = Polycore.Core_getRefreshIntervalMs(self.__ptr)
  273. return retVal
  274. end
  275. function Core:getTimeSleptMs()
  276. local retVal = Polycore.Core_getTimeSleptMs(self.__ptr)
  277. return retVal
  278. end
  279. function Core:getFixedTimestep()
  280. local retVal = Polycore.Core_getFixedTimestep(self.__ptr)
  281. return retVal
  282. end
  283. function Core:getTicksFloat()
  284. local retVal = Polycore.Core_getTicksFloat(self.__ptr)
  285. if retVal == nil then return nil end
  286. local __c = _G["double"]("__skip_ptr__")
  287. __c.__ptr = retVal
  288. return __c
  289. end
  290. function Core:setUserPointer(ptr)
  291. local retVal = Polycore.Core_setUserPointer(self.__ptr, ptr.__ptr)
  292. end
  293. function Core:getUserPointer()
  294. local retVal = Polycore.Core_getUserPointer(self.__ptr)
  295. if retVal == nil then return nil end
  296. local __c = _G["void"]("__skip_ptr__")
  297. __c.__ptr = retVal
  298. return __c
  299. end
  300. function Core:executeExternalCommand(command, args, inDirectory)
  301. local retVal = Polycore.Core_executeExternalCommand(self.__ptr, command, args, inDirectory)
  302. return retVal
  303. end
  304. function Core:getDefaultWorkingDirectory()
  305. local retVal = Polycore.Core_getDefaultWorkingDirectory(self.__ptr)
  306. return retVal
  307. end
  308. function Core:getUserHomeDirectory()
  309. local retVal = Polycore.Core_getUserHomeDirectory(self.__ptr)
  310. return retVal
  311. end
  312. function Core:makeApplicationMain()
  313. local retVal = Polycore.Core_makeApplicationMain(self.__ptr)
  314. end
  315. function Core:getEventMutex()
  316. local retVal = Polycore.Core_getEventMutex(self.__ptr)
  317. if retVal == nil then return nil end
  318. local __c = _G["CoreMutex"]("__skip_ptr__")
  319. __c.__ptr = retVal
  320. return __c
  321. end
  322. function Core:removeThread(thread)
  323. local retVal = Polycore.Core_removeThread(self.__ptr, thread.__ptr)
  324. end
  325. function Core:__delete()
  326. if self then Polycore.delete_Core(self.__ptr) end
  327. end