mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T709, changed to settings provider
* CPlugin is the provider * it is "kept" in DBus object for traffic, service, weather
This commit is contained in:
committed by
Mat Sutcliffe
parent
97926eee26
commit
f9c87326fb
@@ -11,6 +11,7 @@
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include "plugin.h"
|
||||
#include "traffic.h"
|
||||
#include "utils.h"
|
||||
#include "XPMPMultiplayer.h"
|
||||
@@ -31,8 +32,6 @@
|
||||
|
||||
namespace XSwiftBus
|
||||
{
|
||||
CSettings *CTraffic::s_pluginSettings = nullptr;
|
||||
|
||||
CTraffic::Plane::Plane(void *id_, const std::string &callsign_, const std::string &aircraftIcao_, const std::string &airlineIcao_, const std::string &livery_, const std::string &modelName_)
|
||||
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), modelName(modelName_)
|
||||
{
|
||||
@@ -48,17 +47,16 @@ namespace XSwiftBus
|
||||
}
|
||||
|
||||
// *INDENT-OFF*
|
||||
CTraffic::CTraffic(CSettings *staticSettings) :
|
||||
CDBusObject(),
|
||||
CTraffic::CTraffic(ISettingsProvider *settingsProvider) :
|
||||
CDBusObject(settingsProvider),
|
||||
m_followPlaneViewNextCommand("org/swift-project/xswiftbus/follow_next_plane", "Changes plane view to follow next plane in sequence", [this] { followNextPlane(); }),
|
||||
m_followPlaneViewPreviousCommand("org/swift-project/xswiftbus/follow_previous_plane", "Changes plane view to follow previous plane in sequence", [this] { followPreviousPlane(); })
|
||||
{
|
||||
CTraffic::s_pluginSettings = staticSettings;
|
||||
XPLMRegisterDrawCallback(drawCallback, xplm_Phase_Airplanes, 1, this);
|
||||
XPLMRegisterKeySniffer(spaceKeySniffer, 1, this);
|
||||
|
||||
// init labels
|
||||
this->setDrawingLabels(CTraffic::s_pluginSettings->isDrawingLabels());
|
||||
this->setDrawingLabels(this->getSettings().isDrawingLabels());
|
||||
}
|
||||
// *INDENT-ON*
|
||||
|
||||
@@ -84,6 +82,7 @@ namespace XSwiftBus
|
||||
std::string related = dir + "related.txt";
|
||||
std::string doc8643 = dir + "Doc8643.txt";
|
||||
std::string lights = dir + "lights.png";
|
||||
|
||||
auto err = XPMPMultiplayerInitLegacyData(csl.c_str(), related.c_str(), lights.c_str(), doc8643.c_str(),
|
||||
"C172", preferences, preferences);
|
||||
if (*err) { s_legacyDataOK = false; }
|
||||
@@ -217,7 +216,7 @@ namespace XSwiftBus
|
||||
{
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "max_full_count") == 0)
|
||||
{
|
||||
return CTraffic::s_pluginSettings->getMaxPlanes();
|
||||
return s_settingsProvider->getSettings().getMaxPlanes();
|
||||
}
|
||||
else if (strcmp(section, "debug") == 0 && strcmp(name, "allow_obj8_async_load") == 0)
|
||||
{
|
||||
@@ -232,7 +231,7 @@ namespace XSwiftBus
|
||||
{
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "full_distance") == 0)
|
||||
{
|
||||
return static_cast<float>(CTraffic::s_pluginSettings->getMaxDrawDistanceNM());
|
||||
return static_cast<float>(s_settingsProvider->getSettings().getMaxDrawDistanceNM());
|
||||
}
|
||||
return def;
|
||||
}
|
||||
@@ -256,7 +255,7 @@ namespace XSwiftBus
|
||||
|
||||
void CTraffic::setDrawingLabels(bool drawing)
|
||||
{
|
||||
CTraffic::s_pluginSettings->setDrawingLabels(drawing);
|
||||
s_settingsProvider->getSettings().setDrawingLabels(drawing);
|
||||
if (drawing)
|
||||
{
|
||||
XPMPEnableAircraftLabels();
|
||||
@@ -274,12 +273,12 @@ namespace XSwiftBus
|
||||
|
||||
void CTraffic::setMaxPlanes(int planes)
|
||||
{
|
||||
CTraffic::s_pluginSettings->setMaxPlanes(planes);
|
||||
s_settingsProvider->getSettings().setMaxPlanes(planes);
|
||||
}
|
||||
|
||||
void CTraffic::setMaxDrawDistance(double nauticalMiles)
|
||||
{
|
||||
CTraffic::s_pluginSettings->setMaxDrawDistanceNM(nauticalMiles);
|
||||
s_settingsProvider->getSettings().setMaxDrawDistanceNM(nauticalMiles);
|
||||
}
|
||||
|
||||
void CTraffic::addPlane(const std::string &callsign, const std::string &modelName, const std::string &aircraftIcao, const std::string &airlineIcao, const std::string &livery)
|
||||
@@ -898,7 +897,7 @@ namespace XSwiftBus
|
||||
// Now calculate where the camera should be positioned to be x
|
||||
// meters from the plane and pointing at the plane at the pitch and
|
||||
// heading we wanted above.
|
||||
const double distanceMeterM = static_cast<double>(std::max(10, CTraffic::s_pluginSettings->getFollowAircraftDistanceM()));
|
||||
const double distanceMeterM = static_cast<double>(std::max(10, s_settingsProvider->getSettings().getFollowAircraftDistanceM()));
|
||||
static const double PI = std::acos(-1);
|
||||
traffic->m_deltaCameraPosition.dx = -distanceMeterM * sin(traffic->m_deltaCameraPosition.heading * PI / 180.0);
|
||||
traffic->m_deltaCameraPosition.dz = distanceMeterM * cos(traffic->m_deltaCameraPosition.heading * PI / 180.0);
|
||||
|
||||
Reference in New Issue
Block a user