Add weather scenario settings to simulator plugins

refs #663
This commit is contained in:
Roland Winklmeier
2016-06-05 22:42:04 +02:00
parent de0729faad
commit 10c4fa920d
7 changed files with 94 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ namespace BlackSimPlugin
"B737-800 default model",
CAircraftIcaoCode("B738", "L2J")
));
ps_reloadSettings();
}
CSimulatorFsx::~CSimulatorFsx()
@@ -428,7 +429,8 @@ namespace BlackSimPlugin
}
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
if (calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20 )
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20 )
{
m_lastWeatherPosition = currentPosition;
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
@@ -512,6 +514,16 @@ namespace BlackSimPlugin
}
}
void CSimulatorFsx::ps_reloadSettings()
{
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
if (CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
{
m_lastWeatherPosition = {};
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
}
}
bool CSimulatorFsx::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
{
// only remove from sim

View File

@@ -15,6 +15,7 @@
#include "simconnectdatadefinition.h"
#include "simconnectobject.h"
#include "../fscommon/simulatorfscommon.h"
#include "blackcore/settings/simulator.h"
#include "blackcore/simulator.h"
#include "blackmisc/interpolatorlinear.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
@@ -141,6 +142,9 @@ namespace BlackSimPlugin
//! Dispatch SimConnect messages
void ps_dispatch();
//! Reload settings
void ps_reloadSettings();
private:
//! Called when sim has started
void onSimRunning();
@@ -202,6 +206,7 @@ namespace BlackSimPlugin
int m_statsUpdateAircraftCount = 0;
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
BlackMisc::CSetting<BlackCore::Settings::Simulator::SelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorFsx::ps_reloadSettings };
};
//! Listener for FSX