From a61dbcee0bbcd15780574f3ad795c293c553fe20 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 7 Apr 2013 18:54:57 +0200 Subject: [PATCH] luainstance: return render width from RenderString Return the string's renderwidth from RenderString. If boxh is < 0 then the string is not rendered and only the width is determined. --- src/gui/luainstance.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index b1a83ddde..d893ad4dd 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -458,14 +458,16 @@ int CLuaInstance::RenderString(lua_State *L) center = luaL_checkint(L, 9); if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0) f = SNeutrinoSettings::FONT_TYPE_MENU; + int rwidth = g_Font[f]->getRenderWidth(text, true); if (center) { /* center the text inside the box */ - int rwidth = g_Font[f]->getRenderWidth(text, true); if (rwidth < w) x += (w - rwidth) / 2; } c &= 0x000000FF; /* TODO: colors that are not in the palette? */ - W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); - return 0; + if (boxh > -1) /* if boxh < 0, don't paint string */ + W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true); + lua_pushinteger(L, rwidth); /* return renderwidth */ + return 1; } int CLuaInstance::GetInput(lua_State *L)