From e371e915a5e49d43528b63d196fb353b387e1e33 Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Wed, 3 Nov 2010 07:50:33 +0000 Subject: [PATCH] fading more clever, align in tabx --- src/sdl-instead/graphics.c | 12 ++++++++++++ stead/gui.lua | 11 +++++++++-- stead/stead.lua | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index 0fea018..7285868 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -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) diff --git a/stead/gui.lua b/stead/gui.lua index 5664de1..602f17c 100644 --- a/stead/gui.lua +++ b/stead/gui.lua @@ -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 diff --git a/stead/stead.lua b/stead/stead.lua index 172635a..2794f89 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -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'));