mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
CLuainstance: Use lua_Unsigned for color definitions
- Add additional tableLookup() for get lua_Unsigned - Change tableLookup() for int to lua_Integer
This commit is contained in:
@@ -44,11 +44,21 @@ struct table_key {
|
|||||||
lua_Integer code;
|
lua_Integer code;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct table_key_u {
|
||||||
|
const char *name;
|
||||||
|
lua_Unsigned code;
|
||||||
|
};
|
||||||
|
|
||||||
struct lua_envexport {
|
struct lua_envexport {
|
||||||
const char *name;
|
const char *name;
|
||||||
table_key *t;
|
table_key *t;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct lua_envexport_u {
|
||||||
|
const char *name;
|
||||||
|
table_key_u *t;
|
||||||
|
};
|
||||||
|
|
||||||
static void set_lua_variables(lua_State *L)
|
static void set_lua_variables(lua_State *L)
|
||||||
{
|
{
|
||||||
/* keyname table created with
|
/* keyname table created with
|
||||||
@@ -147,7 +157,7 @@ static void set_lua_variables(lua_State *L)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* list of colors, exported e.g. as COL['INFOBAR_SHADOW'] */
|
/* list of colors, exported e.g. as COL['INFOBAR_SHADOW'] */
|
||||||
static table_key colorlist[] =
|
static table_key_u colorlist[] =
|
||||||
{
|
{
|
||||||
{ "COLORED_EVENTS_CHANNELLIST", MAGIC_COLOR | (COL_COLORED_EVENTS_CHANNELLIST) },
|
{ "COLORED_EVENTS_CHANNELLIST", MAGIC_COLOR | (COL_COLORED_EVENTS_CHANNELLIST) },
|
||||||
{ "COLORED_EVENTS_INFOBAR", MAGIC_COLOR | (COL_COLORED_EVENTS_INFOBAR) },
|
{ "COLORED_EVENTS_INFOBAR", MAGIC_COLOR | (COL_COLORED_EVENTS_INFOBAR) },
|
||||||
@@ -172,21 +182,21 @@ static void set_lua_variables(lua_State *L)
|
|||||||
{ "LIGHT_BLUE", MAGIC_COLOR | (COL_LIGHT_BLUE0) },
|
{ "LIGHT_BLUE", MAGIC_COLOR | (COL_LIGHT_BLUE0) },
|
||||||
{ "WHITE", MAGIC_COLOR | (COL_WHITE0) },
|
{ "WHITE", MAGIC_COLOR | (COL_WHITE0) },
|
||||||
{ "BLACK", MAGIC_COLOR | (COL_BLACK0) },
|
{ "BLACK", MAGIC_COLOR | (COL_BLACK0) },
|
||||||
{ "COLORED_EVENTS_TEXT", (lua_Integer) (COL_COLORED_EVENTS_TEXT) },
|
{ "COLORED_EVENTS_TEXT", (lua_Unsigned) (COL_COLORED_EVENTS_TEXT) },
|
||||||
{ "INFOBAR_TEXT", (lua_Integer) (COL_INFOBAR_TEXT) },
|
{ "INFOBAR_TEXT", (lua_Unsigned) (COL_INFOBAR_TEXT) },
|
||||||
{ "INFOBAR_SHADOW_TEXT", (lua_Integer) (COL_INFOBAR_SHADOW_TEXT) },
|
{ "INFOBAR_SHADOW_TEXT", (lua_Unsigned) (COL_INFOBAR_SHADOW_TEXT) },
|
||||||
{ "MENUHEAD_TEXT", (lua_Integer) (COL_MENUHEAD_TEXT) },
|
{ "MENUHEAD_TEXT", (lua_Unsigned) (COL_MENUHEAD_TEXT) },
|
||||||
{ "MENUCONTENT_TEXT", (lua_Integer) (COL_MENUCONTENT_TEXT) },
|
{ "MENUCONTENT_TEXT", (lua_Unsigned) (COL_MENUCONTENT_TEXT) },
|
||||||
{ "MENUCONTENT_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_1) },
|
{ "MENUCONTENT_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_1) },
|
||||||
{ "MENUCONTENT_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_2) },
|
{ "MENUCONTENT_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_2) },
|
||||||
{ "MENUCONTENT_TEXT_PLUS_3", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_3) },
|
{ "MENUCONTENT_TEXT_PLUS_3", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_3) },
|
||||||
{ "MENUCONTENTDARK_TEXT", (lua_Integer) (COL_MENUCONTENTDARK_TEXT) },
|
{ "MENUCONTENTDARK_TEXT", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT) },
|
||||||
{ "MENUCONTENTDARK_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENTDARK_TEXT_PLUS_1) },
|
{ "MENUCONTENTDARK_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT_PLUS_1) },
|
||||||
{ "MENUCONTENTDARK_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENTDARK_TEXT_PLUS_2) },
|
{ "MENUCONTENTDARK_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT_PLUS_2) },
|
||||||
{ "MENUCONTENTSELECTED_TEXT", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT) },
|
{ "MENUCONTENTSELECTED_TEXT", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT) },
|
||||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) },
|
{ "MENUCONTENTSELECTED_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) },
|
||||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) },
|
{ "MENUCONTENTSELECTED_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) },
|
||||||
{ "MENUCONTENTINACTIVE_TEXT", (lua_Integer) (COL_MENUCONTENTINACTIVE_TEXT) },
|
{ "MENUCONTENTINACTIVE_TEXT", (lua_Unsigned) (COL_MENUCONTENTINACTIVE_TEXT) },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -254,7 +264,6 @@ static void set_lua_variables(lua_State *L)
|
|||||||
lua_envexport e[] =
|
lua_envexport e[] =
|
||||||
{
|
{
|
||||||
{ "RC", keyname },
|
{ "RC", keyname },
|
||||||
{ "COL", colorlist },
|
|
||||||
{ "SCREEN", screenopts },
|
{ "SCREEN", screenopts },
|
||||||
{ "FONT", fontlist },
|
{ "FONT", fontlist },
|
||||||
{ "CORNER", corners },
|
{ "CORNER", corners },
|
||||||
@@ -275,6 +284,26 @@ static void set_lua_variables(lua_State *L)
|
|||||||
lua_setglobal(L, e[i].name);
|
lua_setglobal(L, e[i].name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lua_envexport_u e_u[] =
|
||||||
|
{
|
||||||
|
{ "COL", colorlist },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (e_u[i].name) {
|
||||||
|
int j = 0;
|
||||||
|
lua_newtable(L);
|
||||||
|
while (e_u[i].t[j].name) {
|
||||||
|
lua_pushstring(L, e_u[i].t[j].name);
|
||||||
|
lua_pushunsigned(L, e_u[i].t[j].code);
|
||||||
|
lua_settable(L, -3);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
lua_setglobal(L, e_u[i].name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define DBG printf
|
//#define DBG printf
|
||||||
@@ -773,14 +802,26 @@ bool CLuaInstance::tableLookup(lua_State *L, const char *what, std::string &valu
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value)
|
bool CLuaInstance::tableLookup(lua_State *L, const char *what, lua_Integer &value)
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
lua_pushstring(L, what);
|
lua_pushstring(L, what);
|
||||||
lua_gettable(L, -2);
|
lua_gettable(L, -2);
|
||||||
res = lua_isnumber(L, -1);
|
res = lua_isnumber(L, -1);
|
||||||
if (res)
|
if (res)
|
||||||
value = (int) lua_tonumber(L, -1);
|
value = (lua_Integer) lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CLuaInstance::tableLookup(lua_State *L, const char *what, lua_Unsigned &value)
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
lua_pushstring(L, what);
|
||||||
|
lua_gettable(L, -2);
|
||||||
|
res = lua_isnumber(L, -1);
|
||||||
|
if (res)
|
||||||
|
value = (lua_Unsigned) lua_tonumber(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -1434,9 +1475,9 @@ int CLuaInstance::CWindowNew(lua_State *L)
|
|||||||
lua_assert(lua_istable(L,1));
|
lua_assert(lua_istable(L,1));
|
||||||
|
|
||||||
std::string name, icon = std::string(NEUTRINO_ICON_INFO);
|
std::string name, icon = std::string(NEUTRINO_ICON_INFO);
|
||||||
lua_Integer color_frame = (lua_Integer)COL_MENUCONTENT_PLUS_6;
|
lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
|
||||||
lua_Integer color_body = (lua_Integer)COL_MENUCONTENT_PLUS_0;
|
lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
|
||||||
lua_Integer color_shadow = (lua_Integer)COL_MENUCONTENTDARK_PLUS_0;
|
lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
|
||||||
std::string tmp1 = "false";
|
std::string tmp1 = "false";
|
||||||
std::string btnRed = "";
|
std::string btnRed = "";
|
||||||
std::string btnGreen = "";
|
std::string btnGreen = "";
|
||||||
@@ -1729,10 +1770,10 @@ int CLuaInstance::ComponentsTextNew(lua_State *L)
|
|||||||
std::string tmpMode = "";
|
std::string tmpMode = "";
|
||||||
int mode = CTextBox::AUTO_WIDTH;
|
int mode = CTextBox::AUTO_WIDTH;
|
||||||
int font_text = SNeutrinoSettings::FONT_TYPE_MENU;
|
int font_text = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||||
lua_Integer color_text = (lua_Integer)COL_MENUCONTENT_TEXT;
|
lua_Unsigned color_text = (lua_Unsigned)COL_MENUCONTENT_TEXT;
|
||||||
lua_Integer color_frame = (lua_Integer)COL_MENUCONTENT_PLUS_6;
|
lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
|
||||||
lua_Integer color_body = (lua_Integer)COL_MENUCONTENT_PLUS_0;
|
lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
|
||||||
lua_Integer color_shadow = (lua_Integer)COL_MENUCONTENTDARK_PLUS_0;
|
lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
|
||||||
std::string tmp1 = "false";
|
std::string tmp1 = "false";
|
||||||
|
|
||||||
tableLookup(L, "parent" , (void**)&parent);
|
tableLookup(L, "parent" , (void**)&parent);
|
||||||
@@ -1905,9 +1946,9 @@ int CLuaInstance::CPictureNew(lua_State *L)
|
|||||||
std::string image_name = "";
|
std::string image_name = "";
|
||||||
lua_Integer alignment = 0;
|
lua_Integer alignment = 0;
|
||||||
std::string tmp1 = "false"; // has_shadow
|
std::string tmp1 = "false"; // has_shadow
|
||||||
lua_Integer color_frame = (lua_Integer)COL_MENUCONTENT_PLUS_6;
|
lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
|
||||||
lua_Integer color_background = (lua_Integer)COL_MENUCONTENT_PLUS_0;
|
lua_Unsigned color_background = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
|
||||||
lua_Integer color_shadow = (lua_Integer)COL_MENUCONTENTDARK_PLUS_0;
|
lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
transparency = CFrameBuffer::TM_BLACK (2): Transparency when black content ('pseudo' transparency)
|
transparency = CFrameBuffer::TM_BLACK (2): Transparency when black content ('pseudo' transparency)
|
||||||
|
@@ -252,7 +252,8 @@ private:
|
|||||||
static int CPictureDelete(lua_State *L);
|
static int CPictureDelete(lua_State *L);
|
||||||
|
|
||||||
static bool tableLookup(lua_State*, const char*, std::string&);
|
static bool tableLookup(lua_State*, const char*, std::string&);
|
||||||
static bool tableLookup(lua_State*, const char*, int&);
|
static bool tableLookup(lua_State*, const char*, lua_Integer&);
|
||||||
|
static bool tableLookup(lua_State*, const char*, lua_Unsigned&);
|
||||||
static bool tableLookup(lua_State*, const char*, void**);
|
static bool tableLookup(lua_State*, const char*, void**);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user