2
0

lua_Game.cpp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167
  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. {"getGamepadsConnected", lua_Game_getGamepadsConnected},
  44. {"getHeight", lua_Game_getHeight},
  45. {"getPhysicsController", lua_Game_getPhysicsController},
  46. {"getScriptController", lua_Game_getScriptController},
  47. {"getState", lua_Game_getState},
  48. {"getViewport", lua_Game_getViewport},
  49. {"getWidth", lua_Game_getWidth},
  50. {"hasMouse", lua_Game_hasMouse},
  51. {"isCursorVisible", lua_Game_isCursorVisible},
  52. {"isGestureRegistered", lua_Game_isGestureRegistered},
  53. {"isGestureSupported", lua_Game_isGestureSupported},
  54. {"isInitialized", lua_Game_isInitialized},
  55. {"isMouseCaptured", lua_Game_isMouseCaptured},
  56. {"isMultiTouch", lua_Game_isMultiTouch},
  57. {"keyEvent", lua_Game_keyEvent},
  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. default:
  801. {
  802. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  803. lua_error(state);
  804. break;
  805. }
  806. }
  807. return 0;
  808. }
  809. int lua_Game_getGamepadCount(lua_State* state)
  810. {
  811. // Get the number of parameters.
  812. int paramCount = lua_gettop(state);
  813. // Attempt to match the parameters to a valid binding.
  814. switch (paramCount)
  815. {
  816. case 1:
  817. {
  818. if ((lua_type(state, 1) == LUA_TUSERDATA))
  819. {
  820. Game* instance = getInstance(state);
  821. unsigned int result = instance->getGamepadCount();
  822. // Push the return value onto the stack.
  823. lua_pushunsigned(state, result);
  824. return 1;
  825. }
  826. lua_pushstring(state, "lua_Game_getGamepadCount - 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 1).");
  833. lua_error(state);
  834. break;
  835. }
  836. }
  837. return 0;
  838. }
  839. int lua_Game_getGamepadsConnected(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->getGamepadsConnected();
  852. // Push the return value onto the stack.
  853. lua_pushunsigned(state, result);
  854. return 1;
  855. }
  856. lua_pushstring(state, "lua_Game_getGamepadsConnected - 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_menuEvent(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 1:
  1337. {
  1338. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1339. {
  1340. Game* instance = getInstance(state);
  1341. instance->menuEvent();
  1342. return 0;
  1343. }
  1344. lua_pushstring(state, "lua_Game_menuEvent - Failed to match the given parameters to a valid function signature.");
  1345. lua_error(state);
  1346. break;
  1347. }
  1348. default:
  1349. {
  1350. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1351. lua_error(state);
  1352. break;
  1353. }
  1354. }
  1355. return 0;
  1356. }
  1357. int lua_Game_mouseEvent(lua_State* state)
  1358. {
  1359. // Get the number of parameters.
  1360. int paramCount = lua_gettop(state);
  1361. // Attempt to match the parameters to a valid binding.
  1362. switch (paramCount)
  1363. {
  1364. case 5:
  1365. {
  1366. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1367. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1368. lua_type(state, 3) == LUA_TNUMBER &&
  1369. lua_type(state, 4) == LUA_TNUMBER &&
  1370. lua_type(state, 5) == LUA_TNUMBER)
  1371. {
  1372. // Get parameter 1 off the stack.
  1373. Mouse::MouseEvent param1 = (Mouse::MouseEvent)lua_enumFromString_MouseMouseEvent(luaL_checkstring(state, 2));
  1374. // Get parameter 2 off the stack.
  1375. int param2 = (int)luaL_checkint(state, 3);
  1376. // Get parameter 3 off the stack.
  1377. int param3 = (int)luaL_checkint(state, 4);
  1378. // Get parameter 4 off the stack.
  1379. int param4 = (int)luaL_checkint(state, 5);
  1380. Game* instance = getInstance(state);
  1381. bool result = instance->mouseEvent(param1, param2, param3, param4);
  1382. // Push the return value onto the stack.
  1383. lua_pushboolean(state, result);
  1384. return 1;
  1385. }
  1386. lua_pushstring(state, "lua_Game_mouseEvent - Failed to match the given parameters to a valid function signature.");
  1387. lua_error(state);
  1388. break;
  1389. }
  1390. default:
  1391. {
  1392. lua_pushstring(state, "Invalid number of parameters (expected 5).");
  1393. lua_error(state);
  1394. break;
  1395. }
  1396. }
  1397. return 0;
  1398. }
  1399. int lua_Game_pause(lua_State* state)
  1400. {
  1401. // Get the number of parameters.
  1402. int paramCount = lua_gettop(state);
  1403. // Attempt to match the parameters to a valid binding.
  1404. switch (paramCount)
  1405. {
  1406. case 1:
  1407. {
  1408. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1409. {
  1410. Game* instance = getInstance(state);
  1411. instance->pause();
  1412. return 0;
  1413. }
  1414. lua_pushstring(state, "lua_Game_pause - Failed to match the given parameters to a valid function signature.");
  1415. lua_error(state);
  1416. break;
  1417. }
  1418. default:
  1419. {
  1420. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1421. lua_error(state);
  1422. break;
  1423. }
  1424. }
  1425. return 0;
  1426. }
  1427. int lua_Game_registerGesture(lua_State* state)
  1428. {
  1429. // Get the number of parameters.
  1430. int paramCount = lua_gettop(state);
  1431. // Attempt to match the parameters to a valid binding.
  1432. switch (paramCount)
  1433. {
  1434. case 2:
  1435. {
  1436. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1437. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1438. {
  1439. // Get parameter 1 off the stack.
  1440. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1441. Game* instance = getInstance(state);
  1442. instance->registerGesture(param1);
  1443. return 0;
  1444. }
  1445. lua_pushstring(state, "lua_Game_registerGesture - Failed to match the given parameters to a valid function signature.");
  1446. lua_error(state);
  1447. break;
  1448. }
  1449. default:
  1450. {
  1451. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1452. lua_error(state);
  1453. break;
  1454. }
  1455. }
  1456. return 0;
  1457. }
  1458. int lua_Game_resume(lua_State* state)
  1459. {
  1460. // Get the number of parameters.
  1461. int paramCount = lua_gettop(state);
  1462. // Attempt to match the parameters to a valid binding.
  1463. switch (paramCount)
  1464. {
  1465. case 1:
  1466. {
  1467. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1468. {
  1469. Game* instance = getInstance(state);
  1470. instance->resume();
  1471. return 0;
  1472. }
  1473. lua_pushstring(state, "lua_Game_resume - Failed to match the given parameters to a valid function signature.");
  1474. lua_error(state);
  1475. break;
  1476. }
  1477. default:
  1478. {
  1479. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1480. lua_error(state);
  1481. break;
  1482. }
  1483. }
  1484. return 0;
  1485. }
  1486. int lua_Game_run(lua_State* state)
  1487. {
  1488. // Get the number of parameters.
  1489. int paramCount = lua_gettop(state);
  1490. // Attempt to match the parameters to a valid binding.
  1491. switch (paramCount)
  1492. {
  1493. case 1:
  1494. {
  1495. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1496. {
  1497. Game* instance = getInstance(state);
  1498. int result = instance->run();
  1499. // Push the return value onto the stack.
  1500. lua_pushinteger(state, result);
  1501. return 1;
  1502. }
  1503. lua_pushstring(state, "lua_Game_run - Failed to match the given parameters to a valid function signature.");
  1504. lua_error(state);
  1505. break;
  1506. }
  1507. default:
  1508. {
  1509. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1510. lua_error(state);
  1511. break;
  1512. }
  1513. }
  1514. return 0;
  1515. }
  1516. int lua_Game_schedule(lua_State* state)
  1517. {
  1518. // Get the number of parameters.
  1519. int paramCount = lua_gettop(state);
  1520. // Attempt to match the parameters to a valid binding.
  1521. switch (paramCount)
  1522. {
  1523. case 3:
  1524. {
  1525. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1526. lua_type(state, 2) == LUA_TNUMBER &&
  1527. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  1528. {
  1529. // Get parameter 1 off the stack.
  1530. float param1 = (float)luaL_checknumber(state, 2);
  1531. // Get parameter 2 off the stack.
  1532. ScriptUtil::LuaArray<const char> param2 = ScriptUtil::getString(3, false);
  1533. Game* instance = getInstance(state);
  1534. instance->schedule(param1, param2);
  1535. return 0;
  1536. }
  1537. lua_pushstring(state, "lua_Game_schedule - Failed to match the given parameters to a valid function signature.");
  1538. lua_error(state);
  1539. break;
  1540. }
  1541. default:
  1542. {
  1543. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1544. lua_error(state);
  1545. break;
  1546. }
  1547. }
  1548. return 0;
  1549. }
  1550. int lua_Game_setCursorVisible(lua_State* state)
  1551. {
  1552. // Get the number of parameters.
  1553. int paramCount = lua_gettop(state);
  1554. // Attempt to match the parameters to a valid binding.
  1555. switch (paramCount)
  1556. {
  1557. case 2:
  1558. {
  1559. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1560. lua_type(state, 2) == LUA_TBOOLEAN)
  1561. {
  1562. // Get parameter 1 off the stack.
  1563. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1564. Game* instance = getInstance(state);
  1565. instance->setCursorVisible(param1);
  1566. return 0;
  1567. }
  1568. lua_pushstring(state, "lua_Game_setCursorVisible - Failed to match the given parameters to a valid function signature.");
  1569. lua_error(state);
  1570. break;
  1571. }
  1572. default:
  1573. {
  1574. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1575. lua_error(state);
  1576. break;
  1577. }
  1578. }
  1579. return 0;
  1580. }
  1581. int lua_Game_setMouseCaptured(lua_State* state)
  1582. {
  1583. // Get the number of parameters.
  1584. int paramCount = lua_gettop(state);
  1585. // Attempt to match the parameters to a valid binding.
  1586. switch (paramCount)
  1587. {
  1588. case 2:
  1589. {
  1590. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1591. lua_type(state, 2) == LUA_TBOOLEAN)
  1592. {
  1593. // Get parameter 1 off the stack.
  1594. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1595. Game* instance = getInstance(state);
  1596. instance->setMouseCaptured(param1);
  1597. return 0;
  1598. }
  1599. lua_pushstring(state, "lua_Game_setMouseCaptured - Failed to match the given parameters to a valid function signature.");
  1600. lua_error(state);
  1601. break;
  1602. }
  1603. default:
  1604. {
  1605. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1606. lua_error(state);
  1607. break;
  1608. }
  1609. }
  1610. return 0;
  1611. }
  1612. int lua_Game_setMultiTouch(lua_State* state)
  1613. {
  1614. // Get the number of parameters.
  1615. int paramCount = lua_gettop(state);
  1616. // Attempt to match the parameters to a valid binding.
  1617. switch (paramCount)
  1618. {
  1619. case 2:
  1620. {
  1621. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1622. lua_type(state, 2) == LUA_TBOOLEAN)
  1623. {
  1624. // Get parameter 1 off the stack.
  1625. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1626. Game* instance = getInstance(state);
  1627. instance->setMultiTouch(param1);
  1628. return 0;
  1629. }
  1630. lua_pushstring(state, "lua_Game_setMultiTouch - Failed to match the given parameters to a valid function signature.");
  1631. lua_error(state);
  1632. break;
  1633. }
  1634. default:
  1635. {
  1636. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1637. lua_error(state);
  1638. break;
  1639. }
  1640. }
  1641. return 0;
  1642. }
  1643. int lua_Game_setViewport(lua_State* state)
  1644. {
  1645. // Get the number of parameters.
  1646. int paramCount = lua_gettop(state);
  1647. // Attempt to match the parameters to a valid binding.
  1648. switch (paramCount)
  1649. {
  1650. case 2:
  1651. {
  1652. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1653. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1654. {
  1655. // Get parameter 1 off the stack.
  1656. bool param1Valid;
  1657. ScriptUtil::LuaArray<Rectangle> param1 = ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true, &param1Valid);
  1658. if (!param1Valid)
  1659. {
  1660. lua_pushstring(state, "Failed to convert parameter 1 to type 'Rectangle'.");
  1661. lua_error(state);
  1662. }
  1663. Game* instance = getInstance(state);
  1664. instance->setViewport(*param1);
  1665. return 0;
  1666. }
  1667. lua_pushstring(state, "lua_Game_setViewport - Failed to match the given parameters to a valid function signature.");
  1668. lua_error(state);
  1669. break;
  1670. }
  1671. default:
  1672. {
  1673. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1674. lua_error(state);
  1675. break;
  1676. }
  1677. }
  1678. return 0;
  1679. }
  1680. int lua_Game_static_getAbsoluteTime(lua_State* state)
  1681. {
  1682. // Get the number of parameters.
  1683. int paramCount = lua_gettop(state);
  1684. // Attempt to match the parameters to a valid binding.
  1685. switch (paramCount)
  1686. {
  1687. case 0:
  1688. {
  1689. double result = Game::getAbsoluteTime();
  1690. // Push the return value onto the stack.
  1691. lua_pushnumber(state, result);
  1692. return 1;
  1693. break;
  1694. }
  1695. default:
  1696. {
  1697. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1698. lua_error(state);
  1699. break;
  1700. }
  1701. }
  1702. return 0;
  1703. }
  1704. int lua_Game_static_getGameTime(lua_State* state)
  1705. {
  1706. // Get the number of parameters.
  1707. int paramCount = lua_gettop(state);
  1708. // Attempt to match the parameters to a valid binding.
  1709. switch (paramCount)
  1710. {
  1711. case 0:
  1712. {
  1713. double result = Game::getGameTime();
  1714. // Push the return value onto the stack.
  1715. lua_pushnumber(state, result);
  1716. return 1;
  1717. break;
  1718. }
  1719. default:
  1720. {
  1721. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1722. lua_error(state);
  1723. break;
  1724. }
  1725. }
  1726. return 0;
  1727. }
  1728. int lua_Game_static_getInstance(lua_State* state)
  1729. {
  1730. // Get the number of parameters.
  1731. int paramCount = lua_gettop(state);
  1732. // Attempt to match the parameters to a valid binding.
  1733. switch (paramCount)
  1734. {
  1735. case 0:
  1736. {
  1737. void* returnPtr = (void*)Game::getInstance();
  1738. if (returnPtr)
  1739. {
  1740. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1741. object->instance = returnPtr;
  1742. object->owns = false;
  1743. luaL_getmetatable(state, "Game");
  1744. lua_setmetatable(state, -2);
  1745. }
  1746. else
  1747. {
  1748. lua_pushnil(state);
  1749. }
  1750. return 1;
  1751. break;
  1752. }
  1753. default:
  1754. {
  1755. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1756. lua_error(state);
  1757. break;
  1758. }
  1759. }
  1760. return 0;
  1761. }
  1762. int lua_Game_static_isVsync(lua_State* state)
  1763. {
  1764. // Get the number of parameters.
  1765. int paramCount = lua_gettop(state);
  1766. // Attempt to match the parameters to a valid binding.
  1767. switch (paramCount)
  1768. {
  1769. case 0:
  1770. {
  1771. bool result = Game::isVsync();
  1772. // Push the return value onto the stack.
  1773. lua_pushboolean(state, result);
  1774. return 1;
  1775. break;
  1776. }
  1777. default:
  1778. {
  1779. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1780. lua_error(state);
  1781. break;
  1782. }
  1783. }
  1784. return 0;
  1785. }
  1786. int lua_Game_static_setVsync(lua_State* state)
  1787. {
  1788. // Get the number of parameters.
  1789. int paramCount = lua_gettop(state);
  1790. // Attempt to match the parameters to a valid binding.
  1791. switch (paramCount)
  1792. {
  1793. case 1:
  1794. {
  1795. if (lua_type(state, 1) == LUA_TBOOLEAN)
  1796. {
  1797. // Get parameter 1 off the stack.
  1798. bool param1 = ScriptUtil::luaCheckBool(state, 1);
  1799. Game::setVsync(param1);
  1800. return 0;
  1801. }
  1802. lua_pushstring(state, "lua_Game_static_setVsync - Failed to match the given parameters to a valid function signature.");
  1803. lua_error(state);
  1804. break;
  1805. }
  1806. default:
  1807. {
  1808. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1809. lua_error(state);
  1810. break;
  1811. }
  1812. }
  1813. return 0;
  1814. }
  1815. int lua_Game_touchEvent(lua_State* state)
  1816. {
  1817. // Get the number of parameters.
  1818. int paramCount = lua_gettop(state);
  1819. // Attempt to match the parameters to a valid binding.
  1820. switch (paramCount)
  1821. {
  1822. case 5:
  1823. {
  1824. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1825. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1826. lua_type(state, 3) == LUA_TNUMBER &&
  1827. lua_type(state, 4) == LUA_TNUMBER &&
  1828. lua_type(state, 5) == LUA_TNUMBER)
  1829. {
  1830. // Get parameter 1 off the stack.
  1831. Touch::TouchEvent param1 = (Touch::TouchEvent)lua_enumFromString_TouchTouchEvent(luaL_checkstring(state, 2));
  1832. // Get parameter 2 off the stack.
  1833. int param2 = (int)luaL_checkint(state, 3);
  1834. // Get parameter 3 off the stack.
  1835. int param3 = (int)luaL_checkint(state, 4);
  1836. // Get parameter 4 off the stack.
  1837. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  1838. Game* instance = getInstance(state);
  1839. instance->touchEvent(param1, param2, param3, param4);
  1840. return 0;
  1841. }
  1842. lua_pushstring(state, "lua_Game_touchEvent - Failed to match the given parameters to a valid function signature.");
  1843. lua_error(state);
  1844. break;
  1845. }
  1846. default:
  1847. {
  1848. lua_pushstring(state, "Invalid number of parameters (expected 5).");
  1849. lua_error(state);
  1850. break;
  1851. }
  1852. }
  1853. return 0;
  1854. }
  1855. int lua_Game_unregisterGesture(lua_State* state)
  1856. {
  1857. // Get the number of parameters.
  1858. int paramCount = lua_gettop(state);
  1859. // Attempt to match the parameters to a valid binding.
  1860. switch (paramCount)
  1861. {
  1862. case 2:
  1863. {
  1864. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1865. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1866. {
  1867. // Get parameter 1 off the stack.
  1868. Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
  1869. Game* instance = getInstance(state);
  1870. instance->unregisterGesture(param1);
  1871. return 0;
  1872. }
  1873. lua_pushstring(state, "lua_Game_unregisterGesture - Failed to match the given parameters to a valid function signature.");
  1874. lua_error(state);
  1875. break;
  1876. }
  1877. default:
  1878. {
  1879. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1880. lua_error(state);
  1881. break;
  1882. }
  1883. }
  1884. return 0;
  1885. }
  1886. }