mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #438, added plug info to listeners
* listener signal can be directly used without mapping * (during debugging) it is much easier to identify a listener
This commit is contained in:
@@ -327,8 +327,8 @@ namespace BlackSimPlugin
|
||||
return exclude;
|
||||
}
|
||||
|
||||
CSimulatorFs9Listener::CSimulatorFs9Listener(QObject *parent) :
|
||||
BlackCore::ISimulatorListener(parent),
|
||||
CSimulatorFs9Listener::CSimulatorFs9Listener(const CSimulatorPluginInfo &info, QObject *parent) :
|
||||
BlackCore::ISimulatorListener(info, parent),
|
||||
m_timer(new QTimer(this))
|
||||
{
|
||||
Q_CONSTEXPR int QueryInterval = 5 * 1000; // 5 seconds
|
||||
@@ -353,7 +353,7 @@ namespace BlackSimPlugin
|
||||
|
||||
if (!m_isStarted && fs9Host->isConnected())
|
||||
{
|
||||
emit simulatorStarted();
|
||||
emit simulatorStarted(getPluginInfo());
|
||||
m_isStarted = true;
|
||||
m_isConnecting = false;
|
||||
}
|
||||
@@ -402,9 +402,9 @@ namespace BlackSimPlugin
|
||||
return new CSimulatorFs9(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, this);
|
||||
}
|
||||
|
||||
BlackCore::ISimulatorListener *CSimulatorFs9Factory::createListener(QObject *parent)
|
||||
BlackCore::ISimulatorListener *CSimulatorFs9Factory::createListener(const CSimulatorPluginInfo &info, QObject *parent)
|
||||
{
|
||||
return new CSimulatorFs9Listener(parent);
|
||||
return new CSimulatorFs9Listener(info, parent);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorFs9Listener(QObject *parent);
|
||||
CSimulatorFs9Listener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent);
|
||||
|
||||
public slots:
|
||||
//! \copydoc BlackCore::ISimulatorListener::start
|
||||
@@ -167,7 +167,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::IPluginStorageProvider *pluginStorageProvider) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulatorFactory::createListener
|
||||
virtual BlackCore::ISimulatorListener *createListener(QObject *parent = nullptr) override;
|
||||
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent = nullptr) override;
|
||||
|
||||
};
|
||||
} // namespace Fs9
|
||||
|
||||
@@ -40,10 +40,10 @@ namespace BlackSimPlugin
|
||||
namespace Fsx
|
||||
{
|
||||
CSimulatorFsx::CSimulatorFsx(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IPluginStorageProvider *pluginStorageProvider,
|
||||
QObject *parent) :
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IPluginStorageProvider *pluginStorageProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider,
|
||||
simObjectsDir(), excludeDirectories(), parent)
|
||||
{
|
||||
@@ -54,11 +54,11 @@ namespace BlackSimPlugin
|
||||
m_useFsuipc = false; // do not use FSUIPC at the moment with FSX
|
||||
this->m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this);
|
||||
m_modelMatcher.setDefaultModel(CAircraftModel(
|
||||
"Boeing 737-800 Paint1",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-800 default model",
|
||||
CAircraftIcaoData(CAircraftIcaoCode("B738", "L2J"), CAirlineIcaoCode(), "FFFFFF")
|
||||
));
|
||||
"Boeing 737-800 Paint1",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-800 default model",
|
||||
CAircraftIcaoData(CAircraftIcaoCode("B738", "L2J"), CAirlineIcaoCode(), "FFFFFF")
|
||||
));
|
||||
}
|
||||
|
||||
CSimulatorFsx::~CSimulatorFsx()
|
||||
@@ -860,7 +860,8 @@ namespace BlackSimPlugin
|
||||
return exclude;
|
||||
}
|
||||
|
||||
CSimulatorFsxListener::CSimulatorFsxListener(QObject *parent) : ISimulatorListener(parent),
|
||||
CSimulatorFsxListener::CSimulatorFsxListener(const CSimulatorPluginInfo &info, QObject *parent) :
|
||||
ISimulatorListener(info, parent),
|
||||
m_timer(new QTimer(this))
|
||||
{
|
||||
Q_CONSTEXPR int QueryInterval = 5 * 1000; // 5 seconds
|
||||
@@ -873,8 +874,7 @@ namespace BlackSimPlugin
|
||||
HANDLE hSimConnect;
|
||||
HRESULT result = SimConnect_Open(&hSimConnect, BlackMisc::CProject::systemNameAndVersionChar(), nullptr, 0, 0, 0);
|
||||
SimConnect_Close(hSimConnect);
|
||||
|
||||
if (result == S_OK) { emit simulatorStarted(); }
|
||||
if (result == S_OK) { emit simulatorStarted(this->getPluginInfo()); }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorFsxListener(QObject *parent);
|
||||
CSimulatorFsxListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent);
|
||||
|
||||
public slots:
|
||||
//! \copydoc BlackCore::ISimulatorListener::start
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace BlackSimPlugin
|
||||
return new CSimulatorFsx(info, ownAircraftProvider, renderedAircraftProvider, pluginStorageProvider, this);
|
||||
}
|
||||
|
||||
BlackCore::ISimulatorListener *CSimulatorFsxFactory::createListener(QObject *parent)
|
||||
BlackCore::ISimulatorListener *CSimulatorFsxFactory::createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent)
|
||||
{
|
||||
return new CSimulatorFsxListener(parent);
|
||||
return new CSimulatorFsxListener(info, parent);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace BlackSimPlugin
|
||||
namespace Fsx
|
||||
{
|
||||
//! Factory implementation to create CSimulatorFsx instances
|
||||
class CSimulatorFsxFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
class CSimulatorFsxFactory :
|
||||
public QObject,
|
||||
public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift-project.blackcore.simulatorinterface" FILE "simulator_fsx.json")
|
||||
@@ -38,7 +40,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::IPluginStorageProvider *pluginStorageProvider) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulatorFactory::getListener
|
||||
virtual BlackCore::ISimulatorListener *createListener(QObject *parent = nullptr) override;
|
||||
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent = nullptr) override;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *renderedAircraftProvider,
|
||||
IPluginStorageProvider *pluginStorageProvider)
|
||||
@@ -438,19 +438,15 @@ namespace BlackSimPlugin
|
||||
return new CSimulatorXPlane(info, ownAircraftProvider, renderedAircraftProvider, pluginStorageProvider, this);
|
||||
}
|
||||
|
||||
CSimulatorXPlaneListener::CSimulatorXPlaneListener(QObject *parent): ISimulatorListener(parent)
|
||||
{
|
||||
|
||||
}
|
||||
CSimulatorXPlaneListener::CSimulatorXPlaneListener(const CSimulatorPluginInfo &info, QObject *parent): ISimulatorListener(info, parent)
|
||||
{ }
|
||||
|
||||
void CSimulatorXPlaneListener::start()
|
||||
{
|
||||
if (m_watcher) // already started
|
||||
return;
|
||||
|
||||
if (m_watcher) { return; } // already started
|
||||
if (isXBusRunning())
|
||||
{
|
||||
emit simulatorStarted();
|
||||
emit simulatorStarted(getPluginInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -486,7 +482,9 @@ namespace BlackSimPlugin
|
||||
void CSimulatorXPlaneListener::ps_serviceRegistered(const QString &serviceName)
|
||||
{
|
||||
if (serviceName == xbusServiceName())
|
||||
emit simulatorStarted();
|
||||
{
|
||||
emit simulatorStarted(getPluginInfo());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorXPlaneListener(QObject *parent);
|
||||
CSimulatorXPlaneListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent);
|
||||
|
||||
public slots:
|
||||
//! \copydoc BlackCore::ISimulatorListener::start
|
||||
@@ -205,7 +205,6 @@ namespace BlackSimPlugin
|
||||
private:
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
|
||||
};
|
||||
|
||||
//! Factory for creating CSimulatorXPlane instance
|
||||
@@ -223,7 +222,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::IPluginStorageProvider *pluginStorageProvider) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulatorFactory::createListener
|
||||
virtual BlackCore::ISimulatorListener *createListener(QObject *parent = nullptr) override { return new CSimulatorXPlaneListener(parent); }
|
||||
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info, QObject *parent = nullptr) override { return new CSimulatorXPlaneListener(info, parent); }
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user