lua_Game.cpp 63 KB

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