l_mainmenu.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. Minetest
  3. Copyright (C) 2013 sapier
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef L_MAINMENU_H_
  17. #define L_MAINMENU_H_
  18. #include "lua_api/l_base.h"
  19. class AsyncEngine;
  20. /** Implementation of lua api support for mainmenu */
  21. class ModApiMainMenu: public ModApiBase
  22. {
  23. private:
  24. /**
  25. * read a text variable from gamedata table within lua stack
  26. * @param L stack to read variable from
  27. * @param name name of variable to read
  28. * @return string value of requested variable
  29. */
  30. static std::string getTextData(lua_State *L, std::string name);
  31. /**
  32. * read a integer 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 integer value of requested variable
  36. */
  37. static int getIntegerData(lua_State *L, std::string name,bool& valid);
  38. /**
  39. * read a bool variable from gamedata table within lua stack
  40. * @param L stack to read variable from
  41. * @param name name of variable to read
  42. * @return bool value of requested variable
  43. */
  44. static int getBoolData(lua_State *L, std::string name,bool& valid);
  45. /**
  46. * check if a path is within some of minetests folders
  47. * @param path path to check
  48. * @return true/false
  49. */
  50. static bool isMinetestPath(std::string path);
  51. //api calls
  52. static int l_start(lua_State *L);
  53. static int l_close(lua_State *L);
  54. static int l_create_world(lua_State *L);
  55. static int l_delete_world(lua_State *L);
  56. static int l_get_worlds(lua_State *L);
  57. static int l_get_games(lua_State *L);
  58. static int l_get_mapgen_names(lua_State *L);
  59. static int l_get_favorites(lua_State *L);
  60. static int l_delete_favorite(lua_State *L);
  61. static int l_gettext(lua_State *L);
  62. //gui
  63. static int l_show_keys_menu(lua_State *L);
  64. static int l_show_path_select_dialog(lua_State *L);
  65. static int l_set_topleft_text(lua_State *L);
  66. static int l_set_clouds(lua_State *L);
  67. static int l_get_textlist_index(lua_State *L);
  68. static int l_get_table_index(lua_State *L);
  69. static int l_set_background(lua_State *L);
  70. static int l_update_formspec(lua_State *L);
  71. static int l_get_screen_info(lua_State *L);
  72. //filesystem
  73. static int l_get_mainmenu_path(lua_State *L);
  74. static int l_get_modpath(lua_State *L);
  75. static int l_get_clientmodpath(lua_State *L);
  76. static int l_get_gamepath(lua_State *L);
  77. static int l_get_texturepath(lua_State *L);
  78. static int l_get_texturepath_share(lua_State *L);
  79. static int l_create_dir(lua_State *L);
  80. static int l_delete_dir(lua_State *L);
  81. static int l_copy_dir(lua_State *L);
  82. static int l_extract_zip(lua_State *L);
  83. static int l_get_modstore_details(lua_State *L);
  84. static int l_get_modstore_list(lua_State *L);
  85. static int l_download_file(lua_State *L);
  86. static int l_get_video_drivers(lua_State *L);
  87. static int l_get_video_modes(lua_State *L);
  88. //version compatibility
  89. static int l_get_min_supp_proto(lua_State *L);
  90. static int l_get_max_supp_proto(lua_State *L);
  91. // async
  92. static int l_do_async_callback(lua_State *L);
  93. public:
  94. /**
  95. * initialize this API module
  96. * @param L lua stack to initialize
  97. * @param top index (in lua stack) of global API table
  98. */
  99. static void Initialize(lua_State *L, int top);
  100. static void InitializeAsync(lua_State *L, int top);
  101. };
  102. #endif /* L_MAINMENU_H_ */