move core.get_generators to generation.get_generators
This commit is contained in:
parent
c46090f881
commit
50c7308211
@ -1,7 +1,7 @@
|
|||||||
settings = session.get_entry('new_world')
|
settings = session.get_entry('new_world')
|
||||||
|
|
||||||
function on_open()
|
function on_open()
|
||||||
local names = core.get_generators()
|
local names = generation.get_generators()
|
||||||
table.sort(names)
|
table.sort(names)
|
||||||
|
|
||||||
local panel = document.root
|
local panel = document.root
|
||||||
|
|||||||
@ -398,6 +398,12 @@ const Content* Engine::getContent() const {
|
|||||||
return content.get();
|
return content.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ContentPack> Engine::getAllContentPacks() {
|
||||||
|
auto packs = getContentPacks();
|
||||||
|
packs.insert(packs.begin(), ContentPack::createCore(paths));
|
||||||
|
return packs;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ContentPack>& Engine::getContentPacks() {
|
std::vector<ContentPack>& Engine::getContentPacks() {
|
||||||
return contentPacks;
|
return contentPacks;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,6 +130,8 @@ public:
|
|||||||
/// @brief Get selected content packs
|
/// @brief Get selected content packs
|
||||||
std::vector<ContentPack>& getContentPacks();
|
std::vector<ContentPack>& getContentPacks();
|
||||||
|
|
||||||
|
std::vector<ContentPack> getAllContentPacks();
|
||||||
|
|
||||||
std::vector<std::string>& getBasePacks();
|
std::vector<std::string>& getBasePacks();
|
||||||
|
|
||||||
/// @brief Get current screen
|
/// @brief Get current screen
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
#include "content/ContentLoader.hpp"
|
|
||||||
#include "files/engine_paths.hpp"
|
#include "files/engine_paths.hpp"
|
||||||
#include "files/settings_io.hpp"
|
#include "files/settings_io.hpp"
|
||||||
#include "frontend/menu.hpp"
|
#include "frontend/menu.hpp"
|
||||||
@ -180,32 +179,6 @@ static int l_get_default_generator(lua::State* L) {
|
|||||||
return lua::pushstring(L, WorldGenerator::DEFAULT);
|
return lua::pushstring(L, WorldGenerator::DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get a list of all world generators
|
|
||||||
/// @return A table with the IDs of all world generators
|
|
||||||
static int l_get_generators(lua::State* L) {
|
|
||||||
const auto& packs = engine->getContentPacks();
|
|
||||||
|
|
||||||
lua::createtable(L, 0, 0);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
auto names = ContentLoader::scanContent(
|
|
||||||
ContentPack::createCore(engine->getPaths()), ContentType::GENERATOR);
|
|
||||||
for (const auto& name : names) {
|
|
||||||
lua::pushstring(L, name);
|
|
||||||
lua::rawseti(L, i + 1);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
for (const auto& pack : packs) {
|
|
||||||
auto names = ContentLoader::scanContent(pack, ContentType::GENERATOR);
|
|
||||||
for (const auto& name : names) {
|
|
||||||
lua::pushstring(L, name);
|
|
||||||
lua::rawseti(L, i + 1);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const luaL_Reg corelib[] = {
|
const luaL_Reg corelib[] = {
|
||||||
{"new_world", lua::wrap<l_new_world>},
|
{"new_world", lua::wrap<l_new_world>},
|
||||||
{"open_world", lua::wrap<l_open_world>},
|
{"open_world", lua::wrap<l_open_world>},
|
||||||
@ -219,5 +192,4 @@ const luaL_Reg corelib[] = {
|
|||||||
{"get_setting_info", lua::wrap<l_get_setting_info>},
|
{"get_setting_info", lua::wrap<l_get_setting_info>},
|
||||||
{"quit", lua::wrap<l_quit>},
|
{"quit", lua::wrap<l_quit>},
|
||||||
{"get_default_generator", lua::wrap<l_get_default_generator>},
|
{"get_default_generator", lua::wrap<l_get_default_generator>},
|
||||||
{"get_generators", lua::wrap<l_get_generators>},
|
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "coders/binary_json.hpp"
|
#include "coders/binary_json.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
#include "world/generator/VoxelFragment.hpp"
|
#include "world/generator/VoxelFragment.hpp"
|
||||||
|
#include "content/ContentLoader.hpp"
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
#include "lua_custom_types.hpp"
|
#include "lua_custom_types.hpp"
|
||||||
|
|
||||||
@ -42,7 +43,27 @@ static int l_load_structure(lua::State* L) {
|
|||||||
return lua::newuserdata<lua::LuaVoxelStructure>(L, std::move(structure));
|
return lua::newuserdata<lua::LuaVoxelStructure>(L, std::move(structure));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Get a list of all world generators
|
||||||
|
/// @return A table with the IDs of all world generators
|
||||||
|
static int l_get_generators(lua::State* L) {
|
||||||
|
auto packs = engine->getAllContentPacks();
|
||||||
|
|
||||||
|
lua::createtable(L, 0, 0);
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
for (const auto& pack : packs) {
|
||||||
|
auto names = ContentLoader::scanContent(pack, ContentType::GENERATOR);
|
||||||
|
for (const auto& name : names) {
|
||||||
|
lua::pushstring(L, name);
|
||||||
|
lua::rawseti(L, i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg generationlib[] = {
|
const luaL_Reg generationlib[] = {
|
||||||
{"save_structure", lua::wrap<l_save_structure>},
|
{"save_structure", lua::wrap<l_save_structure>},
|
||||||
{"load_structure", lua::wrap<l_load_structure>},
|
{"load_structure", lua::wrap<l_load_structure>},
|
||||||
|
{"get_generators", lua::wrap<l_get_generators>},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user