idk
This commit is contained in:
parent
7c16333850
commit
c457bdb293
@ -103,6 +103,28 @@ static void reopen_world(Engine* engine, World* world) {
|
||||
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) {
|
||||
auto level = controller->getLevel();
|
||||
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,
|
||||
[=](const ContentPack& pack) {
|
||||
auto world = level->getWorld();
|
||||
auto worldFolder = paths->getWorldFolder();
|
||||
for (const auto& dependency : pack.dependencies) {
|
||||
fs::path folder = ContentPack::findPack(paths, worldFolder, dependency);
|
||||
if (!fs::is_directory(folder)) {
|
||||
guiutil::alert(gui, langs::get(L"error.dependency-not-found")+
|
||||
L": "+util::str2wstr_utf8(dependency));
|
||||
return;
|
||||
}
|
||||
if (!world->hasPack(dependency)) {
|
||||
world->wfile->addPack(world, dependency);
|
||||
}
|
||||
std::string missing;
|
||||
if (try_add_dependency(engine, world, pack, missing)) {
|
||||
guiutil::alert(
|
||||
gui, langs::get(L"error.dependency-not-found")+
|
||||
L": "+util::str2wstr_utf8(missing)
|
||||
);
|
||||
return;
|
||||
}
|
||||
world->wfile->addPack(world, pack.id);
|
||||
controller->saveWorld();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user