mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-02 18:25:30 +02:00
Fixed table pushing for LuaCollection::getItemAt(). Cleaned up configuration loading.
This commit is contained in:
@@ -22,6 +22,58 @@ int LuaCollection::load(lua_State *l)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaCollection::getSize(lua_State *l)
|
||||
{
|
||||
CollectionInfo *i = (CollectionInfo *)luaL_checkinteger(l, 1);
|
||||
|
||||
lua_pushinteger(l, (int)i->items.size());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaCollection::getName(lua_State *l)
|
||||
{
|
||||
CollectionInfo *i = (CollectionInfo *)luaL_checkinteger(l, 1);
|
||||
|
||||
lua_pushstring(l, i->name.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaCollection::getItemAt(lua_State *l)
|
||||
{
|
||||
CollectionInfo *i = (CollectionInfo *)luaL_checkinteger(l, 1);
|
||||
int index = (int)luaL_checkinteger(l, 2);
|
||||
Item *item = i->items.at(index);
|
||||
|
||||
std::string name;
|
||||
std::string filepath;
|
||||
std::string title;
|
||||
std::string fullTitle;
|
||||
std::string year;
|
||||
std::string manufacturer;
|
||||
std::string genre;
|
||||
std::string cloneof;
|
||||
std::string numberPlayers;
|
||||
std::string numberButtons;
|
||||
|
||||
lua_createtable(l, 0, 4);
|
||||
lua_pushstring(l, "name");
|
||||
lua_pushstring(l, item->name.c_str());
|
||||
lua_settable(l, -3);
|
||||
|
||||
lua_pushstring(l, "title");
|
||||
lua_pushstring(l, item->title.c_str());
|
||||
lua_settable(l, -3);
|
||||
|
||||
lua_pushstring(l, "filepath");
|
||||
lua_pushstring(l, item->filepath.c_str());
|
||||
lua_settable(l, -3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int LuaCollection::destroy(lua_State *l)
|
||||
{
|
||||
CollectionInfo *i = (CollectionInfo *)luaL_checkinteger(l, 1);
|
||||
@@ -31,9 +83,17 @@ int LuaCollection::destroy(lua_State *l)
|
||||
}
|
||||
|
||||
|
||||
CollectionInfo *loadingCollection = NULL;
|
||||
void LuaCollection::loadCallback(void *context, CollectionInfo *info)
|
||||
{
|
||||
lua_State *l = (lua_State *)context;
|
||||
events->trigger(l, "onCollectionLoaded", (void *)info);
|
||||
|
||||
loadingCollection = info;
|
||||
}
|
||||
|
||||
void LuaCollection::update(lua_State *l) {
|
||||
if(loadingCollection) {
|
||||
events->trigger(l, "onCollectionLoaded", (void *)loadingCollection);
|
||||
loadingCollection = NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user