mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T709, added settings for lights and message box margins
This commit is contained in:
committed by
Mat Sutcliffe
parent
024360a5df
commit
6e90ec5c72
@@ -28,12 +28,14 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
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);
|
||||
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 IndexMessageBoxMargins: return CVariant::fromValue(QString::fromStdString(m_msgBox));
|
||||
case IndexDrawingLabels: return CVariant::fromValue(m_drawingLabels);
|
||||
case IndexBundleTaxiLandingLights: return CVariant::fromValue(m_bundleTaxiLandingLights);
|
||||
case IndexMaxDrawingDistance: return CVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexFollowAircraftDistance: return CVariant::fromValue(m_followAircraftDistanceM);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
@@ -47,12 +49,14 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
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;
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toStdString(); break;
|
||||
case IndexMessageBoxMargins: m_msgBox = variant.toStdString(); break;
|
||||
case IndexNightTextureMode: m_nightTextureMode = variant.toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexBundleTaxiLandingLights: m_bundleTaxiLandingLights = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace BlackMisc
|
||||
IndexDBusServerAddress = CPropertyIndex::GlobalIndexCXSwiftBusSettings,
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexBundleTaxiLandingLights,
|
||||
IndexMessageBoxMargins,
|
||||
IndexMaxDrawingDistance,
|
||||
IndexFollowAircraftDistance,
|
||||
IndexNightTextureMode
|
||||
@@ -94,9 +96,11 @@ namespace BlackMisc
|
||||
BLACK_METACLASS(
|
||||
CXSwiftBusSettings,
|
||||
BLACK_METAMEMBER(dBusServerAddress),
|
||||
BLACK_METAMEMBER(msgBox),
|
||||
BLACK_METAMEMBER(nightTextureMode),
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(bundleTaxiLandingLights),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
BLACK_METAMEMBER(followAircraftDistanceM),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
|
||||
@@ -26,6 +26,8 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMa
|
||||
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::JsonMessageBox[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
|
||||
//! @endcond
|
||||
|
||||
@@ -52,6 +54,10 @@ namespace BlackMisc
|
||||
{
|
||||
m_dBusServerAddress = settingsDoc[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].GetString(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonMessageBox) && settingsDoc[CXSwiftBusSettingsQtFree::JsonMessageBox].IsString())
|
||||
{
|
||||
m_msgBox = settingsDoc[CXSwiftBusSettingsQtFree::JsonMessageBox].GetString(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonNightTextureMode) && settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].IsString())
|
||||
{
|
||||
m_nightTextureMode = settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].GetString(); c++;
|
||||
@@ -60,6 +66,10 @@ namespace BlackMisc
|
||||
{
|
||||
m_drawingLabels = settingsDoc[CXSwiftBusSettingsQtFree::JsonDrawingLabels].GetBool(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights) && settingsDoc[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].IsBool())
|
||||
{
|
||||
m_bundleTaxiLandingLights = settingsDoc[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].GetBool(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonMaxPlanes) && settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].IsInt())
|
||||
{
|
||||
m_maxPlanes = settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].GetInt(); c++;
|
||||
@@ -77,7 +87,7 @@ namespace BlackMisc
|
||||
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
|
||||
}
|
||||
this->objectUpdated(); // post processing
|
||||
return c == 7;
|
||||
return c == 9;
|
||||
}
|
||||
|
||||
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
|
||||
@@ -90,12 +100,14 @@ namespace BlackMisc
|
||||
Document::AllocatorType &a = document.GetAllocator();
|
||||
// Value k1(JsonDBusServerAddress, a);
|
||||
// Value v1(m_dBusServerAddress, a);
|
||||
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
|
||||
document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
|
||||
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
|
||||
document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
|
||||
document.AddMember(JsonMessageBox, StringRef(m_msgBox.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(JsonBundleTaxiLandingLights, m_bundleTaxiLandingLights, a);
|
||||
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
|
||||
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
|
||||
@@ -113,11 +125,13 @@ namespace BlackMisc
|
||||
std::string CXSwiftBusSettingsQtFree::convertToString() const
|
||||
{
|
||||
return "DBusServer: " + m_dBusServerAddress +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", bundle lights: " + QtFreeUtils::boolToYesNo(m_bundleTaxiLandingLights) +
|
||||
", 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) +
|
||||
", msg.box: " + m_msgBox +
|
||||
", ts: " + std::to_string(m_msSinceEpochQtFree);
|
||||
}
|
||||
|
||||
@@ -125,7 +139,9 @@ namespace BlackMisc
|
||||
{
|
||||
int changed = 0;
|
||||
if (m_dBusServerAddress != newValues.m_dBusServerAddress) { m_dBusServerAddress = newValues.m_dBusServerAddress; changed++; }
|
||||
if (m_msgBox != newValues.m_msgBox) { m_msgBox = newValues.m_msgBox; changed++; }
|
||||
if (m_drawingLabels != newValues.m_drawingLabels) { m_drawingLabels = newValues.m_drawingLabels; changed++; }
|
||||
if (m_bundleTaxiLandingLights != newValues.m_bundleTaxiLandingLights) { m_bundleTaxiLandingLights = newValues.m_bundleTaxiLandingLights; 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++; }
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackMisc
|
||||
{
|
||||
/*!
|
||||
* XSwiftBus/swift side settings class, JSON capable, shared among all services
|
||||
* \details Used on swift and XSwiftBus side, MUST BE QT free
|
||||
* \details Used on swift and XSwiftBus side, MUST BE Qt free
|
||||
*/
|
||||
class CXSwiftBusSettingsQtFree
|
||||
{
|
||||
@@ -44,12 +44,48 @@ namespace BlackMisc
|
||||
//! Get whether the plugin draws type and callsign labels above aircraft
|
||||
bool isDrawingLabels() const { return m_drawingLabels; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
void setBundlingTaxiAndLandingLights(bool bundle) { m_bundleTaxiLandingLights = bundle; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
bool isBundlingTaxiAndLandingLights() const { return m_bundleTaxiLandingLights; }
|
||||
|
||||
//! 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; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration
|
||||
void setMessageBoxValues(const std::string &positions) { m_msgBox = positions; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration
|
||||
void setMessageBoxValues(int leftPx, int topPx, int rightPx, int bottomPx, int lines, int durationMs)
|
||||
{
|
||||
if (topPx >= 0) { bottomPx = -1; }
|
||||
if (lines < 3) { lines = 3; }
|
||||
this->setMessageBoxValues(std::to_string(leftPx) + ";" + std::to_string(topPx) + ";" + std::to_string(rightPx) + ";" + std::to_string(bottomPx) + ";" + std::to_string(lines) + ";" + std::to_string(durationMs));
|
||||
}
|
||||
|
||||
//! Left, top, right, bottom, lines, duration
|
||||
const std::string &getMessageBoxValues() const { return m_msgBox; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration
|
||||
std::vector<int> getMessageBoxValuesVector() const
|
||||
{
|
||||
constexpr int partCount = 6;
|
||||
std::vector<int> partsInt = {20, 20, 20, -1, 5, 5000};
|
||||
const std::vector<std::string> parts = XPlane::QtFreeUtils::split(m_msgBox, partCount, ";");
|
||||
|
||||
size_t c = 0;
|
||||
for (const std::string &p : parts)
|
||||
{
|
||||
const int i = std::stoi(p);
|
||||
partsInt[c++] = i;
|
||||
}
|
||||
return partsInt;
|
||||
}
|
||||
|
||||
//! Set the maximum number of aircraft.
|
||||
bool setMaxPlanes(int planes)
|
||||
{
|
||||
@@ -106,6 +142,8 @@ namespace BlackMisc
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonNightTextureMode[] = "nighttexture";
|
||||
static constexpr char JsonTimestamp[] = "timestamp";
|
||||
static constexpr char JsonMessageBox[] = "msgbox";
|
||||
static constexpr char JsonBundleTaxiLandingLights[] = "bundleLights";
|
||||
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
|
||||
//! @}
|
||||
|
||||
@@ -114,11 +152,13 @@ namespace BlackMisc
|
||||
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server
|
||||
std::string m_nightTextureMode { "auto" }; //!< night texture mode
|
||||
std::string m_msgBox { "20;20;20;-1;5;5000" }; //!< left, top, right, bottom, lines, duration
|
||||
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
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
bool m_bundleTaxiLandingLights = true; //!< bundle taxi and landing lights
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int64_t m_msSinceEpochQtFree = 0; //!< timestamp
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user