mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 00:11:08 +02:00
luainstance: formatting code using astyle
Origin commit data
------------------
Branch: ni/coolstream
Commit: 4775115a23
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-11-19 (Fri, 19 Nov 2021)
Origin message was:
------------------
- luainstance: formatting code using astyle
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -488,10 +488,12 @@ static void set_lua_variables(lua_State *L)
|
|||||||
};
|
};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (e[i].name) {
|
while (e[i].name)
|
||||||
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
while (e[i].t[j].name) {
|
while (e[i].t[j].name)
|
||||||
|
{
|
||||||
lua_pushstring(L, e[i].t[j].name);
|
lua_pushstring(L, e[i].t[j].name);
|
||||||
lua_pushinteger(L, e[i].t[j].code);
|
lua_pushinteger(L, e[i].t[j].code);
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
@@ -508,10 +510,12 @@ static void set_lua_variables(lua_State *L)
|
|||||||
};
|
};
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (e_u[i].name) {
|
while (e_u[i].name)
|
||||||
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
while (e_u[i].t[j].name) {
|
while (e_u[i].t[j].name)
|
||||||
|
{
|
||||||
lua_pushstring(L, 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_pushunsigned(L, e_u[i].t[j].code);
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
@@ -528,10 +532,12 @@ static void set_lua_variables(lua_State *L)
|
|||||||
};
|
};
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (e_s[i].name) {
|
while (e_s[i].name)
|
||||||
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
while (e_s[i].t[j].name) {
|
while (e_s[i].t[j].name)
|
||||||
|
{
|
||||||
lua_pushstring(L, e_s[i].t[j].name);
|
lua_pushstring(L, e_s[i].t[j].name);
|
||||||
lua_pushstring(L, e_s[i].t[j].code);
|
lua_pushstring(L, e_s[i].t[j].code);
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
@@ -576,7 +582,8 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
|||||||
// luaL_dofile(lua, fileName);
|
// luaL_dofile(lua, fileName);
|
||||||
/* run the script */
|
/* run the script */
|
||||||
int status = luaL_loadfile(lua, fileName);
|
int status = luaL_loadfile(lua, fileName);
|
||||||
if (status) {
|
if (status)
|
||||||
|
{
|
||||||
bool isString = lua_isstring(lua, -1);
|
bool isString = lua_isstring(lua, -1);
|
||||||
const char *null = "NULL";
|
const char *null = "NULL";
|
||||||
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, isString ? lua_tostring(lua, -1) : null);
|
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, isString ? lua_tostring(lua, -1) : null);
|
||||||
@@ -596,10 +603,13 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
|||||||
lua_pushstring(lua, fileName);
|
lua_pushstring(lua, fileName);
|
||||||
lua_rawseti(lua, -2, n++);
|
lua_rawseti(lua, -2, n++);
|
||||||
|
|
||||||
if (argv && (!argv->empty())) {
|
if (argv && (!argv->empty()))
|
||||||
|
{
|
||||||
std::string abort = "DisableAbort";
|
std::string abort = "DisableAbort";
|
||||||
for(std::vector<std::string>::iterator it = argv->begin(); it != argv->end(); ++it) {
|
for (std::vector<std::string>::iterator it = argv->begin(); it != argv->end(); ++it)
|
||||||
if (!it->compare(abort)) {
|
{
|
||||||
|
if (!it->compare(abort))
|
||||||
|
{
|
||||||
DisableAbort = false;
|
DisableAbort = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -622,15 +632,18 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
|||||||
if (error_string)
|
if (error_string)
|
||||||
*error_string = std::string(lua_tostring(lua, -1));
|
*error_string = std::string(lua_tostring(lua, -1));
|
||||||
/* restoreNeutrino at plugin crash, when blocked from plugin */
|
/* restoreNeutrino at plugin crash, when blocked from plugin */
|
||||||
if (CMoviePlayerGui::getInstance().getBlockedFromPlugin()) {
|
if (CMoviePlayerGui::getInstance().getBlockedFromPlugin())
|
||||||
|
{
|
||||||
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
||||||
CMoviePlayerGui::getInstance().restoreNeutrino();
|
CMoviePlayerGui::getInstance().restoreNeutrino();
|
||||||
} else if (videoDecoder->getBlank())
|
}
|
||||||
|
else if (videoDecoder->getBlank())
|
||||||
CLuaInstVideo::getInstance()->channelRezap(lua);
|
CLuaInstVideo::getInstance()->channelRezap(lua);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CLuaInstVideo::getInstance() && CMoviePlayerGui::getInstance().getBlockedFromPlugin()){
|
if (CLuaInstVideo::getInstance() && CMoviePlayerGui::getInstance().getBlockedFromPlugin())
|
||||||
|
{
|
||||||
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
||||||
CMoviePlayerGui::getInstance().restoreNeutrino();
|
CMoviePlayerGui::getInstance().restoreNeutrino();
|
||||||
}
|
}
|
||||||
@@ -648,8 +661,10 @@ void CLuaInstance::runScript(const char *fileName, const char *arg0, ...)
|
|||||||
va_list list;
|
va_list list;
|
||||||
va_start(list, arg0);
|
va_start(list, arg0);
|
||||||
const char *temp = va_arg(list, const char *);
|
const char *temp = va_arg(list, const char *);
|
||||||
while (temp != NULL) {
|
while (temp != NULL)
|
||||||
if (i >= 64) {
|
{
|
||||||
|
if (i >= 64)
|
||||||
|
{
|
||||||
fprintf(stderr, "CLuaInstance::runScript: too many arguments!\n");
|
fprintf(stderr, "CLuaInstance::runScript: too many arguments!\n");
|
||||||
args.clear();
|
args.clear();
|
||||||
va_end(list);
|
va_end(list);
|
||||||
@@ -794,7 +809,8 @@ CLuaData *CLuaInstance::CheckData(lua_State *L, int narg)
|
|||||||
{
|
{
|
||||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||||
void *ud = luaL_checkudata(L, narg, className);
|
void *ud = luaL_checkudata(L, narg, className);
|
||||||
if (!ud) {
|
if (!ud)
|
||||||
|
{
|
||||||
fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className);
|
fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -831,8 +847,10 @@ int CLuaInstance::GCWindow(lua_State *L)
|
|||||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
CLuaData *w = (CLuaData *)lua_unboxpointer(L, 1);
|
CLuaData *w = (CLuaData *)lua_unboxpointer(L, 1);
|
||||||
|
|
||||||
if (w && w->fbwin) {
|
if (w && w->fbwin)
|
||||||
for (screenmap_iterator_t it = w->screenmap.begin(); it != w->screenmap.end(); ++it) {
|
{
|
||||||
|
for (screenmap_iterator_t it = w->screenmap.begin(); it != w->screenmap.end(); ++it)
|
||||||
|
{
|
||||||
if (it->second != NULL)
|
if (it->second != NULL)
|
||||||
delete[] it->second;
|
delete[] it->second;
|
||||||
}
|
}
|
||||||
@@ -846,14 +864,16 @@ int CLuaInstance::GCWindow(lua_State *L)
|
|||||||
bool block = CMoviePlayerGui::getInstance().getBlockedFromPlugin();
|
bool block = CMoviePlayerGui::getInstance().getBlockedFromPlugin();
|
||||||
bool play = CMoviePlayerGui::getInstance().Playing();
|
bool play = CMoviePlayerGui::getInstance().Playing();
|
||||||
LUA_DEBUG(">>>>[%s:%d] (restoreNeutrino()) BlockedFromPlugin: %d, Playing: %d\n", __func__, __LINE__, block, play);
|
LUA_DEBUG(">>>>[%s:%d] (restoreNeutrino()) BlockedFromPlugin: %d, Playing: %d\n", __func__, __LINE__, block, play);
|
||||||
if (block && play) {
|
if (block && play)
|
||||||
|
{
|
||||||
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
||||||
CMoviePlayerGui::getInstance().restoreNeutrino();
|
CMoviePlayerGui::getInstance().restoreNeutrino();
|
||||||
}
|
}
|
||||||
else if (videoDecoder->getBlank())
|
else if (videoDecoder->getBlank())
|
||||||
CLuaInstVideo::getInstance()->channelRezap(L);
|
CLuaInstVideo::getInstance()->channelRezap(L);
|
||||||
|
|
||||||
if(w){
|
if (w)
|
||||||
|
{
|
||||||
if (w->fbwin)
|
if (w->fbwin)
|
||||||
delete w->fbwin;
|
delete w->fbwin;
|
||||||
w->rcinput = NULL;
|
w->rcinput = NULL;
|
||||||
@@ -869,7 +889,8 @@ int CLuaInstance::GetInput(lua_State *L)
|
|||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
neutrino_msg_data_t data;
|
neutrino_msg_data_t data;
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W) return 0;
|
if (!W)
|
||||||
|
return 0;
|
||||||
if (numargs > 1)
|
if (numargs > 1)
|
||||||
timeout = luaL_checkint(L, 2);
|
timeout = luaL_checkint(L, 2);
|
||||||
W->rcinput->getMsg_ms(&msg, &data, timeout);
|
W->rcinput->getMsg_ms(&msg, &data, timeout);
|
||||||
@@ -895,7 +916,8 @@ int CLuaInstance::Blit(lua_State *)
|
|||||||
int CLuaInstance::Blit(lua_State *L)
|
int CLuaInstance::Blit(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (W && W->fbwin) {
|
if (W && W->fbwin)
|
||||||
|
{
|
||||||
if (lua_isnumber(L, 2))
|
if (lua_isnumber(L, 2))
|
||||||
W->fbwin->blit((int)lua_tonumber(L, 2)); // enable/disable automatic blit
|
W->fbwin->blit((int)lua_tonumber(L, 2)); // enable/disable automatic blit
|
||||||
else
|
else
|
||||||
@@ -923,7 +945,8 @@ int CLuaInstance::PaintBox(lua_State *L)
|
|||||||
lua_Unsigned c;
|
lua_Unsigned c;
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
x = luaL_checkint(L, 2);
|
x = luaL_checkint(L, 2);
|
||||||
y = luaL_checkint(L, 3);
|
y = luaL_checkint(L, 3);
|
||||||
w = luaL_checkint(L, 4);
|
w = luaL_checkint(L, 4);
|
||||||
@@ -955,7 +978,8 @@ int CLuaInstance::paintHLineRel(lua_State *L)
|
|||||||
lua_Unsigned c;
|
lua_Unsigned c;
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
x = luaL_checkint(L, 2);
|
x = luaL_checkint(L, 2);
|
||||||
dx = luaL_checkint(L, 3);
|
dx = luaL_checkint(L, 3);
|
||||||
y = luaL_checkint(L, 4);
|
y = luaL_checkint(L, 4);
|
||||||
@@ -978,7 +1002,8 @@ int CLuaInstance::paintVLineRel(lua_State *L)
|
|||||||
lua_Unsigned c;
|
lua_Unsigned c;
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
x = luaL_checkint(L, 2);
|
x = luaL_checkint(L, 2);
|
||||||
y = luaL_checkint(L, 3);
|
y = luaL_checkint(L, 3);
|
||||||
dy = luaL_checkint(L, 4);
|
dy = luaL_checkint(L, 4);
|
||||||
@@ -1010,31 +1035,38 @@ int CLuaInstance::RenderString(lua_State *L)
|
|||||||
center = 0;
|
center = 0;
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int step = 0;
|
int step = 0;
|
||||||
bool isDynFont = false;
|
bool isDynFont = false;
|
||||||
if (lua_isboolean(L, 2)) {
|
if (lua_isboolean(L, 2))
|
||||||
|
{
|
||||||
if (lua_toboolean(L, 2) == true)
|
if (lua_toboolean(L, 2) == true)
|
||||||
isDynFont = true;
|
isDynFont = true;
|
||||||
step = 1;
|
step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDynFont) {
|
if (!isDynFont)
|
||||||
|
{
|
||||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||||
font = g_Font[f];
|
font = g_Font[f];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||||
if (it->first == id) {
|
{
|
||||||
|
if (it->first == id)
|
||||||
|
{
|
||||||
font = it->second;
|
font = it->second;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (font == NULL) {
|
if (font == NULL)
|
||||||
|
{
|
||||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||||
lua_pushinteger(L, 0); /* no font found */
|
lua_pushinteger(L, 0); /* no font found */
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1057,7 +1089,8 @@ int CLuaInstance::RenderString(lua_State *L)
|
|||||||
|
|
||||||
int rwidth = font->getRenderWidth(text);
|
int rwidth = font->getRenderWidth(text);
|
||||||
|
|
||||||
if (center) { /* center the text inside the box */
|
if (center) /* center the text inside the box */
|
||||||
|
{
|
||||||
if (rwidth < w)
|
if (rwidth < w)
|
||||||
x += (w - rwidth) / 2;
|
x += (w - rwidth) / 2;
|
||||||
}
|
}
|
||||||
@@ -1075,31 +1108,38 @@ int CLuaInstance::getRenderWidth(lua_State *L)
|
|||||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W) return 0;
|
if (!W)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int step = 0;
|
int step = 0;
|
||||||
bool isDynFont = false;
|
bool isDynFont = false;
|
||||||
if (lua_isboolean(L, 2)) {
|
if (lua_isboolean(L, 2))
|
||||||
|
{
|
||||||
if (lua_toboolean(L, 2) == true)
|
if (lua_toboolean(L, 2) == true)
|
||||||
isDynFont = true;
|
isDynFont = true;
|
||||||
step = 1;
|
step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDynFont) {
|
if (!isDynFont)
|
||||||
|
{
|
||||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||||
font = g_Font[f];
|
font = g_Font[f];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||||
if (it->first == id) {
|
{
|
||||||
|
if (it->first == id)
|
||||||
|
{
|
||||||
font = it->second;
|
font = it->second;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (font == NULL) {
|
if (font == NULL)
|
||||||
|
{
|
||||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||||
lua_pushinteger(L, 0); /* no font found */
|
lua_pushinteger(L, 0); /* no font found */
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1118,31 +1158,38 @@ int CLuaInstance::FontHeight(lua_State *L)
|
|||||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W) return 0;
|
if (!W)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int step = 0;
|
int step = 0;
|
||||||
bool isDynFont = false;
|
bool isDynFont = false;
|
||||||
if (lua_isboolean(L, 2)) {
|
if (lua_isboolean(L, 2))
|
||||||
|
{
|
||||||
if (lua_toboolean(L, 2) == true)
|
if (lua_toboolean(L, 2) == true)
|
||||||
isDynFont = true;
|
isDynFont = true;
|
||||||
step = 1;
|
step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDynFont) {
|
if (!isDynFont)
|
||||||
|
{
|
||||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||||
font = g_Font[f];
|
font = g_Font[f];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||||
if (it->first == id) {
|
{
|
||||||
|
if (it->first == id)
|
||||||
|
{
|
||||||
font = it->second;
|
font = it->second;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (font == NULL) {
|
if (font == NULL)
|
||||||
|
{
|
||||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||||
lua_pushinteger(L, 0); /* no font found */
|
lua_pushinteger(L, 0); /* no font found */
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1157,15 +1204,18 @@ int CLuaInstance::getDynFont(lua_State *L)
|
|||||||
{
|
{
|
||||||
int numargs = lua_gettop(L);
|
int numargs = lua_gettop(L);
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (numargs < 3) {
|
if (numargs < 3)
|
||||||
|
{
|
||||||
printf("CLuaInstance::%s: not enough arguments (%d, expected 2)\n", __func__, numargs);
|
printf("CLuaInstance::%s: not enough arguments (%d, expected 2)\n", __func__, numargs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_Integer fontID = W->fontmap.size();
|
lua_Integer fontID = W->fontmap.size();
|
||||||
if (fontID >= CNeutrinoFonts::DYNFONTEXT_MAX) {
|
if (fontID >= CNeutrinoFonts::DYNFONTEXT_MAX)
|
||||||
|
{
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushinteger(L, DYNFONT_MAXIMUM_FONTS);
|
lua_pushinteger(L, DYNFONT_MAXIMUM_FONTS);
|
||||||
return 2;
|
return 2;
|
||||||
@@ -1176,20 +1226,23 @@ int CLuaInstance::getDynFont(lua_State *L)
|
|||||||
std::string text = "";
|
std::string text = "";
|
||||||
|
|
||||||
dx = luaL_checkint(L, 2);
|
dx = luaL_checkint(L, 2);
|
||||||
if (dx > (lua_Integer)CFrameBuffer::getInstance()->getScreenWidth(true)) {
|
if (dx > (lua_Integer)CFrameBuffer::getInstance()->getScreenWidth(true))
|
||||||
|
{
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushinteger(L, DYNFONT_TOO_WIDE);
|
lua_pushinteger(L, DYNFONT_TOO_WIDE);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
dy = luaL_checkint(L, 3);
|
dy = luaL_checkint(L, 3);
|
||||||
if (dy > 100) {
|
if (dy > 100)
|
||||||
|
{
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushinteger(L, DYNFONT_TOO_HIGH);
|
lua_pushinteger(L, DYNFONT_TOO_HIGH);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (numargs > 3)
|
if (numargs > 3)
|
||||||
text = luaL_checkstring(L, 4);
|
text = luaL_checkstring(L, 4);
|
||||||
if (numargs > 4) {
|
if (numargs > 4)
|
||||||
|
{
|
||||||
style = luaL_checkint(L, 5);
|
style = luaL_checkint(L, 5);
|
||||||
if (style > CNeutrinoFonts::FONT_STYLE_ITALIC)
|
if (style > CNeutrinoFonts::FONT_STYLE_ITALIC)
|
||||||
style = CNeutrinoFonts::FONT_STYLE_REGULAR;
|
style = CNeutrinoFonts::FONT_STYLE_REGULAR;
|
||||||
@@ -1214,7 +1267,8 @@ int CLuaInstance::PaintIcon(lua_State *L)
|
|||||||
const char *fname;
|
const char *fname;
|
||||||
|
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
fname = luaL_checkstring(L, 2);
|
fname = luaL_checkstring(L, 2);
|
||||||
x = luaL_checkint(L, 3);
|
x = luaL_checkint(L, 3);
|
||||||
y = luaL_checkint(L, 4);
|
y = luaL_checkint(L, 4);
|
||||||
@@ -1227,7 +1281,8 @@ int CLuaInstance::PaintIcon(lua_State *L)
|
|||||||
int CLuaInstance::DisplayImage(lua_State *L)
|
int CLuaInstance::DisplayImage(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W) return 0;
|
if (!W)
|
||||||
|
return 0;
|
||||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
const char *fname;
|
const char *fname;
|
||||||
@@ -1247,7 +1302,8 @@ int CLuaInstance::DisplayImage(lua_State *L)
|
|||||||
int CLuaInstance::GetSize(lua_State *L)
|
int CLuaInstance::GetSize(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W) return 0;
|
if (!W)
|
||||||
|
return 0;
|
||||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
const char *fname;
|
const char *fname;
|
||||||
@@ -1266,7 +1322,8 @@ int CLuaInstance::saveScreen(lua_State *L)
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
fb_pixel_t *buf;
|
fb_pixel_t *buf;
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
x = luaL_checkint(L, 2);
|
x = luaL_checkint(L, 2);
|
||||||
y = luaL_checkint(L, 3);
|
y = luaL_checkint(L, 3);
|
||||||
w = luaL_checkint(L, 4);
|
w = luaL_checkint(L, 4);
|
||||||
@@ -1286,7 +1343,8 @@ int CLuaInstance::restoreScreen(lua_State *L)
|
|||||||
fb_pixel_t *buf = NULL;
|
fb_pixel_t *buf = NULL;
|
||||||
bool del;
|
bool del;
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
x = luaL_checkint(L, 2);
|
x = luaL_checkint(L, 2);
|
||||||
y = luaL_checkint(L, 3);
|
y = luaL_checkint(L, 3);
|
||||||
w = luaL_checkint(L, 4);
|
w = luaL_checkint(L, 4);
|
||||||
@@ -1294,8 +1352,10 @@ int CLuaInstance::restoreScreen(lua_State *L)
|
|||||||
id = luaL_checkint(L, 6);
|
id = luaL_checkint(L, 6);
|
||||||
del = _luaL_checkbool(L, 7);
|
del = _luaL_checkbool(L, 7);
|
||||||
|
|
||||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it) {
|
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it)
|
||||||
if (it->first == id) {
|
{
|
||||||
|
if (it->first == id)
|
||||||
|
{
|
||||||
buf = it->second;
|
buf = it->second;
|
||||||
if (del)
|
if (del)
|
||||||
it->second = NULL;
|
it->second = NULL;
|
||||||
@@ -1311,12 +1371,16 @@ int CLuaInstance::deleteSavedScreen(lua_State *L)
|
|||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
id = luaL_checkint(L, 2);
|
id = luaL_checkint(L, 2);
|
||||||
|
|
||||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it) {
|
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it)
|
||||||
if (it->first == id) {
|
{
|
||||||
if (it->second != NULL) {
|
if (it->first == id)
|
||||||
|
{
|
||||||
|
if (it->second != NULL)
|
||||||
|
{
|
||||||
delete[] it->second;
|
delete[] it->second;
|
||||||
it->second = NULL;
|
it->second = NULL;
|
||||||
}
|
}
|
||||||
@@ -1329,7 +1393,8 @@ int CLuaInstance::deleteSavedScreen(lua_State *L)
|
|||||||
int CLuaInstance::scale2Res(lua_State *L)
|
int CLuaInstance::scale2Res(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaData *W = CheckData(L, 1);
|
CLuaData *W = CheckData(L, 1);
|
||||||
if (!W || !W->fbwin) return 0;
|
if (!W || !W->fbwin)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int value, ret;
|
int value, ret;
|
||||||
value = luaL_checkint(L, 2);
|
value = luaL_checkint(L, 2);
|
||||||
@@ -1346,12 +1411,14 @@ int CLuaInstance::scale2Res(lua_State *L)
|
|||||||
|
|
||||||
#if LUA_COMPAT_5_2
|
#if LUA_COMPAT_5_2
|
||||||
|
|
||||||
void lua_pushunsigned (lua_State *L, lua_Unsigned n) {
|
void lua_pushunsigned(lua_State *L, lua_Unsigned n)
|
||||||
|
{
|
||||||
lua_pushnumber(L, lua_unsigned2number(n));
|
lua_pushnumber(L, lua_unsigned2number(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lua_Unsigned luaL_checkunsigned (lua_State *L, int i) {
|
lua_Unsigned luaL_checkunsigned(lua_State *L, int i)
|
||||||
|
{
|
||||||
lua_Unsigned result;
|
lua_Unsigned result;
|
||||||
lua_Number n = lua_tonumber(L, i);
|
lua_Number n = lua_tonumber(L, i);
|
||||||
if (n == 0 && !lua_isnumber(L, i))
|
if (n == 0 && !lua_isnumber(L, i))
|
||||||
@@ -1360,19 +1427,22 @@ lua_Unsigned luaL_checkunsigned (lua_State *L, int i) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lua_absindex (lua_State *L, int i) {
|
int lua_absindex(lua_State *L, int i)
|
||||||
|
{
|
||||||
if (i < 0 && i > LUA_REGISTRYINDEX)
|
if (i < 0 && i > LUA_REGISTRYINDEX)
|
||||||
i += lua_gettop(L) + 1;
|
i += lua_gettop(L) + 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_rawgetp (lua_State *L, int i, const void *p) {
|
void lua_rawgetp(lua_State *L, int i, const void *p)
|
||||||
|
{
|
||||||
int abs_i = lua_absindex(L, i);
|
int abs_i = lua_absindex(L, i);
|
||||||
lua_pushlightuserdata(L, (void *)p);
|
lua_pushlightuserdata(L, (void *)p);
|
||||||
lua_rawget(L, abs_i);
|
lua_rawget(L, abs_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_rawsetp (lua_State *L, int i, const void *p) {
|
void lua_rawsetp(lua_State *L, int i, const void *p)
|
||||||
|
{
|
||||||
int abs_i = lua_absindex(L, i);
|
int abs_i = lua_absindex(L, i);
|
||||||
luaL_checkstack(L, 1, "not enough stack slots");
|
luaL_checkstack(L, 1, "not enough stack slots");
|
||||||
lua_pushlightuserdata(L, (void *)p);
|
lua_pushlightuserdata(L, (void *)p);
|
||||||
|
@@ -43,7 +43,8 @@ public:
|
|||||||
void runScript(const char *fileName, std::vector<std::string> *argv = NULL, std::string *result_code = NULL, std::string *result_string = NULL, std::string *error_string = NULL);
|
void runScript(const char *fileName, std::vector<std::string> *argv = NULL, std::string *result_code = NULL, std::string *result_string = NULL, std::string *error_string = NULL);
|
||||||
void abortScript();
|
void abortScript();
|
||||||
bool DisableAbort;
|
bool DisableAbort;
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
DYNFONT_NO_ERROR = 0,
|
DYNFONT_NO_ERROR = 0,
|
||||||
DYNFONT_MAXIMUM_FONTS = 1,
|
DYNFONT_MAXIMUM_FONTS = 1,
|
||||||
DYNFONT_TOO_WIDE = 2,
|
DYNFONT_TOO_WIDE = 2,
|
||||||
|
Reference in New Issue
Block a user