fading more clever, align in tabx

This commit is contained in:
p.kosyh 2010-11-03 07:50:33 +00:00
parent 38e781476a
commit e371e915a5
3 changed files with 39 additions and 2 deletions

View file

@ -1345,6 +1345,7 @@ struct line {
int align;
int pos;
int tabx;
int al_tabx;
struct word *words;
struct line *next;
struct line *prev;
@ -1393,6 +1394,7 @@ struct line *line_new(void)
l->h = 0;
l->num = 0;
l->tabx = -1;
l->al_tabx = ALIGN_LEFT;
l->layout = NULL;
l->align = 0;
l->pos = 0;
@ -3051,6 +3053,11 @@ char *process_token(char *ptr, struct layout *layout, struct line *line, struct
xpos = xpos * game_theme.scale;
}
line->tabx = xpos;
line->al_tabx = ALIGN_LEFT;
if (strstr(val, "right"))
line->al_tabx = ALIGN_RIGHT;
else if (strstr(val, "center"))
line->al_tabx = ALIGN_CENTER;
goto out;
}
if (TOKEN(token) == TOKEN_A) {
@ -3264,6 +3271,11 @@ void _txt_layout_add(layout_t lay, char *txt)
word->x = line->w;
if (line->tabx > 0) {
word->x = line->tabx - line->x;
if (line->al_tabx == ALIGN_RIGHT)
word->x -= word->w;
else if (line->al_tabx == ALIGN_CENTER)
word->x -= word->w/2;
if (word->x + word->w > width)
word->x = width - word->w;
if (word->x < line->w)

View file

@ -306,11 +306,18 @@ function isFading() --to check fading from sdl gui
if not isRoom(h) then
return false
end
r,v = call_bool(h, 'fading');
r,v = call_value(h, 'fading');
if r then
if tonumber(r) and v == nil then
return true, tonumber(r)
end
return true, v
end
g,v = call_bool(game, 'fading', h);
g,v = call_value(game, 'fading', h);
if tonumber(g) and v == nil then
v = tonumber(g)
g = true
end
return g and r ~= false, v
end

View file

@ -854,6 +854,24 @@ function call_bool(v, n, ...)
return true; -- not nil
end
function call_value(v, n, ...)
if type(v) ~= 'table' then
error ("Call value on non table object:"..n, 2);
end
if v[n] == nil then
return nil
end
if type(v[n]) ~= 'function' then
return v[n];
end
callpush(v, unpack(arg))
local r,v = v[n](v, unpack(arg));
callpop();
return r,v;
end
function room_scene(self)
local v;
v = iface:title(call(self,'nam'));