Add get_serverlistpath() API to main menu

This commit is contained in:
Maksim 2020-06-26 16:12:41 +02:00
parent 7838cf8862
commit 3ad4986844
2 changed files with 14 additions and 1 deletions

View File

@ -774,6 +774,16 @@ int ModApiMainMenu::l_get_gamepath(lua_State *L)
return 1; return 1;
} }
/******************************************************************************/
int ModApiMainMenu::l_get_serverlistpath(lua_State *L)
{
std::string modpath = fs::RemoveRelativePathComponents(
porting::path_user + DIR_DELIM + "client" + DIR_DELIM +
"serverlist" + DIR_DELIM);
lua_pushstring(L, modpath.c_str());
return 1;
}
/******************************************************************************/ /******************************************************************************/
int ModApiMainMenu::l_get_texturepath(lua_State *L) int ModApiMainMenu::l_get_texturepath(lua_State *L)
{ {
@ -1152,6 +1162,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(get_mapgen_names); API_FCT(get_mapgen_names);
API_FCT(get_modpath); API_FCT(get_modpath);
API_FCT(get_gamepath); API_FCT(get_gamepath);
API_FCT(get_serverlistpath);
API_FCT(get_texturepath); API_FCT(get_texturepath);
API_FCT(get_texturepath_share); API_FCT(get_texturepath_share);
API_FCT(create_dir); API_FCT(create_dir);
@ -1182,6 +1193,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
API_FCT(get_mapgen_names); API_FCT(get_mapgen_names);
API_FCT(get_modpath); API_FCT(get_modpath);
API_FCT(get_gamepath); API_FCT(get_gamepath);
API_FCT(get_serverlistpath);
API_FCT(get_texturepath); API_FCT(get_texturepath);
API_FCT(get_texturepath_share); API_FCT(get_texturepath_share);
API_FCT(create_dir); API_FCT(create_dir);
@ -1193,4 +1205,3 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
API_FCT(get_modstore_list); API_FCT(get_modstore_list);
//API_FCT(gettext); (gettext lib isn't threadsafe) //API_FCT(gettext); (gettext lib isn't threadsafe)
} }

View File

@ -110,6 +110,8 @@ private:
static int l_get_gamepath(lua_State *L); static int l_get_gamepath(lua_State *L);
static int l_get_serverlistpath(lua_State *L);
static int l_get_texturepath(lua_State *L); static int l_get_texturepath(lua_State *L);
static int l_get_texturepath_share(lua_State *L); static int l_get_texturepath_share(lua_State *L);