summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp76
1 files changed, 27 insertions, 49 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 4a2484613..dc8654960 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -32,14 +32,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "convert_json.h"
#include "serverlist.h"
#include "mapgen.h"
-#include "sound.h"
#include "settings.h"
-#include "log.h"
#include "EDriverTypes.h"
#include <IFileArchive.h>
#include <IFileSystem.h>
+
/******************************************************************************/
std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
{
@@ -299,7 +298,7 @@ int ModApiMainMenu::l_get_games(lua_State *L)
int table2 = lua_gettop(L);
int internal_index=1;
for (std::set<std::string>::iterator iter = games[i].addon_mods_paths.begin();
- iter != games[i].addon_mods_paths.end(); iter++) {
+ iter != games[i].addon_mods_paths.end(); ++iter) {
lua_pushnumber(L,internal_index);
lua_pushstring(L,(*iter).c_str());
lua_settable(L, table2);
@@ -577,6 +576,13 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
lua_settable(L, top_lvl2);
}
+ if (servers[i].isMember("ping")) {
+ float ping = servers[i]["ping"].asFloat();
+ lua_pushstring(L, "ping");
+ lua_pushnumber(L, ping);
+ lua_settable(L, top_lvl2);
+ }
+
lua_settable(L, top);
index++;
}
@@ -956,33 +962,6 @@ int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
}
/******************************************************************************/
-int ModApiMainMenu::l_sound_play(lua_State *L)
-{
- GUIEngine* engine = getGuiEngine(L);
-
- SimpleSoundSpec spec;
- read_soundspec(L, 1, spec);
- bool looped = lua_toboolean(L, 2);
-
- u32 handle = engine->playSound(spec, looped);
-
- lua_pushinteger(L, handle);
-
- return 1;
-}
-
-/******************************************************************************/
-int ModApiMainMenu::l_sound_stop(lua_State *L)
-{
- GUIEngine* engine = getGuiEngine(L);
-
- u32 handle = luaL_checkinteger(L, 1);
- engine->stopSound(handle);
-
- return 1;
-}
-
-/******************************************************************************/
int ModApiMainMenu::l_download_file(lua_State *L)
{
const char *url = luaL_checkstring(L, 1);
@@ -1153,8 +1132,6 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(download_file);
API_FCT(get_modstore_details);
API_FCT(get_modstore_list);
- API_FCT(sound_play);
- API_FCT(sound_stop);
API_FCT(gettext);
API_FCT(get_video_drivers);
API_FCT(get_video_modes);
@@ -1165,23 +1142,24 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
}
/******************************************************************************/
-void ModApiMainMenu::InitializeAsync(AsyncEngine& engine)
+void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
{
- ASYNC_API_FCT(get_worlds);
- ASYNC_API_FCT(get_games);
- ASYNC_API_FCT(get_favorites);
- ASYNC_API_FCT(get_mapgen_names);
- ASYNC_API_FCT(get_modpath);
- ASYNC_API_FCT(get_gamepath);
- ASYNC_API_FCT(get_texturepath);
- ASYNC_API_FCT(get_texturepath_share);
- ASYNC_API_FCT(create_dir);
- ASYNC_API_FCT(delete_dir);
- ASYNC_API_FCT(copy_dir);
- //ASYNC_API_FCT(extract_zip); //TODO remove dependency to GuiEngine
- ASYNC_API_FCT(download_file);
- ASYNC_API_FCT(get_modstore_details);
- ASYNC_API_FCT(get_modstore_list);
- //ASYNC_API_FCT(gettext); (gettext lib isn't threadsafe)
+ API_FCT(get_worlds);
+ API_FCT(get_games);
+ API_FCT(get_favorites);
+ API_FCT(get_mapgen_names);
+ API_FCT(get_modpath);
+ API_FCT(get_gamepath);
+ API_FCT(get_texturepath);
+ API_FCT(get_texturepath_share);
+ API_FCT(create_dir);
+ API_FCT(delete_dir);
+ API_FCT(copy_dir);
+ //API_FCT(extract_zip); //TODO remove dependency to GuiEngine
+ API_FCT(download_file);
+ API_FCT(get_modstore_details);
+ API_FCT(get_modstore_list);
+ //API_FCT(gettext); (gettext lib isn't threadsafe)
}
+