1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-15 13:33:36 +02:00

Update only actually changed mod on enabling / disabling

This commit is contained in:
Ivan Savenko 2024-11-21 20:22:10 +00:00
parent 4aaa6c1eb4
commit 822b6a00e7
2 changed files with 12 additions and 16 deletions

View File

@ -526,31 +526,27 @@ QStringList CModListView::findUnavailableMods(QStringList candidates)
void CModListView::on_enableButton_clicked()
{
QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
enableModByName(modName);
checkManagerErrors();
}
void CModListView::enableModByName(QString modName)
{
manager->enableMods({modName});
modModel->reloadRepositories();
modModel->modChanged(modName);
}
void CModListView::on_disableButton_clicked()
{
QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
disableModByName(modName);
checkManagerErrors();
}
void CModListView::disableModByName(QString modName)
{
manager->disableMod(modName);
modModel->reloadRepositories();
modModel->modChanged(modName);
}
QStringList CModListView::getModsToInstall(QString mod)
@ -566,7 +562,7 @@ QStringList CModListView::getModsToInstall(QString mod)
candidates.pop_back();
processed.push_back(potentialToInstall);
if (modStateModel->isModInstalled(potentialToInstall))
if (modStateModel->isModExists(potentialToInstall) && modStateModel->isModInstalled(potentialToInstall))
continue;
if (modStateModel->isSubmod(potentialToInstall))
@ -607,7 +603,7 @@ void CModListView::on_updateButton_clicked()
auto mod = modStateModel->getMod(name);
// update required mod, install missing (can be new dependency)
if(mod.isUpdateAvailable() || !mod.isInstalled())
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeMegabytes());
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
}
}
@ -634,7 +630,7 @@ void CModListView::on_installButton_clicked()
{
auto mod = modStateModel->getMod(name);
if(mod.isAvailable())
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeMegabytes());
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
else if(!modStateModel->isModEnabled(name))
enableModByName(name);
}
@ -702,12 +698,12 @@ void CModListView::manualInstallFile(QString filePath)
downloadFile(fileName, QUrl::fromLocalFile(filePath), fileName);
}
void CModListView::downloadFile(QString file, QString url, QString description, qint64 size)
void CModListView::downloadFile(QString file, QString url, QString description, qint64 sizeBytes)
{
downloadFile(file, QUrl{url}, description, size);
downloadFile(file, QUrl{url}, description, sizeBytes);
}
void CModListView::downloadFile(QString file, QUrl url, QString description, qint64 size)
void CModListView::downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes)
{
if(!dlManager)
{
@ -728,7 +724,7 @@ void CModListView::downloadFile(QString file, QUrl url, QString description, qin
ui->progressBar->setFormat(progressBarFormat);
}
dlManager->downloadFile(url, file, size);
dlManager->downloadFile(url, file, sizeBytes);
}
void CModListView::downloadProgress(qint64 current, qint64 max)
@ -1033,7 +1029,7 @@ void CModListView::doInstallMod(const QString & modName)
{
auto mod = modStateModel->getMod(name);
if(!mod.isInstalled())
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeMegabytes());
downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
}
}

View File

@ -53,8 +53,8 @@ class CModListView : public QWidget
QStringList findUnavailableMods(QStringList candidates);
void manualInstallFile(QString filePath);
void downloadFile(QString file, QString url, QString description, qint64 size = 0);
void downloadFile(QString file, QUrl url, QString description, qint64 size = 0);
void downloadFile(QString file, QString url, QString description, qint64 sizeBytes = 0);
void downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes = 0);
void installMods(QStringList archives);
void installMaps(QStringList maps);