From 243853cd1692c56cae8642dd6bb35c3c75ff54f7 Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Wed, 14 Aug 2024 16:32:54 -0400 Subject: Working support for setting launcher --- src/read_cfg.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/read_cfg.c') diff --git a/src/read_cfg.c b/src/read_cfg.c index 97a76ff..d9491bb 100644 --- a/src/read_cfg.c +++ b/src/read_cfg.c @@ -147,7 +147,8 @@ int get_entry_count(lua_State *L, int table_stack_index) { void add_groups(lua_State *L, int table_stack_index, GROUP ***g) { const char *group_name; - int entry_table_stack_index; + int group_table_index; // index of Groups.TABLE_NAME + int entry_table_stack_index; // index of Groups.TABLE_NAME.Entries int entry_count; int i; @@ -158,12 +159,13 @@ void add_groups(lua_State *L, int table_stack_index, GROUP ***g) { // looking at Groups.TABLE_NAME if(lua_type(L, -2) == LUA_TSTRING && lua_type(L, -1) == LUA_TTABLE) { group_name = lua_tostring(L, -2); + group_table_index = lua_gettop(L); if(group_name != NULL) { // push the Entries table on the stack (to get entry information) lua_pushstring(L, "Entries"); // get table Groups.TABLE_NAME.Entries - lua_gettable(L, -2); + lua_gettable(L, group_table_index); entry_table_stack_index = lua_gettop(L); // check that 'Entries' is a table @@ -182,6 +184,14 @@ void add_groups(lua_State *L, int table_stack_index, GROUP ***g) { // add entries to this group add_entries(L, entry_table_stack_index, (*g)[i]); } + + // set the launcher, if applicable + lua_pushstring(L, "Launcher"); + lua_gettable(L, group_table_index); + printf("Found launcher: %s\n", lua_tostring(L, -1)); + if(lua_type(L, -1) == LUA_TSTRING) { + set_gprog((*g)[i], lua_tostring(L, -1)); + } } } // pop the top of the stack down to the key of the group -- cgit