l_mainmenu.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #pragma once
  17. #include "lua_api/l_base.h"
  18. class AsyncEngine;
  19. /** Implementation of lua api support for mainmenu */
  20. class ModApiMainMenu: public ModApiBase
  21. {
  22. private:
  23. /**
  24. * read a text variable from gamedata table within lua stack
  25. * @param L stack to read variable from
  26. * @param name name of variable to read
  27. * @return string value of requested variable
  28. */
  29. static std::string getTextData(lua_State *L, std::string name);
  30. /**
  31. * read a integer variable from gamedata table within lua stack
  32. * @param L stack to read variable from
  33. * @param name name of variable to read
  34. * @return integer value of requested variable
  35. */
  36. static int getIntegerData(lua_State *L, std::string name,bool& valid);
  37. /**
  38. * read a bool variable from gamedata table within lua stack
  39. * @param L stack to read variable from
  40. * @param name name of variable to read
  41. * @return bool value of requested variable
  42. */
  43. static int getBoolData(lua_State *L, std::string name,bool& valid);
  44. /**
  45. * check if a path is within some of minetests folders
  46. * @param path path to check
  47. * @return true/false
  48. */
  49. static bool isMinetestPath(std::string path);
  50. //api calls
  51. static int l_start(lua_State *L);
  52. static int l_close(lua_State *L);
  53. static int l_create_world(lua_State *L);
  54. static int l_delete_world(lua_State *L);
  55. static int l_get_worlds(lua_State *L);
  56. static int l_get_games(lua_State *L);
  57. static int l_get_mapgen_names(lua_State *L);
  58. static int l_get_favorites(lua_State *L);
  59. static int l_delete_favorite(lua_State *L);
  60. static int l_gettext(lua_State *L);
  61. //gui
  62. static int l_show_keys_menu(lua_State *L);
  63. static int l_show_path_select_dialog(lua_State *L);
  64. static int l_set_topleft_text(lua_State *L);
  65. static int l_set_clouds(lua_State *L);
  66. static int l_get_textlist_index(lua_State *L);
  67. static int l_get_table_index(lua_State *L);
  68. static int l_set_background(lua_State *L);
  69. static int l_update_formspec(lua_State *L);
  70. static int l_get_screen_info(lua_State *L);
  71. //filesystem
  72. static int l_get_mainmenu_path(lua_State *L);
  73. static int l_get_modpath(lua_State *L);
  74. static int l_get_clientmodpath(lua_State *L);
  75. static int l_get_gamepath(lua_State *L);
  76. static int l_get_texturepath(lua_State *L);
  77. static int l_get_texturepath_share(lua_State *L);
  78. static int l_create_dir(lua_State *L);
  79. static int l_delete_dir(lua_State *L);
  80. static int l_copy_dir(lua_State *L);
  81. static int l_extract_zip(lua_State *L);
  82. static int l_download_file(lua_State *L);
  83. static int l_get_video_drivers(lua_State *L);
  84. static int l_get_video_modes(lua_State *L);
  85. //version compatibility
  86. static int l_get_min_supp_proto(lua_State *L);
  87. static int l_get_max_supp_proto(lua_State *L);
  88. // async
  89. static int l_do_async_callback(lua_State *L);
  90. public:
  91. /**
  92. * initialize this API module
  93. * @param L lua stack to initialize
  94. * @param top index (in lua stack) of global API table
  95. */
  96. static void Initialize(lua_State *L, int top);
  97. static void InitializeAsync(lua_State *L, int top);
  98. };