Add a --enable-lua switch to enable LUA support

This commit is contained in:
M. Liebmann
2014-01-21 16:23:58 +01:00
parent ad206dbbc1
commit 82d4832013
8 changed files with 68 additions and 7 deletions

View File

@@ -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() : ""));
}