diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 305a49268..a8085bfd5 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -581,6 +581,11 @@ QStringList CModListView::getModsToInstall(QString mod) void CModListView::on_updateButton_clicked() { QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString(); + doUpdateMod(modName); +} + +void CModListView::doUpdateMod(const QString & modName) +{ auto targetMod = modStateModel->getMod(modName); if(targetMod.isUpdateAvailable()) @@ -994,6 +999,20 @@ QStringList CModListView::getInstalledChronicles() return result; } +QStringList CModListView::getUpdateableMods() +{ + QStringList result; + + for(const auto & modName : modStateModel->getAllMods()) + { + auto mod = modStateModel->getMod(modName); + if (mod.isUpdateAvailable()) + result.push_back(modName); + } + + return result; +} + QString CModListView::getTranslationModName(const QString & language) { for(const auto & modName : modStateModel->getAllMods()) diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index a0038919c..41be3221d 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -79,6 +79,9 @@ public: /// install mod by name void doInstallMod(const QString & modName); + /// update mod by name + void doUpdateMod(const QString & modName); + /// returns true if mod is available in repository and can be installed bool isModAvailable(const QString & modName); @@ -88,6 +91,9 @@ public: /// finds all already imported Heroes Chronicles mods (if any) QStringList getInstalledChronicles(); + /// finds all mods that can be updated + QStringList getUpdateableMods(); + /// returns true if mod is currently enabled bool isModEnabled(const QString & modName); diff --git a/launcher/startGame/StartGameTab.cpp b/launcher/startGame/StartGameTab.cpp index e8f7a21aa..f979764f4 100644 --- a/launcher/startGame/StartGameTab.cpp +++ b/launcher/startGame/StartGameTab.cpp @@ -106,13 +106,14 @@ void StartGameTab::refreshTranslation(ETranslationStatus status) void StartGameTab::refreshMods() { constexpr int chroniclesCount = 8; - QStringList updateableMods; // TODO + QStringList updateableMods = getMainWindow()->getModView()->getUpdateableMods(); QStringList chroniclesMods = getMainWindow()->getModView()->getInstalledChronicles(); + ui->buttonUpdateMods->setText(tr("Update %n mods", "", updateableMods.size())); ui->buttonUpdateMods->setVisible(!updateableMods.empty()); ui->buttonUpdateModsHelp->setVisible(!updateableMods.empty()); - ui->labelChronicles->setText(tr("Heroes Chronicles:\n%1/%2 installed").arg(chroniclesMods.size()).arg(chroniclesCount)); + ui->labelChronicles->setText(tr("Heroes Chronicles:\n%n/%1 installed", "", chroniclesMods.size()).arg(chroniclesCount)); ui->labelChronicles->setVisible(chroniclesMods.size() != chroniclesCount); ui->buttonChroniclesHelp->setVisible(chroniclesMods.size() != chroniclesCount); } @@ -183,7 +184,17 @@ void StartGameTab::on_buttonImportFiles_clicked() void StartGameTab::on_buttonInstallTranslation_clicked() { - // TODO + if (getMainWindow()->getTranslationStatus() == ETranslationStatus::NOT_INSTALLLED) + { + getMainWindow()->getModView()->getTranslationModName(); + mainWindow->getModView()->doInstallMod(modName); + } + } + else + { + mainWindow->getModView()->enableModByName(modName); + } +} } void StartGameTab::on_buttonActivateTranslation_clicked() @@ -193,7 +204,10 @@ void StartGameTab::on_buttonActivateTranslation_clicked() void StartGameTab::on_buttonUpdateMods_clicked() { - // TODO + QStringList updateableMods = getMainWindow()->getModView()->getUpdateableMods(); + + for (const auto & modName : updateableMods) + getMainWindow()->getModView()->doInstallMod(modName); } void StartGameTab::on_buttonHelpImportFiles_clicked() diff --git a/launcher/startGame/StartGameTab.ui b/launcher/startGame/StartGameTab.ui index f8ec01a85..5847b07f6 100644 --- a/launcher/startGame/StartGameTab.ui +++ b/launcher/startGame/StartGameTab.ui @@ -567,7 +567,7 @@ - Update %1 mods +