fading more clever, align in tabx
This commit is contained in:
parent
38e781476a
commit
e371e915a5
|
@ -1345,6 +1345,7 @@ struct line {
|
||||||
int align;
|
int align;
|
||||||
int pos;
|
int pos;
|
||||||
int tabx;
|
int tabx;
|
||||||
|
int al_tabx;
|
||||||
struct word *words;
|
struct word *words;
|
||||||
struct line *next;
|
struct line *next;
|
||||||
struct line *prev;
|
struct line *prev;
|
||||||
|
@ -1393,6 +1394,7 @@ struct line *line_new(void)
|
||||||
l->h = 0;
|
l->h = 0;
|
||||||
l->num = 0;
|
l->num = 0;
|
||||||
l->tabx = -1;
|
l->tabx = -1;
|
||||||
|
l->al_tabx = ALIGN_LEFT;
|
||||||
l->layout = NULL;
|
l->layout = NULL;
|
||||||
l->align = 0;
|
l->align = 0;
|
||||||
l->pos = 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;
|
xpos = xpos * game_theme.scale;
|
||||||
}
|
}
|
||||||
line->tabx = xpos;
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
if (TOKEN(token) == TOKEN_A) {
|
if (TOKEN(token) == TOKEN_A) {
|
||||||
|
@ -3264,6 +3271,11 @@ void _txt_layout_add(layout_t lay, char *txt)
|
||||||
word->x = line->w;
|
word->x = line->w;
|
||||||
if (line->tabx > 0) {
|
if (line->tabx > 0) {
|
||||||
word->x = line->tabx - line->x;
|
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)
|
if (word->x + word->w > width)
|
||||||
word->x = width - word->w;
|
word->x = width - word->w;
|
||||||
if (word->x < line->w)
|
if (word->x < line->w)
|
||||||
|
|
|
@ -306,11 +306,18 @@ function isFading() --to check fading from sdl gui
|
||||||
if not isRoom(h) then
|
if not isRoom(h) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
r,v = call_bool(h, 'fading');
|
r,v = call_value(h, 'fading');
|
||||||
if r then
|
if r then
|
||||||
|
if tonumber(r) and v == nil then
|
||||||
|
return true, tonumber(r)
|
||||||
|
end
|
||||||
return true, v
|
return true, v
|
||||||
end
|
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
|
return g and r ~= false, v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -854,6 +854,24 @@ function call_bool(v, n, ...)
|
||||||
return true; -- not nil
|
return true; -- not nil
|
||||||
end
|
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)
|
function room_scene(self)
|
||||||
local v;
|
local v;
|
||||||
v = iface:title(call(self,'nam'));
|
v = iface:title(call(self,'nam'));
|
||||||
|
|
Loading…
Reference in a new issue