add config/defaults.toml
This commit is contained in:
parent
de00414456
commit
04e490c896
1
res/config/defaults.toml
Normal file
1
res/config/defaults.toml
Normal file
@ -0,0 +1 @@
|
||||
generator = "core:default"
|
||||
1
res/content/base/config/defaults.toml
Normal file
1
res/content/base/config/defaults.toml
Normal file
@ -0,0 +1 @@
|
||||
generator = "base:demo"
|
||||
@ -29,7 +29,7 @@ function on_open()
|
||||
"%s [%s]", gui.str("Content", "menu"), #pack.get_installed()
|
||||
)
|
||||
if settings.generator == nil then
|
||||
settings.generator = core.get_default_generator()
|
||||
settings.generator = generation.get_default_generator()
|
||||
end
|
||||
document.generator_btn.text = string.format(
|
||||
"%s: %s",
|
||||
|
||||
@ -345,6 +345,11 @@ void Engine::resetContent() {
|
||||
resRoots.push_back({"core", pack.folder});
|
||||
load_configs(pack.folder);
|
||||
}
|
||||
auto manager = createPacksManager(fs::path());
|
||||
manager.scan();
|
||||
for (const auto& pack : manager.getAll(basePacks)) {
|
||||
resRoots.push_back({pack.id, pack.folder});
|
||||
}
|
||||
resPaths = std::make_unique<ResPaths>(resdir, resRoots);
|
||||
contentPacks.clear();
|
||||
content.reset();
|
||||
@ -353,8 +358,6 @@ void Engine::resetContent() {
|
||||
loadAssets();
|
||||
onAssetsLoaded();
|
||||
|
||||
auto manager = createPacksManager(fs::path());
|
||||
manager.scan();
|
||||
contentPacks = manager.getAll(basePacks);
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,9 @@ public:
|
||||
std::filesystem::path resolve(const std::string& path, bool throwErr = true);
|
||||
|
||||
static std::tuple<std::string, std::string> parsePath(std::string_view view);
|
||||
|
||||
static inline auto CONFIG_DEFAULTS =
|
||||
std::filesystem::u8path("config/defaults.toml");
|
||||
private:
|
||||
std::filesystem::path userFilesFolder {"."};
|
||||
std::filesystem::path resourcesFolder {"res"};
|
||||
|
||||
@ -173,12 +173,6 @@ static int l_quit(lua::State*) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief Get the default world generator
|
||||
/// @return The ID of the default world generator
|
||||
static int l_get_default_generator(lua::State* L) {
|
||||
return lua::pushstring(L, WorldGenerator::DEFAULT);
|
||||
}
|
||||
|
||||
const luaL_Reg corelib[] = {
|
||||
{"new_world", lua::wrap<l_new_world>},
|
||||
{"open_world", lua::wrap<l_open_world>},
|
||||
@ -191,5 +185,4 @@ const luaL_Reg corelib[] = {
|
||||
{"str_setting", lua::wrap<l_str_setting>},
|
||||
{"get_setting_info", lua::wrap<l_get_setting_info>},
|
||||
{"quit", lua::wrap<l_quit>},
|
||||
{"get_default_generator", lua::wrap<l_get_default_generator>},
|
||||
{NULL, NULL}};
|
||||
|
||||
@ -62,8 +62,18 @@ static int l_get_generators(lua::State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// @brief Get the default world generator
|
||||
/// @return The ID of the default world generator
|
||||
static int l_get_default_generator(lua::State* L) {
|
||||
auto combined = engine->getResPaths()->readCombinedObject(
|
||||
EnginePaths::CONFIG_DEFAULTS.u8string()
|
||||
);
|
||||
return lua::pushstring(L, combined["generator"].asString());
|
||||
}
|
||||
|
||||
const luaL_Reg generationlib[] = {
|
||||
{"save_structure", lua::wrap<l_save_structure>},
|
||||
{"load_structure", lua::wrap<l_load_structure>},
|
||||
{"get_generators", lua::wrap<l_get_generators>},
|
||||
{"get_default_generator", lua::wrap<l_get_default_generator>},
|
||||
{NULL, NULL}};
|
||||
|
||||
@ -206,9 +206,6 @@ void WorldInfo::deserialize(const dv::value& root) {
|
||||
generator = root["generator"].asString(generator);
|
||||
seed = root["seed"].asInteger(seed);
|
||||
|
||||
if (generator.empty()) {
|
||||
generator = WorldGenerator::DEFAULT;
|
||||
}
|
||||
if (root.has("version")) {
|
||||
auto& verobj = root["version"];
|
||||
major = verobj["major"].asInteger();
|
||||
|
||||
@ -131,7 +131,4 @@ public:
|
||||
void generate(voxel* voxels, int x, int z);
|
||||
|
||||
WorldGenDebugInfo createDebugInfo() const;
|
||||
|
||||
/// @brief Default generator name // TODO: move to config
|
||||
inline static std::string DEFAULT = "core:default";
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user