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

tset

git-svn-id: http://svn.net-core.org/repos/t-engine4@1173 51575b47-30f0-44d4-a5cc-537603b46e54
parent dfd63417
No related branches found
No related tags found
No related merge requests found
......@@ -58,11 +58,14 @@ function _M:call(style, str, ...)
if self.flashing == 0 and #self.log > 0 then self.log = {} end
local base = ""
if #self.log > 0 then base = table.remove(self.log) end
if #self.log > 0 then base = table.remove(self.log)[1] end
local lines = (base .. " " .. str:format(...)):splitLines(self.w - 4, self.font)
for i = 1, #lines do
table.insert(self.log, lines[i])
self.surface:erase(0,0,0,255)
self.surface:drawColorStringBlended(self.font, lines[i], 0, 0, self.color[1], self.color[2], self.color[3])
local t = self.surface:glTexture()
table.insert(self.log, {lines[i],t})
end
self.flashing_style = style
self.flashing = 20
......@@ -79,23 +82,20 @@ function _M:empty(force)
end
function _M:display()
-- If nothing changed, return the same surface as before
if not self.changed then return self.surface end
self.changed = false
-- Erase and the display the map
if self.flashing_style == BAD then
self.surface:erase(self.bgcolor[1] + self.flashing * 10, self.bgcolor[2], self.bgcolor[3])
core.display.drawQuad(self.display_x, self.display_y, self.w, self.h, self.bgcolor[1] + self.flashing * 10, self.bgcolor[2], self.bgcolor[3], 255)
elseif self.flashing_style == NEUTRAL then
self.surface:erase(self.bgcolor[1], self.bgcolor[2], self.bgcolor[3] + self.flashing * 10)
core.display.drawQuad(self.display_x, self.display_y, self.w, self.h, self.bgcolor[1], self.bgcolor[2], self.bgcolor[3] + self.flashing * 10, 255)
else
self.surface:erase(self.bgcolor[1], self.bgcolor[2] + self.flashing * 10, self.bgcolor[3])
end
self.surface:drawColorStringBlended(self.font, self.log[1] or "", 0, 0, self.color[1], self.color[2], self.color[3])
core.display.drawQuad(self.display_x, self.display_y, self.w, self.h, self.bgcolor[1], self.bgcolor[2] + self.flashing * 10, self.bgcolor[3], 255)
end
-- if self.log[1] then self.log[1][2]:toScreen(self.display_x, self.display_y, self.w, self.h) end
self.flashing = self.flashing - 1
if self.flashing > 0 then self.changed = true
if self.flashing > 0 then
else table.remove(self.log, 1) end
return self.surface
end
......@@ -403,8 +403,10 @@ function _M:onTurn()
end
function _M:display()
local st = core.game.getTime()
-- Now the map, if any
if self.level and self.level.map and self.level.map.finished then
print("=====display01", core.game.getTime()-st)
-- Display the map and compute FOV for the player if needed
if self.level.map.changed then
self.player:playerFOV()
......@@ -415,6 +417,7 @@ function _M:display()
self.level.data.background(self.level)
end
print("=====display02", core.game.getTime()-st)
-- Display using Framebuffer, sotaht we can use shaders and all
if self.fbo then
self.fbo:use(true)
......@@ -433,34 +436,46 @@ function _M:display()
self.target:display()
end
print("=====display03", core.game.getTime()-st)
if not self.zone_name_s then
self.zone_name_s = core.display.drawStringBlendedNewSurface(self.player_display.font, ("%s (%d)"):format(self.zone.name, self.level.level), 0, 255, 255)
local s = core.display.drawStringBlendedNewSurface(self.player_display.font, ("%s (%d)"):format(self.zone.name, self.level.level), 0, 255, 255)
self.zone_name_s = s:glTexture()
self.zone_name_w, self.zone_name_h = s:getSize()
end
local znsx, znsy = self.zone_name_s:getSize()
self.zone_name_s:toScreen(
self.level.map.display_x + self.level.map.viewport.width - znsx,
self.level.map.display_y + self.level.map.viewport.height - znsy
self.level.map.display_x + self.level.map.viewport.width - self.zone_name_w,
self.level.map.display_y + self.level.map.viewport.height - self.zone_name_h,
self.zone_name_w, self.zone_name_h
)
print("=====display04", core.game.getTime()-st)
-- Minimap display
self.level.map:minimapDisplay(0, 20, util.bound(self.player.x - 25, 0, self.level.map.w - 50), util.bound(self.player.y - 25, 0, self.level.map.h - 50), 50, 50, 1)
print("=====display05", core.game.getTime()-st)
end
-- We display the player's interface
self.flash:display():toScreen(self.flash.display_x, self.flash.display_y)
self.flash:display()
print("=====display06", core.game.getTime()-st)
self.logdisplay:display():toScreen(self.logdisplay.display_x, self.logdisplay.display_y)
print("=====display07", core.game.getTime()-st)
self.player_display:display():toScreen(self.player_display.display_x, self.player_display.display_y)
print("=====display08", core.game.getTime()-st)
if self.show_npc_list then
self.npcs_display:display():toScreen(self.npcs_display.display_x, self.npcs_display.display_y)
else
self.hotkeys_display:display():toScreen(self.hotkeys_display.display_x, self.hotkeys_display.display_y)
end
if self.player then self.player.changed = false end
print("=====display09", core.game.getTime()-st)
-- Tooltip is displayed over all else
self:targetDisplayTooltip(game.w, game.h)
print("=====display10", core.game.getTime()-st)
engine.GameTurnBased.display(self)
print("=====display11", core.game.getTime()-st)
end
function _M:setupCommands()
......
......@@ -726,6 +726,38 @@ static int gl_texture_to_sdl(lua_State *L)
return 1;
}
static int gl_draw_quad(lua_State *L)
{
int x = luaL_checknumber(L, 1);
int y = luaL_checknumber(L, 2);
int w = luaL_checknumber(L, 3);
int h = luaL_checknumber(L, 4);
float r = luaL_checknumber(L, 5) / 255;
float g = luaL_checknumber(L, 6) / 255;
float b = luaL_checknumber(L, 7) / 255;
float a = luaL_checknumber(L, 8) / 255;
if (lua_isuserdata(L, 9))
{
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 9);
glBindTexture(GL_TEXTURE_2D, *t);
}
else
glBindTexture(GL_TEXTURE_2D, 0);
glColor4f(r, g, b, a);
glBegin( GL_QUADS ); /* Draw A Quad */
glTexCoord2f(0,0); glVertex2f(0 + x, 0 + y);
glTexCoord2f(0,1); glVertex2f(0 + x, h + y);
glTexCoord2f(1,1); glVertex2f(w + x, h + y);
glTexCoord2f(1,0); glVertex2f(w + x, 0 + y);
glEnd( ); /* Done Drawing The Quad */
glColor4f(1, 1, 1, 1);
return 0;
}
static int sdl_load_image(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
......@@ -1345,6 +1377,7 @@ static const struct luaL_reg displaylib[] =
{"newSurface", sdl_new_surface},
{"newTile", sdl_new_tile},
{"newFBO", gl_new_fbo},
{"drawQuad", gl_draw_quad},
{"FBOActive", gl_fbo_is_active},
{"drawStringNewSurface", sdl_surface_drawstring_newsurface},
{"drawStringBlendedNewSurface", sdl_surface_drawstring_newsurface_aa},
......
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