diff --git a/launcher/modManager/chroniclesextractor.cpp b/launcher/modManager/chroniclesextractor.cpp index 566363389..83ef40a72 100644 --- a/launcher/modManager/chroniclesextractor.cpp +++ b/launcher/modManager/chroniclesextractor.cpp @@ -142,7 +142,7 @@ void ChroniclesExtractor::createBaseMod() QJsonObject mod { - { "modType", "Extension" }, + { "modType", "Expansion" }, { "name", "Heroes Chronicles" }, { "description", "" }, { "author", "3DO" }, @@ -156,13 +156,13 @@ void ChroniclesExtractor::createBaseMod() void ChroniclesExtractor::createChronicleMod(int no) { - QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods" / "chronicles" / "Mods")); - dir.mkdir("chronicles_" + QString::number(no)); - dir.cd("chronicles_" + QString::number(no)); + QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods" / "chronicles" / "Mods" / ("chronicles_" + std::to_string(no)))); + dir.removeRecursively(); + dir.mkpath("."); QJsonObject mod { - { "modType", "Extension" }, + { "modType", "Expansion" }, { "name", "Heroes Chronicles - " + QString::number(no) }, { "description", "" }, { "author", "3DO" }, @@ -174,11 +174,7 @@ void ChroniclesExtractor::createChronicleMod(int no) jsonFile.write(QJsonDocument(mod).toJson()); dir.cd("content"); - dir.removeRecursively(); - dir.mkdir("."); - - dir.mkdir("Data"); - dir.mkdir("Sprites"); + extractFiles(no); } diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index c34e90fc9..191cea455 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -839,14 +839,31 @@ void CModListView::installFiles(QStringList files) if(!exe.empty()) { - ChroniclesExtractor ce(this, [](float progress) { }); - ce.installChronicles(exe); + ui->progressBar->setFormat(tr("Installing chronicles")); - //update - CResourceHandler::get("initial")->updateFilteredFiles([](const std::string &){ return true; }); - manager->loadMods(); - modModel->reloadRepositories(); - emit modsChanged(); + float prog = 0.0; + + auto futureExtract = std::async(std::launch::async, [this, exe, &prog]() + { + ChroniclesExtractor ce(this, [this, &prog](float progress) { prog = progress; }); + ce.installChronicles(exe); + return true; + }); + + while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready) + { + emit extractionProgress(int(prog * 1000.f), 1000); + qApp->processEvents(); + } + + if(futureExtract.get()) + { + //update + CResourceHandler::get("initial")->updateFilteredFiles([](const std::string &){ return true; }); + manager->loadMods(); + modModel->reloadRepositories(); + emit modsChanged(); + } } if(!images.empty())