mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Split of CSimulatorPluginInfo and CSimulatorSetup
refs #404, and discussion https://dev.vatsim-germany.org/issues/404#note-8 * Changed CSimulatorSetup to use CNameVariantPairList as data. The old version was an hack and had to go, CNameVariantPairList would allow complex types in the future and can be already shown in the GUI. * CNameVariantPairList was improved slightly in the same step * Functions to get CSimulatorSetup from driver / context * Removed CSimulatorSetup data from CSimulatorPluginInfo
This commit is contained in:
@@ -180,7 +180,7 @@ namespace BlackCore
|
||||
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo());
|
||||
if (getIContextSimulator())
|
||||
{
|
||||
this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorInfo());
|
||||
this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorPluginInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/simulatorinfolist.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
@@ -100,7 +101,10 @@ namespace BlackCore
|
||||
virtual bool isSimulating() const = 0;
|
||||
|
||||
//! Simulator info
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const = 0;
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const = 0;
|
||||
|
||||
//! Simulator setup
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const = 0;
|
||||
|
||||
//! Airports in range
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const = 0;
|
||||
@@ -173,7 +177,7 @@ namespace BlackCore
|
||||
virtual void unloadSimulatorPlugin() = 0;
|
||||
|
||||
//! Simulator avialable (driver available)?
|
||||
bool isSimulatorAvailable() const { return BlackMisc::CProject::isCompiledWithFlightSimulatorSupport() && !getSimulatorInfo().isUnspecified(); }
|
||||
bool isSimulatorAvailable() const { return BlackMisc::CProject::isCompiledWithFlightSimulatorSupport() && !getSimulatorPluginInfo().isUnspecified(); }
|
||||
|
||||
//! Simulator paused?
|
||||
virtual bool isPaused() const = 0;
|
||||
|
||||
@@ -90,131 +90,143 @@ namespace BlackCore
|
||||
{
|
||||
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->isConnected();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->isConnected();
|
||||
}
|
||||
|
||||
bool CContextSimulator::canConnect() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->canConnect();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->canConnect();
|
||||
}
|
||||
|
||||
bool CContextSimulator::disconnectFromSimulator()
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->disconnectFrom();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->disconnectFrom();
|
||||
}
|
||||
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulator::getSimulatorInfo() const
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulator::getSimulatorPluginInfo() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return BlackMisc::Simulation::CSimulatorPluginInfo();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->info;
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->info;
|
||||
}
|
||||
|
||||
CSimulatorSetup CContextSimulator::getSimulatorSetup() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulatorPlugin || !m_simulatorPlugin->simulator)
|
||||
{
|
||||
return BlackMisc::Simulation::CSimulatorSetup();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getSimulatorSetup();
|
||||
}
|
||||
|
||||
CAirportList CContextSimulator::getAirportsInRange() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
// If no ISimulator object is available, return a dummy.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CAirportList();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->getAirportsInRange();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getAirportsInRange();
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulator::getInstalledModels() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
// If no ISimulator object is available, return a dummy.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CAircraftModelList();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->getInstalledModels();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getInstalledModels();
|
||||
}
|
||||
|
||||
int CContextSimulator::getInstalledModelsCount() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator) { return 0; }
|
||||
if (!m_simulatorPlugin) { return 0; }
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return this->m_simulator->simulator->getInstalledModels().size();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return this->m_simulatorPlugin->simulator->getInstalledModels().size();
|
||||
}
|
||||
|
||||
CAircraftModelList CContextSimulator::getInstalledModelsStartingWith(const QString modelString) const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << modelString; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CAircraftModelList();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->getInstalledModels().findModelsStartingWith(modelString);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getInstalledModels().findModelsStartingWith(modelString);
|
||||
}
|
||||
|
||||
void CContextSimulator::reloadInstalledModels()
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
m_simulator->simulator->reloadInstalledModels();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
m_simulatorPlugin->simulator->reloadInstalledModels();
|
||||
}
|
||||
|
||||
CAircraftIcao CContextSimulator::getIcaoForModelString(const QString &modelString) const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << modelString; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CAircraftIcao();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->getIcaoForModelString(modelString);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getIcaoForModelString(modelString);
|
||||
}
|
||||
|
||||
bool CContextSimulator::setTimeSynchronization(bool enable, CTime offset)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
bool c = m_simulator->simulator->setTimeSynchronization(enable, offset);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
bool c = m_simulatorPlugin->simulator->setTimeSynchronization(enable, offset);
|
||||
if (!c)
|
||||
{
|
||||
return false;
|
||||
@@ -227,64 +239,64 @@ namespace BlackCore
|
||||
bool CContextSimulator::isTimeSynchronized() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->isTimeSynchronized();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->isTimeSynchronized();
|
||||
}
|
||||
|
||||
int CContextSimulator::getMaxRenderedAircraft() const
|
||||
{
|
||||
if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->getMaxRenderedAircraft();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->getMaxRenderedAircraft();
|
||||
}
|
||||
|
||||
void CContextSimulator::setMaxRenderedAircraft(int number)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number; }
|
||||
|
||||
if (m_simulator)
|
||||
if (m_simulatorPlugin)
|
||||
{
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
m_simulator->simulator->setMaxRenderedAircraft(number);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
m_simulatorPlugin->simulator->setMaxRenderedAircraft(number);
|
||||
}
|
||||
}
|
||||
|
||||
void CContextSimulator::setMaxRenderedDistance(CLength &distance)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << distance; }
|
||||
if (m_simulator)
|
||||
if (m_simulatorPlugin)
|
||||
{
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
this->m_simulator->simulator->setMaxRenderedDistance(distance);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
this->m_simulatorPlugin->simulator->setMaxRenderedDistance(distance);
|
||||
}
|
||||
}
|
||||
|
||||
QString CContextSimulator::getRenderRestrictionText() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator) { return ""; }
|
||||
if (!m_simulatorPlugin) { return ""; }
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
if (!m_simulator->simulator->isRenderingRestricted()) { return "none"; }
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
if (!m_simulatorPlugin->simulator->isRenderingRestricted()) { return "none"; }
|
||||
QString rt;
|
||||
if (m_simulator->simulator->isMaxAircraftRestricted())
|
||||
if (m_simulatorPlugin->simulator->isMaxAircraftRestricted())
|
||||
{
|
||||
rt.append(QString::number(m_simulator->simulator->getMaxRenderedAircraft())).append(" A/C");
|
||||
rt.append(QString::number(m_simulatorPlugin->simulator->getMaxRenderedAircraft())).append(" A/C");
|
||||
}
|
||||
if (m_simulator->simulator->isMaxDistanceRestricted())
|
||||
if (m_simulatorPlugin->simulator->isMaxDistanceRestricted())
|
||||
{
|
||||
if (!rt.isEmpty()) { rt.append(" ");}
|
||||
rt.append(m_simulator->simulator->getMaxRenderedDistance().valueRoundedWithUnit(CLengthUnit::NM(), 0));
|
||||
rt.append(m_simulatorPlugin->simulator->getMaxRenderedDistance().valueRoundedWithUnit(CLengthUnit::NM(), 0));
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
@@ -292,55 +304,55 @@ namespace BlackCore
|
||||
CLength CContextSimulator::getMaxRenderedDistance() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CLength(0, CLengthUnit::nullUnit());
|
||||
}
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return this->m_simulator->simulator->getMaxRenderedDistance();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return this->m_simulatorPlugin->simulator->getMaxRenderedDistance();
|
||||
}
|
||||
|
||||
CLength CContextSimulator::getRenderedDistanceBoundary() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CLength(20.0, CLengthUnit::NM());
|
||||
}
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return this->m_simulator->simulator->getRenderedDistanceBoundary();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return this->m_simulatorPlugin->simulator->getRenderedDistanceBoundary();
|
||||
}
|
||||
|
||||
void CContextSimulator::deleteAllRenderingRestrictions()
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulator)
|
||||
if (m_simulatorPlugin)
|
||||
{
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
this->m_simulator->simulator->deleteAllRenderingRestrictions();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
this->m_simulatorPlugin->simulator->deleteAllRenderingRestrictions();
|
||||
}
|
||||
}
|
||||
|
||||
bool CContextSimulator::isRenderingRestricted() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return this->m_simulator->simulator->isRenderingRestricted();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return this->m_simulatorPlugin->simulator->isRenderingRestricted();
|
||||
}
|
||||
|
||||
CTime CContextSimulator::getTimeSynchronizationOffset() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return CTime(0, CTimeUnit::hrmin());
|
||||
}
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return this->m_simulator->simulator->getTimeSynchronizationOffset();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return this->m_simulatorPlugin->simulator->getTimeSynchronizationOffset();
|
||||
}
|
||||
|
||||
bool CContextSimulator::loadSimulatorPlugin(const CSimulatorPluginInfo &simulatorInfo)
|
||||
@@ -372,17 +384,17 @@ namespace BlackCore
|
||||
|
||||
PluginData *plugin = findPlugin(simulatorInfo);
|
||||
plugin->simulator = newSimulator;
|
||||
m_simulator = plugin;
|
||||
m_simulatorPlugin = plugin;
|
||||
|
||||
connect(m_simulator->simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::ps_onSimulatorStatusChanged);
|
||||
connect(m_simulator->simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||
connect(m_simulator->simulator, &ISimulator::modelMatchingCompleted, this, &IContextSimulator::modelMatchingCompleted);
|
||||
connect(m_simulator->simulator, &ISimulator::installedAircraftModelsChanged, this, &IContextSimulator::installedAircraftModelsChanged);
|
||||
connect(m_simulator->simulator, &ISimulator::restrictedRenderingChanged, this, &IContextSimulator::restrictedRenderingChanged);
|
||||
connect(m_simulatorPlugin->simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::ps_onSimulatorStatusChanged);
|
||||
connect(m_simulatorPlugin->simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||
connect(m_simulatorPlugin->simulator, &ISimulator::modelMatchingCompleted, this, &IContextSimulator::modelMatchingCompleted);
|
||||
connect(m_simulatorPlugin->simulator, &ISimulator::installedAircraftModelsChanged, this, &IContextSimulator::installedAircraftModelsChanged);
|
||||
connect(m_simulatorPlugin->simulator, &ISimulator::restrictedRenderingChanged, this, &IContextSimulator::restrictedRenderingChanged);
|
||||
|
||||
// log from context to simulator
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, m_simulator->simulator, &ISimulator::displayStatusMessage);
|
||||
connect(CLogHandler::instance(), &CLogHandler::remoteMessageLogged, m_simulator->simulator, &ISimulator::displayStatusMessage);
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, m_simulatorPlugin->simulator, &ISimulator::displayStatusMessage);
|
||||
connect(CLogHandler::instance(), &CLogHandler::remoteMessageLogged, m_simulatorPlugin->simulator, &ISimulator::displayStatusMessage);
|
||||
|
||||
// connect with network
|
||||
IContextNetwork *networkContext = this->getIContextNetwork();
|
||||
@@ -392,17 +404,17 @@ namespace BlackCore
|
||||
for (const CSimulatedAircraft &simAircraft : networkContext->getAircraftInRange())
|
||||
{
|
||||
Q_ASSERT(!simAircraft.getCallsign().isEmpty());
|
||||
m_simulator->simulator->addRemoteAircraft(simAircraft);
|
||||
m_simulatorPlugin->simulator->addRemoteAircraft(simAircraft);
|
||||
}
|
||||
|
||||
// apply latest settings
|
||||
settingsChanged(static_cast<uint>(IContextSettings::SettingsSimulator));
|
||||
|
||||
// try to connect
|
||||
m_simulator->simulator->asyncConnectTo();
|
||||
m_simulatorPlugin->simulator->asyncConnectTo();
|
||||
|
||||
// info about what is going on
|
||||
CLogMessage(this).info("Simulator plugin loaded: %1") << this->m_simulator->info.toQString(true);
|
||||
CLogMessage(this).info("Simulator plugin loaded: %1") << this->m_simulatorPlugin->info.toQString(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -441,10 +453,10 @@ namespace BlackCore
|
||||
Q_ASSERT(this->getIContextApplication()->isUsingImplementingObject());
|
||||
Q_ASSERT(!simulatorInfo.isUnspecified());
|
||||
|
||||
if (this->m_simulator)
|
||||
if (this->m_simulatorPlugin)
|
||||
{
|
||||
// already loaded
|
||||
CLogMessage(this).warning("Cannot listen for simulator while the driver %1 is still loaded") << m_simulator->info.toQString();
|
||||
CLogMessage(this).warning("Cannot listen for simulator while the driver %1 is still loaded") << m_simulatorPlugin->info.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -517,25 +529,25 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::unloadSimulatorPlugin()
|
||||
{
|
||||
if (m_simulator)
|
||||
if (m_simulatorPlugin)
|
||||
{
|
||||
// depending on shutdown order, network might already have been deleted
|
||||
IContextNetwork *networkContext = this->getIContextNetwork();
|
||||
Q_ASSERT(networkContext);
|
||||
Q_ASSERT(networkContext->isLocalObject());
|
||||
Q_UNUSED(networkContext);
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
|
||||
m_simulator->simulator->disconnect();
|
||||
CLogHandler::instance()->disconnect(m_simulator->simulator);
|
||||
this->disconnect(m_simulator->simulator);
|
||||
m_simulatorPlugin->simulator->disconnect();
|
||||
CLogHandler::instance()->disconnect(m_simulatorPlugin->simulator);
|
||||
this->disconnect(m_simulatorPlugin->simulator);
|
||||
|
||||
if (m_simulator->simulator->isConnected())
|
||||
m_simulator->simulator->disconnectFrom(); // disconnect from simulator
|
||||
if (m_simulatorPlugin->simulator->isConnected())
|
||||
m_simulatorPlugin->simulator->disconnectFrom(); // disconnect from simulator
|
||||
|
||||
m_simulator->simulator->deleteLater();
|
||||
m_simulator->simulator = nullptr;
|
||||
m_simulator = nullptr;
|
||||
m_simulatorPlugin->simulator->deleteLater();
|
||||
m_simulatorPlugin->simulator = nullptr;
|
||||
m_simulatorPlugin = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,16 +556,16 @@ namespace BlackCore
|
||||
// todo:
|
||||
// This was previously an assert and it should be one again in the future.
|
||||
// This slot should not even be called when no simulator is available.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
// Do something if no simulator is running
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
Q_ASSERT(!remoteAircraft.getCallsign().isEmpty());
|
||||
|
||||
m_simulator->simulator->addRemoteAircraft(remoteAircraft);
|
||||
m_simulatorPlugin->simulator->addRemoteAircraft(remoteAircraft);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_removedRemoteAircraft(const CCallsign &callsign)
|
||||
@@ -561,21 +573,21 @@ namespace BlackCore
|
||||
// todo:
|
||||
// This was previously an assert and it should be one again in the future.
|
||||
// This slot should not even be called when no simulator is available.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
// Do something if no simulator is running
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
|
||||
m_simulator->simulator->removeRemoteAircraft(callsign);
|
||||
m_simulatorPlugin->simulator->removeRemoteAircraft(callsign);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_onSimulatorStatusChanged(int status)
|
||||
{
|
||||
Q_ASSERT(m_simulator);
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
|
||||
if (!(status & ISimulator::Connected))
|
||||
{
|
||||
@@ -590,16 +602,16 @@ namespace BlackCore
|
||||
// todo:
|
||||
// This was previously an assert and it should be one again in the future.
|
||||
// This slot should not even be called when no simulator is available.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
// Do something if no simulator is running
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
for (const auto &tm : textMessages)
|
||||
{
|
||||
m_simulator->simulator->displayTextMessage(tm);
|
||||
m_simulatorPlugin->simulator->displayTextMessage(tm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,14 +624,14 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::ps_changedRemoteAircraftModel(const CSimulatedAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
Q_ASSERT(this->m_simulator);
|
||||
this->m_simulator->simulator->changeRemoteAircraftModel(aircraft, originator);
|
||||
Q_ASSERT(this->m_simulatorPlugin);
|
||||
this->m_simulatorPlugin->simulator->changeRemoteAircraftModel(aircraft, originator);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_changedRemoteAircraftEnabled(const CSimulatedAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
Q_ASSERT(this->m_simulator);
|
||||
this->m_simulator->simulator->changeRemoteAircraftEnabled(aircraft, originator);
|
||||
Q_ASSERT(this->m_simulatorPlugin);
|
||||
this->m_simulatorPlugin->simulator->changeRemoteAircraftEnabled(aircraft, originator);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_updateSimulatorCockpitFromContext(const CAircraft &ownAircraft, const QString &originator)
|
||||
@@ -627,19 +639,19 @@ namespace BlackCore
|
||||
// todo:
|
||||
// This was previously an assert and it should be one again in the future.
|
||||
// This slot should not even be called when no simulator is available.
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
// Do something if no simulator is running
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
|
||||
// avoid loops
|
||||
if (originator.isEmpty() || originator == IContextSimulator::InterfaceName()) { return; }
|
||||
|
||||
// update
|
||||
this->m_simulator->simulator->updateOwnSimulatorCockpit(ownAircraft, originator);
|
||||
this->m_simulatorPlugin->simulator->updateOwnSimulatorCockpit(ownAircraft, originator);
|
||||
}
|
||||
|
||||
void CContextSimulator::settingsChanged(uint type)
|
||||
@@ -653,7 +665,7 @@ namespace BlackCore
|
||||
CSimulatorPluginInfo plugin = getIContextSettings()->getSimulatorSettings().getSelectedPlugin();
|
||||
|
||||
// no simulator loaded yet, listen
|
||||
if (!m_simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
stopSimulatorListeners();
|
||||
if (plugin.isUnspecified())
|
||||
@@ -670,58 +682,58 @@ namespace BlackCore
|
||||
// time sync
|
||||
bool timeSync = settingsSim.isTimeSyncEnabled();
|
||||
CTime syncOffset = settingsSim.getSyncTimeOffset();
|
||||
m_simulator->simulator->setTimeSynchronization(timeSync, syncOffset);
|
||||
m_simulatorPlugin->simulator->setTimeSynchronization(timeSync, syncOffset);
|
||||
}
|
||||
}
|
||||
|
||||
CPixmap CContextSimulator::iconForModel(const QString &modelString) const
|
||||
{
|
||||
if (!this->m_simulator)
|
||||
if (!this->m_simulatorPlugin)
|
||||
{
|
||||
return CPixmap();
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->iconForModel(modelString);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->iconForModel(modelString);
|
||||
}
|
||||
|
||||
void CContextSimulator::enableDebugMessages(bool driver, bool interpolator)
|
||||
{
|
||||
if (!this->m_simulator)
|
||||
if (!this->m_simulatorPlugin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->enableDebugMessages(driver, interpolator);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->enableDebugMessages(driver, interpolator);
|
||||
}
|
||||
|
||||
void CContextSimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
this->m_simulator->simulator->highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
this->m_simulatorPlugin->simulator->highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CContextSimulator::isPaused() const
|
||||
{
|
||||
if (!this->m_simulator)
|
||||
if (!this->m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->isPaused();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->isPaused();
|
||||
}
|
||||
|
||||
bool CContextSimulator::isSimulating() const
|
||||
{
|
||||
if (!this->m_simulator)
|
||||
if (!this->m_simulatorPlugin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_simulator->simulator);
|
||||
return m_simulator->simulator->isSimulating();
|
||||
Q_ASSERT(m_simulatorPlugin->simulator);
|
||||
return m_simulatorPlugin->simulator->isSimulating();
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_simulatorStarted(QObject *listener)
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* Network simulator concrete implementation
|
||||
*/
|
||||
//! Network simulator concrete implementation
|
||||
class CContextSimulator : public IContextSimulator
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -39,11 +37,11 @@ namespace BlackCore
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CContextSimulator();
|
||||
|
||||
|
||||
//! Lazy-loads the driver, instantiates the factory and returns it.
|
||||
//! \return nullptr if no corresponding driver was found or an error occured during loading it.
|
||||
//! \todo Consider moving to private scope.
|
||||
ISimulatorFactory* getSimulatorFactory(const BlackMisc::Simulation::CSimulatorPluginInfo& simulator);
|
||||
ISimulatorFactory *getSimulatorFactory(const BlackMisc::Simulation::CSimulatorPluginInfo &simulator);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -65,8 +63,11 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::isSimulating
|
||||
virtual bool isSimulating() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const override;
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup()
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAirportsInRange
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
@@ -124,13 +125,13 @@ namespace BlackCore
|
||||
|
||||
//! \copydoc IContextSimulator::loadSimulatorPluginFromSettings()
|
||||
virtual bool loadSimulatorPluginFromSettings() override;
|
||||
|
||||
|
||||
//! \copydoc IContextSimulator::listenForSimulator()
|
||||
virtual void listenForSimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override;
|
||||
|
||||
|
||||
//! \copydoc IContextSimulator::listenForAllSimulators()
|
||||
virtual void listenForAllSimulators() override;
|
||||
|
||||
|
||||
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
||||
virtual void listenForSimulatorFromSettings() override;
|
||||
|
||||
@@ -150,7 +151,7 @@ namespace BlackCore
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
|
||||
//! Register myself in DBus
|
||||
@@ -173,7 +174,7 @@ namespace BlackCore
|
||||
|
||||
//! Text message received
|
||||
void ps_textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
|
||||
//! Listener reports the simulator has started
|
||||
void ps_simulatorStarted(QObject *listener);
|
||||
|
||||
@@ -191,34 +192,34 @@ namespace BlackCore
|
||||
void ps_updateSimulatorCockpitFromContext(const BlackMisc::Aviation::CAircraft &ownAircraft, const QString &originator);
|
||||
|
||||
private:
|
||||
//! \brief find and catalog all simulator plugins
|
||||
//! A simple struct containing all info about the plugin.
|
||||
//! \todo Would we want to use m_member style here?
|
||||
struct PluginData
|
||||
{
|
||||
PluginData(const BlackMisc::Simulation::CSimulatorPluginInfo &info, ISimulatorFactory *factory, ISimulatorListener *listener, ISimulator *simulator, const QString &fileName) :
|
||||
info(info), factory(factory), listener(listener), simulator(simulator), fileName(fileName) {}
|
||||
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo info;
|
||||
ISimulatorFactory *factory = nullptr; //!< Lazy-loaded, nullptr by default
|
||||
ISimulatorListener *listener = nullptr; //!< Listener instance, nullptr by default
|
||||
ISimulator *simulator = nullptr; //!< The simulator itself (always nullptr unless it is the currently working one)
|
||||
QString fileName; //!< Plugin file name (relative to plugins/simulator)
|
||||
};
|
||||
|
||||
//! Find and catalog all simulator plugins
|
||||
void findSimulatorPlugins();
|
||||
|
||||
//! \brief call stop() on all loaded listeners
|
||||
//! Call stop() on all loaded listeners
|
||||
void stopSimulatorListeners();
|
||||
|
||||
struct PluginData;
|
||||
|
||||
//! \brief Locate PluginData (linear search)
|
||||
PluginData* findPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
/*!
|
||||
* A simple struct containing all info about the plugin.
|
||||
*/
|
||||
struct PluginData {
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo info;
|
||||
ISimulatorFactory *factory; //!< Lazy-loaded, nullptr by default
|
||||
ISimulatorListener *listener; //!< Listener instance, nullptr by default
|
||||
ISimulator *simulator; //!< The simulator itself (always nullptr unless it is the currently working one)
|
||||
QString fileName; //!< Plugin file name (relative to plugins/simulator)
|
||||
};
|
||||
|
||||
//! Locate PluginData (linear search)
|
||||
PluginData *findPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
QDir m_pluginsDir;
|
||||
QList<PluginData> m_simulatorPlugins;
|
||||
PluginData *m_simulator = nullptr; //!< Currently loaded simulator plugin
|
||||
QFuture<bool> m_canConnectResult;
|
||||
PluginData *m_simulatorPlugin = nullptr; //!< Currently loaded simulator plugin
|
||||
BlackMisc::CRegularThread m_listenersThread;
|
||||
QSignalMapper* m_mapper;
|
||||
QSignalMapper *m_mapper = nullptr;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -104,9 +104,14 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<CAircraftIcao>(QLatin1Literal("getIcaoForModelString"), modelString);
|
||||
}
|
||||
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorInfo() const
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorPluginInfo() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorPluginInfo>(QLatin1Literal("getSimulatorInfo"));
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorPluginInfo>(QLatin1Literal("getSimulatorPluginInfo"));
|
||||
}
|
||||
|
||||
CSimulatorSetup CContextSimulatorProxy::getSimulatorSetup() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorSetup>(QLatin1Literal("getSimulatorSetup"));
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::setTimeSynchronization(bool enable, CTime offset)
|
||||
@@ -173,17 +178,17 @@ namespace BlackCore
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("loadSimulatorPluginFromSettings"));
|
||||
}
|
||||
|
||||
|
||||
void CContextSimulatorProxy::listenForSimulator(const CSimulatorPluginInfo &simulatorInfo)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulator"), simulatorInfo);
|
||||
}
|
||||
|
||||
|
||||
void CContextSimulatorProxy::listenForAllSimulators()
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForAllSimulators"));
|
||||
}
|
||||
|
||||
|
||||
void CContextSimulatorProxy::listenForSimulatorFromSettings()
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulatorFromSettings"));
|
||||
|
||||
@@ -44,9 +44,6 @@ namespace BlackCore
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginList()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
@@ -80,8 +77,14 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getIcaoForModelString
|
||||
virtual BlackMisc::Aviation::CAircraftIcao getIcaoForModelString(const QString &modelString) const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorInfo() const override;
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginList()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual bool setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
@@ -245,6 +245,11 @@ namespace BlackCore
|
||||
return m_simulatorPluginInfo;
|
||||
}
|
||||
|
||||
const CSimulatorSetup &CSimulatorCommon::getSimulatorSetup() const
|
||||
{
|
||||
return m_simulatorSetup;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::deleteAllRenderingRestrictions()
|
||||
{
|
||||
if (!isRenderingEnabled()) { return; }
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackcore/interpolator.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
@@ -62,19 +63,11 @@ namespace BlackCore
|
||||
//! Simulator running?
|
||||
virtual bool isSimulating() const = 0;
|
||||
|
||||
//! Get the simulator info
|
||||
//! Get the simulator info (metadata of plugin)
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const = 0;
|
||||
|
||||
//! Originator
|
||||
const QString &simulatorOriginator()
|
||||
{
|
||||
// string is generated once, the timestamp allows to use multiple
|
||||
// components (as long as they are not generated at the same ms)
|
||||
static const QString o = QString("SIMULATOR:").append(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||
return o;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Get the setup (simulator environemnt)
|
||||
virtual const BlackMisc::Simulation::CSimulatorSetup &getSimulatorSetup() const = 0;
|
||||
|
||||
//! Connect to simulator
|
||||
virtual bool connectTo() = 0;
|
||||
@@ -174,6 +167,15 @@ namespace BlackCore
|
||||
//! Is rendering enabled
|
||||
virtual bool isRenderingEnabled() const = 0;
|
||||
|
||||
//! Originator
|
||||
const QString &simulatorOriginator()
|
||||
{
|
||||
// string is generated once, the timestamp allows to use multiple
|
||||
// components (as long as they are not generated at the same ms)
|
||||
static const QString o = QString("SIMULATOR:").append(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||
return o;
|
||||
}
|
||||
|
||||
signals:
|
||||
//! Simulator combined status
|
||||
void simulatorStatusChanged(int status);
|
||||
@@ -310,6 +312,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup
|
||||
virtual const BlackMisc::Simulation::CSimulatorSetup &getSimulatorSetup() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::deleteAllRenderingRestrictions
|
||||
virtual void deleteAllRenderingRestrictions();
|
||||
|
||||
@@ -343,6 +348,7 @@ namespace BlackCore
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
QTimer *m_oneSecondTimer = nullptr; //!< timer
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
BlackMisc::Simulation::CSimulatorSetup m_simulatorSetup; //!< setup object
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
int m_maxRenderedAircraft = MaxAircraftInfinite; //!< max.rendered aircraft
|
||||
|
||||
@@ -108,8 +108,9 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
int p = port.toInt();
|
||||
|
||||
//! \todo filename is only available if driver has been loaded
|
||||
QString fileName = this->getIContextSimulator()->getSimulatorInfo().getSimulatorSetupValueAsString(CFsxSimulatorSetup::SetupSimConnectCfgFile);
|
||||
QString fileName = this->getIContextSimulator()->getSimulatorSetup().getStringValue(CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename());
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("Invalid or empty filename empty, driver loaded?");
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace BlackGui
|
||||
if (!this->getIContextSimulator()->isSimulating()) {
|
||||
this->addOrUpdateByName("info",
|
||||
tr("Simulator (%1) not yet running").arg(
|
||||
getIContextSimulator()->getSimulatorInfo().getSimulator()
|
||||
getIContextSimulator()->getSimulatorPluginInfo().getSimulator()
|
||||
),
|
||||
CIcons::StandardIconWarning16);
|
||||
return;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace BlackGui
|
||||
|
||||
int CNameVariantPairModel::getRowIndexForName(const QString &name) const
|
||||
{
|
||||
int rowIndex = this->m_container.getNameRowIndex(name);
|
||||
int rowIndex = this->m_container.getIndexForName(name);
|
||||
return rowIndex;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace BlackGui
|
||||
bool CNameVariantPairModel::containsNameValue(const QString &name, const BlackMisc::CVariant &value) const
|
||||
{
|
||||
int rowIndex = this->getRowIndexForName(name);
|
||||
if (rowIndex < 0) return false;
|
||||
if (rowIndex < 0) { return false; }
|
||||
QModelIndex i = this->index(rowIndex, 0);
|
||||
const CNameVariantPair cv = this->at(i);
|
||||
return value == cv.toCVariant();
|
||||
|
||||
@@ -22,9 +22,7 @@ namespace BlackGui
|
||||
namespace Models
|
||||
{
|
||||
|
||||
/*!
|
||||
* Simple model displaying name / variant values
|
||||
*/
|
||||
//! Simple model displaying name / variant values
|
||||
class CNameVariantPairModel : public CListModelBase<BlackMisc::CNameVariantPair, BlackMisc::CNameVariantPairList>
|
||||
{
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/simulation/simulatorinfolist.h"
|
||||
#include "blackmisc/simulation/setsimulator.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
|
||||
@@ -39,4 +40,5 @@ void BlackMisc::Simulation::registerMetadata()
|
||||
CAircraftModelList::registerMetadata();
|
||||
CSimulatedAircraft::registerMetadata();
|
||||
CSimulatedAircraftList::registerMetadata();
|
||||
CSimulatorSetup::registerMetadata();
|
||||
}
|
||||
|
||||
@@ -14,32 +14,17 @@
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CNameVariantPair::CNameVariantPair(const QString &name, const CVariant &variant, const CIcon &icon)
|
||||
: m_name(name), m_variant(variant), m_icon(icon)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
const CIcon &CNameVariantPair::getIcon() const
|
||||
{
|
||||
return this->m_icon;
|
||||
}
|
||||
CIcon CNameVariantPair::toIcon() const { return m_icon; }
|
||||
|
||||
/*
|
||||
* Icon?
|
||||
*/
|
||||
bool CNameVariantPair::hasIcon() const
|
||||
{
|
||||
return this->getIcon().isSet();
|
||||
return this->m_icon.isSet();
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to string
|
||||
*/
|
||||
QString CNameVariantPair::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->m_name);
|
||||
@@ -47,9 +32,6 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
CVariant CNameVariantPair::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
@@ -60,18 +42,11 @@ namespace BlackMisc
|
||||
return CVariant(this->m_name);
|
||||
case IndexVariant:
|
||||
return this->m_variant;
|
||||
case IndexIcon:
|
||||
return this->m_icon.toCVariant();
|
||||
case IndexPixmap:
|
||||
return CVariant(this->m_icon.toPixmap());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index (setter)
|
||||
*/
|
||||
void CNameVariantPair::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
@@ -104,5 +79,4 @@ namespace BlackMisc
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
/*!
|
||||
* Value / variant pair
|
||||
*/
|
||||
//! Value / variant pair
|
||||
class CNameVariantPair : public CValueObject<CNameVariantPair>
|
||||
{
|
||||
public:
|
||||
@@ -28,9 +26,7 @@ namespace BlackMisc
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexName = BlackMisc::CPropertyIndex::GlobalIndexCNameVariantPair,
|
||||
IndexVariant,
|
||||
IndexIcon,
|
||||
IndexPixmap
|
||||
IndexVariant
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
@@ -48,11 +44,14 @@ namespace BlackMisc
|
||||
//! Set name.
|
||||
void setName(const QString &name) { this->m_name = name; }
|
||||
|
||||
//! Name available?
|
||||
bool hasName() const { return !this->m_name.isEmpty(); }
|
||||
|
||||
//! Set variant.
|
||||
void setVariant(const CVariant &variant) { m_variant = variant; }
|
||||
|
||||
//! Icon
|
||||
const CIcon &getIcon() const;
|
||||
//! \copydoc CValueObject::toIcon()
|
||||
virtual BlackMisc::CIcon toIcon() const override;
|
||||
|
||||
//! Has icon
|
||||
bool hasIcon() const;
|
||||
|
||||
@@ -12,30 +12,54 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CNameVariantPairList::CNameVariantPairList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CNameVariantPairList::CNameVariantPairList(const CSequence<CNameVariantPair> &other) :
|
||||
CSequence<CNameVariantPair>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Name contained?
|
||||
*/
|
||||
bool CNameVariantPairList::containsName(const QString &name)const
|
||||
{
|
||||
return this->contains(&CNameVariantPair::getName, name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Name index
|
||||
*/
|
||||
int CNameVariantPairList::getNameRowIndex(const QString &name) const
|
||||
CNameVariantPair CNameVariantPairList::getValue(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return CNameVariantPair(); }
|
||||
return this->findBy(&CNameVariantPair::getName, name).frontOrDefault();
|
||||
}
|
||||
|
||||
CVariant CNameVariantPairList::getVariantValue(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return CVariant(); }
|
||||
return getValue(name).getVariant();
|
||||
}
|
||||
|
||||
QString CNameVariantPairList::getValueAsString(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return QString(); }
|
||||
CVariant cs(getValue(name).getVariant());
|
||||
if (cs.isNull() || !cs.canConvert<QString>()) { return QString(); }
|
||||
return cs.value<QString>();
|
||||
}
|
||||
|
||||
bool CNameVariantPairList::addOrReplaceValue(const QString &name, const CVariant &value, const CIcon &icon)
|
||||
{
|
||||
if (name.isEmpty()) { return false; }
|
||||
int i = getIndexForName(name);
|
||||
if (i < 0)
|
||||
{
|
||||
this->push_back(CNameVariantPair(name, value, icon));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this)[i] = CNameVariantPair(name, value, icon);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int CNameVariantPairList::getIndexForName(const QString &name) const
|
||||
{
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
@@ -47,9 +71,6 @@ namespace BlackMisc
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CNameVariantPairList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CNameVariantPair>>();
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of name/variant pairs.
|
||||
*/
|
||||
//! Value object encapsulating a list of name/variant pairs
|
||||
//! Currently name must be unique
|
||||
class CNameVariantPairList : public CSequence<CNameVariantPair>
|
||||
{
|
||||
public:
|
||||
@@ -30,12 +29,25 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CNameVariantPairList(const CSequence<CNameVariantPair> &other);
|
||||
|
||||
//! Get name index
|
||||
int getNameRowIndex(const QString &name) const;
|
||||
//! Get name's index, -1 if not found
|
||||
int getIndexForName(const QString &name) const;
|
||||
|
||||
//! Contains name
|
||||
bool containsName(const QString &name) const;
|
||||
|
||||
//! Get value
|
||||
CNameVariantPair getValue(const QString &name) const;
|
||||
|
||||
//! Get pair's variant value or default if not existing
|
||||
CVariant getVariantValue(const QString &name) const;
|
||||
|
||||
//! Get pair's variant value as string (empty if not existing)
|
||||
QString getValueAsString(const QString &name) const;
|
||||
|
||||
//! Add value, if name already exists replace (true)
|
||||
//! If one is sure(!) the name does not exists, \sa push_back() can be used
|
||||
bool addOrReplaceValue(const QString &name, const CVariant &value, const CIcon &icon = CIcon());
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
|
||||
@@ -58,10 +58,11 @@ namespace BlackMisc
|
||||
GlobalIndexCSimulatedAircraft = 4400,
|
||||
GlobalIndexCAircraftMapping = 4500,
|
||||
GlobalIndexCTextMessage = 4600,
|
||||
GlobalIndexCVoiceRoom = 5000,
|
||||
GlobalIndexCSettingKeyboardHotkey = 6000,
|
||||
GlobalIndexCAircraftCfgEntries = 7000,
|
||||
GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise
|
||||
GlobalIndexCSimulatorSetup = 4700,
|
||||
GlobalIndexCAircraftCfgEntries = 4800,
|
||||
GlobalIndexCVoiceRoom = 6000,
|
||||
GlobalIndexCSettingKeyboardHotkey = 7000,
|
||||
GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise, do be removed if no longer needed
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -24,18 +25,29 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
void CFsxSimulatorSetup::init()
|
||||
CSimulatorSetup CFsxSimulatorSetup::getInitialSetup()
|
||||
{
|
||||
CSimulatorSetup::init();
|
||||
this->m_setup.addValue(SetupSimConnectCfgFile, CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
CSimulatorSetup s;
|
||||
s.setValue(KeyLocalSimConnectCfgFilename(), CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
|
||||
if (CProject::isCompiledWithFsxSupport())
|
||||
{
|
||||
// set FSX path
|
||||
QString fsxPath = CFsCommonUtil::fsxDirFromRegistry();
|
||||
if (!fsxPath.isEmpty()) this->m_setup.value(CSimulatorSetup::SetupSimPath, CVariant(fsxPath));
|
||||
if (!fsxPath.isEmpty())
|
||||
{
|
||||
s.setSimulatorInstallationDirectory(fsxPath);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
const QString &CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename()
|
||||
{
|
||||
static const QString k("fsx/simConnectCfgFilename"); return k;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -21,28 +21,20 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
/*!
|
||||
* Simulator settings for FSX Flight simulators
|
||||
*/
|
||||
class CFsxSimulatorSetup : public BlackMisc::Simulation::CSimulatorSetup
|
||||
//! Simulator settings for FSX Flight simulators
|
||||
class CFsxSimulatorSetup
|
||||
{
|
||||
|
||||
public:
|
||||
//! Setup values
|
||||
enum
|
||||
{
|
||||
SetupSimConnectCfgFile = (BlackMisc::CPropertyIndex::GlobalIndexAbuseMode + 100), //!< location of simconnect.cfg file
|
||||
};
|
||||
|
||||
|
||||
//! Default constructor
|
||||
CFsxSimulatorSetup() : BlackMisc::Simulation::CSimulatorSetup() {}
|
||||
|
||||
//! Constructor
|
||||
CFsxSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : BlackMisc::Simulation::CSimulatorSetup(map) {}
|
||||
//! No constructor
|
||||
CFsxSimulatorSetup() = delete;
|
||||
|
||||
//! Init, to be used where FSX runs
|
||||
void init();
|
||||
static BlackMisc::Simulation::CSimulatorSetup getInitialSetup();
|
||||
|
||||
//! Key
|
||||
static const QString &KeyLocalSimConnectCfgFilename();
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace BlackMisc
|
||||
namespace Settings
|
||||
{
|
||||
//! Value object encapsulating information of simulator related settings.
|
||||
//! \deprecated will be removed with new MS settings
|
||||
class CSettingsSimulator : public BlackMisc::CValueObject<CSettingsSimulator>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -44,29 +44,6 @@ namespace BlackMisc
|
||||
return m_name.isEmpty();
|
||||
}
|
||||
|
||||
CVariant CSimulatorPluginInfo::getSimulatorSetupValue(int index) const
|
||||
{
|
||||
return this->m_simsetup.value(index);
|
||||
}
|
||||
|
||||
QString CSimulatorPluginInfo::getSimulatorSetupValueAsString(int index) const
|
||||
{
|
||||
CVariant qv = getSimulatorSetupValue(index);
|
||||
if (qv.canConvert<QString>())
|
||||
{
|
||||
return qv.toQString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorPluginInfo::setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup)
|
||||
{
|
||||
this->m_simsetup = setup;
|
||||
}
|
||||
|
||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
|
||||
@@ -22,22 +22,16 @@ namespace BlackMisc
|
||||
//! Describing a simulator plugin
|
||||
class CSimulatorPluginInfo : public BlackMisc::CValueObject<CSimulatorPluginInfo>
|
||||
{
|
||||
/**
|
||||
* The _name_ property identifies the plugin itself and must be uniqe.
|
||||
*/
|
||||
//! The _name_ property identifies the plugin itself and must be uniqe.
|
||||
Q_PROPERTY(QString getName READ getName)
|
||||
|
||||
/**
|
||||
* The _simulator_ property specifies which simulator the plugin handles.
|
||||
* There cannot be two plugins loaded for the same simulator.
|
||||
* swift enables some features for particular simulators. Currently recognized are:
|
||||
* fsx, fs9, xplane
|
||||
*/
|
||||
//! The _simulator_ property specifies which simulator the plugin handles.
|
||||
//! There cannot be two plugins loaded for the same simulator.
|
||||
//! swift enables some features for particular simulators. Currently recognized are:
|
||||
//! fsx, fs9, xplane
|
||||
Q_PROPERTY(QString getSimulator READ getSimulator)
|
||||
|
||||
/**
|
||||
* The _description_ property provides a short, human-readable description of the plugin.
|
||||
*/
|
||||
//! The _description_ property provides a short, human-readable description of the plugin.
|
||||
Q_PROPERTY(QString getDescription READ getDescription)
|
||||
|
||||
public:
|
||||
@@ -49,15 +43,6 @@ namespace BlackMisc
|
||||
//! Unspecified simulator
|
||||
bool isUnspecified() const;
|
||||
|
||||
//! Single setting value
|
||||
BlackMisc::CVariant getSimulatorSetupValue(int index) const;
|
||||
|
||||
//! Single setting value
|
||||
QString getSimulatorSetupValueAsString(int index) const;
|
||||
|
||||
//! Set single settings
|
||||
void setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup);
|
||||
|
||||
//! Check if the provided plugin metadata is valid.
|
||||
//! Simulator plugin (driver) has to meet the following requirements:
|
||||
//! * implements org.swift.pilotclient.BlackCore.SimulatorInterface;
|
||||
@@ -88,7 +73,6 @@ namespace BlackMisc
|
||||
QString m_simulator;
|
||||
QString m_description;
|
||||
bool m_valid { false };
|
||||
BlackMisc::CPropertyIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -97,8 +81,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, (
|
||||
attr(o.m_name),
|
||||
attr(o.m_simulator),
|
||||
attr(o.m_description),
|
||||
attr(o.m_valid),
|
||||
attr(o.m_simsetup, flags<DisabledForComparison>())
|
||||
attr(o.m_valid)
|
||||
))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorPluginInfo)
|
||||
|
||||
|
||||
@@ -13,14 +13,80 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
void CSimulatorSetup::setSettings(const BlackMisc::CPropertyIndexVariantMap &map)
|
||||
void CSimulatorSetup::setValue(const QString &name, const QString &value)
|
||||
{
|
||||
this->m_setup = map;
|
||||
this->m_data.addOrReplaceValue(name, value);
|
||||
}
|
||||
|
||||
void CSimulatorSetup::init()
|
||||
QString CSimulatorSetup::getStringValue(const QString &name) const
|
||||
{
|
||||
// void
|
||||
return m_data.getValueAsString(name);
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setSimulatorVersion(const QString versionInfo)
|
||||
{
|
||||
this->setValue("all/versionInfo", versionInfo);
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setSimulatorInstallationDirectory(const QString fullFilePath)
|
||||
{
|
||||
this->setValue("all/installDir", fullFilePath);
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::getSimulatorVersion() const
|
||||
{
|
||||
return this->getStringValue("all/versionInfo");
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::getSimulatorInstallationDirectory() const
|
||||
{
|
||||
return this->getStringValue("all/installDir");
|
||||
}
|
||||
|
||||
void CSimulatorSetup::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
qDBusRegisterMetaType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
registerMetaValueType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::convertToQString(bool i18n) const
|
||||
{
|
||||
return m_data.toQString(i18n);
|
||||
}
|
||||
|
||||
CVariant CSimulatorSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexData:
|
||||
return m_data.toCVariant();
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexData:
|
||||
this->m_data.convertFromCVariant(variant.value<QString>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_SIMSETUP_H
|
||||
#define BLACKMISC_SIMULATION_SIMSETUP_H
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATORSETUP_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATORSETUP_H
|
||||
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/namevariantpairlist.h"
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
@@ -20,41 +20,67 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
/*!
|
||||
* \brief Simulator settings for flight simulators
|
||||
* \details Represents the generic part of a simulator setup ("common denominator"),
|
||||
* details kept in specialized classes
|
||||
*/
|
||||
class CSimulatorSetup
|
||||
//! Simulator settings for flight simulators.
|
||||
//! Those are set up at runtime and represent information about the simulator (like a small registry)
|
||||
class CSimulatorSetup : public CValueObject<CSimulatorSetup>
|
||||
{
|
||||
protected:
|
||||
BlackMisc::CPropertyIndexVariantMap m_setup; //!< values describing the simulator setup (path, config files)
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CSimulatorSetup() {}
|
||||
|
||||
//! Constructor
|
||||
CSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &map) : m_setup(map) {}
|
||||
|
||||
public:
|
||||
//! Specific values
|
||||
enum
|
||||
{
|
||||
SetupSimPath = BlackMisc::CPropertyIndex::GlobalIndexAbuseMode
|
||||
IndexData = BlackMisc::CPropertyIndex::GlobalIndexCSimulatorSetup
|
||||
};
|
||||
|
||||
//! Settings
|
||||
BlackMisc::CPropertyIndexVariantMap getSettings() const { return this->m_setup;}
|
||||
//! Default constructor
|
||||
CSimulatorSetup() {}
|
||||
|
||||
//! All values
|
||||
BlackMisc::CNameVariantPairList getData() const { return this->m_data;}
|
||||
|
||||
//! Settings
|
||||
void setSettings(const BlackMisc::CPropertyIndexVariantMap &map);
|
||||
void setData(const BlackMisc::CNameVariantPairList &data) { this->m_data = data; }
|
||||
|
||||
//! Init, to be used where simulator runs
|
||||
void init();
|
||||
//! Set value
|
||||
void setValue(const QString &name, const QString &value);
|
||||
|
||||
//! Get string value
|
||||
QString getStringValue(const QString &name) const;
|
||||
|
||||
//! Simulator version info, something like "FSX 10.3.2"
|
||||
void setSimulatorVersion(const QString versionInfo);
|
||||
|
||||
//! Path where simulator is installed
|
||||
void setSimulatorInstallationDirectory(const QString fullFilePath);
|
||||
|
||||
//! Simulator version info, something like "FSX 10.3.2"
|
||||
QString getSimulatorVersion() const;
|
||||
|
||||
//! Path where simulator is installed
|
||||
QString getSimulatorInstallationDirectory() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Register metadata
|
||||
void static registerMetadata();
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorSetup)
|
||||
BlackMisc::CNameVariantPairList m_data;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorSetup, (o.m_data))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorSetup)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -47,9 +47,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_ASSERT(ownAircraftProvider);
|
||||
Q_ASSERT(remoteAircraftProvider);
|
||||
CFsxSimulatorSetup setup;
|
||||
setup.init(); // this fetches important settings on local side
|
||||
this->m_simulatorPluginInfo.setSimulatorSetup(setup.getSettings());
|
||||
CSimulatorSetup setup(CFsxSimulatorSetup::getInitialSetup());
|
||||
|
||||
m_useFsuipc = false; // do not use FSUIPC at the moment with FSX
|
||||
this->m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this);
|
||||
|
||||
Reference in New Issue
Block a user