mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
autodetect windows
This commit is contained in:
parent
121ef77440
commit
eca1dba750
@ -134,7 +134,12 @@ void FirstLaunchView::activateTabHeroesData()
|
||||
ui->pushButtonDataHelp->hide();
|
||||
ui->labelDataHelp->hide();
|
||||
}
|
||||
heroesDataUpdate();
|
||||
if(heroesDataUpdate())
|
||||
return;
|
||||
|
||||
QString installPath = getHeroesInstallDir();
|
||||
if(!installPath.isEmpty())
|
||||
copyHeroesData(installPath);
|
||||
}
|
||||
|
||||
void FirstLaunchView::activateTabModPreset()
|
||||
@ -164,12 +169,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 +261,25 @@ 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 "";
|
||||
}
|
||||
|
||||
void FirstLaunchView::copyHeroesData(const QString & path)
|
||||
{
|
||||
QDir sourceRoot = QDir(path);
|
||||
|
||||
if(path.isEmpty())
|
||||
sourceRoot = 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();
|
||||
|
Loading…
Reference in New Issue
Block a user