[P3D] Adjustments for P3D v5

* guess version
* added new version selection
This commit is contained in:
Klaus Basan
2020-04-16 02:56:24 +02:00
committed by Mat Sutcliffe
parent 828b57f5a2
commit 8278a7d5e6
12 changed files with 127 additions and 34 deletions

View File

@@ -148,6 +148,7 @@ namespace BlackGui
ui->pb_DisableRendering->setEnabled(m_pluginLoaded); ui->pb_DisableRendering->setEnabled(m_pluginLoaded);
ui->pb_Check->setEnabled(!m_pluginLoaded); ui->pb_Check->setEnabled(!m_pluginLoaded);
ui->pb_ApplyCGSource->setEnabled(m_pluginLoaded); ui->pb_ApplyCGSource->setEnabled(m_pluginLoaded);
ui->pb_Reload->setEnabled(m_pluginLoaded);
if (m_pluginLoaded) if (m_pluginLoaded)
{ {

View File

@@ -65,15 +65,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="wi_Settings"> <widget class="QWidget" name="wi_Settings">
<property name="geometry"> <layout class="QGridLayout" name="gl_SimulatorSettings" columnstretch="1,3,0">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>328</height>
</rect>
</property>
<layout class="QGridLayout" name="gl_SimulatorSettings" columnstretch="0,0,0">
<property name="leftMargin"> <property name="leftMargin">
<number>4</number> <number>4</number>
</property> </property>
@@ -102,6 +94,12 @@
</item> </item>
<item row="8" column="2"> <item row="8" column="2">
<widget class="QPushButton" name="pb_ApplyMaxAircraft"> <widget class="QPushButton" name="pb_ApplyMaxAircraft">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -109,6 +107,12 @@
</item> </item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QPushButton" name="pb_ApplyRecordOwnAircraftGnd"> <widget class="QPushButton" name="pb_ApplyRecordOwnAircraftGnd">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -192,6 +196,12 @@
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="pb_ApplyTimeSync"> <widget class="QPushButton" name="pb_ApplyTimeSync">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -199,6 +209,12 @@
</item> </item>
<item row="6" column="2"> <item row="6" column="2">
<widget class="QPushButton" name="pb_ClearRestrictedRendering"> <widget class="QPushButton" name="pb_ClearRestrictedRendering">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>clear</string> <string>clear</string>
</property> </property>
@@ -213,6 +229,12 @@
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QPushButton" name="pb_ApplyCGSource"> <widget class="QPushButton" name="pb_ApplyCGSource">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -220,6 +242,12 @@
</item> </item>
<item row="4" column="2"> <item row="4" column="2">
<widget class="QPushButton" name="pb_DisableRendering"> <widget class="QPushButton" name="pb_DisableRendering">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>disable all rendering</string> <string>disable all rendering</string>
</property> </property>
@@ -264,6 +292,12 @@
</item> </item>
<item row="11" column="2"> <item row="11" column="2">
<widget class="QPushButton" name="pb_ApplyMaxDistance"> <widget class="QPushButton" name="pb_ApplyMaxDistance">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -391,6 +425,12 @@
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QPushButton" name="pb_ApplyComSync"> <widget class="QPushButton" name="pb_ApplyComSync">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>apply</string> <string>apply</string>
</property> </property>
@@ -408,6 +448,12 @@
</item> </item>
<item row="12" column="2"> <item row="12" column="2">
<widget class="QPushButton" name="pb_Reload"> <widget class="QPushButton" name="pb_Reload">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>reload</string> <string>reload</string>
</property> </property>

View File

@@ -243,7 +243,7 @@ namespace BlackMisc
{ {
// finding the user settings only works on P3D machine // finding the user settings only works on P3D machine
QStringList allPaths = CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(versionHint).values(); QStringList allPaths = CFsCommonUtil::allP3dAddOnXmlSimObjectPaths(versionHint).values();
const QString sod = CFileUtils::normalizeFilePathToQtStandard(simObjectsDir.isEmpty() ? CFsCommonUtil::p3dSimObjectsDir() : simObjectsDir); const QString sod = CFileUtils::normalizeFilePathToQtStandard(simObjectsDir.isEmpty() ? CFsCommonUtil::p3dSimObjectsDir() : simObjectsDir);
if (!sod.isEmpty() && !allPaths.contains(sod, Qt::CaseInsensitive)) if (!sod.isEmpty() && !allPaths.contains(sod, Qt::CaseInsensitive))
{ {
// case insensitive is important here // case insensitive is important here
@@ -256,6 +256,18 @@ namespace BlackMisc
return allPaths; return allPaths;
} }
QString CFsCommonUtil::guessP3DVersion(const QString &candidate)
{
if (candidate.isEmpty()) { return "v4"; }
if (candidate.contains("v5", Qt::CaseInsensitive)) { return QStringLiteral("v5"); }
if (candidate.contains("v4", Qt::CaseInsensitive)) { return QStringLiteral("v4"); }
if (candidate.contains("5", Qt::CaseInsensitive)) { return QStringLiteral("v5"); }
if (candidate.contains("4", Qt::CaseInsensitive)) { return QStringLiteral("v4"); }
return "v5"; // that is the future (in 2020)
}
QString CFsCommonUtil::p3dSimObjectsDirFromSimDir(const QString &simDir) QString CFsCommonUtil::p3dSimObjectsDirFromSimDir(const QString &simDir)
{ {
if (simDir.isEmpty()) { return {}; } if (simDir.isEmpty()) { return {}; }

View File

@@ -57,7 +57,10 @@ namespace BlackMisc
static QStringList fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = ""); static QStringList fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = "");
//! P3D's simObject dir and the add on dirs //! P3D's simObject dir and the add on dirs
static QStringList p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = "", const QString &versionHint = "v4"); static QStringList p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir, const QString &versionHint);
//! Guess the P3D version such as v4, v5
static QString guessP3DVersion(const QString &candidate);
//! P3D directory obtained from registry //! P3D directory obtained from registry
static const QString &p3dDirFromRegistry(); static const QString &p3dDirFromRegistry();

View File

@@ -588,12 +588,15 @@ namespace BlackMisc
switch (m_simulator.getSimulator()) switch (m_simulator.getSimulator())
{ {
case CSimulatorInfo::FG: dirs = QStringList(CFlightgearUtil::modelDirectoriesFromSimDir(s)); break; case CSimulatorInfo::FG: dirs = QStringList(CFlightgearUtil::modelDirectoriesFromSimDir(s)); break;
case CSimulatorInfo::FS9: dirs = QStringList({CFsCommonUtil::fs9AircraftDirFromSimDir(s)}); break; case CSimulatorInfo::FS9: dirs = QStringList({ CFsCommonUtil::fs9AircraftDirFromSimDir(s) }); break;
case CSimulatorInfo::FSX: case CSimulatorInfo::FSX:
dirs = CFsCommonUtil::fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(CFsCommonUtil::fsxSimObjectsDirFromSimDir(s)); dirs = CFsCommonUtil::fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(CFsCommonUtil::fsxSimObjectsDirFromSimDir(s));
break; break;
case CSimulatorInfo::P3D: case CSimulatorInfo::P3D:
dirs = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(CFsCommonUtil::p3dSimObjectsDirFromSimDir(s)); {
const QString versionHint = CFsCommonUtil::guessP3DVersion(s);
dirs = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(CFsCommonUtil::p3dSimObjectsDirFromSimDir(s), versionHint);
}
break; break;
case CSimulatorInfo::XPLANE: dirs = QStringList({CXPlaneUtil::modelDirectoriesFromSimDir(s)}); break; case CSimulatorInfo::XPLANE: dirs = QStringList({CXPlaneUtil::modelDirectoriesFromSimDir(s)}); break;
default: break; default: break;
@@ -678,8 +681,10 @@ namespace BlackMisc
} }
case CSimulatorInfo::P3D: case CSimulatorInfo::P3D:
{ {
if (CFsCommonUtil::p3dSimObjectsDir().isEmpty()) { return e; } static const QString p3d = CFsCommonUtil::p3dSimObjectsDir();
static const QStringList md = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(); if (p3d.isEmpty()) { return e; }
static const QString versionHint = CFsCommonUtil::guessP3DVersion(p3d);
static const QStringList md = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(p3d, versionHint);
return md; return md;
} }
case CSimulatorInfo::XPLANE: case CSimulatorInfo::XPLANE:

View File

@@ -279,7 +279,7 @@ namespace BlackMisc
protected: protected:
CSimulatorSettings m_genericSettings; //!< the generic settings CSimulatorSettings m_genericSettings; //!< the generic settings
CSimulatorInfo m_simulator; //!< represented simulator CSimulatorInfo m_simulator; //!< represented simulator
}; };
//! XPlane specific settings //! XPlane specific settings

