diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index b311349..fd955b3 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -1671,14 +1671,14 @@ static int is_delim(int c) return 0; } -static int word_img(const char *p, char **eptr) +static int process_word_token(const char *p, char **eptr, char ch) { int len = 0; if (eptr) *eptr = (char*)p; if (!p) return 0; - if (p[0] != '<' || p[1] != 'g' || p[2] != ':') + if (p[0] != '<' || p[1] != ch || p[2] != ':') return 0; p += 3; len = strcspn(p, ">"); @@ -1689,6 +1689,16 @@ static int word_img(const char *p, char **eptr) return len + 1; } +static int word_img(const char *p, char **eptr) +{ + return process_word_token(p, eptr, 'g'); +} + +static int word_token(const char *p, char **eptr) +{ + return process_word_token(p, eptr, 'w'); +} + static const char *lookup_token_or_sp(const char *ptr) { @@ -1709,6 +1719,10 @@ static const char *lookup_token_or_sp(const char *ptr) if (p == ptr) /* first one */ p = eptr; return p; + } else if (word_token(p, &eptr)) { + if (p == ptr) /* first one */ + p = eptr; + return p; } p ++; continue; @@ -1745,6 +1759,9 @@ static char *get_word(const char *ptr, char **eptr, int *sp) o[sz] = 0; sz = word_img(ptr, eptr); + if (sz) + return o; + sz = word_token(ptr, eptr); if (sz) return o; *eptr = (char*)ep; @@ -2215,7 +2232,6 @@ void txt_layout_update_links(layout_t layout, int x, int y, clear_fn clear) // gfx_noclip(); } - img_t get_img(struct layout *layout, char *p) { int len; @@ -2251,6 +2267,19 @@ out: return img; } +char *get_word_token(char *p) +{ + int len; + char *r; + len = word_token(p, NULL); + if (!len) + return p; + p[len - 1 + 3] = 0; + r = strdup((p + 3)); + free(p); + return r; +} + char *process_token(char *ptr, struct layout *layout, struct line *line, struct xref **xref, int *sp) { @@ -2337,7 +2366,7 @@ int get_unbrakable_len(struct layout *layout, const char *ptr) if (!p) return w; - if (sp || !*p || word_img(p, NULL)) { + if (sp || !*p || word_img(p, NULL) || word_token(p, NULL)) { free(p); return w; } @@ -2435,6 +2464,7 @@ void _txt_layout_add(layout_t lay, char *txt) w = gfx_img_w(img); h = gfx_img_h(img); } else { + p = get_word_token(p); TTF_SizeUTF8((TTF_Font *)(layout->fn), p, &w, &h); if (!*p && line->h) h = 0; diff --git a/stead/gui.lua b/stead/gui.lua index f31a50d..b03d72e 100644 --- a/stead/gui.lua +++ b/stead/gui.lua @@ -1,61 +1,67 @@ game.hinting = true; game.showlast = true; -iface.img = function(self, str) - return ""; -end; - iface.xref = function(self, str, obj) - local o = ref(obj); - local cmd='' + local o = ref(obj); + local cmd='' - if not isObject(o) or isStatus(o) or not o.id then - return str; - end + if not isObject(o) or isStatus(o) or not o.id then + return str; + end - if ref(ways():srch(obj)) then - cmd = 'go '; - elseif isMenu(o) then - cmd = 'act '; - elseif isSceneUse(o) then - cmd = 'use '; - end + if ref(ways():srch(obj)) then + cmd = 'go '; + elseif isMenu(o) then + cmd = 'act '; + elseif isSceneUse(o) then + cmd = 'use '; + end - return cat('',str,''); + return cat('',str,''); end; iface.title = function(self, str) - return nil + return nil +end; + +iface.img = function(self, str) + if str == nil then return nil; end; + return ""; +end; + +iface.nb = function(self, str) + if str == nil then return nil; end; + return ""; end; iface.under = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.em = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.right = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.left = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.center = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.bold = function(self, str) - if str == nil then return nil; end; - return cat('',str,''); + if str == nil then return nil; end; + return cat('',str,''); end; iface.inv = function(self, str) diff --git a/stead/stead.lua b/stead/stead.lua index 2abe56d..d152e89 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -131,6 +131,11 @@ function cat(v,...) return res; end +function txtnb(v) + if type(v) ~= 'string' then return nil; end + return iface:nb(v); +end + function img(v) if type(v) ~= 'string' then return nil; end; return iface:img(v); @@ -1529,6 +1534,9 @@ iface = { img = function(self, str) return ''; end, + nb = function(self, str) + return str; + end, em = function(self, str) return str; end,