mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 14:07:35 +08:00
Ref T660, unify FSX and P3D directory generation (from config files)
* removed unused functions * sxSimObjectsDirPlusAddOnXmlSimObjectsPaths * use simulator directory for FSX (same as P3D) * renamings
This commit is contained in:
@@ -216,14 +216,38 @@ namespace BlackMisc
|
||||
return dir;
|
||||
}
|
||||
|
||||
QStringList CFsCommonUtil::p3dSimObjectsDirPlusAddOnSimObjectsDirs(const QString &simObjectsDir, const QString &versionHint)
|
||||
QStringList CFsCommonUtil::fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir)
|
||||
{
|
||||
// finding the user settings only works on P3D machine
|
||||
const QSet<QString> allP3dAddOnSimObjectPaths = CFsCommonUtil::allP3dAddOnSimObjectPaths(versionHint);
|
||||
QStringList all(allP3dAddOnSimObjectPaths.toList());
|
||||
all.push_front(simObjectsDir.isEmpty() ? p3dSimObjectsDir() : simObjectsDir);
|
||||
all.sort(Qt::CaseInsensitive);
|
||||
return all;
|
||||
QStringList allPaths = CFsCommonUtil::allFsxSimObjectPaths().toList();
|
||||
const QString sod = simObjectsDir.isEmpty() ? CFsCommonUtil::fsxSimObjectsDir() : simObjectsDir;
|
||||
if (!sod.isEmpty() && !allPaths.contains(sod, Qt::CaseInsensitive))
|
||||
{
|
||||
// case insensitive is important here
|
||||
allPaths.push_front(sod);
|
||||
}
|
||||
|
||||
allPaths.removeAll({}); // remove all empty
|
||||
allPaths.removeDuplicates();
|
||||
allPaths.sort(Qt::CaseInsensitive);
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
QStringList CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir, const QString &versionHint)
|
||||
{
|
||||
// finding the user settings only works on P3D machine
|
||||
QStringList allPaths = CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(versionHint).toList();
|
||||
const QString sod = simObjectsDir.isEmpty() ? CFsCommonUtil::p3dSimObjectsDir() : simObjectsDir;
|
||||
if (!sod.isEmpty() && !allPaths.contains(sod, Qt::CaseInsensitive))
|
||||
{
|
||||
// case insensitive is important here
|
||||
allPaths.push_front(sod);
|
||||
}
|
||||
|
||||
allPaths.removeAll({}); // remove all empty
|
||||
allPaths.removeDuplicates();
|
||||
allPaths.sort(Qt::CaseInsensitive);
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
QString CFsCommonUtil::p3dSimObjectsDirFromSimDir(const QString &simDir)
|
||||
@@ -472,7 +496,7 @@ namespace BlackMisc
|
||||
return paths;
|
||||
}
|
||||
|
||||
QSet<QString> CFsCommonUtil::allP3dAddOnSimObjectPaths(const QStringList &addOnPaths, bool checked)
|
||||
QSet<QString> CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(const QStringList &addOnPaths, bool checked)
|
||||
{
|
||||
if (addOnPaths.isEmpty()) { return QSet<QString>(); }
|
||||
QSet<QString> simObjectPaths;
|
||||
@@ -513,7 +537,7 @@ namespace BlackMisc
|
||||
return simObjectPaths;
|
||||
}
|
||||
|
||||
QSet<QString> CFsCommonUtil::allP3dAddOnSimObjectPaths(const QString &versionHint)
|
||||
QSet<QString> CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(const QString &versionHint)
|
||||
{
|
||||
// all add-ons.cfg files
|
||||
const QStringList addOnConfigFiles = CFsCommonUtil::findP3dAddOnConfigFiles(versionHint).toList();
|
||||
@@ -521,23 +545,14 @@ namespace BlackMisc
|
||||
// all PATH values in those files
|
||||
const QStringList addOnPaths = CFsCommonUtil::allConfigFilesPathValues(addOnConfigFiles, true, {}).toList();
|
||||
|
||||
// based on all paths of all config
|
||||
const QSet<QString> all = CFsCommonUtil::allP3dAddOnSimObjectPaths(addOnPaths, true);
|
||||
// based on all paths of all config files search the XML files
|
||||
const QSet<QString> all = CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(addOnPaths, true);
|
||||
return all;
|
||||
}
|
||||
|
||||
QSet<QString> CFsCommonUtil::allP3dSimObjectsConfigPaths(const QString &simulatorDir, const QString &versionHint)
|
||||
QSet<QString> CFsCommonUtil::allFsxSimObjectPaths()
|
||||
{
|
||||
const QStringList configFiles = CFsCommonUtil::findP3dSimObjectsConfigFiles(versionHint).toList();
|
||||
return CFsCommonUtil::allConfigFilesPathValues(configFiles, true, simulatorDir);
|
||||
}
|
||||
|
||||
QSet<QString> CFsCommonUtil::allP3dSimObjectPaths(const QString &simulatorDir, const QString &versionHint)
|
||||
{
|
||||
const QSet<QString> configFiles = CFsCommonUtil::allP3dSimObjectsConfigPaths(simulatorDir, versionHint);
|
||||
const QSet<QString> addOnFiles = CFsCommonUtil::allP3dAddOnSimObjectPaths(versionHint);
|
||||
QSet<QString> all(configFiles);
|
||||
return all.unite(addOnFiles);
|
||||
return CFsCommonUtil::fsxSimObjectsPaths(CFsCommonUtil::findFsxConfigFiles(), true);
|
||||
}
|
||||
|
||||
QStringList CFsCommonUtil::findFsxConfigFiles()
|
||||
@@ -594,13 +609,13 @@ namespace BlackMisc
|
||||
return paths;
|
||||
}
|
||||
|
||||
CStatusMessageList CFsCommonUtil::validateConfigFiles(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped)
|
||||
CStatusMessageList CFsCommonUtil::validateAircraftConfigFiles(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped)
|
||||
{
|
||||
CStatusMessage m;
|
||||
CAircraftModelList sorted(models);
|
||||
sorted.sortByFileName();
|
||||
stopped = false;
|
||||
CStatusMessageList msgs = sorted.validateFiles(validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped, "", true);
|
||||
CStatusMessageList msgs = sorted.validateFiles(validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped, QString(), true);
|
||||
if (stopped || validModels.isEmpty()) { return msgs; }
|
||||
|
||||
const CAircraftModelList nonFsModels = validModels.findNonFsFamilyModels();
|
||||
@@ -658,14 +673,16 @@ namespace BlackMisc
|
||||
|
||||
CStatusMessageList CFsCommonUtil::validateP3DSimObjectsPath(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped, const QString &simulatorDir)
|
||||
{
|
||||
const QSet<QString> simObjectDirs = CFsCommonUtil::allP3dSimObjectPaths(simulatorDir, "v4");
|
||||
return CFsCommonUtil::validateSimObjectsPath(simObjectDirs, models, validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped);
|
||||
const QString simObjectsDir = simulatorDir.isEmpty() ? CFsCommonUtil::p3dSimObjectsDir() : CFsCommonUtil::p3dSimObjectsDirFromSimDir(simulatorDir);
|
||||
const QSet<QString> simObjectPaths = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(simObjectsDir, "v4").toSet();
|
||||
return CFsCommonUtil::validateSimObjectsPath(simObjectPaths, models, validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped);
|
||||
}
|
||||
|
||||
CStatusMessageList CFsCommonUtil::validateFSXSimObjectsPath(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped)
|
||||
CStatusMessageList CFsCommonUtil::validateFSXSimObjectsPath(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped, const QString &simulatorDir)
|
||||
{
|
||||
const QSet<QString> simObjectDirs = CFsCommonUtil::fsxSimObjectsPaths(CFsCommonUtil::findFsxConfigFiles(), true);
|
||||
return CFsCommonUtil::validateSimObjectsPath(simObjectDirs, models, validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped);
|
||||
Q_UNUSED(simulatorDir);
|
||||
const QSet<QString> simObjectPaths = CFsCommonUtil::fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths().toSet();
|
||||
return CFsCommonUtil::validateSimObjectsPath(simObjectPaths, models, validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped);
|
||||
}
|
||||
|
||||
CStatusMessageList CFsCommonUtil::validateSimObjectsPath(
|
||||
@@ -673,22 +690,24 @@ namespace BlackMisc
|
||||
CAircraftModelList &validModels, CAircraftModelList &invalidModels,
|
||||
bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped)
|
||||
{
|
||||
CAircraftModelList sorted(models);
|
||||
sorted.sortByFileName();
|
||||
CStatusMessageList msgs;
|
||||
if (sorted.isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(getLogCategories()).validationInfo(u"No models to validate"));
|
||||
return msgs;
|
||||
}
|
||||
if (simObjectDirs.isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(getLogCategories()).validationInfo(u"No SimObject directories from cfg files, skipping validation"));
|
||||
return msgs;
|
||||
}
|
||||
|
||||
CAircraftModelList sortedModels(models);
|
||||
sortedModels.sortByFileName();
|
||||
if (sortedModels.isEmpty())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(getLogCategories()).validationInfo(u"No models to validate"));
|
||||
return msgs;
|
||||
}
|
||||
|
||||
// info
|
||||
msgs.push_back(CStatusMessage(getLogCategories()).validationInfo(u"Validating %1 models against %2 SimObject paths: %3") << models.size() << simObjectDirs.size() << joinStringSet(simObjectDirs, ", "));
|
||||
const QString simObjDirs = joinStringSet(simObjectDirs, ", ");
|
||||
msgs.push_back(CStatusMessage(getLogCategories()).validationInfo(u"Validating %1 models against %2 SimObject paths: '%3'") << models.size() << simObjectDirs.size() << simObjDirs);
|
||||
|
||||
// validate
|
||||
int failed = 0;
|
||||
|
||||
@@ -52,6 +52,12 @@ namespace BlackMisc
|
||||
//! Exclude directories for simObjects
|
||||
static const QStringList &fsxSimObjectsExcludeDirectoryPatterns();
|
||||
|
||||
//! FSX's simObject dir and the add on dirs
|
||||
static QStringList fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = "");
|
||||
|
||||
//! P3D's simObject dir and the add on dirs
|
||||
static QStringList p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = "", const QString &versionHint = "v4");
|
||||
|
||||
//! P3D directory obtained from registry
|
||||
static const QString &p3dDirFromRegistry();
|
||||
|
||||
@@ -64,9 +70,6 @@ namespace BlackMisc
|
||||
//! P3D's simObject dir, resolved from multiple sources
|
||||
static const QString &p3dSimObjectsDir();
|
||||
|
||||
//! P3D's simObject dir and the add on dirs
|
||||
static QStringList p3dSimObjectsDirPlusAddOnSimObjectsDirs(const QString &simObjectsDir = "", const QString &versionHint = "v4");
|
||||
|
||||
//! P3D aircraft dir, relative to simulator directory
|
||||
static QString p3dSimObjectsDirFromSimDir(const QString &simDir);
|
||||
|
||||
@@ -113,20 +116,17 @@ namespace BlackMisc
|
||||
//! All PATH values from the config files
|
||||
static QSet<QString> allConfigFilesPathValues(const QStringList &configFiles, bool checked, const QString &pathPrefix);
|
||||
|
||||
//! All add-on paths from the config files
|
||||
static QSet<QString> allP3dAddOnSimObjectPaths(const QStringList &addOnPaths, bool checked);
|
||||
//! All add-on paths from the XML add-on files "add-on.xml"
|
||||
static QSet<QString> allP3dAddOnXmlSimObjectPaths(const QStringList &addOnPaths, bool checked);
|
||||
|
||||
//! All add-on paths from the config files
|
||||
static QSet<QString> allP3dAddOnSimObjectPaths(const QString &versionHint = "v4");
|
||||
//! All add-on paths from the XML add-on files "add-on.xml" files, use CFsCommonUtil::findP3dAddOnConfigFiles to find config files
|
||||
static QSet<QString> allP3dAddOnXmlSimObjectPaths(const QString &versionHint = "v4");
|
||||
|
||||
//! All paths from the simobjects.cfg files
|
||||
static QSet<QString> allP3dSimObjectsConfigPaths(const QString &simulatorDir, const QString &versionHint = "v4");
|
||||
|
||||
//! All add-on paths from the config files and the simobjects.cfg files
|
||||
static QSet<QString> allP3dSimObjectPaths(const QString &simulatorDir, const QString &versionHint = "v4");
|
||||
//! Get all the SimObjects paths from all config files
|
||||
static QSet<QString> allFsxSimObjectPaths();
|
||||
|
||||
//! Find the config files (fsx.cfg)
|
||||
// C:/Users/Joe Doe/AppData/Roaming/Lockheed Martin/Prepar3D v4
|
||||
// C:/Users/Joe Doe/AppData/Roaming/Microsoft/FSX/fsx.cfg
|
||||
static QStringList findFsxConfigFiles();
|
||||
|
||||
//! Get all the SimObjects paths from fsx.cfg
|
||||
@@ -137,9 +137,9 @@ namespace BlackMisc
|
||||
// SimObjectPaths.0=SimObjects\Airplanes
|
||||
static QSet<QString> fsxSimObjectsPaths(const QString &fsxFile, bool checked);
|
||||
|
||||
//! Validate aircraft.cfg entries
|
||||
//! Validate aircraft.cfg entries (sometimes also sim.cfg)
|
||||
//! \remark only for FSX/P3D/FS9 models
|
||||
static CStatusMessageList validateConfigFiles(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped);
|
||||
static CStatusMessageList validateAircraftConfigFiles(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped);
|
||||
|
||||
//! Validate if known SimObjects path are used
|
||||
//! \remark only for P3D
|
||||
@@ -147,7 +147,7 @@ namespace BlackMisc
|
||||
|
||||
//! Validate if known SimObjects path are used
|
||||
//! \remark only for FSX
|
||||
static CStatusMessageList validateFSXSimObjectsPath(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped);
|
||||
static CStatusMessageList validateFSXSimObjectsPath(const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped, const QString &simulatorDir);
|
||||
|
||||
private:
|
||||
//! Utility functions @{
|
||||
@@ -155,7 +155,7 @@ namespace BlackMisc
|
||||
//! @}
|
||||
|
||||
//! Validate if known SimObjects path are used
|
||||
//! \remark only for P3D
|
||||
//! \remark only for P3D/FSX
|
||||
static CStatusMessageList validateSimObjectsPath(const QSet<QString> &simObjectDirs, const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped);
|
||||
|
||||
//! Log the reading of config files
|
||||
|
||||
Reference in New Issue
Block a user