lua_Font.cpp 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "Font.h"
  4. #include "lua_Font.h"
  5. #include "lua_Global.h"
  6. namespace gameplay
  7. {
  8. void luaRegister_Font()
  9. {
  10. ScriptController* sc = ScriptController::getInstance();
  11. const luaL_Reg lua_members[] =
  12. {
  13. {"addRef", lua_Font_addRef},
  14. {"begin", lua_Font_begin},
  15. {"createText", lua_Font_createText},
  16. {"drawText", lua_Font_drawText},
  17. {"finish", lua_Font_finish},
  18. {"getIndexAtLocation", lua_Font_getIndexAtLocation},
  19. {"getLocationAtIndex", lua_Font_getLocationAtIndex},
  20. {"getRefCount", lua_Font_getRefCount},
  21. {"getSize", lua_Font_getSize},
  22. {"getSpriteBatch", lua_Font_getSpriteBatch},
  23. {"measureText", lua_Font_measureText},
  24. {"release", lua_Font_release},
  25. {NULL, NULL}
  26. };
  27. const luaL_Reg lua_statics[] =
  28. {
  29. {"create", lua_Font_static_create},
  30. {"getJustify", lua_Font_static_getJustify},
  31. {NULL, NULL}
  32. };
  33. std::vector<std::string> scopePath;
  34. sc->registerClass("Font", lua_members, NULL, lua_Font__gc, lua_statics, scopePath);
  35. }
  36. static Font* getInstance(lua_State* state)
  37. {
  38. void* userdata = luaL_checkudata(state, 1, "Font");
  39. luaL_argcheck(state, userdata != NULL, 1, "'Font' expected.");
  40. return (Font*)((ScriptController::LuaObject*)userdata)->instance;
  41. }
  42. int lua_Font__gc(lua_State* state)
  43. {
  44. // Get the number of parameters.
  45. int paramCount = lua_gettop(state);
  46. // Attempt to match the parameters to a valid binding.
  47. switch (paramCount)
  48. {
  49. case 1:
  50. {
  51. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  52. {
  53. void* userdata = luaL_checkudata(state, 1, "Font");
  54. luaL_argcheck(state, userdata != NULL, 1, "'Font' expected.");
  55. ScriptController::LuaObject* object = (ScriptController::LuaObject*)userdata;
  56. if (object->owns)
  57. {
  58. Font* instance = (Font*)object->instance;
  59. SAFE_RELEASE(instance);
  60. }
  61. return 0;
  62. }
  63. else
  64. {
  65. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  66. lua_error(state);
  67. }
  68. break;
  69. }
  70. default:
  71. {
  72. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  73. lua_error(state);
  74. break;
  75. }
  76. }
  77. return 0;
  78. }
  79. int lua_Font_addRef(lua_State* state)
  80. {
  81. // Get the number of parameters.
  82. int paramCount = lua_gettop(state);
  83. // Attempt to match the parameters to a valid binding.
  84. switch (paramCount)
  85. {
  86. case 1:
  87. {
  88. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  89. {
  90. Font* instance = getInstance(state);
  91. instance->addRef();
  92. return 0;
  93. }
  94. else
  95. {
  96. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  97. lua_error(state);
  98. }
  99. break;
  100. }
  101. default:
  102. {
  103. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  104. lua_error(state);
  105. break;
  106. }
  107. }
  108. return 0;
  109. }
  110. int lua_Font_begin(lua_State* state)
  111. {
  112. // Get the number of parameters.
  113. int paramCount = lua_gettop(state);
  114. // Attempt to match the parameters to a valid binding.
  115. switch (paramCount)
  116. {
  117. case 1:
  118. {
  119. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  120. {
  121. Font* instance = getInstance(state);
  122. instance->begin();
  123. return 0;
  124. }
  125. else
  126. {
  127. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  128. lua_error(state);
  129. }
  130. break;
  131. }
  132. default:
  133. {
  134. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  135. lua_error(state);
  136. break;
  137. }
  138. }
  139. return 0;
  140. }
  141. int lua_Font_createText(lua_State* state)
  142. {
  143. // Get the number of parameters.
  144. int paramCount = lua_gettop(state);
  145. // Attempt to match the parameters to a valid binding.
  146. switch (paramCount)
  147. {
  148. case 4:
  149. {
  150. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  151. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  152. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  153. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  154. {
  155. // Get parameter 1 off the stack.
  156. const char* param1 = ScriptController::getInstance()->getString(2, false);
  157. // Get parameter 2 off the stack.
  158. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  159. // Get parameter 3 off the stack.
  160. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  161. Font* instance = getInstance(state);
  162. void* returnPtr = (void*)instance->createText(param1, *param2, *param3);
  163. if (returnPtr)
  164. {
  165. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  166. object->instance = returnPtr;
  167. object->owns = false;
  168. luaL_getmetatable(state, "FontText");
  169. lua_setmetatable(state, -2);
  170. }
  171. else
  172. {
  173. lua_pushnil(state);
  174. }
  175. return 1;
  176. }
  177. else
  178. {
  179. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  180. lua_error(state);
  181. }
  182. break;
  183. }
  184. case 5:
  185. {
  186. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  187. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  188. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  189. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  190. lua_type(state, 5) == LUA_TNUMBER)
  191. {
  192. // Get parameter 1 off the stack.
  193. const char* param1 = ScriptController::getInstance()->getString(2, false);
  194. // Get parameter 2 off the stack.
  195. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  196. // Get parameter 3 off the stack.
  197. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  198. // Get parameter 4 off the stack.
  199. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  200. Font* instance = getInstance(state);
  201. void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4);
  202. if (returnPtr)
  203. {
  204. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  205. object->instance = returnPtr;
  206. object->owns = false;
  207. luaL_getmetatable(state, "FontText");
  208. lua_setmetatable(state, -2);
  209. }
  210. else
  211. {
  212. lua_pushnil(state);
  213. }
  214. return 1;
  215. }
  216. else
  217. {
  218. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  219. lua_error(state);
  220. }
  221. break;
  222. }
  223. case 6:
  224. {
  225. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  226. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  227. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  228. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  229. lua_type(state, 5) == LUA_TNUMBER &&
  230. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL))
  231. {
  232. // Get parameter 1 off the stack.
  233. const char* param1 = ScriptController::getInstance()->getString(2, false);
  234. // Get parameter 2 off the stack.
  235. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  236. // Get parameter 3 off the stack.
  237. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  238. // Get parameter 4 off the stack.
  239. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  240. // Get parameter 5 off the stack.
  241. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  242. Font* instance = getInstance(state);
  243. void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5);
  244. if (returnPtr)
  245. {
  246. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  247. object->instance = returnPtr;
  248. object->owns = false;
  249. luaL_getmetatable(state, "FontText");
  250. lua_setmetatable(state, -2);
  251. }
  252. else
  253. {
  254. lua_pushnil(state);
  255. }
  256. return 1;
  257. }
  258. else
  259. {
  260. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  261. lua_error(state);
  262. }
  263. break;
  264. }
  265. case 7:
  266. {
  267. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  268. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  269. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  270. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  271. lua_type(state, 5) == LUA_TNUMBER &&
  272. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  273. lua_type(state, 7) == LUA_TBOOLEAN)
  274. {
  275. // Get parameter 1 off the stack.
  276. const char* param1 = ScriptController::getInstance()->getString(2, false);
  277. // Get parameter 2 off the stack.
  278. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  279. // Get parameter 3 off the stack.
  280. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  281. // Get parameter 4 off the stack.
  282. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  283. // Get parameter 5 off the stack.
  284. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  285. // Get parameter 6 off the stack.
  286. bool param6 = ScriptController::luaCheckBool(state, 7);
  287. Font* instance = getInstance(state);
  288. void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6);
  289. if (returnPtr)
  290. {
  291. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  292. object->instance = returnPtr;
  293. object->owns = false;
  294. luaL_getmetatable(state, "FontText");
  295. lua_setmetatable(state, -2);
  296. }
  297. else
  298. {
  299. lua_pushnil(state);
  300. }
  301. return 1;
  302. }
  303. else
  304. {
  305. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  306. lua_error(state);
  307. }
  308. break;
  309. }
  310. case 8:
  311. {
  312. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  313. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  314. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  315. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  316. lua_type(state, 5) == LUA_TNUMBER &&
  317. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  318. lua_type(state, 7) == LUA_TBOOLEAN &&
  319. lua_type(state, 8) == LUA_TBOOLEAN)
  320. {
  321. // Get parameter 1 off the stack.
  322. const char* param1 = ScriptController::getInstance()->getString(2, false);
  323. // Get parameter 2 off the stack.
  324. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  325. // Get parameter 3 off the stack.
  326. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  327. // Get parameter 4 off the stack.
  328. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  329. // Get parameter 5 off the stack.
  330. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  331. // Get parameter 6 off the stack.
  332. bool param6 = ScriptController::luaCheckBool(state, 7);
  333. // Get parameter 7 off the stack.
  334. bool param7 = ScriptController::luaCheckBool(state, 8);
  335. Font* instance = getInstance(state);
  336. void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6, param7);
  337. if (returnPtr)
  338. {
  339. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  340. object->instance = returnPtr;
  341. object->owns = false;
  342. luaL_getmetatable(state, "FontText");
  343. lua_setmetatable(state, -2);
  344. }
  345. else
  346. {
  347. lua_pushnil(state);
  348. }
  349. return 1;
  350. }
  351. else
  352. {
  353. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  354. lua_error(state);
  355. }
  356. break;
  357. }
  358. case 9:
  359. {
  360. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  361. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  362. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  363. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  364. lua_type(state, 5) == LUA_TNUMBER &&
  365. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  366. lua_type(state, 7) == LUA_TBOOLEAN &&
  367. lua_type(state, 8) == LUA_TBOOLEAN &&
  368. (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL))
  369. {
  370. // Get parameter 1 off the stack.
  371. const char* param1 = ScriptController::getInstance()->getString(2, false);
  372. // Get parameter 2 off the stack.
  373. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  374. // Get parameter 3 off the stack.
  375. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  376. // Get parameter 4 off the stack.
  377. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  378. // Get parameter 5 off the stack.
  379. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  380. // Get parameter 6 off the stack.
  381. bool param6 = ScriptController::luaCheckBool(state, 7);
  382. // Get parameter 7 off the stack.
  383. bool param7 = ScriptController::luaCheckBool(state, 8);
  384. // Get parameter 8 off the stack.
  385. Rectangle* param8 = ScriptController::getInstance()->getObjectPointer<Rectangle>(9, "Rectangle", false);
  386. Font* instance = getInstance(state);
  387. void* returnPtr = (void*)instance->createText(param1, *param2, *param3, param4, param5, param6, param7, param8);
  388. if (returnPtr)
  389. {
  390. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  391. object->instance = returnPtr;
  392. object->owns = false;
  393. luaL_getmetatable(state, "FontText");
  394. lua_setmetatable(state, -2);
  395. }
  396. else
  397. {
  398. lua_pushnil(state);
  399. }
  400. return 1;
  401. }
  402. else
  403. {
  404. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  405. lua_error(state);
  406. }
  407. break;
  408. }
  409. default:
  410. {
  411. lua_pushstring(state, "Invalid number of parameters (expected 4, 5, 6, 7, 8 or 9).");
  412. lua_error(state);
  413. break;
  414. }
  415. }
  416. return 0;
  417. }
  418. int lua_Font_drawText(lua_State* state)
  419. {
  420. // Get the number of parameters.
  421. int paramCount = lua_gettop(state);
  422. // Attempt to match the parameters to a valid binding.
  423. switch (paramCount)
  424. {
  425. case 2:
  426. {
  427. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  428. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  429. {
  430. // Get parameter 1 off the stack.
  431. Font::Text* param1 = ScriptController::getInstance()->getObjectPointer<Font::Text>(2, "FontText", false);
  432. Font* instance = getInstance(state);
  433. instance->drawText(param1);
  434. return 0;
  435. }
  436. else
  437. {
  438. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  439. lua_error(state);
  440. }
  441. break;
  442. }
  443. case 4:
  444. {
  445. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  446. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  447. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  448. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  449. {
  450. // Get parameter 1 off the stack.
  451. const char* param1 = ScriptController::getInstance()->getString(2, false);
  452. // Get parameter 2 off the stack.
  453. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  454. // Get parameter 3 off the stack.
  455. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  456. Font* instance = getInstance(state);
  457. instance->drawText(param1, *param2, *param3);
  458. return 0;
  459. }
  460. else
  461. {
  462. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  463. lua_error(state);
  464. }
  465. break;
  466. }
  467. case 5:
  468. {
  469. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  470. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  471. lua_type(state, 3) == LUA_TNUMBER &&
  472. lua_type(state, 4) == LUA_TNUMBER &&
  473. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL))
  474. {
  475. // Get parameter 1 off the stack.
  476. const char* param1 = ScriptController::getInstance()->getString(2, false);
  477. // Get parameter 2 off the stack.
  478. int param2 = (int)luaL_checkint(state, 3);
  479. // Get parameter 3 off the stack.
  480. int param3 = (int)luaL_checkint(state, 4);
  481. // Get parameter 4 off the stack.
  482. Vector4* param4 = ScriptController::getInstance()->getObjectPointer<Vector4>(5, "Vector4", true);
  483. Font* instance = getInstance(state);
  484. instance->drawText(param1, param2, param3, *param4);
  485. return 0;
  486. }
  487. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  488. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  489. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  490. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  491. lua_type(state, 5) == LUA_TNUMBER)
  492. {
  493. // Get parameter 1 off the stack.
  494. const char* param1 = ScriptController::getInstance()->getString(2, false);
  495. // Get parameter 2 off the stack.
  496. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  497. // Get parameter 3 off the stack.
  498. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  499. // Get parameter 4 off the stack.
  500. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  501. Font* instance = getInstance(state);
  502. instance->drawText(param1, *param2, *param3, param4);
  503. return 0;
  504. }
  505. else
  506. {
  507. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  508. lua_error(state);
  509. }
  510. break;
  511. }
  512. case 6:
  513. {
  514. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  515. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  516. lua_type(state, 3) == LUA_TNUMBER &&
  517. lua_type(state, 4) == LUA_TNUMBER &&
  518. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  519. lua_type(state, 6) == LUA_TNUMBER)
  520. {
  521. // Get parameter 1 off the stack.
  522. const char* param1 = ScriptController::getInstance()->getString(2, false);
  523. // Get parameter 2 off the stack.
  524. int param2 = (int)luaL_checkint(state, 3);
  525. // Get parameter 3 off the stack.
  526. int param3 = (int)luaL_checkint(state, 4);
  527. // Get parameter 4 off the stack.
  528. Vector4* param4 = ScriptController::getInstance()->getObjectPointer<Vector4>(5, "Vector4", true);
  529. // Get parameter 5 off the stack.
  530. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  531. Font* instance = getInstance(state);
  532. instance->drawText(param1, param2, param3, *param4, param5);
  533. return 0;
  534. }
  535. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  536. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  537. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  538. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  539. lua_type(state, 5) == LUA_TNUMBER &&
  540. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL))
  541. {
  542. // Get parameter 1 off the stack.
  543. const char* param1 = ScriptController::getInstance()->getString(2, false);
  544. // Get parameter 2 off the stack.
  545. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  546. // Get parameter 3 off the stack.
  547. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  548. // Get parameter 4 off the stack.
  549. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  550. // Get parameter 5 off the stack.
  551. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  552. Font* instance = getInstance(state);
  553. instance->drawText(param1, *param2, *param3, param4, param5);
  554. return 0;
  555. }
  556. else
  557. {
  558. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  559. lua_error(state);
  560. }
  561. break;
  562. }
  563. case 7:
  564. {
  565. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  566. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  567. lua_type(state, 3) == LUA_TNUMBER &&
  568. lua_type(state, 4) == LUA_TNUMBER &&
  569. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  570. lua_type(state, 6) == LUA_TNUMBER &&
  571. lua_type(state, 7) == LUA_TBOOLEAN)
  572. {
  573. // Get parameter 1 off the stack.
  574. const char* param1 = ScriptController::getInstance()->getString(2, false);
  575. // Get parameter 2 off the stack.
  576. int param2 = (int)luaL_checkint(state, 3);
  577. // Get parameter 3 off the stack.
  578. int param3 = (int)luaL_checkint(state, 4);
  579. // Get parameter 4 off the stack.
  580. Vector4* param4 = ScriptController::getInstance()->getObjectPointer<Vector4>(5, "Vector4", true);
  581. // Get parameter 5 off the stack.
  582. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  583. // Get parameter 6 off the stack.
  584. bool param6 = ScriptController::luaCheckBool(state, 7);
  585. Font* instance = getInstance(state);
  586. instance->drawText(param1, param2, param3, *param4, param5, param6);
  587. return 0;
  588. }
  589. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  590. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  591. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  592. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  593. lua_type(state, 5) == LUA_TNUMBER &&
  594. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  595. lua_type(state, 7) == LUA_TBOOLEAN)
  596. {
  597. // Get parameter 1 off the stack.
  598. const char* param1 = ScriptController::getInstance()->getString(2, false);
  599. // Get parameter 2 off the stack.
  600. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  601. // Get parameter 3 off the stack.
  602. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  603. // Get parameter 4 off the stack.
  604. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  605. // Get parameter 5 off the stack.
  606. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  607. // Get parameter 6 off the stack.
  608. bool param6 = ScriptController::luaCheckBool(state, 7);
  609. Font* instance = getInstance(state);
  610. instance->drawText(param1, *param2, *param3, param4, param5, param6);
  611. return 0;
  612. }
  613. else
  614. {
  615. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  616. lua_error(state);
  617. }
  618. break;
  619. }
  620. case 8:
  621. {
  622. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  623. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  624. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  625. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  626. lua_type(state, 5) == LUA_TNUMBER &&
  627. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  628. lua_type(state, 7) == LUA_TBOOLEAN &&
  629. lua_type(state, 8) == LUA_TBOOLEAN)
  630. {
  631. // Get parameter 1 off the stack.
  632. const char* param1 = ScriptController::getInstance()->getString(2, false);
  633. // Get parameter 2 off the stack.
  634. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  635. // Get parameter 3 off the stack.
  636. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  637. // Get parameter 4 off the stack.
  638. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  639. // Get parameter 5 off the stack.
  640. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  641. // Get parameter 6 off the stack.
  642. bool param6 = ScriptController::luaCheckBool(state, 7);
  643. // Get parameter 7 off the stack.
  644. bool param7 = ScriptController::luaCheckBool(state, 8);
  645. Font* instance = getInstance(state);
  646. instance->drawText(param1, *param2, *param3, param4, param5, param6, param7);
  647. return 0;
  648. }
  649. else
  650. {
  651. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  652. lua_error(state);
  653. }
  654. break;
  655. }
  656. case 9:
  657. {
  658. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  659. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  660. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  661. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  662. lua_type(state, 5) == LUA_TNUMBER &&
  663. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  664. lua_type(state, 7) == LUA_TBOOLEAN &&
  665. lua_type(state, 8) == LUA_TBOOLEAN &&
  666. (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL))
  667. {
  668. // Get parameter 1 off the stack.
  669. const char* param1 = ScriptController::getInstance()->getString(2, false);
  670. // Get parameter 2 off the stack.
  671. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  672. // Get parameter 3 off the stack.
  673. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  674. // Get parameter 4 off the stack.
  675. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  676. // Get parameter 5 off the stack.
  677. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  678. // Get parameter 6 off the stack.
  679. bool param6 = ScriptController::luaCheckBool(state, 7);
  680. // Get parameter 7 off the stack.
  681. bool param7 = ScriptController::luaCheckBool(state, 8);
  682. // Get parameter 8 off the stack.
  683. Rectangle* param8 = ScriptController::getInstance()->getObjectPointer<Rectangle>(9, "Rectangle", false);
  684. Font* instance = getInstance(state);
  685. instance->drawText(param1, *param2, *param3, param4, param5, param6, param7, param8);
  686. return 0;
  687. }
  688. else
  689. {
  690. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  691. lua_error(state);
  692. }
  693. break;
  694. }
  695. default:
  696. {
  697. lua_pushstring(state, "Invalid number of parameters (expected 2, 4, 5, 6, 7, 8 or 9).");
  698. lua_error(state);
  699. break;
  700. }
  701. }
  702. return 0;
  703. }
  704. int lua_Font_finish(lua_State* state)
  705. {
  706. // Get the number of parameters.
  707. int paramCount = lua_gettop(state);
  708. // Attempt to match the parameters to a valid binding.
  709. switch (paramCount)
  710. {
  711. case 1:
  712. {
  713. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  714. {
  715. Font* instance = getInstance(state);
  716. instance->finish();
  717. return 0;
  718. }
  719. else
  720. {
  721. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  722. lua_error(state);
  723. }
  724. break;
  725. }
  726. default:
  727. {
  728. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  729. lua_error(state);
  730. break;
  731. }
  732. }
  733. return 0;
  734. }
  735. int lua_Font_getIndexAtLocation(lua_State* state)
  736. {
  737. // Get the number of parameters.
  738. int paramCount = lua_gettop(state);
  739. // Attempt to match the parameters to a valid binding.
  740. switch (paramCount)
  741. {
  742. case 6:
  743. {
  744. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  745. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  746. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  747. lua_type(state, 4) == LUA_TNUMBER &&
  748. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  749. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL))
  750. {
  751. // Get parameter 1 off the stack.
  752. const char* param1 = ScriptController::getInstance()->getString(2, false);
  753. // Get parameter 2 off the stack.
  754. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  755. // Get parameter 3 off the stack.
  756. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  757. // Get parameter 4 off the stack.
  758. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", true);
  759. // Get parameter 5 off the stack.
  760. Vector2* param5 = ScriptController::getInstance()->getObjectPointer<Vector2>(6, "Vector2", false);
  761. Font* instance = getInstance(state);
  762. int result = instance->getIndexAtLocation(param1, *param2, param3, *param4, param5);
  763. // Push the return value onto the stack.
  764. lua_pushinteger(state, result);
  765. return 1;
  766. }
  767. else
  768. {
  769. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  770. lua_error(state);
  771. }
  772. break;
  773. }
  774. case 7:
  775. {
  776. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  777. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  778. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  779. lua_type(state, 4) == LUA_TNUMBER &&
  780. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  781. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  782. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL))
  783. {
  784. // Get parameter 1 off the stack.
  785. const char* param1 = ScriptController::getInstance()->getString(2, false);
  786. // Get parameter 2 off the stack.
  787. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  788. // Get parameter 3 off the stack.
  789. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  790. // Get parameter 4 off the stack.
  791. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", true);
  792. // Get parameter 5 off the stack.
  793. Vector2* param5 = ScriptController::getInstance()->getObjectPointer<Vector2>(6, "Vector2", false);
  794. // Get parameter 6 off the stack.
  795. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  796. Font* instance = getInstance(state);
  797. int result = instance->getIndexAtLocation(param1, *param2, param3, *param4, param5, param6);
  798. // Push the return value onto the stack.
  799. lua_pushinteger(state, result);
  800. return 1;
  801. }
  802. else
  803. {
  804. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  805. lua_error(state);
  806. }
  807. break;
  808. }
  809. case 8:
  810. {
  811. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  812. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  813. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  814. lua_type(state, 4) == LUA_TNUMBER &&
  815. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  816. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  817. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL) &&
  818. lua_type(state, 8) == LUA_TBOOLEAN)
  819. {
  820. // Get parameter 1 off the stack.
  821. const char* param1 = ScriptController::getInstance()->getString(2, false);
  822. // Get parameter 2 off the stack.
  823. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  824. // Get parameter 3 off the stack.
  825. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  826. // Get parameter 4 off the stack.
  827. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", true);
  828. // Get parameter 5 off the stack.
  829. Vector2* param5 = ScriptController::getInstance()->getObjectPointer<Vector2>(6, "Vector2", false);
  830. // Get parameter 6 off the stack.
  831. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  832. // Get parameter 7 off the stack.
  833. bool param7 = ScriptController::luaCheckBool(state, 8);
  834. Font* instance = getInstance(state);
  835. int result = instance->getIndexAtLocation(param1, *param2, param3, *param4, param5, param6, param7);
  836. // Push the return value onto the stack.
  837. lua_pushinteger(state, result);
  838. return 1;
  839. }
  840. else
  841. {
  842. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  843. lua_error(state);
  844. }
  845. break;
  846. }
  847. case 9:
  848. {
  849. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  850. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  851. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  852. lua_type(state, 4) == LUA_TNUMBER &&
  853. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  854. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  855. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL) &&
  856. lua_type(state, 8) == LUA_TBOOLEAN &&
  857. lua_type(state, 9) == LUA_TBOOLEAN)
  858. {
  859. // Get parameter 1 off the stack.
  860. const char* param1 = ScriptController::getInstance()->getString(2, false);
  861. // Get parameter 2 off the stack.
  862. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  863. // Get parameter 3 off the stack.
  864. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  865. // Get parameter 4 off the stack.
  866. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", true);
  867. // Get parameter 5 off the stack.
  868. Vector2* param5 = ScriptController::getInstance()->getObjectPointer<Vector2>(6, "Vector2", false);
  869. // Get parameter 6 off the stack.
  870. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  871. // Get parameter 7 off the stack.
  872. bool param7 = ScriptController::luaCheckBool(state, 8);
  873. // Get parameter 8 off the stack.
  874. bool param8 = ScriptController::luaCheckBool(state, 9);
  875. Font* instance = getInstance(state);
  876. int result = instance->getIndexAtLocation(param1, *param2, param3, *param4, param5, param6, param7, param8);
  877. // Push the return value onto the stack.
  878. lua_pushinteger(state, result);
  879. return 1;
  880. }
  881. else
  882. {
  883. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  884. lua_error(state);
  885. }
  886. break;
  887. }
  888. default:
  889. {
  890. lua_pushstring(state, "Invalid number of parameters (expected 6, 7, 8 or 9).");
  891. lua_error(state);
  892. break;
  893. }
  894. }
  895. return 0;
  896. }
  897. int lua_Font_getLocationAtIndex(lua_State* state)
  898. {
  899. // Get the number of parameters.
  900. int paramCount = lua_gettop(state);
  901. // Attempt to match the parameters to a valid binding.
  902. switch (paramCount)
  903. {
  904. case 6:
  905. {
  906. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  907. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  908. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  909. lua_type(state, 4) == LUA_TNUMBER &&
  910. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  911. lua_type(state, 6) == LUA_TNUMBER)
  912. {
  913. // Get parameter 1 off the stack.
  914. const char* param1 = ScriptController::getInstance()->getString(2, false);
  915. // Get parameter 2 off the stack.
  916. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  917. // Get parameter 3 off the stack.
  918. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  919. // Get parameter 4 off the stack.
  920. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", false);
  921. // Get parameter 5 off the stack.
  922. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  923. Font* instance = getInstance(state);
  924. instance->getLocationAtIndex(param1, *param2, param3, param4, param5);
  925. return 0;
  926. }
  927. else
  928. {
  929. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  930. lua_error(state);
  931. }
  932. break;
  933. }
  934. case 7:
  935. {
  936. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  937. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  938. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  939. lua_type(state, 4) == LUA_TNUMBER &&
  940. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  941. lua_type(state, 6) == LUA_TNUMBER &&
  942. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL))
  943. {
  944. // Get parameter 1 off the stack.
  945. const char* param1 = ScriptController::getInstance()->getString(2, false);
  946. // Get parameter 2 off the stack.
  947. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  948. // Get parameter 3 off the stack.
  949. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  950. // Get parameter 4 off the stack.
  951. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", false);
  952. // Get parameter 5 off the stack.
  953. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  954. // Get parameter 6 off the stack.
  955. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  956. Font* instance = getInstance(state);
  957. instance->getLocationAtIndex(param1, *param2, param3, param4, param5, param6);
  958. return 0;
  959. }
  960. else
  961. {
  962. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  963. lua_error(state);
  964. }
  965. break;
  966. }
  967. case 8:
  968. {
  969. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  970. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  971. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  972. lua_type(state, 4) == LUA_TNUMBER &&
  973. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  974. lua_type(state, 6) == LUA_TNUMBER &&
  975. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL) &&
  976. lua_type(state, 8) == LUA_TBOOLEAN)
  977. {
  978. // Get parameter 1 off the stack.
  979. const char* param1 = ScriptController::getInstance()->getString(2, false);
  980. // Get parameter 2 off the stack.
  981. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  982. // Get parameter 3 off the stack.
  983. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  984. // Get parameter 4 off the stack.
  985. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", false);
  986. // Get parameter 5 off the stack.
  987. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  988. // Get parameter 6 off the stack.
  989. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  990. // Get parameter 7 off the stack.
  991. bool param7 = ScriptController::luaCheckBool(state, 8);
  992. Font* instance = getInstance(state);
  993. instance->getLocationAtIndex(param1, *param2, param3, param4, param5, param6, param7);
  994. return 0;
  995. }
  996. else
  997. {
  998. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  999. lua_error(state);
  1000. }
  1001. break;
  1002. }
  1003. case 9:
  1004. {
  1005. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1006. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1007. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1008. lua_type(state, 4) == LUA_TNUMBER &&
  1009. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  1010. lua_type(state, 6) == LUA_TNUMBER &&
  1011. (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL) &&
  1012. lua_type(state, 8) == LUA_TBOOLEAN &&
  1013. lua_type(state, 9) == LUA_TBOOLEAN)
  1014. {
  1015. // Get parameter 1 off the stack.
  1016. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1017. // Get parameter 2 off the stack.
  1018. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  1019. // Get parameter 3 off the stack.
  1020. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  1021. // Get parameter 4 off the stack.
  1022. Vector2* param4 = ScriptController::getInstance()->getObjectPointer<Vector2>(5, "Vector2", false);
  1023. // Get parameter 5 off the stack.
  1024. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 6);
  1025. // Get parameter 6 off the stack.
  1026. Font::Justify param6 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 7));
  1027. // Get parameter 7 off the stack.
  1028. bool param7 = ScriptController::luaCheckBool(state, 8);
  1029. // Get parameter 8 off the stack.
  1030. bool param8 = ScriptController::luaCheckBool(state, 9);
  1031. Font* instance = getInstance(state);
  1032. instance->getLocationAtIndex(param1, *param2, param3, param4, param5, param6, param7, param8);
  1033. return 0;
  1034. }
  1035. else
  1036. {
  1037. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1038. lua_error(state);
  1039. }
  1040. break;
  1041. }
  1042. default:
  1043. {
  1044. lua_pushstring(state, "Invalid number of parameters (expected 6, 7, 8 or 9).");
  1045. lua_error(state);
  1046. break;
  1047. }
  1048. }
  1049. return 0;
  1050. }
  1051. int lua_Font_getRefCount(lua_State* state)
  1052. {
  1053. // Get the number of parameters.
  1054. int paramCount = lua_gettop(state);
  1055. // Attempt to match the parameters to a valid binding.
  1056. switch (paramCount)
  1057. {
  1058. case 1:
  1059. {
  1060. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  1061. {
  1062. Font* instance = getInstance(state);
  1063. unsigned int result = instance->getRefCount();
  1064. // Push the return value onto the stack.
  1065. lua_pushunsigned(state, result);
  1066. return 1;
  1067. }
  1068. else
  1069. {
  1070. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1071. lua_error(state);
  1072. }
  1073. break;
  1074. }
  1075. default:
  1076. {
  1077. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1078. lua_error(state);
  1079. break;
  1080. }
  1081. }
  1082. return 0;
  1083. }
  1084. int lua_Font_getSize(lua_State* state)
  1085. {
  1086. // Get the number of parameters.
  1087. int paramCount = lua_gettop(state);
  1088. // Attempt to match the parameters to a valid binding.
  1089. switch (paramCount)
  1090. {
  1091. case 1:
  1092. {
  1093. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  1094. {
  1095. Font* instance = getInstance(state);
  1096. unsigned int result = instance->getSize();
  1097. // Push the return value onto the stack.
  1098. lua_pushunsigned(state, result);
  1099. return 1;
  1100. }
  1101. else
  1102. {
  1103. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1104. lua_error(state);
  1105. }
  1106. break;
  1107. }
  1108. default:
  1109. {
  1110. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1111. lua_error(state);
  1112. break;
  1113. }
  1114. }
  1115. return 0;
  1116. }
  1117. int lua_Font_getSpriteBatch(lua_State* state)
  1118. {
  1119. // Get the number of parameters.
  1120. int paramCount = lua_gettop(state);
  1121. // Attempt to match the parameters to a valid binding.
  1122. switch (paramCount)
  1123. {
  1124. case 1:
  1125. {
  1126. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  1127. {
  1128. Font* instance = getInstance(state);
  1129. void* returnPtr = (void*)instance->getSpriteBatch();
  1130. if (returnPtr)
  1131. {
  1132. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  1133. object->instance = returnPtr;
  1134. object->owns = false;
  1135. luaL_getmetatable(state, "SpriteBatch");
  1136. lua_setmetatable(state, -2);
  1137. }
  1138. else
  1139. {
  1140. lua_pushnil(state);
  1141. }
  1142. return 1;
  1143. }
  1144. else
  1145. {
  1146. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1147. lua_error(state);
  1148. }
  1149. break;
  1150. }
  1151. default:
  1152. {
  1153. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1154. lua_error(state);
  1155. break;
  1156. }
  1157. }
  1158. return 0;
  1159. }
  1160. int lua_Font_measureText(lua_State* state)
  1161. {
  1162. // Get the number of parameters.
  1163. int paramCount = lua_gettop(state);
  1164. // Attempt to match the parameters to a valid binding.
  1165. switch (paramCount)
  1166. {
  1167. case 5:
  1168. {
  1169. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1170. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1171. lua_type(state, 3) == LUA_TNUMBER &&
  1172. (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
  1173. (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA))
  1174. {
  1175. // Get parameter 1 off the stack.
  1176. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1177. // Get parameter 2 off the stack.
  1178. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  1179. // Get parameter 3 off the stack.
  1180. unsigned int* param3 = ScriptController::getInstance()->getUnsignedIntPointer(4);
  1181. // Get parameter 4 off the stack.
  1182. unsigned int* param4 = ScriptController::getInstance()->getUnsignedIntPointer(5);
  1183. Font* instance = getInstance(state);
  1184. instance->measureText(param1, param2, param3, param4);
  1185. return 0;
  1186. }
  1187. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1188. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1189. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1190. lua_type(state, 4) == LUA_TNUMBER &&
  1191. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL))
  1192. {
  1193. // Get parameter 1 off the stack.
  1194. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1195. // Get parameter 2 off the stack.
  1196. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  1197. // Get parameter 3 off the stack.
  1198. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  1199. // Get parameter 4 off the stack.
  1200. Rectangle* param4 = ScriptController::getInstance()->getObjectPointer<Rectangle>(5, "Rectangle", false);
  1201. Font* instance = getInstance(state);
  1202. instance->measureText(param1, *param2, param3, param4);
  1203. return 0;
  1204. }
  1205. else
  1206. {
  1207. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1208. lua_error(state);
  1209. }
  1210. break;
  1211. }
  1212. case 6:
  1213. {
  1214. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1215. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1216. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1217. lua_type(state, 4) == LUA_TNUMBER &&
  1218. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  1219. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL))
  1220. {
  1221. // Get parameter 1 off the stack.
  1222. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1223. // Get parameter 2 off the stack.
  1224. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  1225. // Get parameter 3 off the stack.
  1226. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  1227. // Get parameter 4 off the stack.
  1228. Rectangle* param4 = ScriptController::getInstance()->getObjectPointer<Rectangle>(5, "Rectangle", false);
  1229. // Get parameter 5 off the stack.
  1230. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  1231. Font* instance = getInstance(state);
  1232. instance->measureText(param1, *param2, param3, param4, param5);
  1233. return 0;
  1234. }
  1235. else
  1236. {
  1237. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1238. lua_error(state);
  1239. }
  1240. break;
  1241. }
  1242. case 7:
  1243. {
  1244. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1245. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1246. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1247. lua_type(state, 4) == LUA_TNUMBER &&
  1248. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  1249. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  1250. lua_type(state, 7) == LUA_TBOOLEAN)
  1251. {
  1252. // Get parameter 1 off the stack.
  1253. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1254. // Get parameter 2 off the stack.
  1255. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  1256. // Get parameter 3 off the stack.
  1257. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  1258. // Get parameter 4 off the stack.
  1259. Rectangle* param4 = ScriptController::getInstance()->getObjectPointer<Rectangle>(5, "Rectangle", false);
  1260. // Get parameter 5 off the stack.
  1261. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  1262. // Get parameter 6 off the stack.
  1263. bool param6 = ScriptController::luaCheckBool(state, 7);
  1264. Font* instance = getInstance(state);
  1265. instance->measureText(param1, *param2, param3, param4, param5, param6);
  1266. return 0;
  1267. }
  1268. else
  1269. {
  1270. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1271. lua_error(state);
  1272. }
  1273. break;
  1274. }
  1275. case 8:
  1276. {
  1277. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1278. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1279. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1280. lua_type(state, 4) == LUA_TNUMBER &&
  1281. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  1282. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
  1283. lua_type(state, 7) == LUA_TBOOLEAN &&
  1284. lua_type(state, 8) == LUA_TBOOLEAN)
  1285. {
  1286. // Get parameter 1 off the stack.
  1287. const char* param1 = ScriptController::getInstance()->getString(2, false);
  1288. // Get parameter 2 off the stack.
  1289. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  1290. // Get parameter 3 off the stack.
  1291. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  1292. // Get parameter 4 off the stack.
  1293. Rectangle* param4 = ScriptController::getInstance()->getObjectPointer<Rectangle>(5, "Rectangle", false);
  1294. // Get parameter 5 off the stack.
  1295. Font::Justify param5 = (Font::Justify)lua_enumFromString_FontJustify(luaL_checkstring(state, 6));
  1296. // Get parameter 6 off the stack.
  1297. bool param6 = ScriptController::luaCheckBool(state, 7);
  1298. // Get parameter 7 off the stack.
  1299. bool param7 = ScriptController::luaCheckBool(state, 8);
  1300. Font* instance = getInstance(state);
  1301. instance->measureText(param1, *param2, param3, param4, param5, param6, param7);
  1302. return 0;
  1303. }
  1304. else
  1305. {
  1306. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1307. lua_error(state);
  1308. }
  1309. break;
  1310. }
  1311. default:
  1312. {
  1313. lua_pushstring(state, "Invalid number of parameters (expected 5, 6, 7 or 8).");
  1314. lua_error(state);
  1315. break;
  1316. }
  1317. }
  1318. return 0;
  1319. }
  1320. int lua_Font_release(lua_State* state)
  1321. {
  1322. // Get the number of parameters.
  1323. int paramCount = lua_gettop(state);
  1324. // Attempt to match the parameters to a valid binding.
  1325. switch (paramCount)
  1326. {
  1327. case 1:
  1328. {
  1329. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  1330. {
  1331. Font* instance = getInstance(state);
  1332. instance->release();
  1333. return 0;
  1334. }
  1335. else
  1336. {
  1337. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1338. lua_error(state);
  1339. }
  1340. break;
  1341. }
  1342. default:
  1343. {
  1344. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1345. lua_error(state);
  1346. break;
  1347. }
  1348. }
  1349. return 0;
  1350. }
  1351. int lua_Font_static_create(lua_State* state)
  1352. {
  1353. // Get the number of parameters.
  1354. int paramCount = lua_gettop(state);
  1355. // Attempt to match the parameters to a valid binding.
  1356. switch (paramCount)
  1357. {
  1358. case 1:
  1359. {
  1360. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  1361. {
  1362. // Get parameter 1 off the stack.
  1363. const char* param1 = ScriptController::getInstance()->getString(1, false);
  1364. void* returnPtr = (void*)Font::create(param1);
  1365. if (returnPtr)
  1366. {
  1367. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  1368. object->instance = returnPtr;
  1369. object->owns = false;
  1370. luaL_getmetatable(state, "Font");
  1371. lua_setmetatable(state, -2);
  1372. }
  1373. else
  1374. {
  1375. lua_pushnil(state);
  1376. }
  1377. return 1;
  1378. }
  1379. else
  1380. {
  1381. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1382. lua_error(state);
  1383. }
  1384. break;
  1385. }
  1386. case 2:
  1387. {
  1388. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  1389. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1390. {
  1391. // Get parameter 1 off the stack.
  1392. const char* param1 = ScriptController::getInstance()->getString(1, false);
  1393. // Get parameter 2 off the stack.
  1394. const char* param2 = ScriptController::getInstance()->getString(2, false);
  1395. void* returnPtr = (void*)Font::create(param1, param2);
  1396. if (returnPtr)
  1397. {
  1398. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  1399. object->instance = returnPtr;
  1400. object->owns = false;
  1401. luaL_getmetatable(state, "Font");
  1402. lua_setmetatable(state, -2);
  1403. }
  1404. else
  1405. {
  1406. lua_pushnil(state);
  1407. }
  1408. return 1;
  1409. }
  1410. else
  1411. {
  1412. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1413. lua_error(state);
  1414. }
  1415. break;
  1416. }
  1417. case 6:
  1418. {
  1419. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  1420. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1421. lua_type(state, 3) == LUA_TNUMBER &&
  1422. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  1423. lua_type(state, 5) == LUA_TNUMBER &&
  1424. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL))
  1425. {
  1426. // Get parameter 1 off the stack.
  1427. const char* param1 = ScriptController::getInstance()->getString(1, false);
  1428. // Get parameter 2 off the stack.
  1429. Font::Style param2 = (Font::Style)lua_enumFromString_FontStyle(luaL_checkstring(state, 2));
  1430. // Get parameter 3 off the stack.
  1431. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  1432. // Get parameter 4 off the stack.
  1433. Font::Glyph* param4 = ScriptController::getInstance()->getObjectPointer<Font::Glyph>(4, "FontGlyph", false);
  1434. // Get parameter 5 off the stack.
  1435. int param5 = (int)luaL_checkint(state, 5);
  1436. // Get parameter 6 off the stack.
  1437. Texture* param6 = ScriptController::getInstance()->getObjectPointer<Texture>(6, "Texture", false);
  1438. void* returnPtr = (void*)Font::create(param1, param2, param3, param4, param5, param6);
  1439. if (returnPtr)
  1440. {
  1441. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  1442. object->instance = returnPtr;
  1443. object->owns = false;
  1444. luaL_getmetatable(state, "Font");
  1445. lua_setmetatable(state, -2);
  1446. }
  1447. else
  1448. {
  1449. lua_pushnil(state);
  1450. }
  1451. return 1;
  1452. }
  1453. else
  1454. {
  1455. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1456. lua_error(state);
  1457. }
  1458. break;
  1459. }
  1460. default:
  1461. {
  1462. lua_pushstring(state, "Invalid number of parameters (expected 1, 2 or 6).");
  1463. lua_error(state);
  1464. break;
  1465. }
  1466. }
  1467. return 0;
  1468. }
  1469. int lua_Font_static_getJustify(lua_State* state)
  1470. {
  1471. // Get the number of parameters.
  1472. int paramCount = lua_gettop(state);
  1473. // Attempt to match the parameters to a valid binding.
  1474. switch (paramCount)
  1475. {
  1476. case 1:
  1477. {
  1478. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  1479. {
  1480. // Get parameter 1 off the stack.
  1481. const char* param1 = ScriptController::getInstance()->getString(1, false);
  1482. Font::Justify result = Font::getJustify(param1);
  1483. // Push the return value onto the stack.
  1484. lua_pushstring(state, lua_stringFromEnum_FontJustify(result).c_str());
  1485. return 1;
  1486. }
  1487. else
  1488. {
  1489. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  1490. lua_error(state);
  1491. }
  1492. break;
  1493. }
  1494. default:
  1495. {
  1496. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1497. lua_error(state);
  1498. break;
  1499. }
  1500. }
  1501. return 0;
  1502. }
  1503. }