lua_Game.cpp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_Game.h"
  4. #include "Base.h"
  5. #include "FileSystem.h"
  6. #include "FrameBuffer.h"
  7. #include "Game.h"
  8. #include "Platform.h"
  9. #include "RenderState.h"
  10. #include "SceneLoader.h"
  11. #include "lua_GameClearFlags.h"
  12. #include "lua_GameState.h"
  13. #include "lua_GamepadGamepadEvent.h"
  14. #include "lua_GestureGestureEvent.h"
  15. #include "lua_KeyboardKeyEvent.h"
  16. #include "lua_MouseMouseEvent.h"
  17. #include "lua_TouchTouchEvent.h"
  18. namespace gameplay
  19. {
  20. void luaRegister_Game()
  21. {
  22. const luaL_Reg lua_members[] =
  23. {
  24. {"clear", lua_Game_clear},
  25. {"displayKeyboard", lua_Game_displayKeyboard},
  26. {"exit", lua_Game_exit},
  27. {"frame", lua_Game_frame},
  28. {"gamepadEvent", lua_Game_gamepadEvent},
  29. {"gesturePinchEvent", lua_Game_gesturePinchEvent},
  30. {"gestureSwipeEvent", lua_Game_gestureSwipeEvent},
  31. {"gestureTapEvent", lua_Game_gestureTapEvent},
  32. {"getAIController", lua_Game_getAIController},
  33. {"getAccelerometerValues", lua_Game_getAccelerometerValues},
  34. {"getAnimationController", lua_Game_getAnimationController},
  35. {"getAudioController", lua_Game_getAudioController},
  36. {"getAudioListener", lua_Game_getAudioListener},
  37. {"getConfig", lua_Game_getConfig},
  38. {"getFrameRate", lua_Game_getFrameRate},
  39. {"getGamepad", lua_Game_getGamepad},
  40. {"getGamepadCount", lua_Game_getGamepadCount},
  41. {"getGamepadsConnected", lua_Game_getGamepadsConnected},
  42. {"getHeight", lua_Game_getHeight},
  43. {"getPhysicsController", lua_Game_getPhysicsController},
  44. {"getScriptController", lua_Game_getScriptController},
  45. {"getState", lua_Game_getState},
  46. {"getViewport", lua_Game_getViewport},
  47. {"getWidth", lua_Game_getWidth},
  48. {"hasMouse", lua_Game_hasMouse},
  49. {"isCursorVisible", lua_Game_isCursorVisible},
  50. {"isGestureRegistered", lua_Game_isGestureRegistered},
  51. {"isGestureSupported", lua_Game_isGestureSupported},
  52. {"isInitialized", lua_Game_isInitialized},
  53. {"isMouseCaptured", lua_Game_isMouseCaptured},
  54. {"isMultiTouch", lua_Game_isMultiTouch},
  55. {"keyEvent", lua_Game_keyEvent},
  56. {"menuEvent", lua_Game_menuEvent},
  57. {"mouseEvent", lua_Game_mouseEvent},
  58. {"pause", lua_Game_pause},
  59. {"registerGesture", lua_Game_registerGesture},
  60. {"resume", lua_Game_resume},
  61. {"run", lua_Game_run},
  62. {"schedule", lua_Game_schedule},
  63. {"setCursorVisible", lua_Game_setCursorVisible},
  64. {"setMouseCaptured", lua_Game_setMouseCaptured},
  65. {"setMultiTouch", lua_Game_setMultiTouch},
  66. {"setViewport", lua_Game_setViewport},
  67. {"touchEvent", lua_Game_touchEvent},
  68. {"unregisterGesture", lua_Game_unregisterGesture},
  69. {NULL, NULL}
  70. };
  71. const luaL_Reg lua_statics[] =
  72. {
  73. {"getAbsoluteTime", lua_Game_static_getAbsoluteTime},
  74. {"getGameTime", lua_Game_static_getGameTime},
  75. {"getInstance", lua_Game_static_getInstance},
  76. {"isVsync", lua_Game_static_isVsync},
  77. {"setVsync", lua_Game_static_setVsync},
  78. {NULL, NULL}
  79. };
  80. std::vector<std::string> scopePath;
  81. ScriptUtil::registerClass("Game", lua_members, NULL, lua_Game__gc, lua_statics, scopePath);
  82. }
  83. static Game* getInstance(lua_State* state)
  84. {
  85. void* userdata = luaL_checkudata(state, 1, "Game");
  86. luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
  87. return (Game*)((ScriptUtil::LuaObject*)userdata)->instance;
  88. }
  89. int lua_Game__gc(lua_State* state)
  90. {
  91. // Get the number of parameters.
  92. int paramCount = lua_gettop(state);
  93. // Attempt to match the parameters to a valid binding.
  94. switch (paramCount)
  95. {
  96. case 1:
  97. {
  98. if ((lua_type(state, 1) == LUA_TUSERDATA))
  99. {
  100. void* userdata = luaL_checkudata(state, 1, "Game");
  101. luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
  102. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  103. if (object->owns)
  104. {
  105. Game* instance = (Game*)object->instance;
  106. SAFE_DELETE(instance);
  107. }
  108. return 0;
  109. }
  110. else
  111. {
  112. lua_pushstring(state, "lua_Game__gc - Failed to match the given parameters to a valid function signature.");
  113. lua_error(state);
  114. }
  115. break;
  116. }
  117. default:
  118. {
  119. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  120. lua_error(state);
  121. break;
  122. }
  123. }
  124. return 0;
  125. }
  126. int lua_Game_clear(lua_State* state)
  127. {
  128. // Get the number of parameters.
  129. int paramCount = lua_gettop(state);
  130. // Attempt to match the parameters to a valid binding.
  131. switch (paramCount)
  132. {
  133. case 5:
  134. {
  135. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  136. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  137. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  138. lua_type(state, 4) == LUA_TNUMBER &&
  139. lua_type(state, 5) == LUA_TNUMBER)
  140. {
  141. // Get parameter 1 off the stack.
  142. Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
  143. // Get parameter 2 off the stack.
  144. ScriptUtil::LuaArray<Vector4> param2 = ScriptUtil::getObjectPointer<Vector4>(3, "Vector4", true);
  145. // Get parameter 3 off the stack.
  146. float param3 = (float)luaL_checknumber(state, 4);
  147. // Get parameter 4 off the stack.
  148. int param4 = (int)luaL_checkint(state, 5);
  149. Game* instance = getInstance(state);
  150. instance->clear(param1, *param2, param3, param4);
  151. return 0;
  152. }
  153. else
  154. {
  155. lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
  156. lua_error(state);
  157. }
  158. break;
  159. }
  160. case 8:
  161. {
  162. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  163. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  164. lua_type(state, 3) == LUA_TNUMBER &&
  165. lua_type(state, 4) == LUA_TNUMBER &&
  166. lua_type(state, 5) == LUA_TNUMBER &&
  167. lua_type(state, 6) == LUA_TNUMBER &&
  168. lua_type(state, 7) == LUA_TNUMBER &&
  169. lua_type(state, 8) == LUA_TNUMBER)
  170. {
  171. // Get parameter 1 off the stack.
  172. Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
  173. // Get parameter 2 off the stack.
  174. float param2 = (float)luaL_checknumber(state, 3);
  175. // Get parameter 3 off the stack.
  176. float param3 = (float)luaL_checknumber(state, 4);
  177. // Get parameter 4 off the stack.
  178. float param4 = (float)luaL_checknumber(state, 5);
  179. // Get parameter 5 off the stack.
  180. float param5 = (float)luaL_checknumber(state, 6);
  181. // Get parameter 6 off the stack.
  182. float param6 = (float)luaL_checknumber(state, 7);
  183. // Get parameter 7 off the stack.
  184. int param7 = (int)luaL_checkint(state, 8);
  185. Game* instance = getInstance(state);
  186. instance->clear(param1, param2, param3, param4, param5, param6, param7);
  187. return 0;
  188. }
  189. else
  190. {
  191. lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
  192. lua_error(state);
  193. }
  194. break;
  195. }
  196. default:
  197. {
  198. lua_pushstring(state, "Invalid number of parameters (expected 5 or 8).");
  199. lua_error(state);
  200. break;
  201. }
  202. }
  203. return 0;
  204. }
  205. int lua_Game_displayKeyboard(lua_State* state)
  206. {
  207. // Get the number of parameters.
  208. int paramCount = lua_gettop(state);
  209. // Attempt to match the parameters to a valid binding.
  210. switch (paramCount)
  211. {
  212. case 2:
  213. {
  214. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  215. lua_type(state, 2) == LUA_TBOOLEAN)
  216. {
  217. // Get parameter 1 off the stack.
  218. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  219. Game* instance = getInstance(state);
  220. instance->displayKeyboard(param1);
  221. return 0;
  222. }
  223. else
  224. {
  225. lua_pushstring(state, "lua_Game_displayKeyboard - Failed to match the given parameters to a valid function signature.");
  226. lua_error(state);
  227. }
  228. break;
  229. }
  230. default:
  231. {
  232. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  233. lua_error(state);
  234. break;
  235. }
  236. }
  237. return 0;
  238. }
  239. int lua_Game_exit(lua_State* state)
  240. {
  241. // Get the number of parameters.
  242. int paramCount = lua_gettop(state);
  243. // Attempt to match the parameters to a valid binding.
  244. switch (paramCount)
  245. {
  246. case 1:
  247. {
  248. if ((lua_type(state, 1) == LUA_TUSERDATA))
  249. {
  250. Game* instance = getInstance(state);
  251. instance->exit();
  252. return 0;
  253. }
  254. else
  255. {
  256. lua_pushstring(state, "lua_Game_exit - Failed to match the given parameters to a valid function signature.");
  257. lua_error(state);
  258. }
  259. break;
  260. }
  261. default:
  262. {
  263. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  264. lua_error(state);
  265. break;
  266. }
  267. }
  268. return 0;
  269. }
  270. int lua_Game_frame(lua_State* state)
  271. {
  272. // Get the number of parameters.
  273. int paramCount = lua_gettop(state);
  274. // Attempt to match the parameters to a valid binding.
  275. switch (paramCount)
  276. {
  277. case 1:
  278. {
  279. if ((lua_type(state, 1) == LUA_TUSERDATA))
  280. {
  281. Game* instance = getInstance(state);
  282. instance->frame();
  283. return 0;
  284. }
  285. else
  286. {
  287. lua_pushstring(state, "lua_Game_frame - Failed to match the given parameters to a valid function signature.");
  288. lua_error(state);
  289. }
  290. break;
  291. }
  292. default:
  293. {
  294. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  295. lua_error(state);
  296. break;
  297. }
  298. }
  299. return 0;
  300. }
  301. int lua_Game_gamepadEvent(lua_State* state)
  302. {
  303. // Get the number of parameters.
  304. int paramCount = lua_gettop(state);
  305. // Attempt to match the parameters to a valid binding.
  306. switch (paramCount)
  307. {
  308. case 3:
  309. {
  310. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  311. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  312. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  313. {
  314. // Get parameter 1 off the stack.
  315. Gamepad::GamepadEvent param1 = (Gamepad::GamepadEvent)lua_enumFromString_GamepadGamepadEvent(luaL_checkstring(state, 2));
  316. // Get parameter 2 off the stack.
  317. ScriptUtil::LuaArray<Gamepad> param2 = ScriptUtil::getObjectPointer<Gamepad>(3, "Gamepad", false);
  318. Game* instance = getInstance(state);
  319. instance->gamepadEvent(param1, param2);
  320. return 0;
  321. }
  322. else
  323. {
  324. lua_pushstring(state, "lua_Game_gamepadEvent - Failed to match the given parameters to a valid function signature.");
  325. lua_error(state);
  326. }
  327. break;
  328. }
  329. default:
  330. {
  331. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  332. lua_error(state);
  333. break;
  334. }
  335. }
  336. return 0;
  337. }
  338. int lua_Game_gesturePinchEvent(lua_State* state)
  339. {
  340. // Get the number of parameters.
  341. int paramCount = lua_gettop(state);
  342. // Attempt to match the parameters to a valid binding.
  343. switch (paramCount)
  344. {
  345. case 4:
  346. {
  347. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  348. lua_type(state, 2) == LUA_TNUMBER &&
  349. lua_type(state, 3) == LUA_TNUMBER &&
  350. lua_type(state, 4) == LUA_TNUMBER)
  351. {
  352. // Get parameter 1 off the stack.
  353. int param1 = (int)luaL_checkint(state, 2);
  354. // Get parameter 2 off the stack.
  355. int param2 = (int)luaL_checkint(state, 3);
  356. // Get parameter 3 off the stack.
  357. float param3 = (float)luaL_checknumber(state, 4);
  358. Game* instance = getInstance(state);
  359. instance->gesturePinchEvent(param1, param2, param3);
  360. return 0;
  361. }
  362. else
  363. {
  364. lua_pushstring(state, "lua_Game_gesturePinchEvent - Failed to match the given parameters to a valid function signature.");
  365. lua_error(state);
  366. }
  367. break;
  368. }
  369. default:
  370. {
  371. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  372. lua_error(state);
  373. break;
  374. }
  375. }
  376. return 0;
  377. }
  378. int lua_Game_gestureSwipeEvent(lua_State* state)
  379. {
  380. // Get the number of parameters.
  381. int paramCount = lua_gettop(state);
  382. // Attempt to match the parameters to a valid binding.
  383. switch (paramCount)
  384. {
  385. case 4:
  386. {
  387. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  388. lua_type(state, 2) == LUA_TNUMBER &&
  389. lua_type(state, 3) == LUA_TNUMBER &&
  390. lua_type(state, 4) == LUA_TNUMBER)
  391. {
  392. // Get parameter 1 off the stack.
  393. int param1 = (int)luaL_checkint(state, 2);
  394. // Get parameter 2 off the stack.
  395. int param2 = (int)luaL_checkint(state, 3);
  396. // Get parameter 3 off the stack.
  397. int param3 = (int)luaL_checkint(state, 4);
  398. Game* instance = getInstance(state);
  399. instance->gestureSwipeEvent(param1, param2, param3);
  400. return 0;
  401. }
  402. else
  403. {
  404. lua_pushstring(state, "lua_Game_gestureSwipeEvent - Failed to match the given parameters to a valid function signature.");
  405. lua_error(state);
  406. }
  407. break;
  408. }
  409. default:
  410. {
  411. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  412. lua_error(state);
  413. break;
  414. }
  415. }
  416. return 0;
  417. }
  418. int lua_Game_gestureTapEvent(lua_State* state)
  419. {
  420. // Get the number of parameters.
  421. int paramCount = lua_gettop(state);
  422. // Attempt to match the parameters to a valid binding.
  423. switch (paramCount)
  424. {
  425. case 3:
  426. {
  427. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  428. lua_type(state, 2) == LUA_TNUMBER &&
  429. lua_type(state, 3) == LUA_TNUMBER)
  430. {
  431. // Get parameter 1 off the stack.
  432. int param1 = (int)luaL_checkint(state, 2);
  433. // Get parameter 2 off the stack.
  434. int param2 = (int)luaL_checkint(state, 3);
  435. Game* instance = getInstance(state);
  436. instance->gestureTapEvent(param1, param2);
  437. return 0;
  438. }
  439. else
  440. {
  441. lua_pushstring(state, "lua_Game_gestureTapEvent - Failed to match the given parameters to a valid function signature.");
  442. lua_error(state);
  443. }
  444. break;
  445. }
  446. default:
  447. {
  448. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  449. lua_error(state);
  450. break;
  451. }
  452. }
  453. return 0;
  454. }
  455. int lua_Game_getAIController(lua_State* state)
  456. {
  457. // Get the number of parameters.
  458. int paramCount = lua_gettop(state);
  459. // Attempt to match the parameters to a valid binding.
  460. switch (paramCount)
  461. {
  462. case 1:
  463. {
  464. if ((lua_type(state, 1) == LUA_TUSERDATA))
  465. {
  466. Game* instance = getInstance(state);
  467. void* returnPtr = (void*)instance->getAIController();
  468. if (returnPtr)
  469. {
  470. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  471. object->instance = returnPtr;
  472. object->owns = false;
  473. luaL_getmetatable(state, "AIController");
  474. lua_setmetatable(state, -2);
  475. }
  476. else
  477. {
  478. lua_pushnil(state);
  479. }
  480. return 1;
  481. }
  482. else
  483. {
  484. lua_pushstring(state, "lua_Game_getAIController - Failed to match the given parameters to a valid function signature.");
  485. lua_error(state);
  486. }
  487. break;
  488. }
  489. default:
  490. {
  491. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  492. lua_error(state);
  493. break;
  494. }
  495. }
  496. return 0;
  497. }
  498. int lua_Game_getAccelerometerValues(lua_State* state)
  499. {
  500. // Get the number of parameters.
  501. int paramCount = lua_gettop(state);
  502. // Attempt to match the parameters to a valid binding.
  503. switch (paramCount)
  504. {
  505. case 3:
  506. {
  507. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  508. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  509. (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
  510. {
  511. // Get parameter 1 off the stack.
  512. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  513. // Get parameter 2 off the stack.
  514. ScriptUtil::LuaArray<float> param2 = ScriptUtil::getFloatPointer(3);
  515. Game* instance = getInstance(state);
  516. instance->getAccelerometerValues(param1, param2);
  517. return 0;
  518. }
  519. else
  520. {
  521. lua_pushstring(state, "lua_Game_getAccelerometerValues - Failed to match the given parameters to a valid function signature.");
  522. lua_error(state);
  523. }
  524. break;
  525. }
  526. default:
  527. {
  528. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  529. lua_error(state);
  530. break;
  531. }
  532. }
  533. return 0;
  534. }
  535. int lua_Game_getAnimationController(lua_State* state)
  536. {
  537. // Get the number of parameters.
  538. int paramCount = lua_gettop(state);
  539. // Attempt to match the parameters to a valid binding.
  540. switch (paramCount)
  541. {
  542. case 1:
  543. {
  544. if ((lua_type(state, 1) == LUA_TUSERDATA))
  545. {
  546. Game* instance = getInstance(state);
  547. void* returnPtr = (void*)instance->getAnimationController();
  548. if (returnPtr)
  549. {
  550. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  551. object->instance = returnPtr;
  552. object->owns = false;
  553. luaL_getmetatable(state, "AnimationController");
  554. lua_setmetatable(state, -2);
  555. }
  556. else
  557. {
  558. lua_pushnil(state);
  559. }
  560. return 1;
  561. }
  562. else
  563. {
  564. lua_pushstring(state, "lua_Game_getAnimationController - Failed to match the given parameters to a valid function signature.");
  565. lua_error(state);
  566. }
  567. break;
  568. }
  569. default:
  570. {
  571. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  572. lua_error(state);
  573. break;
  574. }
  575. }
  576. return 0;
  577. }
  578. int lua_Game_getAudioController(lua_State* state)
  579. {
  580. // Get the number of parameters.
  581. int paramCount = lua_gettop(state);
  582. // Attempt to match the parameters to a valid binding.
  583. switch (paramCount)
  584. {
  585. case 1:
  586. {
  587. if ((lua_type(state, 1) == LUA_TUSERDATA))
  588. {
  589. Game* instance = getInstance(state);
  590. void* returnPtr = (void*)instance->getAudioController();
  591. if (returnPtr)
  592. {
  593. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  594. object->instance = returnPtr;
  595. object->owns = false;
  596. luaL_getmetatable(state, "AudioController");
  597. lua_setmetatable(state, -2);
  598. }
  599. else
  600. {
  601. lua_pushnil(state);
  602. }
  603. return 1;
  604. }
  605. else
  606. {
  607. lua_pushstring(state, "lua_Game_getAudioController - Failed to match the given parameters to a valid function signature.");
  608. lua_error(state);
  609. }
  610. break;
  611. }
  612. default:
  613. {
  614. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  615. lua_error(state);
  616. break;
  617. }
  618. }
  619. return 0;
  620. }
  621. int lua_Game_getAudioListener(lua_State* state)
  622. {
  623. // Get the number of parameters.
  624. int paramCount = lua_gettop(state);
  625. // Attempt to match the parameters to a valid binding.
  626. switch (paramCount)
  627. {
  628. case 1:
  629. {
  630. if ((lua_type(state, 1) == LUA_TUSERDATA))
  631. {
  632. Game* instance = getInstance(state);
  633. void* returnPtr = (void*)instance->getAudioListener();
  634. if (returnPtr)
  635. {
  636. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  637. object->instance = returnPtr;
  638. object->owns = false;
  639. luaL_getmetatable(state, "AudioListener");
  640. lua_setmetatable(state, -2);
  641. }
  642. else
  643. {
  644. lua_pushnil(state);
  645. }
  646. return 1;
  647. }
  648. else
  649. {
  650. lua_pushstring(state, "lua_Game_getAudioListener - Failed to match the given parameters to a valid function signature.");
  651. lua_error(state);
  652. }
  653. break;
  654. }
  655. default:
  656. {
  657. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  658. lua_error(state);
  659. break;
  660. }
  661. }
  662. return 0;
  663. }
  664. int lua_Game_getConfig(lua_State* state)
  665. {
  666. // Get the number of parameters.
  667. int paramCount = lua_gettop(state);
  668. // Attempt to match the parameters to a valid binding.
  669. switch (paramCount)
  670. {
  671. case 1:
  672. {
  673. if ((lua_type(state, 1) == LUA_TUSERDATA))
  674. {
  675. Game* instance = getInstance(state);
  676. void* returnPtr = (void*)instance->getConfig();
  677. if (returnPtr)
  678. {
  679. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  680. object->instance = returnPtr;
  681. object->owns = false;
  682. luaL_getmetatable(state, "Properties");
  683. lua_setmetatable(state, -2);
  684. }
  685. else
  686. {
  687. lua_pushnil(state);
  688. }
  689. return 1;
  690. }
  691. else
  692. {
  693. lua_pushstring(state, "lua_Game_getConfig - Failed to match the given parameters to a valid function signature.");
  694. lua_error(state);
  695. }
  696. break;
  697. }
  698. default:
  699. {
  700. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  701. lua_error(state);
  702. break;
  703. }
  704. }
  705. return 0;
  706. }
  707. int lua_Game_getFrameRate(lua_State* state)
  708. {
  709. // Get the number of parameters.
  710. int paramCount = lua_gettop(state);
  711. // Attempt to match the parameters to a valid binding.
  712. switch (paramCount)
  713. {
  714. case 1:
  715. {
  716. if ((lua_type(state, 1) == LUA_TUSERDATA))
  717. {
  718. Game* instance = getInstance(state);
  719. unsigned int result = instance->getFrameRate();
  720. // Push the return value onto the stack.
  721. lua_pushunsigned(state, result);
  722. return 1;
  723. }
  724. else
  725. {
  726. lua_pushstring(state, "lua_Game_getFrameRate - Failed to match the given parameters to a valid function signature.");
  727. lua_error(state);
  728. }
  729. break;
  730. }
  731. default:
  732. {
  733. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  734. lua_error(state);
  735. break;
  736. }
  737. }
  738. return 0;
  739. }
  740. int lua_Game_getGamepad(lua_State* state)
  741. {
  742. // Get the number of parameters.
  743. int paramCount = lua_gettop(state);
  744. // Attempt to match the parameters to a valid binding.
  745. switch (paramCount)
  746. {
  747. case 2:
  748. {
  749. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  750. lua_type(state, 2) == LUA_TNUMBER)
  751. {
  752. // Get parameter 1 off the stack.
  753. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  754. Game* instance = getInstance(state);
  755. void* returnPtr = (void*)instance->getGamepad(param1);
  756. if (returnPtr)
  757. {
  758. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  759. object->instance = returnPtr;
  760. object->owns = false;
  761. luaL_getmetatable(state, "Gamepad");
  762. lua_setmetatable(state, -2);
  763. }
  764. else
  765. {
  766. lua_pushnil(state);
  767. }
  768. return 1;
  769. }
  770. else
  771. {
  772. lua_pushstring(state, "lua_Game_getGamepad - Failed to match the given parameters to a valid function signature.");
  773. lua_error(state);
  774. }
  775. break;
  776. }
  777. default:
  778. {
  779. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  780. lua_error(state);
  781. break;
  782. }
  783. }
  784. return 0;
  785. }
  786. int lua_Game_getGamepadCount(lua_State* state)
  787. {
  788. // Get the number of parameters.
  789. int paramCount = lua_gettop(state);
  790. // Attempt to match the parameters to a valid binding.
  791. switch (paramCount)
  792. {
  793. case 1:
  794. {
  795. if ((lua_type(state, 1) == LUA_TUSERDATA))
  796. {
  797. Game* instance = getInstance(state);
  798. unsigned int result = instance->getGamepadCount();
  799. // Push the return value onto the stack.
  800. lua_pushunsigned(state, result);
  801. return 1;
  802. }
  803. else
  804. {
  805. lua_pushstring(state, "lua_Game_getGamepadCount - Failed to match the given parameters to a valid function signature.");
  806. lua_error(state);
  807. }
  808. break;
  809. }
  810. default:
  811. {
  812. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  813. lua_error(state);
  814. break;
  815. }
  816. }
  817. return 0;
  818. }
  819. int lua_Game_getGamepadsConnected(lua_State* state)
  820. {
  821. // Get the number of parameters.
  822. int paramCount = lua_gettop(state);
  823. // Attempt to match the parameters to a valid binding.
  824. switch (paramCount)
  825. {
  826. case 1:
  827. {
  828. if ((lua_type(state, 1) == LUA_TUSERDATA))
  829. {
  830. Game* instance = getInstance(state);
  831. unsigned int result = instance->getGamepadsConnected();
  832. // Push the return value onto the stack.
  833. lua_pushunsigned(state, result);
  834. return 1;
  835. }
  836. else
  837. {
  838. lua_pushstring(state, "lua_Game_getGamepadsConnected - Failed to match the given parameters to a valid function signature.");
  839. lua_error(state);
  840. }
  841. break;
  842. }
  843. default:
  844. {
  845. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  846. lua_error(state);
  847. break;
  848. }
  849. }
  850. return 0;
  851. }
  852. int lua_Game_getHeight(lua_State* state)
  853. {
  854. // Get the number of parameters.
  855. int paramCount = lua_gettop(state);
  856. // Attempt to match the parameters to a valid binding.
  857. switch (paramCount)
  858. {
  859. case 1:
  860. {
  861. if ((lua_type(state, 1) == LUA_TUSERDATA))
  862. {
  863. Game* instance = getInstance(state);
  864. unsigned int result = instance->getHeight();
  865. // Push the return value onto the stack.
  866. lua_pushunsigned(state, result);
  867. return 1;
  868. }
  869. else
  870. {
  871. lua_pushstring(state, "lua_Game_getHeight - Failed to match the given parameters to a valid function signature.");
  872. lua_error(state);
  873. }
  874. break;
  875. }
  876. default:
  877. {
  878. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  879. lua_error(state);
  880. break;
  881. }
  882. }
  883. return 0;
  884. }
  885. int lua_Game_getPhysicsController(lua_State* state)
  886. {
  887. // Get the number of parameters.
  888. int paramCount = lua_gettop(state);
  889. // Attempt to match the parameters to a valid binding.
  890. switch (paramCount)
  891. {
  892. case 1:
  893. {
  894. if ((lua_type(state, 1) == LUA_TUSERDATA))
  895. {
  896. Game* instance = getInstance(state);
  897. void* returnPtr = (void*)instance->getPhysicsController();
  898. if (returnPtr)
  899. {
  900. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  901. object->instance = returnPtr;
  902. object->owns = false;
  903. luaL_getmetatable(state, "PhysicsController");
  904. lua_setmetatable(state, -2);
  905. }
  906. else
  907. {
  908. lua_pushnil(state);
  909. }
  910. return 1;
  911. }
  912. else
  913. {
  914. lua_pushstring(state, "lua_Game_getPhysicsController - Failed to match the given parameters to a valid function signature.");
  915. lua_error(state);
  916. }
  917. break;
  918. }
  919. default:
  920. {
  921. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  922. lua_error(state);
  923. break;
  924. }
  925. }
  926. return 0;
  927. }
  928. int lua_Game_getScriptController(lua_State* state)
  929. {
  930. // Get the number of parameters.
  931. int paramCount = lua_gettop(state);
  932. // Attempt to match the parameters to a valid binding.
  933. switch (paramCount)
  934. {
  935. case 1:
  936. {
  937. if ((lua_type(state, 1) == LUA_TUSERDATA))
  938. {
  939. Game* instance = getInstance(state);
  940. void* returnPtr = (void*)instance->getScriptController();
  941. if (returnPtr)
  942. {
  943. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  944. object->instance = returnPtr;
  945. object->owns = false;
  946. luaL_getmetatable(state, "ScriptController");
  947. lua_setmetatable(state, -2);
  948. }
  949. else
  950. {
  951. lua_pushnil(state);
  952. }
  953. return 1;
  954. }
  955. else
  956. {
  957. lua_pushstring(state, "lua_Game_getScriptController - Failed to match the given parameters to a valid function signature.");
  958. lua_error(state);
  959. }
  960. break;
  961. }
  962. default:
  963. {
  964. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  965. lua_error(state);
  966. break;
  967. }
  968. }
  969. return 0;
  970. }
  971. int lua_Game_getState(lua_State* state)
  972. {
  973. // Get the number of parameters.
  974. int paramCount = lua_gettop(state);
  975. // Attempt to match the parameters to a valid binding.
  976. switch (paramCount)
  977. {
  978. case 1:
  979. {
  980. if ((lua_type(state, 1) == LUA_TUSERDATA))
  981. {
  982. Game* instance = getInstance(state);
  983. Game::State result = instance->getState();
  984. // Push the return value onto the stack.
  985. lua_pushstring(state, lua_stringFromEnum_GameState(result));
  986. return 1;
  987. }
  988. else
  989. {
  990. lua_pushstring(state, "lua_Game_getState - Failed to match the given parameters to a valid function signature.");
  991. lua_error(state);
  992. }
  993. break;
  994. }
  995. default:
  996. {
  997. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  998. lua_error(state);
  999. break;
  1000. }
  1001. }
  1002. return 0;
  1003. }
  1004. int lua_Game_getViewport(lua_State* state)
  1005. {
  1006. // Get the number of parameters.
  1007. int paramCount = lua_gettop(state);
  1008. // Attempt to match the parameters to a valid binding.
  1009. switch (paramCount)
  1010. {
  1011. case 1:
  1012. {
  1013. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1014. {
  1015. Game* instance = getInstance(state);
  1016. void* returnPtr = (void*)&(instance->getViewport());
  1017. if (returnPtr)
  1018. {
  1019. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1020. object->instance = returnPtr;
  1021. object->owns = false;
  1022. luaL_getmetatable(state, "Rectangle");
  1023. lua_setmetatable(state, -2);
  1024. }
  1025. else
  1026. {
  1027. lua_pushnil(state);
  1028. }
  1029. return 1;
  1030. }
  1031. else
  1032. {
  1033. lua_pushstring(state, "lua_Game_getViewport - Failed to match the given parameters to a valid function signature.");
  1034. lua_error(state);
  1035. }
  1036. break;
  1037. }
  1038. default:
  1039. {
  1040. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1041. lua_error(state);
  1042. break;
  1043. }
  1044. }
  1045. return 0;
  1046. }
  1047. int lua_Game_getWidth(lua_State* state)
  1048. {
  1049. // Get the number of parameters.
  1050. int paramCount = lua_gettop(state);
  1051. // Attempt to match the parameters to a valid binding.
  1052. switch (paramCount)
  1053. {
  1054. case 1:
  1055. {
  1056. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1057. {
  1058. Game* instance = getInstance(state);
  1059. unsigned int result = instance->getWidth();
  1060. // Push the return value onto the stack.
  1061. lua_pushunsigned(state, result);
  1062. return 1;
  1063. }
  1064. else
  1065. {
  1066. lua_pushstring(state, "lua_Game_getWidth - Failed to match the given parameters to a valid function signature.");
  1067. lua_error(state);
  1068. }
  1069. break;
  1070. }
  1071. default:
  1072. {
  1073. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1074. lua_error(state);
  1075. break;
  1076. }
  1077. }
  1078. return 0;
  1079. }
  1080. int lua_Game_hasMouse(lua_State* state)
  1081. {
  1082. // Get the number of parameters.
  1083. int paramCount = lua_gettop(state);
  1084. // Attempt to match the parameters to a valid binding.
  1085. switch (paramCount)
  1086. {
  1087. case 1:
  1088. {
  1089. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1090. {
  1091. Game* instance = getInstance(state);
  1092. bool result = instance->hasMouse();
  1093. // Push the return value onto the stack.
  1094. lua_pushboolean(state, result);
  1095. return 1;
  1096. }
  1097. else
  1098. {
  1099. lua_pushstring(state, "lua_Game_hasMouse - Failed to match the given parameters to a valid function signature.");
  1100. lua_error(state);
  1101. }
  1102. break;
  1103. }
  1104. default:
  1105. {
  1106. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1107. lua_error(state);
  1108. break;
  1109. }
  1110. }
  1111. return 0;
  1112. }
  1113. int lua_Game_isCursorVisible(lua_State* state)
  1114. {
  1115. // Get the number of parameters.
  1116. int paramCount = lua_gettop(state);
  1117. // Attempt to match the parameters to a valid binding.
  1118. switch (paramCount)
  1119. {
  1120. case 1:
  1121. {
  1122. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1123. {
  1124. Game* instance = getInstance(state);
  1125. bool result = instance->isCursorVisible();
  1126. // Push the return value onto the stack.
  1127. lua_pushboolean(state, result);
  1128. return 1;
  1129. }
  1130. else
  1131. {
  1132. lua_pushstring(state, "lua_Game_isCursorVisible - Failed to match the given parameters to a valid function signature.");
  1133. lua_error(state);
  1134. }
  1135. break;
  1136. }
  1137. default:
  1138. {
  1139. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1140. lua_error(state);
  1141. break;
  1142. }
  1143. }
  1144. return 0;
  1145. }
  1146. int lua_Game_isGestureRegistered(lua_State* state)
  1147. {
  1148. // Get the number of parameters.
  1149. int paramCount = lua_gettop(state);
  1150. // Attempt to match the parameters to a valid binding.
  1151. switch (paramCount)
  1152. {
  1153. case 2:
  1154. {
  1155. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1156. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1157. {
  1158. // Get parameter 1 off the stack.
  1159. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1160. Game* instance = getInstance(state);
  1161. bool result = instance->isGestureRegistered(param1);
  1162. // Push the return value onto the stack.
  1163. lua_pushboolean(state, result);
  1164. return 1;
  1165. }
  1166. else
  1167. {
  1168. lua_pushstring(state, "lua_Game_isGestureRegistered - Failed to match the given parameters to a valid function signature.");
  1169. lua_error(state);
  1170. }
  1171. break;
  1172. }
  1173. default:
  1174. {
  1175. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1176. lua_error(state);
  1177. break;
  1178. }
  1179. }
  1180. return 0;
  1181. }
  1182. int lua_Game_isGestureSupported(lua_State* state)
  1183. {
  1184. // Get the number of parameters.
  1185. int paramCount = lua_gettop(state);
  1186. // Attempt to match the parameters to a valid binding.
  1187. switch (paramCount)
  1188. {
  1189. case 2:
  1190. {
  1191. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1192. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1193. {
  1194. // Get parameter 1 off the stack.
  1195. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1196. Game* instance = getInstance(state);
  1197. bool result = instance->isGestureSupported(param1);
  1198. // Push the return value onto the stack.
  1199. lua_pushboolean(state, result);
  1200. return 1;
  1201. }
  1202. else
  1203. {
  1204. lua_pushstring(state, "lua_Game_isGestureSupported - Failed to match the given parameters to a valid function signature.");
  1205. lua_error(state);
  1206. }
  1207. break;
  1208. }
  1209. default:
  1210. {
  1211. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1212. lua_error(state);
  1213. break;
  1214. }
  1215. }
  1216. return 0;
  1217. }
  1218. int lua_Game_isInitialized(lua_State* state)
  1219. {
  1220. // Get the number of parameters.
  1221. int paramCount = lua_gettop(state);
  1222. // Attempt to match the parameters to a valid binding.
  1223. switch (paramCount)
  1224. {
  1225. case 1:
  1226. {
  1227. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1228. {
  1229. Game* instance = getInstance(state);
  1230. bool result = instance->isInitialized();
  1231. // Push the return value onto the stack.
  1232. lua_pushboolean(state, result);
  1233. return 1;
  1234. }
  1235. else
  1236. {
  1237. lua_pushstring(state, "lua_Game_isInitialized - Failed to match the given parameters to a valid function signature.");
  1238. lua_error(state);
  1239. }
  1240. break;
  1241. }
  1242. default:
  1243. {
  1244. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1245. lua_error(state);
  1246. break;
  1247. }
  1248. }
  1249. return 0;
  1250. }
  1251. int lua_Game_isMouseCaptured(lua_State* state)
  1252. {
  1253. // Get the number of parameters.
  1254. int paramCount = lua_gettop(state);
  1255. // Attempt to match the parameters to a valid binding.
  1256. switch (paramCount)
  1257. {
  1258. case 1:
  1259. {
  1260. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1261. {
  1262. Game* instance = getInstance(state);
  1263. bool result = instance->isMouseCaptured();
  1264. // Push the return value onto the stack.
  1265. lua_pushboolean(state, result);
  1266. return 1;
  1267. }
  1268. else
  1269. {
  1270. lua_pushstring(state, "lua_Game_isMouseCaptured - Failed to match the given parameters to a valid function signature.");
  1271. lua_error(state);
  1272. }
  1273. break;
  1274. }
  1275. default:
  1276. {
  1277. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1278. lua_error(state);
  1279. break;
  1280. }
  1281. }
  1282. return 0;
  1283. }
  1284. int lua_Game_isMultiTouch(lua_State* state)
  1285. {
  1286. // Get the number of parameters.
  1287. int paramCount = lua_gettop(state);
  1288. // Attempt to match the parameters to a valid binding.
  1289. switch (paramCount)
  1290. {
  1291. case 1:
  1292. {
  1293. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1294. {
  1295. Game* instance = getInstance(state);
  1296. bool result = instance->isMultiTouch();
  1297. // Push the return value onto the stack.
  1298. lua_pushboolean(state, result);
  1299. return 1;
  1300. }
  1301. else
  1302. {
  1303. lua_pushstring(state, "lua_Game_isMultiTouch - Failed to match the given parameters to a valid function signature.");
  1304. lua_error(state);
  1305. }
  1306. break;
  1307. }
  1308. default:
  1309. {
  1310. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1311. lua_error(state);
  1312. break;
  1313. }
  1314. }
  1315. return 0;
  1316. }
  1317. int lua_Game_keyEvent(lua_State* state)
  1318. {
  1319. // Get the number of parameters.
  1320. int paramCount = lua_gettop(state);
  1321. // Attempt to match the parameters to a valid binding.
  1322. switch (paramCount)
  1323. {
  1324. case 3:
  1325. {
  1326. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1327. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1328. lua_type(state, 3) == LUA_TNUMBER)
  1329. {
  1330. // Get parameter 1 off the stack.
  1331. Keyboard::KeyEvent param1 = (Keyboard::KeyEvent)lua_enumFromString_KeyboardKeyEvent(luaL_checkstring(state, 2));
  1332. // Get parameter 2 off the stack.
  1333. int param2 = (int)luaL_checkint(state, 3);
  1334. Game* instance = getInstance(state);
  1335. instance->keyEvent(param1, param2);
  1336. return 0;
  1337. }
  1338. else
  1339. {
  1340. lua_pushstring(state, "lua_Game_keyEvent - Failed to match the given parameters to a valid function signature.");
  1341. lua_error(state);
  1342. }
  1343. break;
  1344. }
  1345. default:
  1346. {
  1347. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1348. lua_error(state);
  1349. break;
  1350. }
  1351. }
  1352. return 0;
  1353. }
  1354. int lua_Game_menuEvent(lua_State* state)
  1355. {
  1356. // Get the number of parameters.
  1357. int paramCount = lua_gettop(state);
  1358. // Attempt to match the parameters to a valid binding.
  1359. switch (paramCount)
  1360. {
  1361. case 1:
  1362. {
  1363. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1364. {
  1365. Game* instance = getInstance(state);
  1366. instance->menuEvent();
  1367. return 0;
  1368. }
  1369. else
  1370. {
  1371. lua_pushstring(state, "lua_Game_menuEvent - Failed to match the given parameters to a valid function signature.");
  1372. lua_error(state);
  1373. }
  1374. break;
  1375. }
  1376. default:
  1377. {
  1378. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1379. lua_error(state);
  1380. break;
  1381. }
  1382. }
  1383. return 0;
  1384. }
  1385. int lua_Game_mouseEvent(lua_State* state)
  1386. {
  1387. // Get the number of parameters.
  1388. int paramCount = lua_gettop(state);
  1389. // Attempt to match the parameters to a valid binding.
  1390. switch (paramCount)
  1391. {
  1392. case 5:
  1393. {
  1394. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1395. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1396. lua_type(state, 3) == LUA_TNUMBER &&
  1397. lua_type(state, 4) == LUA_TNUMBER &&
  1398. lua_type(state, 5) == LUA_TNUMBER)
  1399. {
  1400. // Get parameter 1 off the stack.
  1401. Mouse::MouseEvent param1 = (Mouse::MouseEvent)lua_enumFromString_MouseMouseEvent(luaL_checkstring(state, 2));
  1402. // Get parameter 2 off the stack.
  1403. int param2 = (int)luaL_checkint(state, 3);
  1404. // Get parameter 3 off the stack.
  1405. int param3 = (int)luaL_checkint(state, 4);
  1406. // Get parameter 4 off the stack.
  1407. int param4 = (int)luaL_checkint(state, 5);
  1408. Game* instance = getInstance(state);
  1409. bool result = instance->mouseEvent(param1, param2, param3, param4);
  1410. // Push the return value onto the stack.
  1411. lua_pushboolean(state, result);
  1412. return 1;
  1413. }
  1414. else
  1415. {
  1416. lua_pushstring(state, "lua_Game_mouseEvent - Failed to match the given parameters to a valid function signature.");
  1417. lua_error(state);
  1418. }
  1419. break;
  1420. }
  1421. default:
  1422. {
  1423. lua_pushstring(state, "Invalid number of parameters (expected 5).");
  1424. lua_error(state);
  1425. break;
  1426. }
  1427. }
  1428. return 0;
  1429. }
  1430. int lua_Game_pause(lua_State* state)
  1431. {
  1432. // Get the number of parameters.
  1433. int paramCount = lua_gettop(state);
  1434. // Attempt to match the parameters to a valid binding.
  1435. switch (paramCount)
  1436. {
  1437. case 1:
  1438. {
  1439. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1440. {
  1441. Game* instance = getInstance(state);
  1442. instance->pause();
  1443. return 0;
  1444. }
  1445. else
  1446. {
  1447. lua_pushstring(state, "lua_Game_pause - Failed to match the given parameters to a valid function signature.");
  1448. lua_error(state);
  1449. }
  1450. break;
  1451. }
  1452. default:
  1453. {
  1454. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1455. lua_error(state);
  1456. break;
  1457. }
  1458. }
  1459. return 0;
  1460. }
  1461. int lua_Game_registerGesture(lua_State* state)
  1462. {
  1463. // Get the number of parameters.
  1464. int paramCount = lua_gettop(state);
  1465. // Attempt to match the parameters to a valid binding.
  1466. switch (paramCount)
  1467. {
  1468. case 2:
  1469. {
  1470. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1471. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1472. {
  1473. // Get parameter 1 off the stack.
  1474. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1475. Game* instance = getInstance(state);
  1476. instance->registerGesture(param1);
  1477. return 0;
  1478. }
  1479. else
  1480. {
  1481. lua_pushstring(state, "lua_Game_registerGesture - Failed to match the given parameters to a valid function signature.");
  1482. lua_error(state);
  1483. }
  1484. break;
  1485. }
  1486. default:
  1487. {
  1488. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1489. lua_error(state);
  1490. break;
  1491. }
  1492. }
  1493. return 0;
  1494. }
  1495. int lua_Game_resume(lua_State* state)
  1496. {
  1497. // Get the number of parameters.
  1498. int paramCount = lua_gettop(state);
  1499. // Attempt to match the parameters to a valid binding.
  1500. switch (paramCount)
  1501. {
  1502. case 1:
  1503. {
  1504. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1505. {
  1506. Game* instance = getInstance(state);
  1507. instance->resume();
  1508. return 0;
  1509. }
  1510. else
  1511. {
  1512. lua_pushstring(state, "lua_Game_resume - Failed to match the given parameters to a valid function signature.");
  1513. lua_error(state);
  1514. }
  1515. break;
  1516. }
  1517. default:
  1518. {
  1519. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1520. lua_error(state);
  1521. break;
  1522. }
  1523. }
  1524. return 0;
  1525. }
  1526. int lua_Game_run(lua_State* state)
  1527. {
  1528. // Get the number of parameters.
  1529. int paramCount = lua_gettop(state);
  1530. // Attempt to match the parameters to a valid binding.
  1531. switch (paramCount)
  1532. {
  1533. case 1:
  1534. {
  1535. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1536. {
  1537. Game* instance = getInstance(state);
  1538. int result = instance->run();
  1539. // Push the return value onto the stack.
  1540. lua_pushinteger(state, result);
  1541. return 1;
  1542. }
  1543. else
  1544. {
  1545. lua_pushstring(state, "lua_Game_run - Failed to match the given parameters to a valid function signature.");
  1546. lua_error(state);
  1547. }
  1548. break;
  1549. }
  1550. default:
  1551. {
  1552. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1553. lua_error(state);
  1554. break;
  1555. }
  1556. }
  1557. return 0;
  1558. }
  1559. int lua_Game_schedule(lua_State* state)
  1560. {
  1561. // Get the number of parameters.
  1562. int paramCount = lua_gettop(state);
  1563. // Attempt to match the parameters to a valid binding.
  1564. switch (paramCount)
  1565. {
  1566. case 3:
  1567. {
  1568. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1569. lua_type(state, 2) == LUA_TNUMBER &&
  1570. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  1571. {
  1572. // Get parameter 1 off the stack.
  1573. float param1 = (float)luaL_checknumber(state, 2);
  1574. // Get parameter 2 off the stack.
  1575. ScriptUtil::LuaArray<const char> param2 = ScriptUtil::getString(3, false);
  1576. Game* instance = getInstance(state);
  1577. instance->schedule(param1, param2);
  1578. return 0;
  1579. }
  1580. else
  1581. {
  1582. lua_pushstring(state, "lua_Game_schedule - Failed to match the given parameters to a valid function signature.");
  1583. lua_error(state);
  1584. }
  1585. break;
  1586. }
  1587. default:
  1588. {
  1589. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1590. lua_error(state);
  1591. break;
  1592. }
  1593. }
  1594. return 0;
  1595. }
  1596. int lua_Game_setCursorVisible(lua_State* state)
  1597. {
  1598. // Get the number of parameters.
  1599. int paramCount = lua_gettop(state);
  1600. // Attempt to match the parameters to a valid binding.
  1601. switch (paramCount)
  1602. {
  1603. case 2:
  1604. {
  1605. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1606. lua_type(state, 2) == LUA_TBOOLEAN)
  1607. {
  1608. // Get parameter 1 off the stack.
  1609. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1610. Game* instance = getInstance(state);
  1611. instance->setCursorVisible(param1);
  1612. return 0;
  1613. }
  1614. else
  1615. {
  1616. lua_pushstring(state, "lua_Game_setCursorVisible - Failed to match the given parameters to a valid function signature.");
  1617. lua_error(state);
  1618. }
  1619. break;
  1620. }
  1621. default:
  1622. {
  1623. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1624. lua_error(state);
  1625. break;
  1626. }
  1627. }
  1628. return 0;
  1629. }
  1630. int lua_Game_setMouseCaptured(lua_State* state)
  1631. {
  1632. // Get the number of parameters.
  1633. int paramCount = lua_gettop(state);
  1634. // Attempt to match the parameters to a valid binding.
  1635. switch (paramCount)
  1636. {
  1637. case 2:
  1638. {
  1639. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1640. lua_type(state, 2) == LUA_TBOOLEAN)
  1641. {
  1642. // Get parameter 1 off the stack.
  1643. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1644. Game* instance = getInstance(state);
  1645. instance->setMouseCaptured(param1);
  1646. return 0;
  1647. }
  1648. else
  1649. {
  1650. lua_pushstring(state, "lua_Game_setMouseCaptured - Failed to match the given parameters to a valid function signature.");
  1651. lua_error(state);
  1652. }
  1653. break;
  1654. }
  1655. default:
  1656. {
  1657. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1658. lua_error(state);
  1659. break;
  1660. }
  1661. }
  1662. return 0;
  1663. }
  1664. int lua_Game_setMultiTouch(lua_State* state)
  1665. {
  1666. // Get the number of parameters.
  1667. int paramCount = lua_gettop(state);
  1668. // Attempt to match the parameters to a valid binding.
  1669. switch (paramCount)
  1670. {
  1671. case 2:
  1672. {
  1673. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1674. lua_type(state, 2) == LUA_TBOOLEAN)
  1675. {
  1676. // Get parameter 1 off the stack.
  1677. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1678. Game* instance = getInstance(state);
  1679. instance->setMultiTouch(param1);
  1680. return 0;
  1681. }
  1682. else
  1683. {
  1684. lua_pushstring(state, "lua_Game_setMultiTouch - Failed to match the given parameters to a valid function signature.");
  1685. lua_error(state);
  1686. }
  1687. break;
  1688. }
  1689. default:
  1690. {
  1691. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1692. lua_error(state);
  1693. break;
  1694. }
  1695. }
  1696. return 0;
  1697. }
  1698. int lua_Game_setViewport(lua_State* state)
  1699. {
  1700. // Get the number of parameters.
  1701. int paramCount = lua_gettop(state);
  1702. // Attempt to match the parameters to a valid binding.
  1703. switch (paramCount)
  1704. {
  1705. case 2:
  1706. {
  1707. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1708. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1709. {
  1710. // Get parameter 1 off the stack.
  1711. ScriptUtil::LuaArray<Rectangle> param1 = ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true);
  1712. Game* instance = getInstance(state);
  1713. instance->setViewport(*param1);
  1714. return 0;
  1715. }
  1716. else
  1717. {
  1718. lua_pushstring(state, "lua_Game_setViewport - Failed to match the given parameters to a valid function signature.");
  1719. lua_error(state);
  1720. }
  1721. break;
  1722. }
  1723. default:
  1724. {
  1725. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1726. lua_error(state);
  1727. break;
  1728. }
  1729. }
  1730. return 0;
  1731. }
  1732. int lua_Game_static_getAbsoluteTime(lua_State* state)
  1733. {
  1734. // Get the number of parameters.
  1735. int paramCount = lua_gettop(state);
  1736. // Attempt to match the parameters to a valid binding.
  1737. switch (paramCount)
  1738. {
  1739. case 0:
  1740. {
  1741. double result = Game::getAbsoluteTime();
  1742. // Push the return value onto the stack.
  1743. lua_pushnumber(state, result);
  1744. return 1;
  1745. break;
  1746. }
  1747. default:
  1748. {
  1749. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1750. lua_error(state);
  1751. break;
  1752. }
  1753. }
  1754. return 0;
  1755. }
  1756. int lua_Game_static_getGameTime(lua_State* state)
  1757. {
  1758. // Get the number of parameters.
  1759. int paramCount = lua_gettop(state);
  1760. // Attempt to match the parameters to a valid binding.
  1761. switch (paramCount)
  1762. {
  1763. case 0:
  1764. {
  1765. double result = Game::getGameTime();
  1766. // Push the return value onto the stack.
  1767. lua_pushnumber(state, result);
  1768. return 1;
  1769. break;
  1770. }
  1771. default:
  1772. {
  1773. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1774. lua_error(state);
  1775. break;
  1776. }
  1777. }
  1778. return 0;
  1779. }
  1780. int lua_Game_static_getInstance(lua_State* state)
  1781. {
  1782. // Get the number of parameters.
  1783. int paramCount = lua_gettop(state);
  1784. // Attempt to match the parameters to a valid binding.
  1785. switch (paramCount)
  1786. {
  1787. case 0:
  1788. {
  1789. void* returnPtr = (void*)Game::getInstance();
  1790. if (returnPtr)
  1791. {
  1792. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1793. object->instance = returnPtr;
  1794. object->owns = false;
  1795. luaL_getmetatable(state, "Game");
  1796. lua_setmetatable(state, -2);
  1797. }
  1798. else
  1799. {
  1800. lua_pushnil(state);
  1801. }
  1802. return 1;
  1803. break;
  1804. }
  1805. default:
  1806. {
  1807. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1808. lua_error(state);
  1809. break;
  1810. }
  1811. }
  1812. return 0;
  1813. }
  1814. int lua_Game_static_isVsync(lua_State* state)
  1815. {
  1816. // Get the number of parameters.
  1817. int paramCount = lua_gettop(state);
  1818. // Attempt to match the parameters to a valid binding.
  1819. switch (paramCount)
  1820. {
  1821. case 0:
  1822. {
  1823. bool result = Game::isVsync();
  1824. // Push the return value onto the stack.
  1825. lua_pushboolean(state, result);
  1826. return 1;
  1827. break;
  1828. }
  1829. default:
  1830. {
  1831. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1832. lua_error(state);
  1833. break;
  1834. }
  1835. }
  1836. return 0;
  1837. }
  1838. int lua_Game_static_setVsync(lua_State* state)
  1839. {
  1840. // Get the number of parameters.
  1841. int paramCount = lua_gettop(state);
  1842. // Attempt to match the parameters to a valid binding.
  1843. switch (paramCount)
  1844. {
  1845. case 1:
  1846. {
  1847. if (lua_type(state, 1) == LUA_TBOOLEAN)
  1848. {
  1849. // Get parameter 1 off the stack.
  1850. bool param1 = ScriptUtil::luaCheckBool(state, 1);
  1851. Game::setVsync(param1);
  1852. return 0;
  1853. }
  1854. else
  1855. {
  1856. lua_pushstring(state, "lua_Game_static_setVsync - Failed to match the given parameters to a valid function signature.");
  1857. lua_error(state);
  1858. }
  1859. break;
  1860. }
  1861. default:
  1862. {
  1863. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1864. lua_error(state);
  1865. break;
  1866. }
  1867. }
  1868. return 0;
  1869. }
  1870. int lua_Game_touchEvent(lua_State* state)
  1871. {
  1872. // Get the number of parameters.
  1873. int paramCount = lua_gettop(state);
  1874. // Attempt to match the parameters to a valid binding.
  1875. switch (paramCount)
  1876. {
  1877. case 5:
  1878. {
  1879. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1880. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1881. lua_type(state, 3) == LUA_TNUMBER &&
  1882. lua_type(state, 4) == LUA_TNUMBER &&
  1883. lua_type(state, 5) == LUA_TNUMBER)
  1884. {
  1885. // Get parameter 1 off the stack.
  1886. Touch::TouchEvent param1 = (Touch::TouchEvent)lua_enumFromString_TouchTouchEvent(luaL_checkstring(state, 2));
  1887. // Get parameter 2 off the stack.
  1888. int param2 = (int)luaL_checkint(state, 3);
  1889. // Get parameter 3 off the stack.
  1890. int param3 = (int)luaL_checkint(state, 4);
  1891. // Get parameter 4 off the stack.
  1892. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  1893. Game* instance = getInstance(state);
  1894. instance->touchEvent(param1, param2, param3, param4);
  1895. return 0;
  1896. }
  1897. else
  1898. {
  1899. lua_pushstring(state, "lua_Game_touchEvent - Failed to match the given parameters to a valid function signature.");
  1900. lua_error(state);
  1901. }
  1902. break;
  1903. }
  1904. default:
  1905. {
  1906. lua_pushstring(state, "Invalid number of parameters (expected 5).");
  1907. lua_error(state);
  1908. break;
  1909. }
  1910. }
  1911. return 0;
  1912. }
  1913. int lua_Game_unregisterGesture(lua_State* state)
  1914. {
  1915. // Get the number of parameters.
  1916. int paramCount = lua_gettop(state);
  1917. // Attempt to match the parameters to a valid binding.
  1918. switch (paramCount)
  1919. {
  1920. case 2:
  1921. {
  1922. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1923. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1924. {
  1925. // Get parameter 1 off the stack.
  1926. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1927. Game* instance = getInstance(state);
  1928. instance->unregisterGesture(param1);
  1929. return 0;
  1930. }
  1931. else
  1932. {
  1933. lua_pushstring(state, "lua_Game_unregisterGesture - Failed to match the given parameters to a valid function signature.");
  1934. lua_error(state);
  1935. }
  1936. break;
  1937. }
  1938. default:
  1939. {
  1940. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1941. lua_error(state);
  1942. break;
  1943. }
  1944. }
  1945. return 0;
  1946. }
  1947. }