1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Added some values in the gfx lib

This commit is contained in:
Firew0lf 2015-08-19 01:36:15 +02:00
parent 8a05ba5bff
commit 0c2f641c74
2 changed files with 21 additions and 3 deletions

View file

@ -89,6 +89,19 @@ static const struct luaL_Reg gfx_lib[] = {
{ NULL, NULL }
};
// constants
struct { char *name; int value; } gfx_constants[] = {
{ "GFX_TOP", 0 },
{ "GFX_BOTTOM", 1 },
{ "GFX_LEFT", 0 },
{ "GFX_RIGHT", 1 },
{ "TOP_HEIGHT", 240 },
{ "TOP_WIDTH", 400 },
{ "BOTTOM_HEIGHT", 240 },
{ "BOTTOM_WIDTH", 320 },
{ NULL, 0 }
};
struct { char *name; int (*load)(lua_State *L); } gfx_libs[] = {
{ "color", load_color_lib },
{ NULL, NULL }
@ -97,6 +110,11 @@ struct { char *name; int (*load)(lua_State *L); } gfx_libs[] = {
int luaopen_gfx_lib(lua_State *L) {
luaL_newlib(L, gfx_lib);
for (int i = 0; gfx_constants[i].name; i++) {
lua_pushinteger(L, gfx_constants[i].value);
lua_setfield(L, -2, gfx_constants[i].name);
}
for (int i = 0; gfx_libs[i].name; i++) {
gfx_libs[i].load(L);
lua_setfield(L, -2, gfx_libs[i].name);