mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
async launcher
This commit is contained in:
parent
46872b764b
commit
23652a8ba1
@ -142,7 +142,7 @@ void ChroniclesExtractor::createBaseMod()
|
|||||||
|
|
||||||
QJsonObject mod
|
QJsonObject mod
|
||||||
{
|
{
|
||||||
{ "modType", "Extension" },
|
{ "modType", "Expansion" },
|
||||||
{ "name", "Heroes Chronicles" },
|
{ "name", "Heroes Chronicles" },
|
||||||
{ "description", "" },
|
{ "description", "" },
|
||||||
{ "author", "3DO" },
|
{ "author", "3DO" },
|
||||||
@ -156,13 +156,13 @@ void ChroniclesExtractor::createBaseMod()
|
|||||||
|
|
||||||
void ChroniclesExtractor::createChronicleMod(int no)
|
void ChroniclesExtractor::createChronicleMod(int no)
|
||||||
{
|
{
|
||||||
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods" / "chronicles" / "Mods"));
|
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods" / "chronicles" / "Mods" / ("chronicles_" + std::to_string(no))));
|
||||||
dir.mkdir("chronicles_" + QString::number(no));
|
dir.removeRecursively();
|
||||||
dir.cd("chronicles_" + QString::number(no));
|
dir.mkpath(".");
|
||||||
|
|
||||||
QJsonObject mod
|
QJsonObject mod
|
||||||
{
|
{
|
||||||
{ "modType", "Extension" },
|
{ "modType", "Expansion" },
|
||||||
{ "name", "Heroes Chronicles - " + QString::number(no) },
|
{ "name", "Heroes Chronicles - " + QString::number(no) },
|
||||||
{ "description", "" },
|
{ "description", "" },
|
||||||
{ "author", "3DO" },
|
{ "author", "3DO" },
|
||||||
@ -174,11 +174,7 @@ void ChroniclesExtractor::createChronicleMod(int no)
|
|||||||
jsonFile.write(QJsonDocument(mod).toJson());
|
jsonFile.write(QJsonDocument(mod).toJson());
|
||||||
|
|
||||||
dir.cd("content");
|
dir.cd("content");
|
||||||
dir.removeRecursively();
|
|
||||||
dir.mkdir(".");
|
|
||||||
|
|
||||||
dir.mkdir("Data");
|
|
||||||
dir.mkdir("Sprites");
|
|
||||||
extractFiles(no);
|
extractFiles(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,14 +839,31 @@ void CModListView::installFiles(QStringList files)
|
|||||||
|
|
||||||
if(!exe.empty())
|
if(!exe.empty())
|
||||||
{
|
{
|
||||||
ChroniclesExtractor ce(this, [](float progress) { });
|
ui->progressBar->setFormat(tr("Installing chronicles"));
|
||||||
ce.installChronicles(exe);
|
|
||||||
|
|
||||||
//update
|
float prog = 0.0;
|
||||||
CResourceHandler::get("initial")->updateFilteredFiles([](const std::string &){ return true; });
|
|
||||||
manager->loadMods();
|
auto futureExtract = std::async(std::launch::async, [this, exe, &prog]()
|
||||||
modModel->reloadRepositories();
|
{
|
||||||
emit modsChanged();
|
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())
|
if(!images.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user