refs #271 CSimulatorXPlane sends text messages to XBus and they are displayed in X-Plane.

This commit is contained in:
Mathew Sutcliffe
2015-09-25 00:51:39 +01:00
parent 011488eaf1
commit b0b1a3a65d
8 changed files with 329 additions and 7 deletions

View File

@@ -266,19 +266,38 @@ namespace BlackSimPlugin
void CSimulatorXPlane::displayStatusMessage(const BlackMisc::CStatusMessage &message) const
{
// avoid infinite recursion in case this function is called due to a message caused by this very function
static bool isInFunction = false;
if (isInFunction) { return; }
isInFunction = true;
/* We do not assert here as status message may come because of network problems */
if (!isConnected()) { return; }
//! \todo XP driver, display text message: XPLMSpeakString()? http://www.xsquawkbox.net/xpsdk/mediawiki/XPLMSpeakString
Q_UNUSED(message);
QColor color;
switch (message.getSeverity())
{
case CStatusMessage::SeverityDebug: color = "teal"; break;
case CStatusMessage::SeverityInfo: color = "cyan"; break;
case CStatusMessage::SeverityWarning: color = "orange"; break;
case CStatusMessage::SeverityError: color = "red"; break;
}
m_service->addTextMessage("swift: " + message.getMessage(), color.redF(), color.greenF(), color.blueF());
isInFunction = false;
}
void CSimulatorXPlane::displayTextMessage(const BlackMisc::Network::CTextMessage &message) const
{
if (!isConnected()) { return; }
//! \todo XP driver, display text message: XPLMSpeakString()? http://www.xsquawkbox.net/xpsdk/mediawiki/XPLMSpeakString
Q_UNUSED(message);
QColor color;
if (message.isServerMessage()) { color = "orchid"; }
else if (message.isSupervisorMessage()) { color = "yellow"; }
else if (message.isPrivateMessage()) { color = "magenta"; }
else { color = "lime"; }
m_service->addTextMessage(message.getSenderCallsign().toQString() + ": " + message.getMessage(), color.redF(), color.greenF(), color.blueF());
}
CAircraftModelList CSimulatorXPlane::getInstalledModels() const

View File

@@ -20,6 +20,11 @@ namespace BlackSimPlugin
if (! dummy) { m_dbusInterface->relayParentSignals(); }
}
void CXBusServiceProxy::addTextMessage(const QString &text, double red, double green, double blue)
{
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text, red, green, blue);
}
void CXBusServiceProxy::updateAirportsInRange()
{
m_dbusInterface->callDBus(QLatin1String("updateAirportsInRange"));

View File

@@ -79,6 +79,9 @@ namespace BlackSimPlugin
void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const QList<double> &lats, const QList<double> &lons, const QList<double> &alts);
public slots:
//! \copydoc XBus::CService::addTextMessage
void addTextMessage(const QString &text, double red, double green, double blue);
//! \copydoc XBus::CService::updateAirportsInRange
void updateAirportsInRange();