1
0
mirror of https://github.com/minetest/minetest.git synced 2024-11-15 23:10:28 +01:00

Hide mapgens from main menu not intended for end users

This commit is contained in:
kwolekr 2015-10-04 16:37:03 -04:00
parent 0850d3bb93
commit 9f25aba6c2
4 changed files with 16 additions and 11 deletions

View File

@ -141,8 +141,8 @@ core.get_game(index)
addon_mods_paths = {[1] = <path>,}, addon_mods_paths = {[1] = <path>,},
} }
core.get_games() -> table of all games in upper format (possible in async calls) core.get_games() -> table of all games in upper format (possible in async calls)
core.get_mapgen_names() -> table of all map generator algorithms registered in core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
the core (possible in async calls) registered in the core (possible in async calls)
Favorites: Favorites:
core.get_favorites(location) -> list of favorites (possible in async calls) core.get_favorites(location) -> list of favorites (possible in async calls)

View File

@ -54,6 +54,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct MapgenDesc { struct MapgenDesc {
const char *name; const char *name;
MapgenFactory *factory; MapgenFactory *factory;
bool is_user_visible;
}; };
class EmergeThread : public Thread { class EmergeThread : public Thread {
@ -100,10 +101,10 @@ private:
//// ////
MapgenDesc g_reg_mapgens[] = { MapgenDesc g_reg_mapgens[] = {
{"v5", new MapgenFactoryV5}, {"v5", new MapgenFactoryV5, true},
{"v6", new MapgenFactoryV6}, {"v6", new MapgenFactoryV6, true},
{"v7", new MapgenFactoryV7}, {"v7", new MapgenFactoryV7, true},
{"singlenode", new MapgenFactorySinglenode}, {"singlenode", new MapgenFactorySinglenode, false},
}; };
//// ////
@ -343,11 +344,14 @@ bool EmergeManager::isBlockUnderground(v3s16 blockpos)
} }
void EmergeManager::getMapgenNames(std::vector<const char *> *mgnames) void EmergeManager::getMapgenNames(
std::vector<const char *> *mgnames, bool include_hidden)
{ {
for (u32 i = 0; i != ARRLEN(g_reg_mapgens); i++) for (u32 i = 0; i != ARRLEN(g_reg_mapgens); i++) {
if (include_hidden || g_reg_mapgens[i].is_user_visible)
mgnames->push_back(g_reg_mapgens[i].name); mgnames->push_back(g_reg_mapgens[i].name);
} }
}
MapgenFactory *EmergeManager::getMapgenFactory(const std::string &mgname) MapgenFactory *EmergeManager::getMapgenFactory(const std::string &mgname)

View File

@ -139,7 +139,8 @@ public:
bool isBlockUnderground(v3s16 blockpos); bool isBlockUnderground(v3s16 blockpos);
static MapgenFactory *getMapgenFactory(const std::string &mgname); static MapgenFactory *getMapgenFactory(const std::string &mgname);
static void getMapgenNames(std::vector<const char *> *mgnames); static void getMapgenNames(
std::vector<const char *> *mgnames, bool include_hidden);
static v3s16 getContainingChunk(v3s16 blockpos, s16 chunksize); static v3s16 getContainingChunk(v3s16 blockpos, s16 chunksize);
private: private:

View File

@ -707,7 +707,7 @@ int ModApiMainMenu::l_set_topleft_text(lua_State *L)
int ModApiMainMenu::l_get_mapgen_names(lua_State *L) int ModApiMainMenu::l_get_mapgen_names(lua_State *L)
{ {
std::vector<const char *> names; std::vector<const char *> names;
EmergeManager::getMapgenNames(&names); EmergeManager::getMapgenNames(&names, lua_toboolean(L, 1));
lua_newtable(L); lua_newtable(L);
for (size_t i = 0; i != names.size(); i++) { for (size_t i = 0; i != names.size(); i++) {