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