mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
Add a --enable-lua switch to enable LUA support
Origin commit data
------------------
Commit: 82d4832013
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2014-01-21 (Tue, 21 Jan 2014)
This commit is contained in:
@@ -1260,10 +1260,12 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
|
||||
else
|
||||
(*optionValue)++;
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty()) {
|
||||
// optionValue is int*
|
||||
observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str());
|
||||
} else
|
||||
#endif
|
||||
if(observ)
|
||||
observ->changeNotify(name, optionValue);
|
||||
|
||||
@@ -1484,8 +1486,9 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
{
|
||||
bool wantsRepaint = false;
|
||||
int ret = menu_return::RETURN_NONE;
|
||||
#if ENABLE_LUA
|
||||
char *optionValname = NULL;
|
||||
|
||||
#endif
|
||||
if (optionsSort) {
|
||||
optionsSort = false;
|
||||
clearChooserOptions();
|
||||
@@ -1538,7 +1541,9 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
if(select >= 0)
|
||||
{
|
||||
*optionValue = options[select].key;
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[select].valname;
|
||||
#endif
|
||||
}
|
||||
delete menu;
|
||||
delete selector;
|
||||
@@ -1547,23 +1552,31 @@ int CMenuOptionChooser::exec(CMenuTarget*)
|
||||
if (options[count].key == (*optionValue)) {
|
||||
if(msg == CRCInput::RC_left) {
|
||||
if(count > 0)
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[(count-1) % number_of_options].valname,
|
||||
#endif
|
||||
*optionValue = options[(count-1) % number_of_options].key;
|
||||
else
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[number_of_options-1].valname,
|
||||
#endif
|
||||
*optionValue = options[number_of_options-1].key;
|
||||
} else
|
||||
#if ENABLE_LUA
|
||||
optionValname = (char *) options[(count+1) % number_of_options].valname,
|
||||
#endif
|
||||
*optionValue = options[(count+1) % number_of_options].key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
paint(true);
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty()) {
|
||||
if (optionValname)
|
||||
wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname);
|
||||
} else
|
||||
#endif
|
||||
if(observ)
|
||||
wantsRepaint = observ->changeNotify(name, optionValue);
|
||||
|
||||
@@ -1724,9 +1737,11 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
|
||||
|
||||
paint(true);
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
if(observ && !luaAction.empty())
|
||||
wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValueString ? optionValueString->c_str() : ""));
|
||||
else
|
||||
#endif
|
||||
if(observ) {
|
||||
wantsRepaint = observ->changeNotify(name, (void *)(optionValueString ? optionValueString->c_str() : ""));
|
||||
}
|
||||
|
@@ -45,11 +45,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if ENABLE_LUA
|
||||
extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NO_WIDGET_ID -1
|
||||
|
||||
@@ -75,10 +77,12 @@ class CChangeObserver
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#if ENABLE_LUA
|
||||
virtual bool changeNotify(lua_State * /*L*/, const std::string & /*luaId*/, const std::string & /*luaAction*/, void * /*Data*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class CMenuTarget
|
||||
@@ -103,9 +107,11 @@ class CMenuItem
|
||||
fb_pixel_t item_color, item_bgcolor;
|
||||
|
||||
void initItemColors(const bool select_mode);
|
||||
#if ENABLE_LUA
|
||||
lua_State *luaState;
|
||||
std::string luaAction;
|
||||
std::string luaId;
|
||||
#endif
|
||||
neutrino_locale_t name;
|
||||
std::string nameString;
|
||||
|
||||
@@ -170,8 +176,9 @@ class CMenuItem
|
||||
void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
||||
void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; }
|
||||
|
||||
#if ENABLE_LUA
|
||||
void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; };
|
||||
|
||||
#endif
|
||||
virtual const char *getName();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user