diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp index 387481c71..3c116c23b 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp @@ -35,6 +35,11 @@ namespace BlackSimPlugin "airportsInRangeUpdated", this, SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList, QList, QList))); Q_ASSERT(s); + + s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service", + "sceneryLoaded", this, + SIGNAL(sceneryLoaded())); + Q_ASSERT(s); } } diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h index 822d6a1a1..36569d844 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h @@ -96,6 +96,9 @@ namespace BlackSimPlugin //! Airports in range are updated void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const QList &lats, const QList &lons, const QList &alts); + //! Scenery was loaded + void sceneryLoaded(); + public slots: //! Get XSwiftBus version number QString getVersionNumber(); diff --git a/src/xswiftbus/main.cpp b/src/xswiftbus/main.cpp index 95d12f361..26243007d 100644 --- a/src/xswiftbus/main.cpp +++ b/src/xswiftbus/main.cpp @@ -77,6 +77,10 @@ PLUGIN_API void XPluginReceiveMessage(XPLMPluginID from, long msg, void *param) case XPLM_MSG_AIRPORT_LOADED: g_plugin->onAircraftRepositioned(); break; + + case XPLM_MSG_SCENERY_LOADED: + g_plugin->onSceneryLoaded(); + break; } } } diff --git a/src/xswiftbus/plugin.cpp b/src/xswiftbus/plugin.cpp index ae1c7c30c..13f027da1 100644 --- a/src/xswiftbus/plugin.cpp +++ b/src/xswiftbus/plugin.cpp @@ -174,6 +174,14 @@ namespace XSwiftBus } } + void CPlugin::onSceneryLoaded() + { + if (m_service) + { + m_service->onSceneryLoaded(); + } + } + float CPlugin::startServerDeferred(float, float, int, void *refcon) { auto *plugin = static_cast(refcon); diff --git a/src/xswiftbus/plugin.h b/src/xswiftbus/plugin.h index 73b4c3aa2..32079982c 100644 --- a/src/xswiftbus/plugin.h +++ b/src/xswiftbus/plugin.h @@ -56,6 +56,9 @@ namespace XSwiftBus //! Called by XPluginReceiveMessage when the aircraft is positioned at an airport void onAircraftRepositioned(); + //! Called by XPluginReceiveMessage when some scenery is loaded + void onSceneryLoaded(); + //! Is running bool isRunning() const { return m_isRunning; } diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index f2c1bd20e..e3d778919 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -111,6 +111,11 @@ namespace XSwiftBus emitAircraftModelChanged(path, filename, getAircraftLivery(), getAircraftIcaoCode(), acfProperties.modelString, acfProperties.modelName, getAircraftDescription()); } + void CService::onSceneryLoaded() + { + emitSceneryLoaded(); + } + std::string CService::getVersionNumber() const { return XSWIFTBUS_VERSION; @@ -955,6 +960,12 @@ namespace XSwiftBus int CService::process() { + if (m_sceneryIsLoading.get() != m_sceneryWasLoading) + { + if (!m_sceneryIsLoading.get()) { onSceneryLoaded(); } + m_sceneryWasLoading = m_sceneryIsLoading.get(); + } + invokeQueuedDBusCalls(); if (m_disappearMessageWindowTime != std::chrono::system_clock::time_point() @@ -997,6 +1008,12 @@ namespace XSwiftBus sendDBusMessage(signalAirportsInRangeUpdated); } + void CService::emitSceneryLoaded() + { + CDBusMessage signal = CDBusMessage::createSignal(XSWIFTBUS_SERVICE_OBJECTPATH, XSWIFTBUS_SERVICE_INTERFACENAME, "sceneryLoaded"); + sendDBusMessage(signal); + } + std::vector CService::findClosestAirports(int number, double latitude, double longitude) { CNavDataReference ref(0, latitude, longitude); diff --git a/src/xswiftbus/service.h b/src/xswiftbus/service.h index 3eab7b76f..9e61e88d5 100644 --- a/src/xswiftbus/service.h +++ b/src/xswiftbus/service.h @@ -59,6 +59,9 @@ namespace XSwiftBus //! Called by XPluginReceiveMessage when the model changes. void onAircraftModelChanged(); + //! Called by XPluginReceiveMessage when some scenery is loaded. + void onSceneryLoaded(); + //! Returns the XSwiftBus version number std::string getVersionNumber() const; @@ -307,6 +310,8 @@ namespace XSwiftBus void emitAirportsInRangeUpdated(const std::vector &icaoCodes, const std::vector &names, const std::vector &lats, const std::vector &lons, const std::vector &alts); + void emitSceneryLoaded(); + CMessageBoxControl m_messages { 16, 16, 16 }; bool m_popupMessageWindow = true; bool m_disappearMessageWindow = true; @@ -323,6 +328,9 @@ namespace XSwiftBus struct FramePeriodSampler; std::unique_ptr m_framePeriodSampler; + DataRef m_sceneryIsLoading; + int m_sceneryWasLoading = 0; + StringDataRef m_liveryPath; StringDataRef m_icao; StringDataRef m_descrip;