mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 05:51:23 +08:00
Ref T252, utility functions for simulator directories
This commit is contained in:
@@ -205,6 +205,12 @@ namespace BlackMisc
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CFsCommonUtil::p3dSimObjectsDirFromSimDir(const QString &simDir)
|
||||||
|
{
|
||||||
|
if (simDir.isEmpty()) { return QStringLiteral(""); }
|
||||||
|
return CFileUtils::appendFilePaths(simDir, "SimObjects");
|
||||||
|
}
|
||||||
|
|
||||||
const QStringList &CFsCommonUtil::p3dSimObjectsExcludeDirectoryPatterns()
|
const QStringList &CFsCommonUtil::p3dSimObjectsExcludeDirectoryPatterns()
|
||||||
{
|
{
|
||||||
static const QStringList exclude
|
static const QStringList exclude
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ namespace BlackMisc
|
|||||||
//! P3D's sim object dir, resolved from multiple sources
|
//! P3D's sim object dir, resolved from multiple sources
|
||||||
static const QString &p3dSimObjectsDir();
|
static const QString &p3dSimObjectsDir();
|
||||||
|
|
||||||
|
//! P3D aircraft dir, relative to simulator directory
|
||||||
|
static QString p3dSimObjectsDirFromSimDir(const QString &simDir);
|
||||||
|
|
||||||
//! Exclude directories for simObjects
|
//! Exclude directories for simObjects
|
||||||
static const QStringList &p3dSimObjectsExcludeDirectoryPatterns();
|
static const QStringList &p3dSimObjectsExcludeDirectoryPatterns();
|
||||||
|
|
||||||
|
|||||||
@@ -101,25 +101,38 @@ namespace BlackMisc
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CXPlaneUtil::xplaneRootDir()
|
const QString &CXPlaneUtil::xplaneRootDir()
|
||||||
{
|
{
|
||||||
if (!xplane11Dir().isEmpty()) { return xplane11Dir(); }
|
static const QString dir = []
|
||||||
else if (!xplane10Dir().isEmpty()) { return xplane10Dir(); }
|
{
|
||||||
else if (!xplane9Dir().isEmpty()) { return xplane9Dir(); }
|
if (!xplane11Dir().isEmpty()) { return xplane11Dir(); }
|
||||||
else { return {}; }
|
else if (!xplane10Dir().isEmpty()) { return xplane10Dir(); }
|
||||||
|
else if (!xplane9Dir().isEmpty()) { return xplane9Dir(); }
|
||||||
|
else { return QString(); }
|
||||||
|
}();
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CXPlaneUtil::isXplaneRootDirExisting()
|
bool CXPlaneUtil::isXplaneRootDirExisting()
|
||||||
{
|
{
|
||||||
const QDir dir(xplaneRootDir());
|
static const bool exists = QDir(xplaneRootDir()).exists();
|
||||||
return dir.exists();
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CXPlaneUtil::xplanePluginDir()
|
const QString &CXPlaneUtil::xplanePluginDir()
|
||||||
{
|
{
|
||||||
const QString xp = xplaneRootDir();
|
static const QString pd(xplaneRootDir().isEmpty() ? "" : CFileUtils::appendFilePaths(xplaneRootDir(), xplanePluginPath()));
|
||||||
if (xp.isEmpty()) { return xp; }
|
return pd;
|
||||||
return CFileUtils::appendFilePaths(xp, xplanePluginPath());
|
}
|
||||||
|
|
||||||
|
QString CXPlaneUtil::pluginDirFromSimDir(const QString &simulatorDir)
|
||||||
|
{
|
||||||
|
return CFileUtils::appendFilePaths(simulatorDir, xplanePluginPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList CXPlaneUtil::modelDirectoriesFromSimDir(const QString &simulatorDir)
|
||||||
|
{
|
||||||
|
return QStringList({ simulatorDir });
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CXPlaneUtil::xplanePluginPath()
|
QString CXPlaneUtil::xplanePluginPath()
|
||||||
@@ -130,19 +143,20 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool CXPlaneUtil::isXplanePluginDirDirExisting()
|
bool CXPlaneUtil::isXplanePluginDirDirExisting()
|
||||||
{
|
{
|
||||||
const QDir dir(xplanePluginDir());
|
static const bool exists = QDir(xplanePluginDir()).exists();
|
||||||
return dir.exists();
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CXPlaneUtil::xplaneModelDirectories()
|
const QStringList &CXPlaneUtil::xplaneModelDirectories()
|
||||||
{
|
{
|
||||||
if (xplaneRootDir().isEmpty()) { return QStringList(); }
|
static const QStringList dirs = xplaneRootDir().isEmpty() ? QStringList() : QStringList({xplaneRootDir()});
|
||||||
return QStringList({ xplaneRootDir() });
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CXPlaneUtil::xplaneModelExcludeDirectoryPatterns()
|
const QStringList &CXPlaneUtil::xplaneModelExcludeDirectoryPatterns()
|
||||||
{
|
{
|
||||||
return QStringList();
|
static const QStringList empty;
|
||||||
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CXPlaneUtil::xswiftbusLegacyDir(const QString &rootDir)
|
QString CXPlaneUtil::xswiftbusLegacyDir(const QString &rootDir)
|
||||||
|
|||||||
@@ -40,14 +40,20 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! XPlane root directory
|
//! XPlane root directory
|
||||||
//! In case more then one XPlane version is found, the path to the highest version is used
|
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||||
static QString xplaneRootDir();
|
static const QString &xplaneRootDir();
|
||||||
|
|
||||||
//! Is the xplaneRootDir existing?
|
//! Is the xplaneRootDir existing?
|
||||||
static bool isXplaneRootDirExisting();
|
static bool isXplaneRootDirExisting();
|
||||||
|
|
||||||
//! XPlane plugin directory
|
//! XPlane plugin directory
|
||||||
//! In case more then one XPlane version is found, the path to the highest version is used
|
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||||
static QString xplanePluginDir();
|
static const QString &xplanePluginDir();
|
||||||
|
|
||||||
|
//! Plugin directory from given simulator directory
|
||||||
|
static QString pluginDirFromSimDir(const QString &simulatorDir);
|
||||||
|
|
||||||
|
//! Model directories from simultaor directory
|
||||||
|
static QStringList modelDirectoriesFromSimDir(const QString &simulatorDir);
|
||||||
|
|
||||||
//! XPlane relative plugin path
|
//! XPlane relative plugin path
|
||||||
static QString xplanePluginPath();
|
static QString xplanePluginPath();
|
||||||
@@ -56,10 +62,10 @@ namespace BlackMisc
|
|||||||
static bool isXplanePluginDirDirExisting();
|
static bool isXplanePluginDirDirExisting();
|
||||||
|
|
||||||
//! Directories with models
|
//! Directories with models
|
||||||
static QStringList xplaneModelDirectories();
|
static const QStringList &xplaneModelDirectories();
|
||||||
|
|
||||||
//! Exclude directories for models
|
//! Exclude directories for models
|
||||||
static QStringList xplaneModelExcludeDirectoryPatterns();
|
static const QStringList &xplaneModelExcludeDirectoryPatterns();
|
||||||
|
|
||||||
//! XSwiftBus legacy directory
|
//! XSwiftBus legacy directory
|
||||||
static QString xswiftbusLegacyDir(const QString &rootDir);
|
static QString xswiftbusLegacyDir(const QString &rootDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user