mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
CLuaInstance: Add script function 'setActive' to enable or disable...
...individual menu items.
- Set Lua api version to 1.2
Origin commit data
------------------
Branch: ni/coolstream
Commit: 39d10e03df
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2015-09-14 (Mon, 14 Sep 2015)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -1050,6 +1050,7 @@ void CLuaInstance::MenuRegister(lua_State *L)
|
||||
{ "addItem", CLuaInstance::MenuAddItem },
|
||||
{ "exec", CLuaInstance::MenuExec },
|
||||
{ "hide", CLuaInstance::MenuHide },
|
||||
{ "setActive", CLuaInstance::MenuSetActive },
|
||||
{ "__gc", CLuaInstance::MenuDelete },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
@@ -1272,6 +1273,28 @@ int CLuaInstance::MenuAddKey(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstance::MenuSetActive(lua_State *L)
|
||||
{
|
||||
CLuaMenu *m = MenuCheck(L, 1);
|
||||
if (!m)
|
||||
return 0;
|
||||
lua_assert(lua_istable(L, 2));
|
||||
|
||||
lua_Integer id; tableLookup(L, "item", id);
|
||||
bool activ; tableLookup(L, "activ", activ);
|
||||
|
||||
CMenuItem* item = NULL;
|
||||
for (itemmap_iterator_t it = m->itemmap.begin(); it != m->itemmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
item = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item)
|
||||
item->setActive(activ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstance::MenuAddItem(lua_State *L)
|
||||
{
|
||||
CLuaMenu *m = MenuCheck(L, 1);
|
||||
|
@@ -34,7 +34,7 @@ extern "C" {
|
||||
#include <vector>
|
||||
|
||||
#define LUA_API_VERSION_MAJOR 1
|
||||
#define LUA_API_VERSION_MINOR 1
|
||||
#define LUA_API_VERSION_MINOR 2
|
||||
|
||||
/* this is stored as userdata in the lua_State */
|
||||
struct CLuaData
|
||||
@@ -243,6 +243,7 @@ private:
|
||||
static int MenuHide(lua_State *L);
|
||||
static int MenuExec(lua_State *L);
|
||||
static CLuaMenu *MenuCheck(lua_State *L, int n);
|
||||
static int MenuSetActive(lua_State *L);
|
||||
|
||||
void HintboxRegister(lua_State *L);
|
||||
static int HintboxNew(lua_State *L);
|
||||
|
Reference in New Issue
Block a user