mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Merge pull request #3442 from Laserlicht/autodetect_windows
Autodetect and copy installed heroes on windows
This commit is contained in:
		| @@ -134,7 +134,16 @@ void FirstLaunchView::activateTabHeroesData() | ||||
| 		ui->pushButtonDataHelp->hide(); | ||||
| 		ui->labelDataHelp->hide(); | ||||
| 	} | ||||
| 	heroesDataUpdate(); | ||||
| 	if(heroesDataUpdate()) | ||||
| 		return; | ||||
|  | ||||
| 	QString installPath = getHeroesInstallDir(); | ||||
| 	if(!installPath.isEmpty()) | ||||
| 	{ | ||||
| 		auto reply = QMessageBox::question(this, tr("Heroes III installation found!"), tr("Copy data to VCMI folder?"), QMessageBox::Yes | QMessageBox::No); | ||||
| 		if(reply == QMessageBox::Yes) | ||||
| 			copyHeroesData(installPath); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::activateTabModPreset() | ||||
| @@ -164,12 +173,14 @@ void FirstLaunchView::languageSelected(const QString & selectedLanguage) | ||||
| 		mainWindow->updateTranslation(); | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::heroesDataUpdate() | ||||
| bool FirstLaunchView::heroesDataUpdate() | ||||
| { | ||||
| 	if(heroesDataDetect()) | ||||
| 	bool detected = heroesDataDetect(); | ||||
| 	if(detected) | ||||
| 		heroesDataDetected(); | ||||
| 	else | ||||
| 		heroesDataMissing(); | ||||
| 	return detected; | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::heroesDataMissing() | ||||
| @@ -254,9 +265,26 @@ void FirstLaunchView::forceHeroesLanguage(const QString & language) | ||||
| 	node->String() = language.toStdString(); | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::copyHeroesData() | ||||
| QString FirstLaunchView::getHeroesInstallDir() | ||||
| { | ||||
| 	QDir sourceRoot = QFileDialog::getExistingDirectory(this, "", "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); | ||||
| #ifdef VCMI_WINDOWS | ||||
| 	QString gogPath = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\GOG.com\\Games\\1207658787", QSettings::NativeFormat).value("path").toString(); | ||||
| 	if(!gogPath.isEmpty()) | ||||
| 		return gogPath; | ||||
|  | ||||
| 	QString cdPath = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\New World Computing\\Heroes of Might and Magic® III\\1.0", QSettings::NativeFormat).value("AppPath").toString(); | ||||
| 	if(!cdPath.isEmpty()) | ||||
| 		return cdPath; | ||||
| #endif | ||||
| 	return QString{}; | ||||
| } | ||||
|  | ||||
| void FirstLaunchView::copyHeroesData(const QString & path) | ||||
| { | ||||
| 	QDir sourceRoot = QDir(path); | ||||
| 	 | ||||
| 	if(path.isEmpty()) | ||||
| 		sourceRoot.setPath(QFileDialog::getExistingDirectory(this, {}, {}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); | ||||
|  | ||||
| 	if(!sourceRoot.exists()) | ||||
| 		return; | ||||
|   | ||||
| @@ -42,7 +42,7 @@ class FirstLaunchView : public QWidget | ||||
| 	void languageSelected(const QString & languageCode); | ||||
|  | ||||
| 	// Tab Heroes III Data | ||||
| 	void heroesDataUpdate(); | ||||
| 	bool heroesDataUpdate(); | ||||
| 	bool heroesDataDetect(); | ||||
|  | ||||
| 	void heroesDataMissing(); | ||||
| @@ -51,7 +51,8 @@ class FirstLaunchView : public QWidget | ||||
| 	void heroesLanguageUpdate(); | ||||
| 	void forceHeroesLanguage(const QString & language); | ||||
|  | ||||
| 	void copyHeroesData(); | ||||
| 	QString getHeroesInstallDir(); | ||||
| 	void copyHeroesData(const QString & path = {}); | ||||
|  | ||||
| 	// Tab Mod Preset | ||||
| 	void modPresetUpdate(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user