View File

@@ -39,13 +39,13 @@ namespace BlackSimPlugin
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->pb_OpenSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::openSwiftSimConnectCfgFile); connect(ui->pb_OpenSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::openSwiftSimConnectCfgFile);
connect(ui->pb_DeleteSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::deleteSwiftSimConnectCfgFile); connect(ui->pb_DeleteSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::deleteSwiftSimConnectCfgFile);
connect(ui->pb_ExistsSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::checkSwiftSimConnectCfgFile); connect(ui->pb_ExistsSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::checkSwiftSimConnectCfgFile);
connect(ui->pb_SaveSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::saveSimConnectCfgFile); connect(ui->pb_SaveSwiftSimConnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::saveSimConnectCfgFile);
connect(ui->pb_OpenUserCfgFile, &QPushButton::clicked, this, &CSimConnectSettingsComponent::openUserSimConnectCfgFile); connect(ui->pb_OpenUserCfgFile, &QPushButton::clicked, this, &CSimConnectSettingsComponent::openUserSimConnectCfgFile);
connect(ui->pb_TestConnection, &QPushButton::clicked, this, &CSimConnectSettingsComponent::testSwiftSimConnectConnection); connect(ui->pb_TestConnection, &QPushButton::clicked, this, &CSimConnectSettingsComponent::testSwiftSimConnectConnection);
connect(ui->pb_SaveAsSimConnectIni, &QPushButton::clicked, this, &CSimConnectSettingsComponent::saveSimConnectIniFileDialog); connect(ui->pb_SaveAsSimConnectIni, &QPushButton::clicked, this, &CSimConnectSettingsComponent::saveSimConnectIniFileDialog);
this->setSimConnectInfo(); this->setSimConnectInfo();
if (m_p3d64bit) if (m_p3d64bit)
@@ -252,7 +252,7 @@ namespace BlackSimPlugin
ui->cb_P3DVersion->setCurrentText(found ? v : ""); ui->cb_P3DVersion->setCurrentText(found ? v : "");
} }
void BlackSimPlugin::FsxCommon::CSimConnectSettingsComponent::onP3DVersionChanged(const QString &version) void CSimConnectSettingsComponent::onP3DVersionChanged(const QString &version)
{ {
if (m_p3dVersion.get() == version) { return; } if (m_p3dVersion.get() == version) { return; }
const CStatusMessage saveMsg = m_p3dVersion.setAndSave(version); const CStatusMessage saveMsg = m_p3dVersion.setAndSave(version);

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>410</width> <width>410</width>
<height>466</height> <height>481</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -156,11 +156,31 @@ console=1
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="cb_P3DVersion"> <widget class="QComboBox" name="cb_P3DVersion">
<property name="currentText"> <property name="currentText">
<string>4.5 64bit</string> <string>6.0 64bit</string>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<item>
<property name="text">
<string>6.0 64bit</string>
</property>
</item>
<item>
<property name="text">
<string>5.2 64bit</string>
</property>
</item>
<item>
<property name="text">
<string>5.1 64bit</string>
</property>
</item>
<item>
<property name="text">
<string>5.0 64bit</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>4.5 64bit</string> <string>4.5 64bit</string>

View File

@@ -191,6 +191,11 @@ P3DSimConnectVersion stringToP3DVersion(const QString &p3d)
if (p.contains("43")) { return P3DSimConnectv43; } if (p.contains("43")) { return P3DSimConnectv43; }
if (p.contains("44")) { return P3DSimConnectv44; } if (p.contains("44")) { return P3DSimConnectv44; }
if (p.contains("45")) { return P3DSimConnectv45; } if (p.contains("45")) { return P3DSimConnectv45; }
if (p.contains("50")) { return P3DSimConnectv45; }
if (p.contains("51")) { return P3DSimConnectv45; }
if (p.contains("52")) { return P3DSimConnectv45; }
} }
return P3DSimConnectv44; // default return P3DSimConnectv44; // default
} }

