mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 20:25:34 +08:00
Initial "Auto" option
* Added ContextSimulator::listenForAllSimulators() * Added "auto" option in SettingsSimulatorComponent * Default plugin is UnspecifiedSim, which stands for "auto" option
This commit is contained in:
committed by
Roland Winklmeier
parent
a0033bee02
commit
5b4c2377b6
@@ -171,6 +171,9 @@ namespace BlackCore
|
|||||||
//! Listen for the specific simulator to start, load plugin automatically
|
//! Listen for the specific simulator to start, load plugin automatically
|
||||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) = 0;
|
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) = 0;
|
||||||
|
|
||||||
|
//! Listen for all available simulators
|
||||||
|
virtual void listenForAllSimulators() = 0;
|
||||||
|
|
||||||
//! Listen for simulator as set in settings
|
//! Listen for simulator as set in settings
|
||||||
virtual void listenForSimulatorFromSettings() = 0;
|
virtual void listenForSimulatorFromSettings() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -413,10 +413,22 @@ namespace BlackCore
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextSimulator::listenForAllSimulators()
|
||||||
|
{
|
||||||
|
auto plugins = getAvailableSimulatorPlugins();
|
||||||
|
for (const auto &p: plugins)
|
||||||
|
listenForSimulator(p);
|
||||||
|
}
|
||||||
|
|
||||||
void CContextSimulator::listenForSimulatorFromSettings()
|
void CContextSimulator::listenForSimulatorFromSettings()
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
listenForSimulator(getIContextSettings()->getSimulatorSettings().getSelectedPlugin());
|
|
||||||
|
auto plugin = getIContextSettings()->getSimulatorSettings().getSelectedPlugin();
|
||||||
|
if (plugin.isUnspecified())
|
||||||
|
listenForAllSimulators();
|
||||||
|
else
|
||||||
|
listenForSimulator(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextSimulator::unloadSimulatorPlugin()
|
void CContextSimulator::unloadSimulatorPlugin()
|
||||||
@@ -512,30 +524,31 @@ namespace BlackCore
|
|||||||
void CContextSimulator::settingsChanged(uint type)
|
void CContextSimulator::settingsChanged(uint type)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
Q_ASSERT(this->m_simulator);
|
|
||||||
if (!this->getIContextSettings()) return;
|
|
||||||
auto settingsType = static_cast<IContextSettings::SettingsType>(type);
|
auto settingsType = static_cast<IContextSettings::SettingsType>(type);
|
||||||
if (settingsType != IContextSettings::SettingsSimulator) return;
|
if (settingsType != IContextSettings::SettingsSimulator)
|
||||||
|
return;
|
||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
CSettingsSimulator settingsSim = this->getIContextSettings()->getSimulatorSettings();
|
CSettingsSimulator settingsSim = this->getIContextSettings()->getSimulatorSettings();
|
||||||
CSimulatorInfo plugin = settingsSim.getSelectedPlugin();
|
CSimulatorInfo plugin = getIContextSettings()->getSimulatorSettings().getSelectedPlugin();
|
||||||
if (!this->getSimulatorInfo().isSameSimulator(plugin))
|
|
||||||
{
|
// no simulator loaded yet, listen
|
||||||
if (this->loadSimulatorPlugin(plugin))
|
if (!m_simulator) {
|
||||||
{
|
stopSimulatorListeners();
|
||||||
CLogMessage(this).info("Plugin loaded: '%1'") << plugin.toQString(true);
|
if (plugin.isSameSimulator(CSimulatorInfo::UnspecifiedSim())) {
|
||||||
}
|
listenForAllSimulators();
|
||||||
else
|
} else {
|
||||||
{
|
listenForSimulator(plugin);
|
||||||
CLogMessage(this).error("Cannot load driver: '%1'") << plugin.toQString(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// time sync
|
{
|
||||||
bool timeSync = settingsSim.isTimeSyncEnabled();
|
// time sync
|
||||||
CTime syncOffset = settingsSim.getSyncTimeOffset();
|
bool timeSync = settingsSim.isTimeSyncEnabled();
|
||||||
this->m_simulator->setTimeSynchronization(timeSync, syncOffset);
|
CTime syncOffset = settingsSim.getSyncTimeOffset();
|
||||||
|
m_simulator->setTimeSynchronization(timeSync, syncOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPixmap CContextSimulator::iconForModel(const QString &modelString) const
|
CPixmap CContextSimulator::iconForModel(const QString &modelString) const
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Lazy-loads the driver, instantiates the factory and returns it.
|
//! 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.
|
//! \return nullptr if no corresponding driver was found or an error occured during loading it.
|
||||||
|
//! \todo Consider moving to private scope.
|
||||||
ISimulatorFactory* getSimulatorFactory(const BlackSim::CSimulatorInfo& simulator);
|
ISimulatorFactory* getSimulatorFactory(const BlackSim::CSimulatorInfo& simulator);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -132,6 +133,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextSimulator::listenForSimulator()
|
//! \copydoc IContextSimulator::listenForSimulator()
|
||||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextSimulator::listenForAllSimulators()
|
||||||
|
virtual void listenForAllSimulators() override;
|
||||||
|
|
||||||
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
||||||
virtual void listenForSimulatorFromSettings() override;
|
virtual void listenForSimulatorFromSettings() override;
|
||||||
|
|
||||||
|
|||||||
@@ -189,6 +189,11 @@ namespace BlackCore
|
|||||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulator"), simulatorInfo);
|
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulator"), simulatorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextSimulatorProxy::listenForAllSimulators()
|
||||||
|
{
|
||||||
|
m_dBusInterface->callDBus(QLatin1Literal("listenForAllSimulators"));
|
||||||
|
}
|
||||||
|
|
||||||
void CContextSimulatorProxy::listenForSimulatorFromSettings()
|
void CContextSimulatorProxy::listenForSimulatorFromSettings()
|
||||||
{
|
{
|
||||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulatorFromSettings"));
|
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulatorFromSettings"));
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextSimulator::listenForSimulator()
|
//! \copydoc IContextSimulator::listenForSimulator()
|
||||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextSimulator::listenForAllSimulators()
|
||||||
|
virtual void listenForAllSimulators() override;
|
||||||
|
|
||||||
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
||||||
virtual void listenForSimulatorFromSettings() override;
|
virtual void listenForSimulatorFromSettings() override;
|
||||||
|
|
||||||
|
|||||||
@@ -43,39 +43,35 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSimulator());
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
if (this->getIContextSimulator())
|
|
||||||
|
// set values
|
||||||
|
this->setRestrictedValues();
|
||||||
|
|
||||||
|
ui->cb_Plugins->addItem(tr("Auto"), CSimulatorPluginInfo().toQVariant());
|
||||||
|
|
||||||
|
for (const auto &p: getIContextSimulator()->getAvailableSimulatorPlugins())
|
||||||
{
|
{
|
||||||
QStringList plugins = this->getIContextSimulator()->getAvailableSimulatorPlugins().toStringList(true);
|
ui->cb_Plugins->addItem(p.toQString(), p.toQVariant());
|
||||||
CSimulatorInfo currentPlugin = this->getIContextSimulator()->getSimulatorInfo();
|
|
||||||
this->ui->cb_Plugins->addItems(plugins);
|
|
||||||
this->setCurrentPlugin(currentPlugin);
|
|
||||||
|
|
||||||
// disable / enable driver specific GUI parts
|
|
||||||
bool fsxDriver = this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
|
||||||
this->ui->comp_SettingsSimulatorFsx->setVisible(fsxDriver);
|
|
||||||
|
|
||||||
// time sync
|
|
||||||
bool timeSynced = this->getIContextSimulator()->isTimeSynchronized();
|
|
||||||
this->ui->cb_TimeSync->setChecked(timeSynced);
|
|
||||||
CTime timeOffset = this->getIContextSimulator()->getTimeSynchronizationOffset();
|
|
||||||
this->ui->le_TimeSyncOffset->setText(timeOffset.formattedHrsMin());
|
|
||||||
|
|
||||||
// only with simulator context set GUI values
|
|
||||||
bool connected = this->connect(this->ui->cb_Plugins, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CSettingsSimulatorComponent::ps_pluginHasChanged);
|
|
||||||
Q_ASSERT(connected);
|
|
||||||
connected = this->connect(getIContextSimulator(), &IContextSimulator::restrictedRenderingChanged, this, &CSettingsSimulatorComponent::ps_onRenderingRestricted);
|
|
||||||
Q_ASSERT(connected);
|
|
||||||
Q_UNUSED(connected);
|
|
||||||
|
|
||||||
// set values
|
|
||||||
this->setRestrictedValues();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->getIContextSettings())
|
this->setCurrentPlugin(getIContextSettings()->getSimulatorSettings().getSelectedPlugin());
|
||||||
{
|
|
||||||
connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsSimulatorComponent::ps_settingsHaveChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// disable / enable driver specific GUI parts
|
||||||
|
bool hasFsxDriver =
|
||||||
|
this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(QStringLiteral("fsx"));
|
||||||
|
this->ui->comp_SettingsSimulatorFsx->setVisible(hasFsxDriver);
|
||||||
|
|
||||||
|
// time sync
|
||||||
|
bool timeSynced = this->getIContextSimulator()->isTimeSynchronized();
|
||||||
|
this->ui->cb_TimeSync->setChecked(timeSynced);
|
||||||
|
CTime timeOffset = this->getIContextSimulator()->getTimeSynchronizationOffset();
|
||||||
|
this->ui->le_TimeSyncOffset->setText(timeOffset.formattedHrsMin());
|
||||||
|
|
||||||
|
// max.aircraft
|
||||||
|
this->ui->sb_MaxAircraft->setValue(getIContextSimulator()->getMaxRenderedAircraft());
|
||||||
|
|
||||||
|
connect(this->ui->cb_Plugins, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CSettingsSimulatorComponent::ps_pluginHasChanged);
|
||||||
|
connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsSimulatorComponent::ps_settingsHaveChanged);
|
||||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
||||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||||
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
||||||
@@ -84,7 +80,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSettingsSimulatorComponent::setCurrentPlugin(const CSimulatorInfo &plugin)
|
void CSettingsSimulatorComponent::setCurrentPlugin(const CSimulatorInfo &plugin)
|
||||||
{
|
{
|
||||||
if (plugin.isUnspecified()) return;
|
if (plugin.isUnspecified()) {
|
||||||
|
ui->cb_Plugins->setCurrentIndex(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const QString searchFor = plugin.getShortName();
|
const QString searchFor = plugin.getShortName();
|
||||||
for (int i = 0; i < this->ui->cb_Plugins->count(); ++i)
|
for (int i = 0; i < this->ui->cb_Plugins->count(); ++i)
|
||||||
{
|
{
|
||||||
@@ -119,6 +119,7 @@ namespace BlackGui
|
|||||||
if (!this->getIContextSimulator() || !this->getIContextSettings()) return;
|
if (!this->getIContextSimulator() || !this->getIContextSettings()) return;
|
||||||
|
|
||||||
CSimulatorInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins();
|
CSimulatorInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins();
|
||||||
|
simDrivers.insert(simDrivers.begin(), CSimulatorInfo::UnspecifiedSim());
|
||||||
if (simDrivers.isEmpty())
|
if (simDrivers.isEmpty())
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("No drivers available");
|
CLogMessage(this).error("No drivers available");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace BlackSim
|
|||||||
*/
|
*/
|
||||||
void CSettingsSimulator::initDefaultValues()
|
void CSettingsSimulator::initDefaultValues()
|
||||||
{
|
{
|
||||||
this->m_selectedPlugin = CSimulatorInfo::FSX();
|
this->m_selectedPlugin = CSimulatorInfo::UnspecifiedSim();
|
||||||
this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin());
|
this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin());
|
||||||
this->m_timeSync = false;
|
this->m_timeSync = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user