Core.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. require('Polycode/EventDispatcher')
  2. function Core() {
  3. Object.defineProperties(this, {
  4. 'paused': { enumerable: true, configurable: true, get: Core.prototype.__get_paused, set: Core.prototype.__set_paused},
  5. 'pauseOnLoseFocus': { enumerable: true, configurable: true, get: Core.prototype.__get_pauseOnLoseFocus, set: Core.prototype.__set_pauseOnLoseFocus},
  6. 'defaultScreenWidth': { enumerable: true, configurable: true, get: Core.prototype.__get_defaultScreenWidth, set: Core.prototype.__set_defaultScreenWidth},
  7. 'defaultScreenHeight': { enumerable: true, configurable: true, get: Core.prototype.__get_defaultScreenHeight, set: Core.prototype.__set_defaultScreenHeight},
  8. 'deviceAttitude': { enumerable: true, configurable: true, get: Core.prototype.__get_deviceAttitude, set: Core.prototype.__set_deviceAttitude}
  9. })
  10. }
  11. Core.EVENTBASE_CORE = 0x200
  12. Core.EVENT_CORE_RESIZE = EVENTBASE_CORE + 0
  13. Core.EVENT_LOST_FOCUS = EVENTBASE_CORE + 1
  14. Core.EVENT_GAINED_FOCUS = EVENTBASE_CORE + 2
  15. Core.EVENT_UNDO = EVENTBASE_CORE + 3
  16. Core.EVENT_REDO = EVENTBASE_CORE + 4
  17. Core.EVENT_COPY = EVENTBASE_CORE + 5
  18. Core.EVENT_CUT = EVENTBASE_CORE + 6
  19. Core.EVENT_SELECT_ALL = EVENTBASE_CORE + 7
  20. Core.EVENT_PASTE = EVENTBASE_CORE + 8
  21. Core.EVENT_GYRO_ROTATION = EVENTBASE_CORE + 9
  22. Core.EVENT_ACCELEROMETER_MOTION = EVENTBASE_CORE + 10
  23. Core.CURSOR_ARROW = 0
  24. Core.CURSOR_TEXT = 1
  25. Core.CURSOR_POINTER = 2
  26. Core.CURSOR_CROSSHAIR = 3
  27. Core.CURSOR_RESIZE_LEFT_RIGHT = 4
  28. Core.CURSOR_RESIZE_UP_DOWN = 5
  29. Core.CURSOR_OPEN_HAND = 6
  30. Core.prototype = Object.create(EventDispatcher.prototype)
  31. Core.prototype.__get_paused = function() {
  32. return Polycode.Core__get_paused(this.__ptr)
  33. }
  34. Core.prototype.__set_paused = function(val) {
  35. Polycode.Core__set_paused(this.__ptr, val)
  36. }
  37. Core.prototype.__get_pauseOnLoseFocus = function() {
  38. return Polycode.Core__get_pauseOnLoseFocus(this.__ptr)
  39. }
  40. Core.prototype.__set_pauseOnLoseFocus = function(val) {
  41. Polycode.Core__set_pauseOnLoseFocus(this.__ptr, val)
  42. }
  43. Core.prototype.__get_defaultScreenWidth = function() {
  44. return Polycode.Core__get_defaultScreenWidth(this.__ptr)
  45. }
  46. Core.prototype.__set_defaultScreenWidth = function(val) {
  47. Polycode.Core__set_defaultScreenWidth(this.__ptr, val)
  48. }
  49. Core.prototype.__get_defaultScreenHeight = function() {
  50. return Polycode.Core__get_defaultScreenHeight(this.__ptr)
  51. }
  52. Core.prototype.__set_defaultScreenHeight = function(val) {
  53. Polycode.Core__set_defaultScreenHeight(this.__ptr, val)
  54. }
  55. Core.prototype.__get_deviceAttitude = function() {
  56. var retVal = new Quaternion("__skip_ptr__")
  57. retVal.__ptr = Polycode.Core__get_deviceAttitude(this.__ptr)
  58. return retVal
  59. }
  60. Core.prototype.__set_deviceAttitude = function(val) {
  61. Polycode.Core__set_deviceAttitude(this.__ptr, val.__ptr)
  62. }
  63. Duktape.fin(Core.prototype, function (x) {
  64. if (x === Core.prototype) {
  65. return;
  66. }
  67. Polycode.Core__delete(x.__ptr)
  68. })
  69. Core.prototype.Update = function() {
  70. return Polycode.Core_Update(this.__ptr)
  71. }
  72. Core.prototype.fixedUpdate = function() {
  73. return Polycode.Core_fixedUpdate(this.__ptr)
  74. }
  75. Core.prototype.systemUpdate = function() {
  76. return Polycode.Core_systemUpdate(this.__ptr)
  77. }
  78. Core.prototype.enableMouse = function(newval) {
  79. Polycode.Core_enableMouse(this.__ptr, newval)
  80. }
  81. Core.prototype.captureMouse = function(newval) {
  82. Polycode.Core_captureMouse(this.__ptr, newval)
  83. }
  84. Core.prototype.setCursor = function(cursorType) {
  85. Polycode.Core_setCursor(this.__ptr, cursorType)
  86. }
  87. Core.prototype.warpCursor = function(x,y) {
  88. Polycode.Core_warpCursor(this.__ptr, x, y)
  89. }
  90. Core.prototype.openOnScreenKeyboard = function(open) {
  91. Polycode.Core_openOnScreenKeyboard(this.__ptr, open)
  92. }
  93. Core.prototype.copyStringToClipboard = function(str) {
  94. Polycode.Core_copyStringToClipboard(this.__ptr, str)
  95. }
  96. Core.prototype.getClipboardString = function() {
  97. return Polycode.Core_getClipboardString(this.__ptr)
  98. }
  99. Core.prototype.getFPS = function() {
  100. return Polycode.Core_getFPS(this.__ptr)
  101. }
  102. Core.prototype.Shutdown = function() {
  103. Polycode.Core_Shutdown(this.__ptr)
  104. }
  105. Core.prototype.isFullscreen = function() {
  106. return Polycode.Core_isFullscreen(this.__ptr)
  107. }
  108. Core.prototype.getAALevel = function() {
  109. return Polycode.Core_getAALevel(this.__ptr)
  110. }
  111. Core.prototype.getXRes = function() {
  112. return Polycode.Core_getXRes(this.__ptr)
  113. }
  114. Core.prototype.getYRes = function() {
  115. return Polycode.Core_getYRes(this.__ptr)
  116. }
  117. Core.prototype.getBackingXRes = function() {
  118. return Polycode.Core_getBackingXRes(this.__ptr)
  119. }
  120. Core.prototype.getBackingYRes = function() {
  121. return Polycode.Core_getBackingYRes(this.__ptr)
  122. }
  123. Core.prototype.getScreenWidth = function() {
  124. return Polycode.Core_getScreenWidth(this.__ptr)
  125. }
  126. Core.prototype.getScreenHeight = function() {
  127. return Polycode.Core_getScreenHeight(this.__ptr)
  128. }
  129. Core.prototype.createFolder = function(folderPath) {
  130. Polycode.Core_createFolder(this.__ptr, folderPath)
  131. }
  132. Core.prototype.copyDiskItem = function(itemPath,destItemPath) {
  133. Polycode.Core_copyDiskItem(this.__ptr, itemPath, destItemPath)
  134. }
  135. Core.prototype.moveDiskItem = function(itemPath,destItemPath) {
  136. Polycode.Core_moveDiskItem(this.__ptr, itemPath, destItemPath)
  137. }
  138. Core.prototype.removeDiskItem = function(itemPath) {
  139. Polycode.Core_removeDiskItem(this.__ptr, itemPath)
  140. }
  141. Core.prototype.openFolderPicker = function() {
  142. return Polycode.Core_openFolderPicker(this.__ptr)
  143. }
  144. Core.prototype.setFramerate = function(frameRate,maxFixedCycles) {
  145. Polycode.Core_setFramerate(this.__ptr, frameRate, maxFixedCycles)
  146. }
  147. Core.prototype.openFilePicker = function(extensions,allowMultiple) {
  148. Polycode.Core_openFilePicker(this.__ptr, extensions, allowMultiple)
  149. }
  150. Core.prototype.saveFilePicker = function(extensions) {
  151. return Polycode.Core_saveFilePicker(this.__ptr, extensions)
  152. }
  153. Core.prototype.flushRenderContext = function() {
  154. Polycode.Core_flushRenderContext(this.__ptr)
  155. }
  156. Core.prototype.prepareRenderContext = function() {
  157. Polycode.Core_prepareRenderContext(this.__ptr)
  158. }
  159. Core.prototype.isWindowInitialized = function() {
  160. return Polycode.Core_isWindowInitialized(this.__ptr)
  161. }
  162. Core.prototype.addFileSource = function(type,source) {
  163. Polycode.Core_addFileSource(this.__ptr, type, source)
  164. }
  165. Core.prototype.removeFileSource = function(type,source) {
  166. Polycode.Core_removeFileSource(this.__ptr, type, source)
  167. }
  168. Core.prototype.parseFolder = function(pathString,showHidden) {
  169. Polycode.Core_parseFolder(this.__ptr, pathString, showHidden)
  170. }
  171. Core.prototype.systemParseFolder = function(pathString,showHidden,targetVector) {
  172. return Polycode.Core_systemParseFolder(this.__ptr, pathString, showHidden, targetVector)
  173. }
  174. Core.prototype.getResourcePathForFile = function(fileName) {
  175. return Polycode.Core_getResourcePathForFile(this.__ptr, fileName)
  176. }
  177. Core.prototype.setVideoMode = function(xRes,yRes,fullScreen,vSync,aaLevel,anisotropyLevel,retinaSupport) {
  178. Polycode.Core_setVideoMode(this.__ptr, xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport)
  179. }
  180. Core.prototype.resizeTo = function(xRes,yRes) {
  181. Polycode.Core_resizeTo(this.__ptr, xRes, yRes)
  182. }
  183. Core.prototype.doSleep = function() {
  184. Polycode.Core_doSleep(this.__ptr)
  185. }
  186. Core.prototype.openURL = function(url) {
  187. Polycode.Core_openURL(this.__ptr, url)
  188. }
  189. Core.prototype.getElapsed = function() {
  190. return Polycode.Core_getElapsed(this.__ptr)
  191. }
  192. Core.prototype.getTicks = function() {
  193. return Polycode.Core_getTicks(this.__ptr)
  194. }
  195. Core.prototype.getRefreshIntervalMs = function() {
  196. return Polycode.Core_getRefreshIntervalMs(this.__ptr)
  197. }
  198. Core.prototype.getTimeSleptMs = function() {
  199. return Polycode.Core_getTimeSleptMs(this.__ptr)
  200. }
  201. Core.prototype.getFixedTimestep = function() {
  202. return Polycode.Core_getFixedTimestep(this.__ptr)
  203. }
  204. Core.prototype.getViewport = function() {
  205. var retVal = new Rectangle("__skip_ptr__")
  206. retVal.__ptr = Polycode.Core_getViewport(this.__ptr)
  207. return retVal
  208. }
  209. Core.prototype.getTicksFloat = function() {
  210. return Polycode.Core_getTicksFloat(this.__ptr)
  211. }
  212. Core.prototype.executeExternalCommand = function(command,args,inDirectory) {
  213. return Polycode.Core_executeExternalCommand(this.__ptr, command, args, inDirectory)
  214. }
  215. Core.prototype.getDefaultWorkingDirectory = function() {
  216. return Polycode.Core_getDefaultWorkingDirectory(this.__ptr)
  217. }
  218. Core.prototype.getUserHomeDirectory = function() {
  219. return Polycode.Core_getUserHomeDirectory(this.__ptr)
  220. }
  221. Core.prototype.makeApplicationMain = function() {
  222. Polycode.Core_makeApplicationMain(this.__ptr)
  223. }
  224. Core.prototype.getConfig = function() {
  225. var retVal = new ConfigRef("__skip_ptr__")
  226. retVal.__ptr = Polycode.Core_getConfig(this.__ptr)
  227. return retVal
  228. }