mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
refs #614, changed matcher and applied changes
* new function in model list * removed all models in matcher, only provider data will be used
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "simulatorfscommon.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h"
|
||||
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -33,41 +33,17 @@ namespace BlackSimPlugin
|
||||
QObject *parent) :
|
||||
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, pluginStorageProvider, weatherGridProvider, parent),
|
||||
m_fsuipc(new CFsuipc()),
|
||||
m_aircraftCfgParser(CAircraftCfgParser::createModelLoader(CSimulatorInfo(info.getIdentifier()))),
|
||||
m_modelMatcher(CAircraftMatcher::AllModes, this)
|
||||
{
|
||||
// hack to init mapper
|
||||
connect(&m_modelMatcher, &CAircraftMatcher::initializationFinished, this, &CSimulatorFsCommon::ps_mapperInitialized);
|
||||
auto modelMappingsProvider = std::unique_ptr<IModelMappingsProvider> { std::make_unique<CModelMappingsProviderVPilot>(true) };
|
||||
m_modelMatcher.setModelMappingProvider(std::move(modelMappingsProvider));
|
||||
|
||||
bool c = connect(m_aircraftCfgParser.get(), &CAircraftCfgParser::loadingFinished, this, &CSimulatorFsCommon::ps_aircraftCfgParsingFinished);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect signal");
|
||||
Q_UNUSED(c);
|
||||
|
||||
//! \todo remove from plugin if data there are cached as well
|
||||
/**
|
||||
CVariant aircraftCfg = getPluginData(this, "aircraft_cfg");
|
||||
if (aircraftCfg.isValid())
|
||||
{
|
||||
// will behave like parsing was finished
|
||||
m_aircraftCfgParser->updateCfgEntriesList(aircraftCfg.value<CAircraftCfgEntriesList>());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aircraftCfgParser->startLoading(CAircraftCfgParser::LoadInBackground);
|
||||
}
|
||||
**/
|
||||
m_aircraftCfgParser->startLoading(CAircraftCfgParser::InBackgroundWithCache);
|
||||
// init mapper
|
||||
CSimulatorInfo sim(info.getIdentifier());
|
||||
this->m_modelMatcher.setModelMappingProvider(
|
||||
std::make_unique<CachedModelSetProvider>(sim, this)
|
||||
);
|
||||
}
|
||||
|
||||
CSimulatorFsCommon::~CSimulatorFsCommon() { }
|
||||
|
||||
void CSimulatorFsCommon::ps_mapperInitialized()
|
||||
{
|
||||
emit this->installedAircraftModelsChanged();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::disconnectFrom()
|
||||
{
|
||||
if (this->m_fsuipc) { this->m_fsuipc->disconnect(); }
|
||||
@@ -125,18 +101,19 @@ namespace BlackSimPlugin
|
||||
|
||||
CAircraftModelList CSimulatorFsCommon::getInstalledModels() const
|
||||
{
|
||||
return m_modelMatcher.getInstalledModelsList();
|
||||
return m_modelMatcher.getMatchingModels();
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::reloadInstalledModels()
|
||||
{
|
||||
m_aircraftCfgParser->startLoading();
|
||||
this->m_modelMatcher.reload();
|
||||
}
|
||||
|
||||
CPixmap CSimulatorFsCommon::iconForModel(const QString &modelString) const
|
||||
{
|
||||
CStatusMessage msg;
|
||||
CPixmap pm(m_aircraftCfgParser->iconForModel(modelString, msg));
|
||||
// CPixmap pm(m_aircraftCfgParser->iconForModel(modelString, msg));
|
||||
CPixmap pm;
|
||||
if (!msg.isEmpty()) { CLogMessage::preformatted(msg);}
|
||||
return pm;
|
||||
}
|
||||
@@ -172,23 +149,5 @@ namespace BlackSimPlugin
|
||||
}
|
||||
CSimulatorCommon::enableDebugMessages(driver, interpolator);
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::unload()
|
||||
{
|
||||
this->m_aircraftCfgParser->cancelLoading();
|
||||
this->m_modelMatcher.cancelInit();
|
||||
CSimulatorCommon::unload();
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::ps_aircraftCfgParsingFinished(bool success)
|
||||
{
|
||||
if (!success) { return; }
|
||||
setPluginData(this, "aircraft_cfg", CVariant::from(m_aircraftCfgParser->getAircraftCfgEntriesList()));
|
||||
m_modelMatcher.setInstalledModels(m_aircraftCfgParser->getAircraftCfgEntriesList().toAircraftModelList());
|
||||
|
||||
// Now the matcher has all required information to be initialized
|
||||
m_modelMatcher.init();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -73,9 +73,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackCore::ISimulator::enableDebugMessages
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::unload
|
||||
virtual void unload() override;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorFsCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
@@ -91,15 +88,14 @@ namespace BlackSimPlugin
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< airports in range of own aircraft
|
||||
|
||||
// cockpit as set in SIM
|
||||
BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 state in simulator
|
||||
BlackMisc::Aviation::CComSystem m_simCom2; //!< cockpit COM2 state in simulator
|
||||
BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 state in simulator
|
||||
BlackMisc::Aviation::CComSystem m_simCom2; //!< cockpit COM2 state in simulator
|
||||
BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator
|
||||
|
||||
// parser / matcher
|
||||
std::unique_ptr<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser
|
||||
BlackMisc::Simulation::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||
|
||||
//! Set own model
|
||||
@@ -107,13 +103,6 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Set own model
|
||||
void setOwnAircraftModel(const QString &modelName);
|
||||
|
||||
protected slots:
|
||||
//! Mapper has been initialized
|
||||
void ps_mapperInitialized();
|
||||
|
||||
//! aircraft.cfg files parsing is finished
|
||||
void ps_aircraftCfgParsingFinished(bool success);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -191,9 +191,6 @@ namespace BlackSimPlugin
|
||||
CAircraftModel aircraftModel(*modelStringsIt, CAircraftModel::TypeDatabaseEntry, QString(), aircraftIcao, livery);
|
||||
m_installedModels.push_back(aircraftModel);
|
||||
}
|
||||
|
||||
m_modelMatcher.setInstalledModels(m_installedModels);
|
||||
m_modelMatcher.init();
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isConnected() const
|
||||
|
||||
Reference in New Issue
Block a user