View File

@@ -31,10 +31,10 @@ namespace BlackSimPlugin
namespace P3D namespace P3D
{ {
CSimulatorP3D::CSimulatorP3D(const CSimulatorPluginInfo &info, CSimulatorP3D::CSimulatorP3D(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider, IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider,
IWeatherGridProvider *weatherGridProvider, IWeatherGridProvider *weatherGridProvider,
IClientProvider *clientProvider, IClientProvider *clientProvider,
QObject *parent) : QObject *parent) :
CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent) CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
{ {
@@ -104,9 +104,9 @@ namespace BlackSimPlugin
// P3D version with new P3D simconnect functions // P3D version with new P3D simconnect functions
bool CSimulatorP3D::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign) bool CSimulatorP3D::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
{ {
if (reference.isNull()) { return false; } if (reference.isNull()) { return false; }
if (this->isShuttingDown()) { return false; } if (this->isShuttingDown()) { return false; }
if (!this->isConnected()) { return false; } if (!this->isConnected()) { return false; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread"); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
const bool hasHeight = reference.hasMSLGeodeticHeight(); const bool hasHeight = reference.hasMSLGeodeticHeight();

View File

@@ -37,10 +37,10 @@ namespace BlackSimPlugin
public: public:
//! Constructor, parameters as in \sa BlackCore::ISimulatorFactory::create //! Constructor, parameters as in \sa BlackCore::ISimulatorFactory::create
CSimulatorP3D(const BlackMisc::Simulation::CSimulatorPluginInfo &info, CSimulatorP3D(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
BlackMisc::Network::IClientProvider *clientProvider, BlackMisc::Network::IClientProvider *clientProvider,
QObject *parent = nullptr); QObject *parent = nullptr);
//! \name ISimulator implementations //! \name ISimulator implementations

View File

@@ -664,9 +664,10 @@ void CSwiftLauncher::showSimulatorConfigDirs()
if (s == ui->pb_P3DConfigDirs) if (s == ui->pb_P3DConfigDirs)
{ {
dirs = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths();
simDir = CFsCommonUtil::p3dDir(); simDir = CFsCommonUtil::p3dDir();
simObjDir = CFsCommonUtil::p3dSimObjectsDir(); simObjDir = CFsCommonUtil::p3dSimObjectsDir();
const QString versionHint = CFsCommonUtil::guessP3DVersion(simDir);
dirs = CFsCommonUtil::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(simObjDir, versionHint);
} }
else if (s == ui->pb_FSXConfigDirs) else if (s == ui->pb_FSXConfigDirs)
{ {