Skip to content
Snippets Groups Projects
Commit ee642fac authored by dg's avatar dg
Browse files

surface:erase() can take coordonates

git-svn-id: http://svn.net-core.org/repos/t-engine4@656 51575b47-30f0-44d4-a5cc-537603b46e54
parent b69289cf
No related branches found
No related tags found
No related merge requests found
...@@ -95,12 +95,10 @@ function _M:display() ...@@ -95,12 +95,10 @@ function _M:display()
txt = ("%2d) %-"..(self.max_char_w-4-24).."s Key: %s"):format(i, txt, ts[4]) txt = ("%2d) %-"..(self.max_char_w-4-24).."s Key: %s"):format(i, txt, ts[4])
local w, h = self.font:size(txt) local w, h = self.font:size(txt)
s = core.display.newSurface(w + 4, h + 4) if self.cur_sel and self.cur_sel == i then self.surface:erase(0, 50, 120, nil, x, y, w+4, h+4) end
if self.cur_sel and self.cur_sel == i then s:erase(0, 50, 120) end self.surface:drawString(self.font, txt, x+2, y+2, color[1], color[2], color[3])
s:drawString(self.font, txt, 2, 2, color[1], color[2], color[3])
self.clics[i] = {x,y,w+4,h+4} self.clics[i] = {x,y,w+4,h+4}
self.surface:merge(s, x, y)
if y + self.font_h * 2 > self.h then if y + self.font_h * 2 > self.h then
x = x + self.w / 2 x = x + self.w / 2
y = 0 y = 0
......
...@@ -343,13 +343,6 @@ function _M:onTurn() ...@@ -343,13 +343,6 @@ function _M:onTurn()
end end
function _M:display() function _M:display()
-- We display the player's interface
self.flash:display():toScreen(self.flash.display_x, self.flash.display_y)
self.logdisplay:display():toScreen(self.logdisplay.display_x, self.logdisplay.display_y)
self.player_display:display():toScreen(self.player_display.display_x, self.player_display.display_y)
self.hotkeys_display:display():toScreen(self.hotkeys_display.display_x, self.hotkeys_display.display_y)
if self.player then self.player.changed = false end
-- Now the map, if any -- Now the map, if any
if self.level and self.level.map and self.level.map.finished then if self.level and self.level.map and self.level.map.finished then
-- Display the map and compute FOV for the player if needed -- Display the map and compute FOV for the player if needed
...@@ -399,6 +392,13 @@ function _M:display() ...@@ -399,6 +392,13 @@ function _M:display()
end end
end end
-- We display the player's interface
self.flash:display():toScreen(self.flash.display_x, self.flash.display_y)
self.logdisplay:display():toScreen(self.logdisplay.display_x, self.logdisplay.display_y)
self.player_display:display():toScreen(self.player_display.display_x, self.player_display.display_y)
self.hotkeys_display:display():toScreen(self.hotkeys_display.display_x, self.hotkeys_display.display_y)
if self.player then self.player.changed = false end
engine.GameTurnBased.display(self) engine.GameTurnBased.display(self)
end end
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
quickEntity('a', {show_tooltip=true, name='Ephel Duath', display='^', color=colors.LIGHT_DARK, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true}) quickEntity('a', {show_tooltip=true, name='Ephel Duath', display='^', color=colors.LIGHT_DARK, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true})
quickEntity('d', {show_tooltip=true, name='Haradwaith', display='.', color={r=203,g=189,b=72}, back_color={r=163,g=149,b=42}, image="terrain/sand.png", block_move=true}) quickEntity('d', {show_tooltip=true, name='Haradwaith', display='.', color={r=203,g=189,b=72}, back_color={r=163,g=149,b=42}, image="terrain/sand.png", block_move=true})
quickEntity('b', {show_tooltip=true, name='blue mountains', display='^', color=colors.LIGHT_BLUE, back_color=colors.BLUE, image="terrain/mountain.png", block_move=true}) quickEntity('b', {show_tooltip=true, name='blue mountains', display='^', color=colors.LIGHT_BLUE, back_color=colors.BLUE, tint=colors.LIGHT_BLUE, image="terrain/mountain.png", block_move=true})
quickEntity('m', {show_tooltip=true, name='misty mountains', display='^', color=colors.LIGHT_UMBER, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true}) quickEntity('m', {show_tooltip=true, name='misty mountains', display='^', color=colors.LIGHT_UMBER, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true})
quickEntity('f', {show_tooltip=true, name='grey mountains', display='^', color=colors.SLATE, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true}) quickEntity('f', {show_tooltip=true, name='grey mountains', display='^', color=colors.SLATE, back_color=colors.UMBER, image="terrain/mountain.png", block_move=true})
quickEntity('u', {show_tooltip=true, name='deep forest', display='#', color=colors.GREEN, back_color=colors.DARK_GREEN, image="terrain/tree.png", block_move=true}) quickEntity('u', {show_tooltip=true, name='deep forest', display='#', color=colors.GREEN, back_color=colors.DARK_GREEN, image="terrain/tree.png", block_move=true})
......
...@@ -427,6 +427,7 @@ static int sdl_new_font(lua_State *L) ...@@ -427,6 +427,7 @@ static int sdl_new_font(lua_State *L)
auxiliar_setclass(L, "sdl{font}", -1); auxiliar_setclass(L, "sdl{font}", -1);
*f = TTF_OpenFontRW(PHYSFSRWOPS_openRead(name), TRUE, size); *f = TTF_OpenFontRW(PHYSFSRWOPS_openRead(name), TRUE, size);
// TTF_SetFontOutline(*f, 2);
return 1; return 1;
} }
...@@ -480,7 +481,7 @@ static int sdl_surface_drawstring(lua_State *L) ...@@ -480,7 +481,7 @@ static int sdl_surface_drawstring(lua_State *L)
int b = luaL_checknumber(L, 8); int b = luaL_checknumber(L, 8);
SDL_Color color = {r,g,b}; SDL_Color color = {r,g,b};
SDL_Surface *txt = TTF_RenderUTF8_Solid(*f, str, color); SDL_Surface *txt = TTF_RenderUTF8_Blended(*f, str, color);
if (txt) if (txt)
{ {
sdlDrawImage(*s, txt, x, y); sdlDrawImage(*s, txt, x, y);
...@@ -499,7 +500,7 @@ static int sdl_surface_drawstring_newsurface(lua_State *L) ...@@ -499,7 +500,7 @@ static int sdl_surface_drawstring_newsurface(lua_State *L)
int b = luaL_checknumber(L, 5); int b = luaL_checknumber(L, 5);
SDL_Color color = {r,g,b}; SDL_Color color = {r,g,b};
SDL_Surface *txt = TTF_RenderUTF8_Solid(*f, str, color); SDL_Surface *txt = TTF_RenderUTF8_Blended(*f, str, color);
if (txt) if (txt)
{ {
SDL_Surface **s = (SDL_Surface**)lua_newuserdata(L, sizeof(SDL_Surface*)); SDL_Surface **s = (SDL_Surface**)lua_newuserdata(L, sizeof(SDL_Surface*));
...@@ -648,7 +649,17 @@ static int sdl_surface_erase(lua_State *L) ...@@ -648,7 +649,17 @@ static int sdl_surface_erase(lua_State *L)
int g = lua_tonumber(L, 3); int g = lua_tonumber(L, 3);
int b = lua_tonumber(L, 4); int b = lua_tonumber(L, 4);
int a = lua_isnumber(L, 5) ? lua_tonumber(L, 5) : 255; int a = lua_isnumber(L, 5) ? lua_tonumber(L, 5) : 255;
SDL_FillRect(*s, NULL, SDL_MapRGBA((*s)->format, r, g, b, a)); if (lua_isnumber(L, 6))
{
SDL_Rect rect;
rect.x = lua_tonumber(L, 6);
rect.y = lua_tonumber(L, 7);
rect.w = lua_tonumber(L, 8);
rect.h = lua_tonumber(L, 9);
SDL_FillRect(*s, &rect, SDL_MapRGBA((*s)->format, r, g, b, a));
}
else
SDL_FillRect(*s, NULL, SDL_MapRGBA((*s)->format, r, g, b, a));
return 0; return 0;
} }
...@@ -752,6 +763,14 @@ static int sdl_surface_toscreen(lua_State *L) ...@@ -752,6 +763,14 @@ static int sdl_surface_toscreen(lua_State *L)
SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1); SDL_Surface **s = (SDL_Surface**)auxiliar_checkclass(L, "sdl{surface}", 1);
int x = luaL_checknumber(L, 2); int x = luaL_checknumber(L, 2);
int y = luaL_checknumber(L, 3); int y = luaL_checknumber(L, 3);
if (lua_isnumber(L, 4))
{
float r = luaL_checknumber(L, 4);
float g = luaL_checknumber(L, 5);
float b = luaL_checknumber(L, 6);
float a = luaL_checknumber(L, 7);
glColor4f(r, g, b, a);
}
GLuint t; GLuint t;
glGenTextures(1, &t); glGenTextures(1, &t);
...@@ -763,6 +782,8 @@ static int sdl_surface_toscreen(lua_State *L) ...@@ -763,6 +782,8 @@ static int sdl_surface_toscreen(lua_State *L)
glDeleteTextures(1, &t); glDeleteTextures(1, &t);
if (lua_isnumber(L, 4)) glColor4f(1, 1, 1, 1);
return 0; return 0;
} }
...@@ -772,12 +793,22 @@ static int sdl_surface_toscreen_with_texture(lua_State *L) ...@@ -772,12 +793,22 @@ static int sdl_surface_toscreen_with_texture(lua_State *L)
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 2); GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 2);
int x = luaL_checknumber(L, 3); int x = luaL_checknumber(L, 3);
int y = luaL_checknumber(L, 4); int y = luaL_checknumber(L, 4);
if (lua_isnumber(L, 5))
{
float r = luaL_checknumber(L, 5);
float g = luaL_checknumber(L, 6);
float b = luaL_checknumber(L, 7);
float a = luaL_checknumber(L, 8);
glColor4f(r, g, b, a);
}
glBindTexture(GL_TEXTURE_2D, *t); glBindTexture(GL_TEXTURE_2D, *t);
copy_surface_to_texture(*s); copy_surface_to_texture(*s);
draw_textured_quad(x,y,(*s)->w,(*s)->h); draw_textured_quad(x,y,(*s)->w,(*s)->h);
if (lua_isnumber(L, 5)) glColor4f(1, 1, 1, 1);
return 0; return 0;
} }
...@@ -833,6 +864,14 @@ static int sdl_texture_toscreen(lua_State *L) ...@@ -833,6 +864,14 @@ static int sdl_texture_toscreen(lua_State *L)
int y = luaL_checknumber(L, 3); int y = luaL_checknumber(L, 3);
int w = luaL_checknumber(L, 4); int w = luaL_checknumber(L, 4);
int h = luaL_checknumber(L, 5); int h = luaL_checknumber(L, 5);
if (lua_isnumber(L, 6))
{
float r = luaL_checknumber(L, 6);
float g = luaL_checknumber(L, 7);
float b = luaL_checknumber(L, 8);
float a = luaL_checknumber(L, 9);
glColor4f(r, g, b, a);
}
glBindTexture(GL_TEXTURE_2D, *t); glBindTexture(GL_TEXTURE_2D, *t);
glBegin( GL_QUADS ); /* Draw A Quad */ glBegin( GL_QUADS ); /* Draw A Quad */
...@@ -842,6 +881,7 @@ static int sdl_texture_toscreen(lua_State *L) ...@@ -842,6 +881,7 @@ static int sdl_texture_toscreen(lua_State *L)
glTexCoord2f(1,0); glVertex2f(w + x, 0 + y); glTexCoord2f(1,0); glVertex2f(w + x, 0 + y);
glEnd( ); /* Done Drawing The Quad */ glEnd( ); /* Done Drawing The Quad */
if (lua_isnumber(L, 6)) glColor4f(1, 1, 1, 1);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment