World content packs list

This commit is contained in:
MihailRis
2023-12-18 19:45:29 +03:00
parent 7f8935a93c
commit 082599e78c
8 changed files with 82 additions and 26 deletions
+14 -2
View File
@@ -159,15 +159,27 @@ Panel* create_main_menu_panel(Engine* engine, PagesControl* menu) {
button->color(vec4(1.0f, 1.0f, 1.0f, 0.1f));
button->listenAction([=](GUI* gui) {
// TODO: complete and move somewhere
auto folder = paths->getWorldsFolder()/u8path(name);
auto resdir = engine->getPaths()->getResources();
auto& packs = engine->getContentPacks();
packs.clear();
packs.push_back(ContentPack::read(resdir/path("content/base")));
auto packnames = ContentPack::worldPacksList(folder);
for (auto name : packnames) {
path packfolder;
try {
packfolder = ContentPack::findPack(paths, name);
} catch (std::runtime_error& error) {
guiutil::alert(gui, langs::get(L"error.pack-not-found")+
L": "+util::str2wstr_utf8(name));
return;
}
packs.push_back(ContentPack::read(packfolder));
}
engine->loadContent();
auto* content = engine->getContent();
auto& settings = engine->getSettings();
auto folder = paths->getWorldsFolder()/u8path(name);
std::filesystem::create_directories(folder);
ContentLUT* lut = World::checkIndices(folder, content);
if (lut) {