mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 08:29:31 +00:00
Moved ":setBlendColor()" to the texture object, removed useless functions
This commit is contained in:
parent
49ae4454d3
commit
604247f278
3 changed files with 17 additions and 45 deletions
16
source/map.c
16
source/map.c
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
typedef struct {
|
||||
texture_userdata *texture;
|
||||
u32 blendColor;
|
||||
u8 tileSizeX;
|
||||
u8 tileSizeY;
|
||||
int tilesetSizeX; // in tiles
|
||||
|
|
@ -43,7 +42,6 @@ static int map_load(lua_State *L) {
|
|||
lua_setmetatable(L, -2);
|
||||
|
||||
map->texture = texture;
|
||||
map->blendColor = 0xffffffff;
|
||||
map->tileSizeX = tileSizeX;
|
||||
map->tileSizeY = tileSizeY;
|
||||
map->tilesetSizeX = (map->texture->texture->width/tileSizeX);
|
||||
|
|
@ -101,7 +99,7 @@ static int map_draw(lua_State *L) {
|
|||
int texY = 0;
|
||||
|
||||
|
||||
if (map->blendColor == 0xffffffff) {
|
||||
if (map->texture->blendColor == 0xffffffff) {
|
||||
for (int xp=0; xp<map->width; xp++) {
|
||||
for (int yp=0; yp<map->height; yp++) {
|
||||
u16 tile = getTile(map, xp, yp);
|
||||
|
|
@ -114,7 +112,7 @@ static int map_draw(lua_State *L) {
|
|||
for (int yp=0; yp<map->height; yp++) {
|
||||
u16 tile = getTile(map, xp, yp);
|
||||
getTilePos(map, tile, &texX, &texY);
|
||||
sf2d_draw_texture_part_blend(map->texture->texture, (x+(map->tileSizeX*xp)), (y+(map->tileSizeY*yp)), texX, texY, map->tileSizeX, map->tileSizeY, map->blendColor);
|
||||
sf2d_draw_texture_part_blend(map->texture->texture, (x+(map->tileSizeX*xp)), (y+(map->tileSizeY*yp)), texX, texY, map->tileSizeX, map->tileSizeY, map->texture->blendColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,15 +156,6 @@ static int map_setTile(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int map_setBlendColor(lua_State *L) {
|
||||
map_userdata *map = luaL_checkudata(L, 1, "LMap");
|
||||
u32 color = luaL_checkinteger(L, 2);
|
||||
|
||||
map->blendColor = color;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// object
|
||||
static const struct luaL_Reg map_methods[] = {
|
||||
{"draw", map_draw },
|
||||
|
|
@ -174,7 +163,6 @@ static const struct luaL_Reg map_methods[] = {
|
|||
{"getSize", map_getSize },
|
||||
{"getTile", map_getTile },
|
||||
{"setTile", map_setTile },
|
||||
{"setBlendColor", map_setBlendColor},
|
||||
{"__gc", map_unload },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ static int texture_load(lua_State *L) {
|
|||
|
||||
texture->scaleX = 1.0f;
|
||||
texture->scaleY = 1.0f;
|
||||
texture->blendColor = 0xffffffff;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -56,10 +57,10 @@ static int texture_draw(lua_State *L) {
|
|||
int y = luaL_checkinteger(L, 3);
|
||||
float rad = luaL_optnumber(L, 4, 0.0f);
|
||||
|
||||
if (rad == 0.0f && texture->scaleX == 1.0f && texture->scaleY == 1.0f) {
|
||||
if (rad == 0.0f && texture->scaleX == 1.0f && texture->scaleY == 1.0f && texture->blendColor == 0xffffffff) {
|
||||
sf2d_draw_texture(texture->texture, x, y);
|
||||
} else {
|
||||
sf2d_draw_texture_part_rotate_scale(texture->texture, x, y, rad, 0, 0, texture->texture->width, texture->texture->height, texture->scaleX, texture->scaleY);
|
||||
sf2d_draw_texture_part_rotate_scale_blend(texture->texture, x, y, rad, 0, 0, texture->texture->width, texture->texture->height, texture->scaleX, texture->scaleY, texture->blendColor);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -75,33 +76,7 @@ static int texture_drawPart(lua_State *L) {
|
|||
int h = luaL_checkinteger(L, 7);
|
||||
int rad = luaL_optnumber(L, 8, 0.0f);
|
||||
|
||||
sf2d_draw_texture_part_rotate_scale(texture->texture, x, y, rad, sx, sy, w, h, texture->scaleX, texture->scaleY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int texture_drawBlend(lua_State *L) {
|
||||
texture_userdata *texture = luaL_checkudata(L, 1, "LTexture");
|
||||
int x = luaL_checkinteger(L, 2);
|
||||
int y = luaL_checkinteger(L, 3);
|
||||
u32 color = luaL_checkinteger(L, 4);
|
||||
|
||||
sf2d_draw_texture_blend(texture->texture, x, y, color);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int texture_drawPartBlend(lua_State *L) {
|
||||
texture_userdata *texture = luaL_checkudata(L, 1, "LTexture");
|
||||
int x = luaL_checkinteger(L, 2);
|
||||
int y = luaL_checkinteger(L, 3);
|
||||
int sx = luaL_checkinteger(L, 4);
|
||||
int sy = luaL_checkinteger(L, 5);
|
||||
int w = luaL_checkinteger(L, 6);
|
||||
int h = luaL_checkinteger(L, 7);
|
||||
u32 color = luaL_checkinteger(L, 8);
|
||||
|
||||
sf2d_draw_texture_part_blend(texture->texture, x, y, sx, sy, w, h, color);
|
||||
sf2d_draw_texture_part_rotate_scale_blend(texture->texture, x, y, rad, sx, sy, w, h, texture->scaleX, texture->scaleY, texture->blendColor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -149,16 +124,24 @@ static int texture_setPixel(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int texture_setBlendColor(lua_State *L) {
|
||||
texture_userdata *texture = luaL_checkudata(L, 1, "LTexture");
|
||||
u32 color = luaL_checkinteger(L, 2);
|
||||
|
||||
texture->blendColor = color;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// object
|
||||
static const struct luaL_Reg texture_methods[] = {
|
||||
{ "draw", texture_draw },
|
||||
{ "drawPart", texture_drawPart },
|
||||
{ "drawBlend", texture_drawBlend },
|
||||
{ "drawPartBlend", texture_drawPartBlend },
|
||||
{ "scale", texture_scale },
|
||||
{ "unload", texture_unload },
|
||||
{ "getPixel", texture_getPixel },
|
||||
{ "setPixel", texture_setPixel },
|
||||
{ "setBlendColor", texture_setBlendColor },
|
||||
{ "__gc", texture_unload },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ typedef struct {
|
|||
sf2d_texture *texture;
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
u32 blendColor;
|
||||
} texture_userdata;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue