2
0

Core.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. require('Polycode/EventDispatcher')
  2. function Core() {
  3. Object.defineProperties(this, {
  4. 'eventMutex': { enumerable: true, configurable: true, get: Core.prototype.__get_eventMutex, set: Core.prototype.__set_eventMutex},
  5. 'paused': { enumerable: true, configurable: true, get: Core.prototype.__get_paused, set: Core.prototype.__set_paused},
  6. 'pauseOnLoseFocus': { enumerable: true, configurable: true, get: Core.prototype.__get_pauseOnLoseFocus, set: Core.prototype.__set_pauseOnLoseFocus},
  7. 'defaultScreenWidth': { enumerable: true, configurable: true, get: Core.prototype.__get_defaultScreenWidth, set: Core.prototype.__set_defaultScreenWidth},
  8. 'defaultScreenHeight': { enumerable: true, configurable: true, get: Core.prototype.__get_defaultScreenHeight, set: Core.prototype.__set_defaultScreenHeight},
  9. 'deviceAttitude': { enumerable: true, configurable: true, get: Core.prototype.__get_deviceAttitude, set: Core.prototype.__set_deviceAttitude}
  10. })
  11. }
  12. Core.prototype = Object.create(EventDispatcher.prototype);
  13. Core.prototype.__get_eventMutex = function() {
  14. var retVal = new CoreMutex()
  15. retVal.__ptr = Polycode.Core__get_eventMutex(this.__ptr)
  16. return retVal
  17. }
  18. Core.prototype.__set_eventMutex = function(val) {
  19. Polycode.Core__set_eventMutex(this.__ptr, val.__ptr)
  20. }
  21. Core.prototype.__get_paused = function() {
  22. return Polycode.Core__get_paused(this.__ptr)
  23. }
  24. Core.prototype.__set_paused = function(val) {
  25. Polycode.Core__set_paused(this.__ptr, val)
  26. }
  27. Core.prototype.__get_pauseOnLoseFocus = function() {
  28. return Polycode.Core__get_pauseOnLoseFocus(this.__ptr)
  29. }
  30. Core.prototype.__set_pauseOnLoseFocus = function(val) {
  31. Polycode.Core__set_pauseOnLoseFocus(this.__ptr, val)
  32. }
  33. Core.prototype.__get_defaultScreenWidth = function() {
  34. return Polycode.Core__get_defaultScreenWidth(this.__ptr)
  35. }
  36. Core.prototype.__set_defaultScreenWidth = function(val) {
  37. Polycode.Core__set_defaultScreenWidth(this.__ptr, val)
  38. }
  39. Core.prototype.__get_defaultScreenHeight = function() {
  40. return Polycode.Core__get_defaultScreenHeight(this.__ptr)
  41. }
  42. Core.prototype.__set_defaultScreenHeight = function(val) {
  43. Polycode.Core__set_defaultScreenHeight(this.__ptr, val)
  44. }
  45. Core.prototype.__get_deviceAttitude = function() {
  46. var retVal = new Quaternion()
  47. retVal.__ptr = Polycode.Core__get_deviceAttitude(this.__ptr)
  48. return retVal
  49. }
  50. Core.prototype.__set_deviceAttitude = function(val) {
  51. Polycode.Core__set_deviceAttitude(this.__ptr, val.__ptr)
  52. }
  53. Duktape.fin(Core.prototype, function (x) {
  54. if (x === Core.prototype) {
  55. return;
  56. }
  57. Polycode.Core__delete(x.__ptr)
  58. })
  59. Core.prototype.Update = function() {
  60. return Polycode.Core_Update(this.__ptr)
  61. }
  62. Core.prototype.Render = function() {
  63. Polycode.Core_Render(this.__ptr)
  64. }
  65. Core.prototype.fixedUpdate = function() {
  66. return Polycode.Core_fixedUpdate(this.__ptr)
  67. }
  68. Core.prototype.systemUpdate = function() {
  69. return Polycode.Core_systemUpdate(this.__ptr)
  70. }
  71. Core.prototype.updateAndRender = function() {
  72. return Polycode.Core_updateAndRender(this.__ptr)
  73. }
  74. Core.prototype.enableMouse = function(newval) {
  75. Polycode.Core_enableMouse(this.__ptr, newval)
  76. }
  77. Core.prototype.captureMouse = function(newval) {
  78. Polycode.Core_captureMouse(this.__ptr, newval)
  79. }
  80. Core.prototype.setCursor = function(cursorType) {
  81. Polycode.Core_setCursor(this.__ptr, cursorType)
  82. }
  83. Core.prototype.warpCursor = function(x,y) {
  84. Polycode.Core_warpCursor(this.__ptr, x, y)
  85. }
  86. Core.prototype.openOnScreenKeyboard = function(open) {
  87. Polycode.Core_openOnScreenKeyboard(this.__ptr, open)
  88. }
  89. Core.prototype.createThread = function(target) {
  90. Polycode.Core_createThread(this.__ptr, target.__ptr)
  91. }
  92. Core.prototype.lockMutex = function(mutex) {
  93. Polycode.Core_lockMutex(this.__ptr, mutex.__ptr)
  94. }
  95. Core.prototype.unlockMutex = function(mutex) {
  96. Polycode.Core_unlockMutex(this.__ptr, mutex.__ptr)
  97. }
  98. Core.prototype.createMutex = function() {
  99. var retVal = new CoreMutex()
  100. retVal.__ptr = Polycode.Core_createMutex(this.__ptr)
  101. return retVal
  102. }
  103. Core.prototype.copyStringToClipboard = function(str) {
  104. Polycode.Core_copyStringToClipboard(this.__ptr, str)
  105. }
  106. Core.prototype.getClipboardString = function() {
  107. return Polycode.Core_getClipboardString(this.__ptr)
  108. }
  109. Core.prototype.getServices = function() {
  110. var retVal = new CoreServices()
  111. retVal.__ptr = Polycode.Core_getServices(this.__ptr)
  112. return retVal
  113. }
  114. Core.prototype.getFPS = function() {
  115. return Polycode.Core_getFPS(this.__ptr)
  116. }
  117. Core.prototype.Shutdown = function() {
  118. Polycode.Core_Shutdown(this.__ptr)
  119. }
  120. Core.prototype.isFullscreen = function() {
  121. return Polycode.Core_isFullscreen(this.__ptr)
  122. }
  123. Core.prototype.getAALevel = function() {
  124. return Polycode.Core_getAALevel(this.__ptr)
  125. }
  126. Core.prototype.getInput = function() {
  127. var retVal = new CoreInput()
  128. retVal.__ptr = Polycode.Core_getInput(this.__ptr)
  129. return retVal
  130. }
  131. Core.prototype.getXRes = function() {
  132. return Polycode.Core_getXRes(this.__ptr)
  133. }
  134. Core.prototype.getYRes = function() {
  135. return Polycode.Core_getYRes(this.__ptr)
  136. }
  137. Core.prototype.getBackingXRes = function() {
  138. return Polycode.Core_getBackingXRes(this.__ptr)
  139. }
  140. Core.prototype.getBackingYRes = function() {
  141. return Polycode.Core_getBackingYRes(this.__ptr)
  142. }
  143. Core.prototype.getScreenInfo = function(width,height,hz) {
  144. Polycode.Core_getScreenInfo(width.__ptr, height.__ptr, hz.__ptr)
  145. }
  146. Core.prototype.getScreenWidth = function() {
  147. return Polycode.Core_getScreenWidth(this.__ptr)
  148. }
  149. Core.prototype.getScreenHeight = function() {
  150. return Polycode.Core_getScreenHeight(this.__ptr)
  151. }
  152. Core.prototype.createFolder = function(folderPath) {
  153. Polycode.Core_createFolder(this.__ptr, folderPath)
  154. }
  155. Core.prototype.copyDiskItem = function(itemPath,destItemPath) {
  156. Polycode.Core_copyDiskItem(this.__ptr, itemPath, destItemPath)
  157. }
  158. Core.prototype.moveDiskItem = function(itemPath,destItemPath) {
  159. Polycode.Core_moveDiskItem(this.__ptr, itemPath, destItemPath)
  160. }
  161. Core.prototype.removeDiskItem = function(itemPath) {
  162. Polycode.Core_removeDiskItem(this.__ptr, itemPath)
  163. }
  164. Core.prototype.openFolderPicker = function() {
  165. return Polycode.Core_openFolderPicker(this.__ptr)
  166. }
  167. Core.prototype.setFramerate = function(frameRate,maxFixedCycles) {
  168. Polycode.Core_setFramerate(this.__ptr, frameRate, maxFixedCycles)
  169. }
  170. Core.prototype.openFilePicker = function(extensions,allowMultiple) {
  171. Polycode.Core_openFilePicker(this.__ptr, extensions, allowMultiple)
  172. }
  173. Core.prototype.saveFilePicker = function(extensions) {
  174. return Polycode.Core_saveFilePicker(this.__ptr, extensions)
  175. }
  176. Core.prototype.handleVideoModeChange = function(modeInfo) {
  177. Polycode.Core_handleVideoModeChange(this.__ptr, modeInfo.__ptr)
  178. }
  179. Core.prototype.flushRenderContext = function() {
  180. Polycode.Core_flushRenderContext(this.__ptr)
  181. }
  182. Core.prototype.prepareRenderContext = function() {
  183. Polycode.Core_prepareRenderContext(this.__ptr)
  184. }
  185. Core.prototype.isWindowInitialized = function() {
  186. return Polycode.Core_isWindowInitialized(this.__ptr)
  187. }
  188. Core.prototype.openFile = function(fileName,opts) {
  189. var retVal = new CoreFile()
  190. retVal.__ptr = Polycode.Core_openFile(this.__ptr, fileName, opts)
  191. return retVal
  192. }
  193. Core.prototype.closeFile = function(file) {
  194. Polycode.Core_closeFile(this.__ptr, file.__ptr)
  195. }
  196. Core.prototype.addFileSource = function(type,source) {
  197. Polycode.Core_addFileSource(this.__ptr, type, source)
  198. }
  199. Core.prototype.removeFileSource = function(type,source) {
  200. Polycode.Core_removeFileSource(this.__ptr, type, source)
  201. }
  202. Core.prototype.parseFolder = function(pathString,showHidden) {
  203. Polycode.Core_parseFolder(this.__ptr, pathString, showHidden)
  204. }
  205. Core.prototype.systemParseFolder = function(pathString,showHidden,targetVector) {
  206. return Polycode.Core_systemParseFolder(this.__ptr, pathString, showHidden, targetVector)
  207. }
  208. Core.prototype.getResourcePathForFile = function(fileName) {
  209. return Polycode.Core_getResourcePathForFile(this.__ptr, fileName)
  210. }
  211. Core.prototype.setVideoMode = function(xRes,yRes,fullScreen,vSync,aaLevel,anisotropyLevel,retinaSupport) {
  212. Polycode.Core_setVideoMode(this.__ptr, xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport)
  213. }
  214. Core.prototype.resizeTo = function(xRes,yRes) {
  215. Polycode.Core_resizeTo(this.__ptr, xRes, yRes)
  216. }
  217. Core.prototype.doSleep = function() {
  218. Polycode.Core_doSleep(this.__ptr)
  219. }
  220. Core.prototype.openURL = function(url) {
  221. Polycode.Core_openURL(this.__ptr, url)
  222. }
  223. Core.prototype.getElapsed = function() {
  224. return Polycode.Core_getElapsed(this.__ptr)
  225. }
  226. Core.prototype.getTicks = function() {
  227. return Polycode.Core_getTicks(this.__ptr)
  228. }
  229. Core.prototype.getRefreshIntervalMs = function() {
  230. return Polycode.Core_getRefreshIntervalMs(this.__ptr)
  231. }
  232. Core.prototype.getTimeSleptMs = function() {
  233. return Polycode.Core_getTimeSleptMs(this.__ptr)
  234. }
  235. Core.prototype.getFixedTimestep = function() {
  236. return Polycode.Core_getFixedTimestep(this.__ptr)
  237. }
  238. Core.prototype.getTicksFloat = function() {
  239. return Polycode.Core_getTicksFloat(this.__ptr)
  240. }
  241. Core.prototype.setUserPointer = function(ptr) {
  242. Polycode.Core_setUserPointer(this.__ptr, ptr.__ptr)
  243. }
  244. Core.prototype.getUserPointer = function() {
  245. Polycode.Core_getUserPointer(this.__ptr)
  246. }
  247. Core.prototype.executeExternalCommand = function(command,args,inDirectory) {
  248. return Polycode.Core_executeExternalCommand(this.__ptr, command, args, inDirectory)
  249. }
  250. Core.prototype.getDefaultWorkingDirectory = function() {
  251. return Polycode.Core_getDefaultWorkingDirectory(this.__ptr)
  252. }
  253. Core.prototype.getUserHomeDirectory = function() {
  254. return Polycode.Core_getUserHomeDirectory(this.__ptr)
  255. }
  256. Core.prototype.makeApplicationMain = function() {
  257. Polycode.Core_makeApplicationMain(this.__ptr)
  258. }
  259. Core.prototype.getEventMutex = function() {
  260. var retVal = new CoreMutex()
  261. retVal.__ptr = Polycode.Core_getEventMutex(this.__ptr)
  262. return retVal
  263. }
  264. Core.prototype.removeThread = function(thread) {
  265. Polycode.Core_removeThread(this.__ptr, thread.__ptr)
  266. }