Exposed gameid_alias directly to Lua

This commit is contained in:
Nauta Turbidus 2024-04-15 01:40:38 +02:00
parent eb7778f0da
commit 3310aebced
3 changed files with 14 additions and 4 deletions

View File

@ -212,14 +212,18 @@ SubgameSpec findSubgame(const std::string &id)
if (conf.exists("release"))
game_release = conf.getS32("release");
std::string gameid_alias;
if (conf.exists("gameid_alias"))
gameid_alias = conf.get("gameid_alias");
std::string menuicon_path;
#ifndef SERVER
menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif
SubgameSpec spec(idv, game_path, gamemod_path, mods_paths, game_title,
menuicon_path, game_author, game_release);
SubgameSpec spec(id, game_path, gamemod_path, mods_paths, game_title,
menuicon_path, game_author, game_release, gameid_alias);
if (conf.exists("name") && !conf.exists("title"))
spec.deprecation_msgs.push_back("\"name\" setting in game.conf is deprecated, please use \"title\" instead");

View File

@ -34,6 +34,7 @@ struct SubgameSpec
int release;
std::string path;
std::string gamemods_path;
std::string gameid_alias;
/**
* Map from virtual path to mods path
@ -49,11 +50,12 @@ struct SubgameSpec
const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
const std::string &title = "",
const std::string &menuicon_path = "",
const std::string &author = "", int release = 0) :
const std::string &author = "", int release = 0,
const std::string &gameid_alias = "") :
id(id),
title(title), author(author), release(release), path(path),
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
menuicon_path(menuicon_path)
menuicon_path(menuicon_path), gameid_alias(gameid_alias)
{
}

View File

@ -332,6 +332,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_pushstring(L, game.menuicon_path.c_str());
lua_settable(L, top_lvl2);
lua_pushstring(L, "aliases");
lua_pushstring(L, game.gameid_alias.c_str());
lua_settable(L, top_lvl2);
lua_pushstring(L, "addon_mods_paths");
lua_newtable(L);
int table2 = lua_gettop(L);