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

@@ -28,6 +28,30 @@ namespace XBus
emit aircraftModelChanged(path, filename, getAircraftLivery(), getAircraftIcaoCode());
}
void CService::addTextMessage(const QString &text, double red, double green, double blue)
{
if (text.isEmpty()) { return; }
int lineLength = m_messages.maxLineLength() - 1;
QStringList wrappedLines;
for (int i = 0; i < text.size(); i += lineLength)
{
static const QChar ellipsis = 0x2026;
wrappedLines.push_back(text.mid(i, lineLength) + ellipsis);
}
wrappedLines.back().chop(1);
if (wrappedLines.back().isEmpty()) { wrappedLines.pop_back(); }
else if (wrappedLines.back().size() == 1 && wrappedLines.size() > 1)
{
(wrappedLines.end() - 2)->chop(1);
(wrappedLines.end() - 2)->append(wrappedLines.back());
wrappedLines.pop_back();
}
for (const auto &line : wrappedLines)
{
m_messages.addMessage({ line.toStdString(), static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue) });
}
}
QString CService::getAircraftModelPath() const
{
char filename[256];