lua_Game.cpp 67 KB

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