Win32Core.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. require "Polycode/Core"
  2. class "Win32Core" (Core)
  3. function Win32Core:Win32Core(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "Core" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Polycore.Win32Core(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function Win32Core:enableMouse(newval)
  23. local retVal = Polycore.Win32Core_enableMouse(self.__ptr, newval)
  24. end
  25. function Win32Core:getTicks()
  26. local retVal = Polycore.Win32Core_getTicks(self.__ptr)
  27. return retVal
  28. end
  29. function Win32Core:Update()
  30. local retVal = Polycore.Win32Core_Update(self.__ptr)
  31. return retVal
  32. end
  33. function Win32Core:handleKeyDown(lParam, wParam)
  34. local retVal = Polycore.Win32Core_handleKeyDown(self.__ptr, lParam.__ptr, wParam.__ptr)
  35. end
  36. function Win32Core:handleKeyUp(lParam, wParam)
  37. local retVal = Polycore.Win32Core_handleKeyUp(self.__ptr, lParam.__ptr, wParam.__ptr)
  38. end
  39. function Win32Core:handleMouseMove(lParam, wParam)
  40. local retVal = Polycore.Win32Core_handleMouseMove(self.__ptr, lParam.__ptr, wParam.__ptr)
  41. end
  42. function Win32Core:handleMouseWheel(lParam, wParam)
  43. local retVal = Polycore.Win32Core_handleMouseWheel(self.__ptr, lParam.__ptr, wParam.__ptr)
  44. end
  45. function Win32Core:handleMouseDown(mouseCode, lParam, wParam)
  46. local retVal = Polycore.Win32Core_handleMouseDown(self.__ptr, mouseCode, lParam.__ptr, wParam.__ptr)
  47. end
  48. function Win32Core:handleMouseUp(mouseCode, lParam, wParam)
  49. local retVal = Polycore.Win32Core_handleMouseUp(self.__ptr, mouseCode, lParam.__ptr, wParam.__ptr)
  50. end
  51. function Win32Core:setVideoMode(xRes, yRes, fullScreen, aaLevel)
  52. local retVal = Polycore.Win32Core_setVideoMode(self.__ptr, xRes, yRes, fullScreen, aaLevel)
  53. end
  54. function Win32Core:initContext(usePixelFormat, pixelFormat)
  55. local retVal = Polycore.Win32Core_initContext(self.__ptr, usePixelFormat, pixelFormat)
  56. end
  57. function Win32Core:destroyContext()
  58. local retVal = Polycore.Win32Core_destroyContext(self.__ptr)
  59. end
  60. function Win32Core:createThread(target)
  61. local retVal = Polycore.Win32Core_createThread(self.__ptr, target.__ptr)
  62. end
  63. function Win32Core:mapKey(lParam, wParam)
  64. local retVal = Polycore.Win32Core_mapKey(self.__ptr, lParam.__ptr, wParam.__ptr)
  65. if Polycore.__ptr_lookup[retVal] ~= nil then
  66. return Polycore.__ptr_lookup[retVal]
  67. else
  68. Polycore.__ptr_lookup[retVal] = PolyKEY("__skip_ptr__")
  69. Polycore.__ptr_lookup[retVal].__ptr = retVal
  70. return Polycore.__ptr_lookup[retVal]
  71. end
  72. end
  73. function Win32Core:lockMutex(mutex)
  74. local retVal = Polycore.Win32Core_lockMutex(self.__ptr, mutex.__ptr)
  75. end
  76. function Win32Core:unlockMutex(mutex)
  77. local retVal = Polycore.Win32Core_unlockMutex(self.__ptr, mutex.__ptr)
  78. end
  79. function Win32Core:createMutex()
  80. local retVal = Polycore.Win32Core_createMutex(self.__ptr)
  81. if Polycore.__ptr_lookup[retVal] ~= nil then
  82. return Polycore.__ptr_lookup[retVal]
  83. else
  84. Polycore.__ptr_lookup[retVal] = CoreMutex("__skip_ptr__")
  85. Polycore.__ptr_lookup[retVal].__ptr = retVal
  86. return Polycore.__ptr_lookup[retVal]
  87. end
  88. end
  89. function Win32Core:checkEvents()
  90. local retVal = Polycore.Win32Core_checkEvents(self.__ptr)
  91. end
  92. function Win32Core:initKeymap()
  93. local retVal = Polycore.Win32Core_initKeymap(self.__ptr)
  94. end
  95. function Win32Core:platformSleep(msecs)
  96. local retVal = Polycore.Win32Core_platformSleep(self.__ptr, msecs)
  97. end
  98. function Win32Core:setCursor(cursorType)
  99. local retVal = Polycore.Win32Core_setCursor(self.__ptr, cursorType)
  100. end
  101. function Win32Core:copyStringToClipboard(str)
  102. local retVal = Polycore.Win32Core_copyStringToClipboard(self.__ptr, str)
  103. end
  104. function Win32Core:getClipboardString()
  105. local retVal = Polycore.Win32Core_getClipboardString(self.__ptr)
  106. return retVal
  107. end
  108. function Win32Core:createFolder(folderPath)
  109. local retVal = Polycore.Win32Core_createFolder(self.__ptr, folderPath)
  110. end
  111. function Win32Core:copyDiskItem(itemPath, destItemPath)
  112. local retVal = Polycore.Win32Core_copyDiskItem(self.__ptr, itemPath, destItemPath)
  113. end
  114. function Win32Core:moveDiskItem(itemPath, destItemPath)
  115. local retVal = Polycore.Win32Core_moveDiskItem(self.__ptr, itemPath, destItemPath)
  116. end
  117. function Win32Core:openFolderPicker()
  118. local retVal = Polycore.Win32Core_openFolderPicker(self.__ptr)
  119. return retVal
  120. end
  121. function Win32Core:removeDiskItem(itemPath)
  122. local retVal = Polycore.Win32Core_removeDiskItem(self.__ptr, itemPath)
  123. end
  124. function Win32Core:resizeTo(xRes, yRes)
  125. local retVal = Polycore.Win32Core_resizeTo(self.__ptr, xRes, yRes)
  126. end
  127. function Win32Core:__delete()
  128. Polycore.__ptr_lookup[self.__ptr] = nil
  129. Polycore.delete_Win32Core(self.__ptr)
  130. end