Issue #17 Fix aircraft labels setting not being updated in xswiftbus

Also related tidying up.
This commit is contained in:
Mat Sutcliffe
2020-08-13 14:32:06 +01:00
parent f114171083
commit e710c777ab
5 changed files with 5 additions and 35 deletions

View File

@@ -84,16 +84,6 @@ namespace BlackSimPlugin
m_dbusInterface->callDBus(QLatin1String("setDefaultIcao"), defaultIcao); m_dbusInterface->callDBus(QLatin1String("setDefaultIcao"), defaultIcao);
} }
void CXSwiftBusTrafficProxy::setDrawingLabels(bool drawing)
{
m_dbusInterface->callDBus(QLatin1String("setDrawingLabels"), drawing);
}
bool CXSwiftBusTrafficProxy::isDrawingLabels() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isDrawingLabels"));
}
void CXSwiftBusTrafficProxy::setMaxPlanes(int planes) void CXSwiftBusTrafficProxy::setMaxPlanes(int planes)
{ {
m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes); m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes);

View File

@@ -213,12 +213,6 @@ namespace BlackSimPlugin
//! \copydoc XSwiftBus::CTraffic::setDefaultIcao //! \copydoc XSwiftBus::CTraffic::setDefaultIcao
void setDefaultIcao(const QString &defaultIcao); void setDefaultIcao(const QString &defaultIcao);
//! \copydoc XSwiftBus::CTraffic::setDrawingLabels
void setDrawingLabels(bool drawing);
//! \copydoc XSwiftBus::CTraffic::isDrawingLabels
bool isDrawingLabels() const;
//! \copydoc XSwiftBus::CTraffic::setMaxPlanes //! \copydoc XSwiftBus::CTraffic::setMaxPlanes
void setMaxPlanes(int planes); void setMaxPlanes(int planes);

View File

@@ -34,6 +34,7 @@ namespace XSwiftBus
//! Register the draw callback. //! Register the draw callback.
void show() void show()
{ {
if (m_visible) { return; }
m_visible = true; m_visible = true;
XPLMRegisterDrawCallback(callback, m_phase, m_before, static_cast<void*>(this)); XPLMRegisterDrawCallback(callback, m_phase, m_before, static_cast<void*>(this));
} }
@@ -41,6 +42,7 @@ namespace XSwiftBus
//! Unregister the draw callback. //! Unregister the draw callback.
void hide() void hide()
{ {
if (!m_visible) { return; }
m_visible = false; m_visible = false;
XPLMUnregisterDrawCallback(callback, m_phase, m_before, static_cast<void*>(this)); XPLMUnregisterDrawCallback(callback, m_phase, m_before, static_cast<void*>(this));
} }

View File

@@ -36,10 +36,12 @@ namespace XSwiftBus
public: public:
//! Get settings //! Get settings
//! \threadsafe //! \threadsafe
//! \fixme Does this really need to be threadsafe?
CSettings getSettings() const; CSettings getSettings() const;
//! Set settings //! Set settings
//! \threadsafe //! \threadsafe
//! \fixme Does this really need to be threadsafe?
void setSettings(const CSettings &settings); void setSettings(const CSettings &settings);
//! Get settings from xswiftbus.conf (needed during plugin initialization) //! Get settings from xswiftbus.conf (needed during plugin initialization)

View File

@@ -605,24 +605,6 @@ namespace XSwiftBus
setDefaultIcao(defaultIcao); setDefaultIcao(defaultIcao);
}); });
} }
else if (message.getMethodName() == "setDrawingLabels")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
bool drawing = true;
message.beginArgumentRead();
message.getArgument(drawing);
queueDBusCall([ = ]()
{
setDrawingLabels(drawing);
});
}
else if (message.getMethodName() == "isDrawingLabels")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, isDrawingLabels());
});
}
else if (message.getMethodName() == "setMaxPlanes") else if (message.getMethodName() == "setMaxPlanes")
{ {
maybeSendEmptyDBusReply(wantsReply, sender, serial); maybeSendEmptyDBusReply(wantsReply, sender, serial);
@@ -844,6 +826,7 @@ namespace XSwiftBus
{ {
invokeQueuedDBusCalls(); invokeQueuedDBusCalls();
doPlaneUpdates(); doPlaneUpdates();
setDrawingLabels(getSettings().isDrawingLabels());
emitSimFrame(); emitSimFrame();
m_countFrame++; m_countFrame++;
return 1; return 1;
@@ -876,7 +859,6 @@ namespace XSwiftBus
void CTraffic::interpolatePosition(Plane *plane) void CTraffic::interpolatePosition(Plane *plane)
{ {
std::memcpy(&plane->positions[3], &plane->positions[2], sizeof(plane->positions[2])); std::memcpy(&plane->positions[3], &plane->positions[2], sizeof(plane->positions[2]));
return;
const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now();
const auto t1 = plane->positionTimes[2] - plane->positionTimes[0]; const auto t1 = plane->positionTimes[2] - plane->positionTimes[0];