lua_Game.cpp 53 KB

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