idk
This commit is contained in:
@@ -103,6 +103,28 @@ static void reopen_world(Engine* engine, World* world) {
|
|||||||
menus::open_world(wname, engine, true);
|
menus::open_world(wname, engine, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME
|
||||||
|
static bool try_add_dependency(Engine* engine, World* world, const ContentPack& pack, std::string& missing) {
|
||||||
|
auto paths = engine->getPaths();
|
||||||
|
auto gui = engine->getGUI();
|
||||||
|
for (const auto& dependency : pack.dependencies) {
|
||||||
|
fs::path folder = ContentPack::findPack(
|
||||||
|
paths,
|
||||||
|
world->wfile->directory,
|
||||||
|
dependency
|
||||||
|
);
|
||||||
|
if (!fs::is_directory(folder)) {
|
||||||
|
missing = dependency;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!world->hasPack(dependency)) {
|
||||||
|
world->wfile->addPack(world, dependency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
world->wfile->addPack(world, pack.id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
@@ -145,17 +167,13 @@ void create_content_panel(Engine* engine, LevelController* controller) {
|
|||||||
auto panel = menus::create_packs_panel(scanned, engine, true,
|
auto panel = menus::create_packs_panel(scanned, engine, true,
|
||||||
[=](const ContentPack& pack) {
|
[=](const ContentPack& pack) {
|
||||||
auto world = level->getWorld();
|
auto world = level->getWorld();
|
||||||
auto worldFolder = paths->getWorldFolder();
|
std::string missing;
|
||||||
for (const auto& dependency : pack.dependencies) {
|
if (try_add_dependency(engine, world, pack, missing)) {
|
||||||
fs::path folder = ContentPack::findPack(paths, worldFolder, dependency);
|
guiutil::alert(
|
||||||
if (!fs::is_directory(folder)) {
|
gui, langs::get(L"error.dependency-not-found")+
|
||||||
guiutil::alert(gui, langs::get(L"error.dependency-not-found")+
|
L": "+util::str2wstr_utf8(missing)
|
||||||
L": "+util::str2wstr_utf8(dependency));
|
);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (!world->hasPack(dependency)) {
|
|
||||||
world->wfile->addPack(world, dependency);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
world->wfile->addPack(world, pack.id);
|
world->wfile->addPack(world, pack.id);
|
||||||
controller->saveWorld();
|
controller->saveWorld();
|
||||||
|
|||||||
Reference in New Issue
Block a user