diff --git a/src/blackmisc/simulation/settings/xswiftbussettings.cpp b/src/blackmisc/simulation/settings/xswiftbussettings.cpp
index dd550e75d..fa9478dbb 100644
--- a/src/blackmisc/simulation/settings/xswiftbussettings.cpp
+++ b/src/blackmisc/simulation/settings/xswiftbussettings.cpp
@@ -30,6 +30,7 @@ namespace BlackMisc
{
case IndexMaxPlanes: return CVariant::fromValue(m_maxPlanes);
case IndexDBusServerAddress: return CVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
+ case IndexNightTextureMode: return CVariant::fromValue(QString::fromStdString(m_nightTextureMode));
case IndexDrawingLabels: return CVariant::fromValue(m_drawingLabels);
case IndexMaxDrawingDistance: return CVariant::fromValue(m_maxDrawDistanceNM);
case IndexFollowAircraftDistance: return CVariant::fromValue(m_followAircraftDistanceM);
@@ -48,6 +49,7 @@ namespace BlackMisc
{
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
case IndexDBusServerAddress: m_dBusServerAddress = variant.toStdString(); break;
+ case IndexNightTextureMode: m_nightTextureMode = variant.toStdString(); break;
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
diff --git a/src/blackmisc/simulation/settings/xswiftbussettings.h b/src/blackmisc/simulation/settings/xswiftbussettings.h
index 11733df03..ea8e7135c 100644
--- a/src/blackmisc/simulation/settings/xswiftbussettings.h
+++ b/src/blackmisc/simulation/settings/xswiftbussettings.h
@@ -40,7 +40,8 @@ namespace BlackMisc
IndexMaxPlanes,
IndexDrawingLabels,
IndexMaxDrawingDistance,
- IndexFollowAircraftDistance
+ IndexFollowAircraftDistance,
+ IndexNightTextureMode
};
//! Default constructor
@@ -64,6 +65,12 @@ namespace BlackMisc
//! \copydoc CXSwiftBusSettingsQtFree::setDBusServerAddress
void setDBusServerAddressQt(const QString &dBusAddress) { this->setDBusServerAddress(dBusAddress.toStdString()); }
+ //! \copydoc CXSwiftBusSettingsQtFree::getNightTextureMode
+ QString getNightTextureModeQt() const { return QString::fromStdString(this->getNightTextureMode()); }
+
+ //! \copydoc CXSwiftBusSettingsQtFree::setNightTextureMode
+ void setNightTextureModeQt(const QString &nightTexture) { this->setNightTextureMode(nightTexture.toStdString()); }
+
//! \copydoc CXSwiftBusSettingsQtFree::toXSwiftBusJsonString
QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
@@ -87,6 +94,7 @@ namespace BlackMisc
BLACK_METACLASS(
CXSwiftBusSettings,
BLACK_METAMEMBER(dBusServerAddress),
+ BLACK_METAMEMBER(nightTextureMode),
BLACK_METAMEMBER(maxPlanes),
BLACK_METAMEMBER(drawingLabels),
BLACK_METAMEMBER(maxDrawDistanceNM),
diff --git a/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.cpp b/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.cpp
index eae8951a2..a4e9b20b5 100644
--- a/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.cpp
+++ b/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.cpp
@@ -25,6 +25,7 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDr
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxPlanes[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxDrawDistance[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM[];
+constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonNightTextureMode[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
//! @endcond
@@ -56,6 +57,10 @@ namespace BlackMisc
{
m_dBusServerAddress = settingsDoc[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].GetString(); c++;
}
+ if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonNightTextureMode) && settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].IsString())
+ {
+ m_nightTextureMode = settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].GetString(); c++;
+ }
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonDrawingLabels) && settingsDoc[CXSwiftBusSettingsQtFree::JsonDrawingLabels].IsBool())
{
m_drawingLabels = settingsDoc[CXSwiftBusSettingsQtFree::JsonDrawingLabels].GetBool(); c++;
@@ -77,7 +82,7 @@ namespace BlackMisc
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
}
this->objectUpdated(); // post processing
- return c == 6;
+ return c == 7;
}
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
@@ -91,10 +96,11 @@ namespace BlackMisc
// Value k1(JsonDBusServerAddress, a);
// Value v1(m_dBusServerAddress, a);
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
- document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
+ document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
document.AddMember(JsonMaxPlanes, m_maxPlanes, a);
document.AddMember(JsonMaxDrawDistance, m_maxDrawDistanceNM, a);
document.AddMember(JsonTimestamp, m_msSinceEpochQtFree, a);
+ document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
@@ -113,6 +119,7 @@ namespace BlackMisc
{
return "DBusServer: " + m_dBusServerAddress +
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
+ ", night t.: " + m_nightTextureMode +
", max planes: " + std::to_string(m_maxPlanes) +
", max distance NM: " + std::to_string(m_maxDrawDistanceNM) +
", follow dist m: " + std::to_string(m_followAircraftDistanceM) +
@@ -124,6 +131,7 @@ namespace BlackMisc
int changed = 0;
if (m_dBusServerAddress != newValues.m_dBusServerAddress) { m_dBusServerAddress = newValues.m_dBusServerAddress; changed++; }
if (m_drawingLabels != newValues.m_drawingLabels) { m_drawingLabels = newValues.m_drawingLabels; changed++; }
+ if (m_nightTextureMode != newValues.m_nightTextureMode) { m_nightTextureMode = newValues.m_nightTextureMode; changed++; }
if (m_maxPlanes != newValues.m_maxPlanes) { m_maxPlanes = newValues.m_maxPlanes; changed++; }
if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) { m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; changed++; }
if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) { m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; changed++; }
diff --git a/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.h b/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.h
index 2771321c8..cccf88772 100644
--- a/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.h
+++ b/src/blackmisc/simulation/settings/xswiftbussettingsqtfree.h
@@ -46,6 +46,12 @@ namespace BlackMisc
//! Get whether the plugin draws type and callsign labels above aircraft
bool isDrawingLabels() const { return m_drawingLabels; }
+ //! The the night texture mode
+ void setNightTextureMode(const std::string &mode) { m_nightTextureMode = XPlane::QtFreeUtils::toLower(mode); }
+
+ //! The the night texture mode
+ const std::string &getNightTextureMode() const { return m_nightTextureMode; }
+
//! Set the maximum number of aircraft.
bool setMaxPlanes(int planes)
{
@@ -100,6 +106,7 @@ namespace BlackMisc
static constexpr char JsonDrawingLabels[] = "drawinglabels";
static constexpr char JsonMaxPlanes[] = "maxplanes";
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
+ static constexpr char JsonNightTextureMode[] = "nighttexture";
static constexpr char JsonTimestamp[] = "timestamp";
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
//! @}
@@ -108,11 +115,12 @@ namespace BlackMisc
virtual void objectUpdated();
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server
- int m_maxPlanes = 100; //!< max. planes in XPlane
- int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
- bool m_drawingLabels = true; //!< labels in XPlane
- double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
- int64_t m_msSinceEpochQtFree = 0; //!< timestamp
+ std::string m_nightTextureMode { "auto" }; //!< night texture mode
+ int m_maxPlanes = 100; //!< max. planes in XPlane
+ int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
+ bool m_drawingLabels = true; //!< labels in XPlane
+ double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
+ int64_t m_msSinceEpochQtFree = 0; //!< timestamp
};
} // ns
} // ns
diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp
index 698e24852..cac8a9a8b 100644
--- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp
+++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp
@@ -67,6 +67,7 @@ namespace BlackSimPlugin
s.setMaxPlanes(ui->sb_MaxAircraft->value());
s.setFollowAircraftDistanceM(ui->sb_FollowAircraftDistanceM->value());
s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
+ s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText());
return s;
}
@@ -77,6 +78,19 @@ namespace BlackSimPlugin
ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM());
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
+
+ const QString s = settings.getNightTextureModeQt().left(1);
+ if (!s.isEmpty())
+ {
+ for (int i = 0; i < ui->cb_NightTextureMode->count(); i++)
+ {
+ if (ui->cb_NightTextureMode->itemText(i).startsWith(s, Qt::CaseInsensitive))
+ {
+ ui->cb_NightTextureMode->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
}
void CSimulatorXPlaneConfigWindow::onSettingsChanged()
diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui
index ecc5a088a..5d35eab8f 100644
--- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui
+++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui
@@ -7,7 +7,7 @@
0
0
300
- 298
+ 325
@@ -144,6 +144,32 @@
+ -
+
+
-
+
+ auto
+
+
+ -
+
+ daylight texture only
+
+
+ -
+
+ night texture only
+
+
+
+
+ -
+
+
+ Night texture
+
+
+
diff --git a/tests/blackmisc/simulation/testxplane/testxplane.cpp b/tests/blackmisc/simulation/testxplane/testxplane.cpp
index d04077235..1e732e8c1 100644
--- a/tests/blackmisc/simulation/testxplane/testxplane.cpp
+++ b/tests/blackmisc/simulation/testxplane/testxplane.cpp
@@ -108,9 +108,11 @@ namespace BlackMiscTest
s.setMaxDrawDistanceNM(11.11);
s.setDrawingLabels(false);
s.setFollowAircraftDistanceM(123);
+ s.setNightTextureModeQt("FOO");
s.setCurrentUtcTime();
- QString json = s.toXSwiftBusJsonStringQt();
+ QVERIFY2(s.getNightTextureModeQt() == "foo", "Expect lower case");
+ QString json = s.toXSwiftBusJsonStringQt();
qDebug() << json;
qDebug() << s.toQString();
@@ -121,6 +123,7 @@ namespace BlackMiscTest
QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt());
QCOMPARE(s.getFollowAircraftDistanceM(), s2.getFollowAircraftDistanceM());
QCOMPARE(s.getMSecsSinceEpoch(), s2.getMSecsSinceEpoch());
+ QVERIFY2(s2.getNightTextureModeQt() == "foo", "Expect lower case foo");
s.setDBusServerAddressQt(CDBusServer::sessionBusAddress());
json = s.toXSwiftBusJsonStringQt();
@@ -136,6 +139,7 @@ namespace BlackMiscTest
QCOMPARE(s.getMaxPlanes(), s2.getMaxPlanes());
QCOMPARE(s.isDrawingLabels(), s2.isDrawingLabels());
QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt());
+ QVERIFY2(s2.getNightTextureModeQt() == "foo", "Expect lower case foo");
}
}