lua_Game.cpp 72 KB

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