mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T778 XSwiftBus service emits a signal when scenery is loaded
This commit is contained in:
@@ -35,6 +35,11 @@ namespace BlackSimPlugin
|
||||
"airportsInRangeUpdated", this,
|
||||
SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
|
||||
Q_ASSERT(s);
|
||||
|
||||
s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service",
|
||||
"sceneryLoaded", this,
|
||||
SIGNAL(sceneryLoaded()));
|
||||
Q_ASSERT(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace BlackSimPlugin
|
||||
//! Airports in range are updated
|
||||
void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const QList<double> &lats, const QList<double> &lons, const QList<double> &alts);
|
||||
|
||||
//! Scenery was loaded
|
||||
void sceneryLoaded();
|
||||
|
||||
public slots:
|
||||
//! Get XSwiftBus version number
|
||||
QString getVersionNumber();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CPlugin *>(refcon);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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<CNavDataReference> CService::findClosestAirports(int number, double latitude, double longitude)
|
||||
{
|
||||
CNavDataReference ref(0, latitude, longitude);
|
||||
|
||||
@@ -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<std::string> &icaoCodes, const std::vector<std::string> &names,
|
||||
const std::vector<double> &lats, const std::vector<double> &lons, const std::vector<double> &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<FramePeriodSampler> m_framePeriodSampler;
|
||||
|
||||
DataRef<xplane::data::sim::graphics::scenery::async_scenery_load_in_progress> m_sceneryIsLoading;
|
||||
int m_sceneryWasLoading = 0;
|
||||
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_livery_path> m_liveryPath;
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_ICAO> m_icao;
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_descrip> m_descrip;
|
||||
|
||||
Reference in New Issue
Block a user