lua_Game.cpp 71 KB

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