lua: pack.data_file(packid, name)
This commit is contained in:
parent
daaba374a3
commit
739282dce9
@ -100,6 +100,11 @@ function pack.is_installed(packid)
|
||||
return file.isfile(packid..":package.json")
|
||||
end
|
||||
|
||||
function pack.data_file(packid, name)
|
||||
file.mkdirs("world:data/"..packid)
|
||||
return "world:data/"..packid.."/"..name
|
||||
end
|
||||
|
||||
vec2_mt = {}
|
||||
function vec2_mt.__tostring(self)
|
||||
return "vec2("..self[1]..", "..self[2]..")"
|
||||
|
||||
@ -230,6 +230,7 @@ void Engine::loadWorldContent(const fs::path& folder) {
|
||||
contentPacks.clear();
|
||||
auto packNames = ContentPack::worldPacksList(folder);
|
||||
ContentPack::readPacks(paths, contentPacks, packNames, folder);
|
||||
paths->setWorldFolder(folder);
|
||||
loadContent();
|
||||
}
|
||||
|
||||
|
||||
@ -95,13 +95,19 @@ uint WorldRegion::getChunkDataSize(uint x, uint z) {
|
||||
}
|
||||
|
||||
WorldFiles::WorldFiles(fs::path directory, const DebugSettings& settings)
|
||||
: directory(directory),
|
||||
generatorTestMode(settings.generatorTestMode),
|
||||
doWriteLights(settings.doWriteLights) {
|
||||
compressionBuffer.reset(new ubyte[CHUNK_DATA_LEN * 2]);
|
||||
: directory(directory),
|
||||
generatorTestMode(settings.generatorTestMode),
|
||||
doWriteLights(settings.doWriteLights)
|
||||
{
|
||||
compressionBuffer = std::make_unique<ubyte[]>(CHUNK_DATA_LEN * 2);
|
||||
}
|
||||
|
||||
WorldFiles::~WorldFiles(){
|
||||
WorldFiles::~WorldFiles() {
|
||||
}
|
||||
|
||||
void WorldFiles::createDirectories() {
|
||||
fs::create_directories(directory / fs::path("data"));
|
||||
fs::create_directories(directory / fs::path("content"));
|
||||
}
|
||||
|
||||
WorldRegion* WorldFiles::getRegion(regionsmap& regions, int x, int z) {
|
||||
|
||||
@ -125,6 +125,8 @@ public:
|
||||
WorldFiles(fs::path directory, const DebugSettings& settings);
|
||||
~WorldFiles();
|
||||
|
||||
void createDirectories();
|
||||
|
||||
void put(Chunk* chunk);
|
||||
void put(int x, int z, const ubyte* voxelData);
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ void create_languages_panel(Engine* engine) {
|
||||
panel->add(guiutil::backButton(menu));
|
||||
}
|
||||
|
||||
std::string translate_generator_id(std::string& id) {
|
||||
static std::string translate_generator_id(std::string& id) {
|
||||
int delimiterPosition = id.find(":");
|
||||
std::string pack = id.substr(0, delimiterPosition);
|
||||
std::string generator = id.substr(delimiterPosition + 1);
|
||||
@ -241,12 +241,11 @@ void menus::open_world(std::string name, Engine* engine, bool confirmConvert) {
|
||||
);
|
||||
return;
|
||||
}
|
||||
paths->setWorldFolder(folder);
|
||||
|
||||
auto& packs = engine->getContentPacks();
|
||||
auto* content = engine->getContent();
|
||||
auto& settings = engine->getSettings();
|
||||
fs::create_directories(folder);
|
||||
|
||||
std::shared_ptr<ContentLUT> lut (World::checkIndices(folder, content));
|
||||
if (lut) {
|
||||
if (lut->hasMissingContent()) {
|
||||
@ -265,6 +264,7 @@ void menus::open_world(std::string name, Engine* engine, bool confirmConvert) {
|
||||
} else {
|
||||
try {
|
||||
Level* level = World::load(folder, settings, content, packs);
|
||||
level->world->wfile->createDirectories();
|
||||
engine->setScreen(std::make_shared<LevelScreen>(engine, level));
|
||||
} catch (const world_load_error& error) {
|
||||
guiutil::alert(
|
||||
@ -365,7 +365,7 @@ void create_new_world_panel(Engine* engine) {
|
||||
|
||||
panel->add(guiutil::gotoButton(langs::get(L"World generator", L"world"), "world_generators", engine->getGUI()->getMenu()));
|
||||
|
||||
panel->add(menus::create_button( L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
||||
panel->add(menus::create_button(L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
||||
[=](GUI*) {
|
||||
if (!nameInput->validate())
|
||||
return;
|
||||
@ -406,6 +406,7 @@ void create_new_world_panel(Engine* engine) {
|
||||
engine->getContent(),
|
||||
engine->getContentPacks()
|
||||
);
|
||||
level->world->wfile->createDirectories();
|
||||
menus::generatorID = WorldGenerators::getDefaultGeneratorID();
|
||||
engine->setScreen(std::make_shared<LevelScreen>(engine, level));
|
||||
}));
|
||||
|
||||
@ -104,7 +104,6 @@ static void reopen_world(Engine* engine, World* world) {
|
||||
menus::open_world(wname, engine, true);
|
||||
}
|
||||
|
||||
// TODO: refactor
|
||||
void create_content_panel(Engine* engine, LevelController* controller) {
|
||||
auto level = controller->getLevel();
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
|
||||
@ -20,8 +20,6 @@ namespace lua {
|
||||
int nextEnvironment = 1;
|
||||
|
||||
void logError(const std::string& text);
|
||||
void initEnvironment();
|
||||
|
||||
void removeLibFuncs(const char* libname, const char* funcs[]);
|
||||
void createLibs();
|
||||
public:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user