mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Correctly handle scenario of unavailable mod repository
This commit is contained in:
		| @@ -310,6 +310,10 @@ void FirstLaunchView::modPresetUpdate() | ||||
| 	ui->checkBoxPresetExtras->setEnabled(checkCanInstallExtras()); | ||||
| 	ui->checkBoxPresetHota->setEnabled(checkCanInstallHota()); | ||||
| 	ui->checkBoxPresetWog->setEnabled(checkCanInstallWog()); | ||||
|  | ||||
| 	// we can't install anything - either repository checkout is off or all recommended mods are already installed | ||||
| 	if (!checkCanInstallTranslation() && !checkCanInstallExtras() && !checkCanInstallHota() && !checkCanInstallWog()) | ||||
| 		exitSetup(); | ||||
| } | ||||
|  | ||||
| QString FirstLaunchView::findTranslationModName() | ||||
| @@ -364,7 +368,7 @@ CModListView * FirstLaunchView::getModView() | ||||
|  | ||||
| bool FirstLaunchView::checkCanInstallMod(const QString & modID) | ||||
| { | ||||
| 	return getModView() && !getModView()->isModInstalled(modID); | ||||
| 	return getModView() && getModView()->isModAvailable(modID); | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::on_pushButtonPresetBack_clicked() | ||||
| @@ -376,16 +380,16 @@ void FirstLaunchView::on_pushButtonPresetNext_clicked() | ||||
| { | ||||
| 	QStringList modsToInstall; | ||||
|  | ||||
| 	if (ui->checkBoxPresetLanguage && checkCanInstallTranslation()) | ||||
| 	if (ui->checkBoxPresetLanguage->isChecked() && checkCanInstallTranslation()) | ||||
| 		modsToInstall.push_back(findTranslationModName()); | ||||
|  | ||||
| 	if (ui->checkBoxPresetExtras && checkCanInstallExtras()) | ||||
| 	if (ui->checkBoxPresetExtras->isChecked() && checkCanInstallExtras()) | ||||
| 		modsToInstall.push_back("vcmi-extras"); | ||||
|  | ||||
| 	if (ui->checkBoxPresetWog && checkCanInstallWog()) | ||||
| 	if (ui->checkBoxPresetWog->isChecked() && checkCanInstallWog()) | ||||
| 		modsToInstall.push_back("wake-of-gods"); | ||||
|  | ||||
| 	if (ui->checkBoxPresetHota && checkCanInstallHota()) | ||||
| 	if (ui->checkBoxPresetHota->isChecked() && checkCanInstallHota()) | ||||
| 		modsToInstall.push_back("hota"); | ||||
|  | ||||
| 	exitSetup(); | ||||
|   | ||||
| @@ -829,10 +829,10 @@ void CModListView::doInstallMod(const QString & modName) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| bool CModListView::isModInstalled(const QString & modName) | ||||
| bool CModListView::isModAvailable(const QString & modName) | ||||
| { | ||||
| 	auto mod = modModel->getMod(modName); | ||||
| 	return mod.isInstalled(); | ||||
| 	return mod.isAvailable(); | ||||
| } | ||||
|  | ||||
| bool CModListView::isModEnabled(const QString & modName) | ||||
|   | ||||
| @@ -86,8 +86,8 @@ public: | ||||
| 	/// install mod by name | ||||
| 	void doInstallMod(const QString & modName); | ||||
|  | ||||
| 	/// returns true if mod is currently installed | ||||
| 	bool isModInstalled(const QString & modName); | ||||
| 	/// returns true if mod is available in repository and can be installed | ||||
| 	bool isModAvailable(const QString & modName); | ||||
|  | ||||
| 	/// finds translation mod for specified languages. Returns empty string on error | ||||
| 	QString getTranslationModName(const QString & language); | ||||
|   | ||||
| @@ -375,7 +375,7 @@ void CSettingsView::loadTranslation() | ||||
| 	if (!translationExists) | ||||
| 		return; | ||||
|  | ||||
| 	bool translationInstalled = mainWindow->getModView()->isModInstalled(modName); | ||||
| 	bool translationAvailable = mainWindow->getModView()->isModAvailable(modName); | ||||
| 	bool translationEnabled = mainWindow->getModView()->isModEnabled(modName); | ||||
|  | ||||
| 	ui->pushButtonTranslation->setVisible(!translationEnabled); | ||||
| @@ -385,13 +385,13 @@ void CSettingsView::loadTranslation() | ||||
| 		ui->labelTranslationStatus->setText(tr("Active")); | ||||
| 	} | ||||
|  | ||||
| 	if (translationInstalled && !translationEnabled) | ||||
| 	if (!translationEnabled && !translationAvailable) | ||||
| 	{ | ||||
| 		ui->labelTranslationStatus->setText(tr("Disabled")); | ||||
| 		ui->pushButtonTranslation->setText(tr("Enable")); | ||||
| 	} | ||||
|  | ||||
| 	if (!translationInstalled) | ||||
| 	if (translationAvailable) | ||||
| 	{ | ||||
| 		ui->labelTranslationStatus->setText(tr("Not Installed")); | ||||
| 		ui->pushButtonTranslation->setText(tr("Install")); | ||||
| @@ -413,15 +413,15 @@ void CSettingsView::on_pushButtonTranslation_clicked() | ||||
| 	if (modName.isEmpty()) | ||||
| 		return; | ||||
|  | ||||
| 	if (mainWindow->getModView()->isModInstalled(modName)) | ||||
| 	{ | ||||
| 		mainWindow->getModView()->enableModByName(modName); | ||||
| 	} | ||||
| 	else | ||||
| 	if (mainWindow->getModView()->isModAvailable(modName)) | ||||
| 	{ | ||||
| 		mainWindow->switchToModsTab(); | ||||
| 		mainWindow->getModView()->doInstallMod(modName); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		mainWindow->getModView()->enableModByName(modName); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CSettingsView::on_comboBoxLanguageBase_currentIndexChanged(int index) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user