3 Copyright (C) 2013 sapier
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "lua_api/l_base.h"
26 /** Implementation of lua api support for mainmenu */
27 class ModApiMainMenu
: public ModApiBase
32 * read a text variable from gamedata table within lua stack
33 * @param L stack to read variable from
34 * @param name name of variable to read
35 * @return string value of requested variable
37 static std::string
getTextData(lua_State
*L
, const std::string
&name
);
40 * read an integer variable from gamedata table within lua stack
41 * @param L stack to read variable from
42 * @param name name of variable to read
43 * @return integer value of requested variable
45 static int getIntegerData(lua_State
*L
, const std::string
&name
, bool& valid
);
48 * read a bool variable from gamedata table within lua stack
49 * @param L stack to read variable from
50 * @param name name of variable to read
51 * @return bool value of requested variable
53 static int getBoolData(lua_State
*L
, const std::string
&name
,bool& valid
);
56 * Checks if a path may be modified. Paths in the temp directory or the user
57 * games, mods, textures, or worlds directories may be modified.
58 * @param path path to check
59 * @return true if the path may be modified
61 static bool mayModifyPath(std::string path
);
65 static int l_start(lua_State
*L
);
67 static int l_close(lua_State
*L
);
69 static int l_create_world(lua_State
*L
);
71 static int l_delete_world(lua_State
*L
);
73 static int l_get_worlds(lua_State
*L
);
75 static int l_get_mapgen_names(lua_State
*L
);
77 static int l_get_language(lua_State
*L
);
79 static int l_gettext(lua_State
*L
);
83 static int l_get_games(lua_State
*L
);
85 static int l_get_content_info(lua_State
*L
);
87 static int l_check_mod_configuration(lua_State
*L
);
89 static int l_get_content_translation(lua_State
*L
);
93 static int l_show_keys_menu(lua_State
*L
);
95 static int l_show_path_select_dialog(lua_State
*L
);
97 static int l_set_topleft_text(lua_State
*L
);
99 static int l_set_clouds(lua_State
*L
);
101 static int l_get_textlist_index(lua_State
*L
);
103 static int l_get_table_index(lua_State
*L
);
105 static int l_set_background(lua_State
*L
);
107 static int l_update_formspec(lua_State
*L
);
109 static int l_set_formspec_prepend(lua_State
*L
);
111 static int l_get_window_info(lua_State
*L
);
113 static int l_get_active_driver(lua_State
*L
);
115 static int l_get_active_renderer(lua_State
*L
);
117 static int l_get_active_irrlicht_device(lua_State
*L
);
121 static int l_get_mainmenu_path(lua_State
*L
);
123 static int l_get_user_path(lua_State
*L
);
125 static int l_get_modpath(lua_State
*L
);
127 static int l_get_modpaths(lua_State
*L
);
129 static int l_get_clientmodpath(lua_State
*L
);
131 static int l_get_gamepath(lua_State
*L
);
133 static int l_get_texturepath(lua_State
*L
);
135 static int l_get_texturepath_share(lua_State
*L
);
137 static int l_get_cache_path(lua_State
*L
);
139 static int l_get_temp_path(lua_State
*L
);
141 static int l_create_dir(lua_State
*L
);
143 static int l_delete_dir(lua_State
*L
);
145 static int l_copy_dir(lua_State
*L
);
147 static int l_is_dir(lua_State
*L
);
149 static int l_extract_zip(lua_State
*L
);
151 static int l_may_modify_path(lua_State
*L
);
153 static int l_download_file(lua_State
*L
);
155 static int l_get_video_drivers(lua_State
*L
);
157 //version compatibility
158 static int l_get_min_supp_proto(lua_State
*L
);
160 static int l_get_max_supp_proto(lua_State
*L
);
163 static int l_open_url(lua_State
*L
);
165 static int l_open_dir(lua_State
*L
);
167 static int l_share_file(lua_State
*L
);
170 static int l_do_async_callback(lua_State
*L
);
175 * initialize this API module
176 * @param L lua stack to initialize
177 * @param top index (in lua stack) of global API table
179 static void Initialize(lua_State
*L
, int top
);
181 static void InitializeAsync(lua_State
*L
, int top
);