mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #466 Resolved TODO items in xbus.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
//! \file
|
||||
|
||||
#include <XPLM/XPLMDataAccess.h>
|
||||
#include <XPLM/XPLMUtilities.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -24,7 +25,11 @@ namespace XBus
|
||||
public:
|
||||
DataRefImpl(char const* name) : m_ref(XPLMFindDataRef(name))
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -43,7 +48,11 @@ namespace XBus
|
||||
public:
|
||||
ArrayDataRefImpl(char const* name, size_t size) : m_ref(XPLMFindDataRef(name)), m_size(size)
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -131,7 +140,11 @@ namespace XBus
|
||||
//! Constructor
|
||||
StringDataRef() : m_ref(XPLMFindDataRef(DataRefTraits::name()))
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(DataRefTraits::name());
|
||||
}
|
||||
}
|
||||
|
||||
//! Set the value of the whole string (if it is writable)
|
||||
|
||||
@@ -98,6 +98,12 @@ namespace XBus
|
||||
//! Get full path to X-Plane preferences file
|
||||
QString getXPlanePreferencesPath() const;
|
||||
|
||||
//! True if sim is paused
|
||||
bool isPaused() const { return m_paused.get(); }
|
||||
|
||||
//! True if sim time is tracking operating system time
|
||||
bool isUsingRealTime() const { return m_useSystemTime.get(); }
|
||||
|
||||
//! Get aircraft latitude in degrees
|
||||
double getLatitude() const { return m_latitude.get(); }
|
||||
|
||||
@@ -217,6 +223,8 @@ namespace XBus
|
||||
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_livery_path> m_liveryPath;
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_ICAO> m_icao;
|
||||
DataRef<xplane::data::sim::time::paused> m_paused;
|
||||
DataRef<xplane::data::sim::time::use_system_time> m_useSystemTime;
|
||||
DataRef<xplane::data::sim::flightmodel::position::latitude> m_latitude;
|
||||
DataRef<xplane::data::sim::flightmodel::position::longitude> m_longitude;
|
||||
DataRef<xplane::data::sim::flightmodel::position::elevation> m_elevation;
|
||||
|
||||
@@ -101,19 +101,24 @@ namespace XBus
|
||||
}
|
||||
}
|
||||
|
||||
int g_maxPlanes = 100;
|
||||
float g_drawDistance = 50.0f;
|
||||
|
||||
int CTraffic::preferences(const char *section, const char *name, int def)
|
||||
{
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(section);
|
||||
// TODO [planes] max_full_count
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "max_full_count") == 0)
|
||||
{
|
||||
return g_maxPlanes;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
float CTraffic::preferences(const char *section, const char *name, float def)
|
||||
{
|
||||
// TODO [planes] full_distance
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(section);
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "full_distance") == 0)
|
||||
{
|
||||
return g_drawDistance;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
@@ -173,6 +178,16 @@ namespace XBus
|
||||
emit installedModelsUpdated(modelNames, icaos, airlines, liveries);
|
||||
}
|
||||
|
||||
void CTraffic::setMaxPlanes(int planes)
|
||||
{
|
||||
g_maxPlanes = planes;
|
||||
}
|
||||
|
||||
void CTraffic::setMaxDrawDistance(float nauticalMiles)
|
||||
{
|
||||
g_drawDistance = nauticalMiles;
|
||||
}
|
||||
|
||||
void CTraffic::addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
|
||||
{
|
||||
XPMPPlaneID id = nullptr;
|
||||
|
||||
@@ -81,6 +81,12 @@ namespace XBus
|
||||
//! Called by newly connected client to cause installedModelsUpdated to be emitted.
|
||||
void updateInstalledModels();
|
||||
|
||||
//! Set the maximum number of aircraft.
|
||||
void setMaxPlanes(int planes);
|
||||
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
void setMaxDrawDistance(float nauticalMiles);
|
||||
|
||||
//! Introduce a new traffic aircraft
|
||||
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user