mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
refs #409 Read FS9 installation directory from registry
This commit is contained in:
@@ -35,6 +35,15 @@ namespace BlackMisc
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithFs9Support()
|
||||||
|
{
|
||||||
|
#ifdef WITH_FS9
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool CProject::isCompiledWithFsxSupport()
|
bool CProject::isCompiledWithFsxSupport()
|
||||||
{
|
{
|
||||||
#ifdef WITH_FSX
|
#ifdef WITH_FSX
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace BlackMisc
|
|||||||
//! with BlackInput?
|
//! with BlackInput?
|
||||||
static bool isCompiledWithBlackInput();
|
static bool isCompiledWithBlackInput();
|
||||||
|
|
||||||
|
//! with FS9 support?
|
||||||
|
static bool isCompiledWithFs9Support();
|
||||||
|
|
||||||
//! with FSX support?
|
//! with FSX support?
|
||||||
static bool isCompiledWithFsxSupport();
|
static bool isCompiledWithFsxSupport();
|
||||||
|
|
||||||
|
|||||||
@@ -21,19 +21,26 @@ namespace BlackMisc
|
|||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using FsRegistryPathPair = QList<QPair<QString, QString>>;
|
||||||
|
|
||||||
QString CFsCommonUtil::fsxDirFromRegistry()
|
QString CFsCommonUtil::fsxDirFromRegistry()
|
||||||
{
|
{
|
||||||
QString fsxPath;
|
QString fsxPath;
|
||||||
if (CProject::isCompiledWithFsxSupport())
|
if (CProject::isCompiledWithFsxSupport())
|
||||||
{
|
{
|
||||||
// set FSX path
|
|
||||||
QSettings fsxRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat);
|
FsRegistryPathPair fsxRegistryPathPairs =
|
||||||
fsxPath = fsxRegistry.value("AppPath").toString().trimmed();
|
|
||||||
if (fsxPath.isEmpty())
|
|
||||||
{
|
{
|
||||||
// another trial
|
{ QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0"), QStringLiteral("AppPath") },
|
||||||
QSettings fsxRegistry("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat);
|
{ QStringLiteral("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0"), QStringLiteral("AppPath") }
|
||||||
fsxPath = fsxRegistry.value("SetupPath").toString().trimmed();
|
};
|
||||||
|
|
||||||
|
for (const auto ®istryPair : fsxRegistryPathPairs)
|
||||||
|
{
|
||||||
|
QSettings fsxRegistry(registryPair.first, QSettings::NativeFormat);
|
||||||
|
fsxPath = fsxRegistry.value(registryPair.second).toString().trimmed();
|
||||||
|
|
||||||
|
if (!fsxPath.isEmpty()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fsxPath;
|
return fsxPath;
|
||||||
@@ -47,6 +54,36 @@ namespace BlackMisc
|
|||||||
return fsxPath;
|
return fsxPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CFsCommonUtil::fs9DirFromRegistry()
|
||||||
|
{
|
||||||
|
QString fs9Path;
|
||||||
|
if (CProject::isCompiledWithFs9Support())
|
||||||
|
{
|
||||||
|
FsRegistryPathPair fs9RegistryPathPairs =
|
||||||
|
{
|
||||||
|
{ QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\DirectPlay\\Applications\\Microsoft Flight Simulator 2004"), QStringLiteral("AppPath") },
|
||||||
|
{ QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\DirectPlay\\Applications\\Microsoft Flight Simulator 2004"), QStringLiteral("AppPath") }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto ®istryPair : fs9RegistryPathPairs)
|
||||||
|
{
|
||||||
|
QSettings fs9Registry(registryPair.first, QSettings::NativeFormat);
|
||||||
|
fs9Path = fs9Registry.value(registryPair.second).toString().trimmed();
|
||||||
|
|
||||||
|
if (!fs9Path.isEmpty()) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fs9Path;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFsCommonUtil::fs9AircraftDirFromRegistry()
|
||||||
|
{
|
||||||
|
QString fs9Path = fs9DirFromRegistry();
|
||||||
|
if (fs9Path.isEmpty()) { return ""; }
|
||||||
|
fs9Path = QDir(fs9Path).filePath("Aircraft");
|
||||||
|
return fs9Path;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ namespace BlackMisc
|
|||||||
//! FSX's simObject directory from registry
|
//! FSX's simObject directory from registry
|
||||||
static QString fsxSimObjectsDirFromRegistry();
|
static QString fsxSimObjectsDirFromRegistry();
|
||||||
|
|
||||||
|
//! FS9 directory obtained from registry
|
||||||
|
static QString fs9DirFromRegistry();
|
||||||
|
|
||||||
|
//! FS9's aircraft directory from registry
|
||||||
|
static QString fs9AircraftDirFromRegistry();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user