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:
@@ -62,8 +62,8 @@
|
||||
/* autogenerated from luainstance.h */
|
||||
#include "lua_api_version.h"
|
||||
|
||||
extern CPictureViewer * g_PicViewer;
|
||||
extern cVideo * videoDecoder;
|
||||
extern CPictureViewer *g_PicViewer;
|
||||
extern cVideo *videoDecoder;
|
||||
|
||||
static void set_lua_variables(lua_State *L)
|
||||
{
|
||||
@@ -213,44 +213,44 @@ static void set_lua_variables(lua_State *L)
|
||||
{ "PROGRESSBAR_PASSIVE", MAGIC_COLOR | (COL_PROGRESSBAR_PASSIVE_PLUS_0) },
|
||||
{ "BACKGROUND", MAGIC_COLOR | (COL_BACKGROUND) },
|
||||
|
||||
{ "COLORED_EVENTS_TEXT", (lua_Unsigned) (COL_COLORED_EVENTS_TEXT) },
|
||||
{ "INFOBAR_TEXT", (lua_Unsigned) (COL_INFOBAR_TEXT) },
|
||||
/* obsolete */ { "INFOBAR_SHADOW_TEXT", (lua_Unsigned) (COL_MENUFOOT_TEXT) }, // just here to stay backward compatible
|
||||
{ "MENUHEAD_TEXT", (lua_Unsigned) (COL_MENUHEAD_TEXT) },
|
||||
{ "MENUCONTENT_TEXT", (lua_Unsigned) (COL_MENUCONTENT_TEXT) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_3", (lua_Unsigned) (COL_MENUCONTENT_TEXT_PLUS_3) },
|
||||
{ "MENUCONTENTDARK_TEXT", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT) },
|
||||
{ "MENUCONTENTDARK_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENTDARK_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTDARK_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENTSELECTED_TEXT", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT) },
|
||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENTINACTIVE_TEXT", (lua_Unsigned) (COL_MENUCONTENTINACTIVE_TEXT) },
|
||||
{ "MENUFOOT_TEXT", (lua_Unsigned) (COL_MENUFOOT_TEXT) },
|
||||
{ "SHADOW_PLUS_0", (lua_Unsigned) (COL_SHADOW_PLUS_0) },
|
||||
{ "MENUHEAD_PLUS_0", (lua_Unsigned) (COL_MENUHEAD_PLUS_0) },
|
||||
{ "MENUCONTENT_PLUS_0", (lua_Unsigned) (COL_MENUCONTENT_PLUS_0) },
|
||||
{ "MENUCONTENT_PLUS_1", (lua_Unsigned) (COL_MENUCONTENT_PLUS_1) },
|
||||
{ "MENUCONTENT_PLUS_2", (lua_Unsigned) (COL_MENUCONTENT_PLUS_2) },
|
||||
{ "MENUCONTENT_PLUS_3", (lua_Unsigned) (COL_MENUCONTENT_PLUS_3) },
|
||||
{ "MENUCONTENT_PLUS_4", (lua_Unsigned) (COL_MENUCONTENT_PLUS_4) },
|
||||
{ "MENUCONTENT_PLUS_5", (lua_Unsigned) (COL_MENUCONTENT_PLUS_5) },
|
||||
{ "MENUCONTENT_PLUS_6", (lua_Unsigned) (COL_MENUCONTENT_PLUS_6) },
|
||||
{ "MENUCONTENT_PLUS_7", (lua_Unsigned) (COL_MENUCONTENT_PLUS_7) },
|
||||
{ "MENUCONTENTDARK_PLUS_0", (lua_Unsigned) (COL_MENUCONTENTDARK_PLUS_0) },
|
||||
{ "MENUCONTENTDARK_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTDARK_PLUS_2) },
|
||||
{ "MENUCONTENTSELECTED_PLUS_0", (lua_Unsigned) (COL_MENUCONTENTSELECTED_PLUS_0) },
|
||||
{ "MENUCONTENTSELECTED_PLUS_2", (lua_Unsigned) (COL_MENUCONTENTSELECTED_PLUS_2) },
|
||||
{ "MENUCONTENTINACTIVE_PLUS_0", (lua_Unsigned) (COL_MENUCONTENTINACTIVE_PLUS_0) },
|
||||
{ "MENUFOOT_PLUS_0", (lua_Unsigned) (COL_MENUFOOT_PLUS_0) },
|
||||
{ "FRAME_PLUS_0", (lua_Unsigned) (COL_FRAME_PLUS_0) },
|
||||
{ "SCROLLBAR_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_PLUS_0) },
|
||||
{ "SCROLLBAR_ACTIVE_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_ACTIVE_PLUS_0) },
|
||||
{ "SCROLLBAR_PASSIVE_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_PASSIVE_PLUS_0) },
|
||||
{ "PROGRESSBAR_ACTIVE_PLUS_0", (lua_Unsigned) (COL_PROGRESSBAR_ACTIVE_PLUS_0) },
|
||||
{ "PROGRESSBAR_PASSIVE_PLUS_0", (lua_Unsigned) (COL_PROGRESSBAR_PASSIVE_PLUS_0) },
|
||||
{ "COLORED_EVENTS_TEXT", (lua_Unsigned)(COL_COLORED_EVENTS_TEXT) },
|
||||
{ "INFOBAR_TEXT", (lua_Unsigned)(COL_INFOBAR_TEXT) },
|
||||
/* obsolete */ { "INFOBAR_SHADOW_TEXT", (lua_Unsigned)(COL_MENUFOOT_TEXT) }, // just here to stay backward compatible
|
||||
{ "MENUHEAD_TEXT", (lua_Unsigned)(COL_MENUHEAD_TEXT) },
|
||||
{ "MENUCONTENT_TEXT", (lua_Unsigned)(COL_MENUCONTENT_TEXT) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_1", (lua_Unsigned)(COL_MENUCONTENT_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_2", (lua_Unsigned)(COL_MENUCONTENT_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENT_TEXT_PLUS_3", (lua_Unsigned)(COL_MENUCONTENT_TEXT_PLUS_3) },
|
||||
{ "MENUCONTENTDARK_TEXT", (lua_Unsigned)(COL_MENUCONTENTDARK_TEXT) },
|
||||
{ "MENUCONTENTDARK_TEXT_PLUS_1", (lua_Unsigned)(COL_MENUCONTENTDARK_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENTDARK_TEXT_PLUS_2", (lua_Unsigned)(COL_MENUCONTENTDARK_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENTSELECTED_TEXT", (lua_Unsigned)(COL_MENUCONTENTSELECTED_TEXT) },
|
||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_1", (lua_Unsigned)(COL_MENUCONTENTSELECTED_TEXT_PLUS_1) },
|
||||
{ "MENUCONTENTSELECTED_TEXT_PLUS_2", (lua_Unsigned)(COL_MENUCONTENTSELECTED_TEXT_PLUS_2) },
|
||||
{ "MENUCONTENTINACTIVE_TEXT", (lua_Unsigned)(COL_MENUCONTENTINACTIVE_TEXT) },
|
||||
{ "MENUFOOT_TEXT", (lua_Unsigned)(COL_MENUFOOT_TEXT) },
|
||||
{ "SHADOW_PLUS_0", (lua_Unsigned)(COL_SHADOW_PLUS_0) },
|
||||
{ "MENUHEAD_PLUS_0", (lua_Unsigned)(COL_MENUHEAD_PLUS_0) },
|
||||
{ "MENUCONTENT_PLUS_0", (lua_Unsigned)(COL_MENUCONTENT_PLUS_0) },
|
||||
{ "MENUCONTENT_PLUS_1", (lua_Unsigned)(COL_MENUCONTENT_PLUS_1) },
|
||||
{ "MENUCONTENT_PLUS_2", (lua_Unsigned)(COL_MENUCONTENT_PLUS_2) },
|
||||
{ "MENUCONTENT_PLUS_3", (lua_Unsigned)(COL_MENUCONTENT_PLUS_3) },
|
||||
{ "MENUCONTENT_PLUS_4", (lua_Unsigned)(COL_MENUCONTENT_PLUS_4) },
|
||||
{ "MENUCONTENT_PLUS_5", (lua_Unsigned)(COL_MENUCONTENT_PLUS_5) },
|
||||
{ "MENUCONTENT_PLUS_6", (lua_Unsigned)(COL_MENUCONTENT_PLUS_6) },
|
||||
{ "MENUCONTENT_PLUS_7", (lua_Unsigned)(COL_MENUCONTENT_PLUS_7) },
|
||||
{ "MENUCONTENTDARK_PLUS_0", (lua_Unsigned)(COL_MENUCONTENTDARK_PLUS_0) },
|
||||
{ "MENUCONTENTDARK_PLUS_2", (lua_Unsigned)(COL_MENUCONTENTDARK_PLUS_2) },
|
||||
{ "MENUCONTENTSELECTED_PLUS_0", (lua_Unsigned)(COL_MENUCONTENTSELECTED_PLUS_0) },
|
||||
{ "MENUCONTENTSELECTED_PLUS_2", (lua_Unsigned)(COL_MENUCONTENTSELECTED_PLUS_2) },
|
||||
{ "MENUCONTENTINACTIVE_PLUS_0" , (lua_Unsigned)(COL_MENUCONTENTINACTIVE_PLUS_0) },
|
||||
{ "MENUFOOT_PLUS_0", (lua_Unsigned)(COL_MENUFOOT_PLUS_0) },
|
||||
{ "FRAME_PLUS_0", (lua_Unsigned)(COL_FRAME_PLUS_0) },
|
||||
{ "SCROLLBAR_PLUS_0", (lua_Unsigned)(COL_SCROLLBAR_PLUS_0) },
|
||||
{ "SCROLLBAR_ACTIVE_PLUS_0", (lua_Unsigned)(COL_SCROLLBAR_ACTIVE_PLUS_0) },
|
||||
{ "SCROLLBAR_PASSIVE_PLUS_0", (lua_Unsigned)(COL_SCROLLBAR_PASSIVE_PLUS_0) },
|
||||
{ "PROGRESSBAR_ACTIVE_PLUS_0", (lua_Unsigned)(COL_PROGRESSBAR_ACTIVE_PLUS_0) },
|
||||
{ "PROGRESSBAR_PASSIVE_PLUS_0", (lua_Unsigned)(COL_PROGRESSBAR_PASSIVE_PLUS_0) },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -290,7 +290,7 @@ static void set_lua_variables(lua_State *L)
|
||||
{ "BUTTON_TEXT", SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT },
|
||||
{ "WINDOW_GENERAL", SNeutrinoSettings::FONT_TYPE_WINDOW_GENERAL },
|
||||
{ "RADIOTEXT_TITLE", SNeutrinoSettings::FONT_TYPE_WINDOW_RADIOTEXT_TITLE },
|
||||
{ "WINDOW_RADIOTEXT_DESC", SNeutrinoSettings::FONT_TYPE_WINDOW_RADIOTEXT_DESC },
|
||||
{ "WINDOW_RADIOTEXT_DESC", SNeutrinoSettings::FONT_TYPE_WINDOW_RADIOTEXT_DESC },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -352,11 +352,11 @@ static void set_lua_variables(lua_State *L)
|
||||
|
||||
table_key playstate[] =
|
||||
{
|
||||
{ "NORMAL", CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL },
|
||||
{ "STOP", CMoviePlayerGui::PLUGIN_PLAYSTATE_STOP },
|
||||
{ "NEXT", CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT },
|
||||
{ "PREV", CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV },
|
||||
{ "LEAVE_ALL", CMoviePlayerGui::PLUGIN_PLAYSTATE_LEAVE_ALL },
|
||||
{ "NORMAL", CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL },
|
||||
{ "STOP", CMoviePlayerGui::PLUGIN_PLAYSTATE_STOP },
|
||||
{ "NEXT", CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT },
|
||||
{ "PREV", CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV },
|
||||
{ "LEAVE_ALL", CMoviePlayerGui::PLUGIN_PLAYSTATE_LEAVE_ALL },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -396,25 +396,25 @@ static void set_lua_variables(lua_State *L)
|
||||
|
||||
table_key neutrino_mode[] =
|
||||
{
|
||||
{ "UNKNOWN", (lua_Integer)NeutrinoModes::mode_unknown },
|
||||
{ "TV", (lua_Integer)NeutrinoModes::mode_tv },
|
||||
{ "RADIO", (lua_Integer)NeutrinoModes::mode_radio },
|
||||
{ "AVINPUT", (lua_Integer)NeutrinoModes::mode_avinput },
|
||||
{ "STANDBY", (lua_Integer)NeutrinoModes::mode_standby },
|
||||
{ "AUDIO", (lua_Integer)NeutrinoModes::mode_audio },
|
||||
{ "PIC", (lua_Integer)NeutrinoModes::mode_pic },
|
||||
{ "TS", (lua_Integer)NeutrinoModes::mode_ts },
|
||||
{ "OFF", (lua_Integer)NeutrinoModes::mode_off },
|
||||
{ "WEBTV", (lua_Integer)NeutrinoModes::mode_webtv },
|
||||
{ "WEBRADIO", (lua_Integer)NeutrinoModes::mode_webradio },
|
||||
{ "MASK", (lua_Integer)NeutrinoModes::mode_mask },
|
||||
{ "NOREZAP", (lua_Integer)NeutrinoModes::norezap },
|
||||
{ "UNKNOWN", (lua_Integer)NeutrinoModes::mode_unknown },
|
||||
{ "TV", (lua_Integer)NeutrinoModes::mode_tv },
|
||||
{ "RADIO", (lua_Integer)NeutrinoModes::mode_radio },
|
||||
{ "AVINPUT", (lua_Integer)NeutrinoModes::mode_avinput },
|
||||
{ "STANDBY", (lua_Integer)NeutrinoModes::mode_standby },
|
||||
{ "AUDIO", (lua_Integer)NeutrinoModes::mode_audio },
|
||||
{ "PIC", (lua_Integer)NeutrinoModes::mode_pic },
|
||||
{ "TS", (lua_Integer)NeutrinoModes::mode_ts },
|
||||
{ "OFF", (lua_Integer)NeutrinoModes::mode_off },
|
||||
{ "WEBTV", (lua_Integer)NeutrinoModes::mode_webtv },
|
||||
{ "WEBRADIO", (lua_Integer)NeutrinoModes::mode_webradio },
|
||||
{ "MASK", (lua_Integer)NeutrinoModes::mode_mask },
|
||||
{ "NOREZAP", (lua_Integer)NeutrinoModes::norezap },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
table_key post_msg[] =
|
||||
{
|
||||
{ "STANDBY_ON", (lua_Integer)CLuaInstMisc::POSTMSG_STANDBY_ON },
|
||||
{ "STANDBY_ON", (lua_Integer)CLuaInstMisc::POSTMSG_STANDBY_ON },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -424,9 +424,9 @@ static void set_lua_variables(lua_State *L)
|
||||
*/
|
||||
table_key text_alignment[] =
|
||||
{
|
||||
{ "DEFAULT", (lua_Integer)CTextBox::NO_AUTO_LINEBREAK},
|
||||
{ "CENTER", (lua_Integer)CTextBox::CENTER},
|
||||
{ "RIGHT", (lua_Integer)CTextBox::RIGHT},
|
||||
{ "DEFAULT", (lua_Integer)CTextBox::NO_AUTO_LINEBREAK},
|
||||
{ "CENTER", (lua_Integer)CTextBox::CENTER},
|
||||
{ "RIGHT", (lua_Integer)CTextBox::RIGHT},
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -475,23 +475,25 @@ static void set_lua_variables(lua_State *L)
|
||||
{ "FONT", fontlist },
|
||||
{ "CORNER", corners },
|
||||
{ "OFFSET", offsets },
|
||||
{ "MENU_RETURN", menureturn },
|
||||
{ "APIVERSION", apiversion },
|
||||
{ "PLAYSTATE", playstate },
|
||||
{ "CC", ccomponents },
|
||||
{ "DYNFONT", dynfont },
|
||||
{ "CURL", curl_status },
|
||||
{ "NMODE", neutrino_mode },
|
||||
{ "POSTMSG", post_msg },
|
||||
{ "MENU_RETURN", menureturn },
|
||||
{ "APIVERSION", apiversion },
|
||||
{ "PLAYSTATE", playstate },
|
||||
{ "CC", ccomponents },
|
||||
{ "DYNFONT", dynfont },
|
||||
{ "CURL", curl_status },
|
||||
{ "NMODE", neutrino_mode },
|
||||
{ "POSTMSG", post_msg },
|
||||
{ "TEXT_ALIGNMENT", text_alignment },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
while (e[i].name) {
|
||||
while (e[i].name)
|
||||
{
|
||||
int j = 0;
|
||||
lua_newtable(L);
|
||||
while (e[i].t[j].name) {
|
||||
while (e[i].t[j].name)
|
||||
{
|
||||
lua_pushstring(L, e[i].t[j].name);
|
||||
lua_pushinteger(L, e[i].t[j].code);
|
||||
lua_settable(L, -3);
|
||||
@@ -508,10 +510,12 @@ static void set_lua_variables(lua_State *L)
|
||||
};
|
||||
|
||||
i = 0;
|
||||
while (e_u[i].name) {
|
||||
while (e_u[i].name)
|
||||
{
|
||||
int j = 0;
|
||||
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_pushunsigned(L, e_u[i].t[j].code);
|
||||
lua_settable(L, -3);
|
||||
@@ -528,10 +532,12 @@ static void set_lua_variables(lua_State *L)
|
||||
};
|
||||
|
||||
i = 0;
|
||||
while (e_s[i].name) {
|
||||
while (e_s[i].name)
|
||||
{
|
||||
int j = 0;
|
||||
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].code);
|
||||
lua_settable(L, -3);
|
||||
@@ -547,7 +553,7 @@ const char CLuaInstance::className[] = LUA_CLASSNAME;
|
||||
CLuaInstance::CLuaInstance()
|
||||
{
|
||||
DisableAbort = true;
|
||||
/* Create the intepreter object. */
|
||||
/* Create the intepreter object. */
|
||||
lua = luaL_newstate();
|
||||
|
||||
/* register standard + custom functions. */
|
||||
@@ -576,11 +582,12 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
||||
// luaL_dofile(lua, fileName);
|
||||
/* run the script */
|
||||
int status = luaL_loadfile(lua, fileName);
|
||||
if (status) {
|
||||
bool isString = lua_isstring(lua,-1);
|
||||
if (status)
|
||||
{
|
||||
bool isString = lua_isstring(lua, -1);
|
||||
const char *null = "NULL";
|
||||
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, isString ? lua_tostring(lua, -1):null);
|
||||
DisplayErrorMessage(isString ? lua_tostring(lua, -1):null, "Lua Script Error:");
|
||||
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, isString ? lua_tostring(lua, -1) : null);
|
||||
DisplayErrorMessage(isString ? lua_tostring(lua, -1) : null, "Lua Script Error:");
|
||||
if (error_string)
|
||||
*error_string = std::string(lua_tostring(lua, -1));
|
||||
return;
|
||||
@@ -596,10 +603,13 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
||||
lua_pushstring(lua, fileName);
|
||||
lua_rawseti(lua, -2, n++);
|
||||
|
||||
if (argv && (!argv->empty())) {
|
||||
if (argv && (!argv->empty()))
|
||||
{
|
||||
std::string abort = "DisableAbort";
|
||||
for(std::vector<std::string>::iterator it = argv->begin(); it != argv->end(); ++it) {
|
||||
if (!it->compare(abort)) {
|
||||
for (std::vector<std::string>::iterator it = argv->begin(); it != argv->end(); ++it)
|
||||
{
|
||||
if (!it->compare(abort))
|
||||
{
|
||||
DisableAbort = false;
|
||||
continue;
|
||||
}
|
||||
@@ -615,22 +625,25 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
||||
*result_string = std::string(lua_tostring(lua, -1));
|
||||
if (status)
|
||||
{
|
||||
bool isString = lua_isstring(lua,-1);
|
||||
bool isString = lua_isstring(lua, -1);
|
||||
const char *null = "NULL";
|
||||
fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, isString ? lua_tostring(lua, -1):null);
|
||||
DisplayErrorMessage(isString ? lua_tostring(lua, -1):null, "Lua Script Error:");
|
||||
fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, isString ? lua_tostring(lua, -1) : null);
|
||||
DisplayErrorMessage(isString ? lua_tostring(lua, -1) : null, "Lua Script Error:");
|
||||
if (error_string)
|
||||
*error_string = std::string(lua_tostring(lua, -1));
|
||||
/* restoreNeutrino at plugin crash, when blocked from plugin */
|
||||
if (CMoviePlayerGui::getInstance().getBlockedFromPlugin()) {
|
||||
if (CMoviePlayerGui::getInstance().getBlockedFromPlugin())
|
||||
{
|
||||
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
||||
CMoviePlayerGui::getInstance().restoreNeutrino();
|
||||
} else if (videoDecoder->getBlank())
|
||||
}
|
||||
else if (videoDecoder->getBlank())
|
||||
CLuaInstVideo::getInstance()->channelRezap(lua);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CLuaInstVideo::getInstance() && CMoviePlayerGui::getInstance().getBlockedFromPlugin()){
|
||||
if (CLuaInstVideo::getInstance() && CMoviePlayerGui::getInstance().getBlockedFromPlugin())
|
||||
{
|
||||
CMoviePlayerGui::getInstance().setBlockedFromPlugin(false);
|
||||
CMoviePlayerGui::getInstance().restoreNeutrino();
|
||||
}
|
||||
@@ -647,16 +660,18 @@ void CLuaInstance::runScript(const char *fileName, const char *arg0, ...)
|
||||
args.push_back(arg0);
|
||||
va_list list;
|
||||
va_start(list, arg0);
|
||||
const char* temp = va_arg(list, const char*);
|
||||
while (temp != NULL) {
|
||||
if (i >= 64) {
|
||||
const char *temp = va_arg(list, const char *);
|
||||
while (temp != NULL)
|
||||
{
|
||||
if (i >= 64)
|
||||
{
|
||||
fprintf(stderr, "CLuaInstance::runScript: too many arguments!\n");
|
||||
args.clear();
|
||||
va_end(list);
|
||||
return;
|
||||
}
|
||||
args.push_back(temp);
|
||||
temp = va_arg(list, const char*);
|
||||
temp = va_arg(list, const char *);
|
||||
i++;
|
||||
}
|
||||
va_end(list);
|
||||
@@ -671,7 +686,7 @@ static void abortHook(lua_State *lua, lua_Debug *)
|
||||
|
||||
void CLuaInstance::abortScript()
|
||||
{
|
||||
if(DisableAbort)
|
||||
if (DisableAbort)
|
||||
lua_sethook(lua, &abortHook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||
else
|
||||
fprintf(stderr, "DisableAbort Script is aktiv\n");
|
||||
@@ -681,7 +696,7 @@ void CLuaInstance::abortScript()
|
||||
#ifdef STATIC_LUAPOSIX
|
||||
/* hack: we link against luaposix, which is included in our
|
||||
* custom built lualib */
|
||||
extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); }
|
||||
extern "C" { LUAMOD_API int (luaopen_posix_c)(lua_State *L); }
|
||||
#endif
|
||||
|
||||
/* load basic functions and register our own C callbacks */
|
||||
@@ -794,11 +809,12 @@ CLuaData *CLuaInstance::CheckData(lua_State *L, int narg)
|
||||
{
|
||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||
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);
|
||||
return NULL;
|
||||
}
|
||||
return *(CLuaData **)ud; // unbox pointer
|
||||
return *(CLuaData **)ud; // unbox pointer
|
||||
}
|
||||
|
||||
int CLuaInstance::NewWindow(lua_State *L)
|
||||
@@ -831,8 +847,10 @@ int CLuaInstance::GCWindow(lua_State *L)
|
||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
CLuaData *w = (CLuaData *)lua_unboxpointer(L, 1);
|
||||
|
||||
if (w && w->fbwin) {
|
||||
for (screenmap_iterator_t it = w->screenmap.begin(); it != w->screenmap.end(); ++it) {
|
||||
if (w && w->fbwin)
|
||||
{
|
||||
for (screenmap_iterator_t it = w->screenmap.begin(); it != w->screenmap.end(); ++it)
|
||||
{
|
||||
if (it->second != NULL)
|
||||
delete[] it->second;
|
||||
}
|
||||
@@ -846,15 +864,17 @@ int CLuaInstance::GCWindow(lua_State *L)
|
||||
bool block = CMoviePlayerGui::getInstance().getBlockedFromPlugin();
|
||||
bool play = CMoviePlayerGui::getInstance().Playing();
|
||||
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().restoreNeutrino();
|
||||
}
|
||||
else if (videoDecoder->getBlank())
|
||||
CLuaInstVideo::getInstance()->channelRezap(L);
|
||||
|
||||
if(w){
|
||||
if(w->fbwin)
|
||||
if (w)
|
||||
{
|
||||
if (w->fbwin)
|
||||
delete w->fbwin;
|
||||
w->rcinput = NULL;
|
||||
delete w;
|
||||
@@ -869,7 +889,8 @@ int CLuaInstance::GetInput(lua_State *L)
|
||||
neutrino_msg_t msg;
|
||||
neutrino_msg_data_t data;
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W) return 0;
|
||||
if (!W)
|
||||
return 0;
|
||||
if (numargs > 1)
|
||||
timeout = luaL_checkint(L, 2);
|
||||
W->rcinput->getMsg_ms(&msg, &data, timeout);
|
||||
@@ -895,7 +916,8 @@ int CLuaInstance::Blit(lua_State *)
|
||||
int CLuaInstance::Blit(lua_State *L)
|
||||
{
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (W && W->fbwin) {
|
||||
if (W && W->fbwin)
|
||||
{
|
||||
if (lua_isnumber(L, 2))
|
||||
W->fbwin->blit((int)lua_tonumber(L, 2)); // enable/disable automatic blit
|
||||
else
|
||||
@@ -923,7 +945,8 @@ int CLuaInstance::PaintBox(lua_State *L)
|
||||
lua_Unsigned c;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
x = luaL_checkint(L, 2);
|
||||
y = luaL_checkint(L, 3);
|
||||
w = luaL_checkint(L, 4);
|
||||
@@ -955,7 +978,8 @@ int CLuaInstance::paintHLineRel(lua_State *L)
|
||||
lua_Unsigned c;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
x = luaL_checkint(L, 2);
|
||||
dx = luaL_checkint(L, 3);
|
||||
y = luaL_checkint(L, 4);
|
||||
@@ -978,7 +1002,8 @@ int CLuaInstance::paintVLineRel(lua_State *L)
|
||||
lua_Unsigned c;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
x = luaL_checkint(L, 2);
|
||||
y = luaL_checkint(L, 3);
|
||||
dy = luaL_checkint(L, 4);
|
||||
@@ -1000,7 +1025,7 @@ int CLuaInstance::paintVLineRel(lua_State *L)
|
||||
int CLuaInstance::RenderString(lua_State *L)
|
||||
{
|
||||
int x, y, w, boxh, center;
|
||||
Font* font = NULL;
|
||||
Font *font = NULL;
|
||||
lua_Unsigned c;
|
||||
const char *text;
|
||||
int numargs = lua_gettop(L);
|
||||
@@ -1010,54 +1035,62 @@ int CLuaInstance::RenderString(lua_State *L)
|
||||
center = 0;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
|
||||
int step = 0;
|
||||
bool isDynFont = false;
|
||||
if (lua_isboolean(L, 2)) {
|
||||
if (lua_isboolean(L, 2))
|
||||
{
|
||||
if (lua_toboolean(L, 2) == true)
|
||||
isDynFont = true;
|
||||
step = 1;
|
||||
}
|
||||
|
||||
if (!isDynFont) {
|
||||
int f = luaL_checkint(L, 2+step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (!isDynFont)
|
||||
{
|
||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
font = g_Font[f];
|
||||
}
|
||||
else {
|
||||
int id = luaL_checkint(L, 2+step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
else
|
||||
{
|
||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||
{
|
||||
if (it->first == id)
|
||||
{
|
||||
font = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (font == NULL) {
|
||||
if (font == NULL)
|
||||
{
|
||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||
lua_pushinteger(L, 0); /* no font found */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
text = luaL_checkstring(L, 3+step); /* text */
|
||||
x = luaL_checkint(L, 4+step);
|
||||
y = luaL_checkint(L, 5+step);
|
||||
if (numargs > 5+step)
|
||||
c = luaL_checkunsigned(L, 6+step);
|
||||
if (numargs > 6+step)
|
||||
w = luaL_checkint(L, 7+step);
|
||||
text = luaL_checkstring(L, 3 + step); /* text */
|
||||
x = luaL_checkint(L, 4 + step);
|
||||
y = luaL_checkint(L, 5 + step);
|
||||
if (numargs > 5 + step)
|
||||
c = luaL_checkunsigned(L, 6 + step);
|
||||
if (numargs > 6 + step)
|
||||
w = luaL_checkint(L, 7 + step);
|
||||
else
|
||||
w = W->fbwin->dx - x;
|
||||
if (numargs > 7+step)
|
||||
boxh = luaL_checkint(L, 8+step);
|
||||
if (numargs > 8+step)
|
||||
center = luaL_checkint(L, 9+step);
|
||||
if (numargs > 7 + step)
|
||||
boxh = luaL_checkint(L, 8 + step);
|
||||
if (numargs > 8 + step)
|
||||
center = luaL_checkint(L, 9 + step);
|
||||
|
||||
int rwidth = font->getRenderWidth(text);
|
||||
|
||||
if (center) { /* center the text inside the box */
|
||||
if (center) /* center the text inside the box */
|
||||
{
|
||||
if (rwidth < w)
|
||||
x += (w - rwidth) / 2;
|
||||
}
|
||||
@@ -1070,43 +1103,50 @@ int CLuaInstance::RenderString(lua_State *L)
|
||||
|
||||
int CLuaInstance::getRenderWidth(lua_State *L)
|
||||
{
|
||||
Font* font = NULL;
|
||||
Font *font = NULL;
|
||||
const char *text;
|
||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W) return 0;
|
||||
if (!W)
|
||||
return 0;
|
||||
|
||||
int step = 0;
|
||||
bool isDynFont = false;
|
||||
if (lua_isboolean(L, 2)) {
|
||||
if (lua_isboolean(L, 2))
|
||||
{
|
||||
if (lua_toboolean(L, 2) == true)
|
||||
isDynFont = true;
|
||||
step = 1;
|
||||
}
|
||||
|
||||
if (!isDynFont) {
|
||||
int f = luaL_checkint(L, 2+step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (!isDynFont)
|
||||
{
|
||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
font = g_Font[f];
|
||||
}
|
||||
else {
|
||||
int id = luaL_checkint(L, 2+step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
else
|
||||
{
|
||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||
{
|
||||
if (it->first == id)
|
||||
{
|
||||
font = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (font == NULL) {
|
||||
if (font == NULL)
|
||||
{
|
||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||
lua_pushinteger(L, 0); /* no font found */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
text = luaL_checkstring(L, 3+step); /* text */
|
||||
text = luaL_checkstring(L, 3 + step); /* text */
|
||||
|
||||
lua_pushinteger(L, (int)font->getRenderWidth(text));
|
||||
return 1;
|
||||
@@ -1114,35 +1154,42 @@ int CLuaInstance::getRenderWidth(lua_State *L)
|
||||
|
||||
int CLuaInstance::FontHeight(lua_State *L)
|
||||
{
|
||||
Font* font = NULL;
|
||||
Font *font = NULL;
|
||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W) return 0;
|
||||
if (!W)
|
||||
return 0;
|
||||
|
||||
int step = 0;
|
||||
bool isDynFont = false;
|
||||
if (lua_isboolean(L, 2)) {
|
||||
if (lua_isboolean(L, 2))
|
||||
{
|
||||
if (lua_toboolean(L, 2) == true)
|
||||
isDynFont = true;
|
||||
step = 1;
|
||||
}
|
||||
|
||||
if (!isDynFont) {
|
||||
int f = luaL_checkint(L, 2+step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (!isDynFont)
|
||||
{
|
||||
int f = luaL_checkint(L, 2 + step); /* font number, use FONT_TYPE_XXX in the script */
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
font = g_Font[f];
|
||||
}
|
||||
else {
|
||||
int id = luaL_checkint(L, 2+step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
else
|
||||
{
|
||||
int id = luaL_checkint(L, 2 + step); /* dynfont */
|
||||
for (fontmap_iterator_t it = W->fontmap.begin(); it != W->fontmap.end(); ++it)
|
||||
{
|
||||
if (it->first == id)
|
||||
{
|
||||
font = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (font == NULL) {
|
||||
if (font == NULL)
|
||||
{
|
||||
printf("[CLuaInstance::%s:%d] no font found\n", __func__, __LINE__);
|
||||
lua_pushinteger(L, 0); /* no font found */
|
||||
return 1;
|
||||
@@ -1157,15 +1204,18 @@ int CLuaInstance::getDynFont(lua_State *L)
|
||||
{
|
||||
int numargs = lua_gettop(L);
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_Integer fontID = W->fontmap.size();
|
||||
if (fontID >= CNeutrinoFonts::DYNFONTEXT_MAX) {
|
||||
if (fontID >= CNeutrinoFonts::DYNFONTEXT_MAX)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_pushinteger(L, DYNFONT_MAXIMUM_FONTS);
|
||||
return 2;
|
||||
@@ -1173,29 +1223,32 @@ int CLuaInstance::getDynFont(lua_State *L)
|
||||
|
||||
int dx = 0, dy = 0;
|
||||
lua_Integer style = CNeutrinoFonts::FONT_STYLE_REGULAR;
|
||||
std::string text="";
|
||||
std::string text = "";
|
||||
|
||||
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_pushinteger(L, DYNFONT_TOO_WIDE);
|
||||
return 2;
|
||||
}
|
||||
dy = luaL_checkint(L, 3);
|
||||
if (dy > 100) {
|
||||
if (dy > 100)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_pushinteger(L, DYNFONT_TOO_HIGH);
|
||||
return 2;
|
||||
}
|
||||
if (numargs > 3)
|
||||
text = luaL_checkstring(L, 4);
|
||||
if (numargs > 4) {
|
||||
if (numargs > 4)
|
||||
{
|
||||
style = luaL_checkint(L, 5);
|
||||
if (style > CNeutrinoFonts::FONT_STYLE_ITALIC)
|
||||
style = CNeutrinoFonts::FONT_STYLE_REGULAR;
|
||||
}
|
||||
|
||||
Font* f = CNeutrinoFonts::getInstance()->getDynFontExt(dx, dy, fontID, text, style);
|
||||
Font *f = CNeutrinoFonts::getInstance()->getDynFontExt(dx, dy, fontID, text, style);
|
||||
|
||||
lua_Integer id = fontID + 1;
|
||||
W->fontmap.insert(fontmap_pair_t(id, f));
|
||||
@@ -1214,7 +1267,8 @@ int CLuaInstance::PaintIcon(lua_State *L)
|
||||
const char *fname;
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
fname = luaL_checkstring(L, 2);
|
||||
x = luaL_checkint(L, 3);
|
||||
y = luaL_checkint(L, 4);
|
||||
@@ -1227,7 +1281,8 @@ int CLuaInstance::PaintIcon(lua_State *L)
|
||||
int CLuaInstance::DisplayImage(lua_State *L)
|
||||
{
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W) return 0;
|
||||
if (!W)
|
||||
return 0;
|
||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
int x, y, w, h;
|
||||
const char *fname;
|
||||
@@ -1247,7 +1302,8 @@ int CLuaInstance::DisplayImage(lua_State *L)
|
||||
int CLuaInstance::GetSize(lua_State *L)
|
||||
{
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W) return 0;
|
||||
if (!W)
|
||||
return 0;
|
||||
LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
int w = 0, h = 0;
|
||||
const char *fname;
|
||||
@@ -1264,9 +1320,10 @@ int CLuaInstance::GetSize(lua_State *L)
|
||||
int CLuaInstance::saveScreen(lua_State *L)
|
||||
{
|
||||
int x, y, w, h;
|
||||
fb_pixel_t* buf;
|
||||
fb_pixel_t *buf;
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
x = luaL_checkint(L, 2);
|
||||
y = luaL_checkint(L, 3);
|
||||
w = luaL_checkint(L, 4);
|
||||
@@ -1283,10 +1340,11 @@ int CLuaInstance::saveScreen(lua_State *L)
|
||||
int CLuaInstance::restoreScreen(lua_State *L)
|
||||
{
|
||||
int x, y, w, h, id;
|
||||
fb_pixel_t* buf = NULL;
|
||||
fb_pixel_t *buf = NULL;
|
||||
bool del;
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
x = luaL_checkint(L, 2);
|
||||
y = luaL_checkint(L, 3);
|
||||
w = luaL_checkint(L, 4);
|
||||
@@ -1294,8 +1352,10 @@ int CLuaInstance::restoreScreen(lua_State *L)
|
||||
id = luaL_checkint(L, 6);
|
||||
del = _luaL_checkbool(L, 7);
|
||||
|
||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it)
|
||||
{
|
||||
if (it->first == id)
|
||||
{
|
||||
buf = it->second;
|
||||
if (del)
|
||||
it->second = NULL;
|
||||
@@ -1311,12 +1371,16 @@ int CLuaInstance::deleteSavedScreen(lua_State *L)
|
||||
{
|
||||
int id;
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
id = luaL_checkint(L, 2);
|
||||
|
||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
if (it->second != NULL) {
|
||||
for (screenmap_iterator_t it = W->screenmap.begin(); it != W->screenmap.end(); ++it)
|
||||
{
|
||||
if (it->first == id)
|
||||
{
|
||||
if (it->second != NULL)
|
||||
{
|
||||
delete[] it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
@@ -1329,12 +1393,13 @@ int CLuaInstance::deleteSavedScreen(lua_State *L)
|
||||
int CLuaInstance::scale2Res(lua_State *L)
|
||||
{
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W || !W->fbwin) return 0;
|
||||
if (!W || !W->fbwin)
|
||||
return 0;
|
||||
|
||||
int value, ret;
|
||||
value = luaL_checkint(L, 2);
|
||||
|
||||
/* Remove this when pu/fb-setmode branch is merged to master */
|
||||
/* Remove this when pu/fb-setmode branch is merged to master */
|
||||
#ifdef SCALE2RES_DEFINED
|
||||
ret = CFrameBuffer::getInstance()->scale2Res(value);
|
||||
#else
|
||||
@@ -1346,38 +1411,43 @@ int CLuaInstance::scale2Res(lua_State *L)
|
||||
|
||||
#if LUA_COMPAT_5_2
|
||||
|
||||
void lua_pushunsigned (lua_State *L, lua_Unsigned n) {
|
||||
lua_pushnumber(L, lua_unsigned2number(n));
|
||||
void lua_pushunsigned(lua_State *L, lua_Unsigned n)
|
||||
{
|
||||
lua_pushnumber(L, lua_unsigned2number(n));
|
||||
}
|
||||
|
||||
|
||||
lua_Unsigned luaL_checkunsigned (lua_State *L, int i) {
|
||||
lua_Unsigned result;
|
||||
lua_Number n = lua_tonumber(L, i);
|
||||
if (n == 0 && !lua_isnumber(L, i))
|
||||
luaL_checktype(L, i, LUA_TNUMBER);
|
||||
lua_number2unsigned(result, n);
|
||||
return result;
|
||||
lua_Unsigned luaL_checkunsigned(lua_State *L, int i)
|
||||
{
|
||||
lua_Unsigned result;
|
||||
lua_Number n = lua_tonumber(L, i);
|
||||
if (n == 0 && !lua_isnumber(L, i))
|
||||
luaL_checktype(L, i, LUA_TNUMBER);
|
||||
lua_number2unsigned(result, n);
|
||||
return result;
|
||||
}
|
||||
|
||||
int lua_absindex (lua_State *L, int i) {
|
||||
if (i < 0 && i > LUA_REGISTRYINDEX)
|
||||
i += lua_gettop(L) + 1;
|
||||
return i;
|
||||
int lua_absindex(lua_State *L, int i)
|
||||
{
|
||||
if (i < 0 && i > LUA_REGISTRYINDEX)
|
||||
i += lua_gettop(L) + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
void lua_rawgetp (lua_State *L, int i, const void *p) {
|
||||
int abs_i = lua_absindex(L, i);
|
||||
lua_pushlightuserdata(L, (void*)p);
|
||||
lua_rawget(L, abs_i);
|
||||
void lua_rawgetp(lua_State *L, int i, const void *p)
|
||||
{
|
||||
int abs_i = lua_absindex(L, i);
|
||||
lua_pushlightuserdata(L, (void *)p);
|
||||
lua_rawget(L, abs_i);
|
||||
}
|
||||
|
||||
void lua_rawsetp (lua_State *L, int i, const void *p) {
|
||||
int abs_i = lua_absindex(L, i);
|
||||
luaL_checkstack(L, 1, "not enough stack slots");
|
||||
lua_pushlightuserdata(L, (void*)p);
|
||||
lua_insert(L, -2);
|
||||
lua_rawset(L, abs_i);
|
||||
void lua_rawsetp(lua_State *L, int i, const void *p)
|
||||
{
|
||||
int abs_i = lua_absindex(L, i);
|
||||
luaL_checkstack(L, 1, "not enough stack slots");
|
||||
lua_pushlightuserdata(L, (void *)p);
|
||||
lua_insert(L, -2);
|
||||
lua_rawset(L, abs_i);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -30,53 +30,54 @@ extern "C" {
|
||||
|
||||
#include "luainstance_helpers.h"
|
||||
|
||||
void LuaInstRegisterFunctions(lua_State *L, bool fromThreads=false);
|
||||
void LuaInstRegisterFunctions(lua_State *L, bool fromThreads = false);
|
||||
|
||||
/* inspired by Steve Kemp http://www.steve.org.uk/ */
|
||||
class CLuaInstance
|
||||
{
|
||||
static const char className[];
|
||||
static CLuaData *CheckData(lua_State *L, int narg);
|
||||
public:
|
||||
CLuaInstance();
|
||||
~CLuaInstance();
|
||||
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();
|
||||
bool DisableAbort;
|
||||
enum {
|
||||
DYNFONT_NO_ERROR = 0,
|
||||
DYNFONT_MAXIMUM_FONTS = 1,
|
||||
DYNFONT_TOO_WIDE = 2,
|
||||
DYNFONT_TOO_HIGH = 3
|
||||
};
|
||||
static const char className[];
|
||||
static CLuaData *CheckData(lua_State *L, int narg);
|
||||
public:
|
||||
CLuaInstance();
|
||||
~CLuaInstance();
|
||||
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();
|
||||
bool DisableAbort;
|
||||
enum
|
||||
{
|
||||
DYNFONT_NO_ERROR = 0,
|
||||
DYNFONT_MAXIMUM_FONTS = 1,
|
||||
DYNFONT_TOO_WIDE = 2,
|
||||
DYNFONT_TOO_HIGH = 3
|
||||
};
|
||||
|
||||
// Example: runScript(fileName, "Arg1", "Arg2", "Arg3", ..., NULL);
|
||||
// Type of all parameters: const char*
|
||||
// The last parameter to NULL is imperative.
|
||||
void runScript(const char *fileName, const char *arg0, ...);
|
||||
// Example: runScript(fileName, "Arg1", "Arg2", "Arg3", ..., NULL);
|
||||
// Type of all parameters: const char*
|
||||
// The last parameter to NULL is imperative.
|
||||
void runScript(const char *fileName, const char *arg0, ...);
|
||||
|
||||
static int NewWindow(lua_State *L);
|
||||
static int GCWindow(lua_State *L);
|
||||
static int GetInput(lua_State *L);
|
||||
static int Blit(lua_State *L);
|
||||
static int GetLanguage(lua_State *L);
|
||||
static int PaintBox(lua_State *L);
|
||||
static int paintHLineRel(lua_State *L);
|
||||
static int paintVLineRel(lua_State *L);
|
||||
static int RenderString(lua_State *L);
|
||||
static int getRenderWidth(lua_State *L);
|
||||
static int FontHeight(lua_State *L);
|
||||
static int getDynFont(lua_State *L);
|
||||
static int PaintIcon(lua_State *L);
|
||||
static int DisplayImage(lua_State *L);
|
||||
static int GetSize(lua_State *L);
|
||||
static int saveScreen(lua_State *L);
|
||||
static int restoreScreen(lua_State *L);
|
||||
static int deleteSavedScreen(lua_State *L);
|
||||
static int scale2Res(lua_State *L);
|
||||
static int NewWindow(lua_State *L);
|
||||
static int GCWindow(lua_State *L);
|
||||
static int GetInput(lua_State *L);
|
||||
static int Blit(lua_State *L);
|
||||
static int GetLanguage(lua_State *L);
|
||||
static int PaintBox(lua_State *L);
|
||||
static int paintHLineRel(lua_State *L);
|
||||
static int paintVLineRel(lua_State *L);
|
||||
static int RenderString(lua_State *L);
|
||||
static int getRenderWidth(lua_State *L);
|
||||
static int FontHeight(lua_State *L);
|
||||
static int getDynFont(lua_State *L);
|
||||
static int PaintIcon(lua_State *L);
|
||||
static int DisplayImage(lua_State *L);
|
||||
static int GetSize(lua_State *L);
|
||||
static int saveScreen(lua_State *L);
|
||||
static int restoreScreen(lua_State *L);
|
||||
static int deleteSavedScreen(lua_State *L);
|
||||
static int scale2Res(lua_State *L);
|
||||
|
||||
private:
|
||||
lua_State* lua;
|
||||
private:
|
||||
lua_State *lua;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user