mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
luainstance: remove utf8 parameter from RenderString, add center
Everybody should always be using utf8 anyway, so remove the "utf8" parameter from RenderString and replace it with a "center" parameter which centers the string horizontally in its box. new usage: RenderString(font, text, x, y, color, boxwidth, boxheight, center) defaults: color = COL_MENUCONTENT, boxwidth = window's width minus x boxheight = 0, center = 0
This commit is contained in:
committed by
M. Liebmann
parent
3f57d7c528
commit
7c7c7e55a4
@@ -430,14 +430,14 @@ int CLuaInstance::PaintIcon(lua_State *L)
|
||||
|
||||
int CLuaInstance::RenderString(lua_State *L)
|
||||
{
|
||||
int x, y, w, boxh, utf8, f;
|
||||
int x, y, w, boxh, f, center;
|
||||
unsigned int c;
|
||||
const char *text;
|
||||
int numargs = lua_gettop(L);
|
||||
DBG("CLuaInstance::%s %d\n", __func__, numargs);
|
||||
c = COL_MENUCONTENT;
|
||||
boxh = 0;
|
||||
utf8 = 1;
|
||||
center = 0;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin)
|
||||
@@ -455,11 +455,16 @@ int CLuaInstance::RenderString(lua_State *L)
|
||||
if (numargs > 7)
|
||||
boxh = luaL_checkint(L, 8);
|
||||
if (numargs > 8)
|
||||
utf8 = luaL_checkint(L, 9);
|
||||
if (f >= FONT_TYPE_COUNT || f < 0)
|
||||
center = luaL_checkint(L, 9);
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
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, utf8);
|
||||
W->fbwin->RenderString(g_Font[f], x, y, w, text, c, boxh, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -497,7 +502,7 @@ int CLuaInstance::FontHeight(lua_State *L)
|
||||
if (!W)
|
||||
return 0;
|
||||
f = luaL_checkint(L, 2); /* font number, use FONT['xxx'] for FONT_TYPE_xxx in the script */
|
||||
if (f >= FONT_TYPE_COUNT || f < 0)
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
lua_pushinteger(L, (int)g_Font[f]->getHeight());
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user