mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T294, display simulator internals correctly
* view rows not selectable * added settings to ISimulator * ISimulator implements initSimulatorInternals() and sets default values * also display plugin name * XPlane using initSimulatorInternals()
This commit is contained in:
@@ -32,6 +32,7 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Weather;
|
||||
@@ -612,6 +613,10 @@ namespace BlackCore
|
||||
|
||||
connect(sApp, &CApplication::aboutToShutdown, this, &ISimulator::unload, Qt::QueuedConnection);
|
||||
|
||||
// info data
|
||||
m_simulatorInternals.setSimulatorName(this->getSimulatorName());
|
||||
m_simulatorInternals.setSwiftPluginName(this->getSimulatorPluginInfo().toQString());
|
||||
|
||||
// info
|
||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
|
||||
}
|
||||
@@ -724,6 +729,14 @@ namespace BlackCore
|
||||
// void, can be overridden in specialized drivers
|
||||
}
|
||||
|
||||
void ISimulator::initSimulatorInternals()
|
||||
{
|
||||
const CSimulatorSettings s = this->getSimulatorSettings();
|
||||
m_simulatorInternals.setSimulatorName(this->getSimulatorName());
|
||||
m_simulatorInternals.setSwiftPluginName(this->getSimulatorPluginInfo().toQString());
|
||||
m_simulatorInternals.setSimulatorInstallationDirectory(s.getSimulatorDirectory());
|
||||
}
|
||||
|
||||
void ISimulator::rememberElevationAndCG(const CCallsign &callsign, const QString &modelString, const Geo::CElevationPlane &elevation, const CLength &cg)
|
||||
{
|
||||
if (callsign.isEmpty()) { return; }
|
||||
|
||||
@@ -172,6 +172,9 @@ namespace BlackCore
|
||||
//! Reload weather settings
|
||||
void reloadWeatherSettings();
|
||||
|
||||
//! Settings for current simulator
|
||||
BlackMisc::Simulation::Settings::CSimulatorSettings getSimulatorSettings() const { return m_settings.getSettings(this->getSimulatorInfo()); }
|
||||
|
||||
//! Driver will be unloaded
|
||||
virtual void unload();
|
||||
|
||||
@@ -346,6 +349,9 @@ namespace BlackCore
|
||||
virtual void onSwiftDbAirportsRead();
|
||||
//! @}
|
||||
|
||||
//! Init the internals info
|
||||
virtual void initSimulatorInternals();
|
||||
|
||||
//! Parsed in derived classes
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) = 0;
|
||||
|
||||
@@ -512,6 +518,9 @@ namespace BlackCore
|
||||
BlackMisc::CTokenBucket m_limitUpdateAircraftBucket { 5, 100, 5 }; //!< means 50 per second
|
||||
bool m_limitUpdateAircraft = false; //!< limit the update frequency by using BlackMisc::CTokenBucket
|
||||
|
||||
// general settings
|
||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_settings { this }; //!< simulator settings for all simulators
|
||||
|
||||
// weather
|
||||
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
|
||||
@@ -73,6 +73,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CNameVariantPairView" name="tvp_Internals">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace BlackMisc
|
||||
{
|
||||
void CSimulatorInternals::setValue(const QString &name, const QString &value)
|
||||
{
|
||||
this->m_data.addOrReplaceValue(name, value);
|
||||
m_data.addOrReplaceValue(name, value);
|
||||
}
|
||||
|
||||
CVariant CSimulatorInternals::getVariantValue(const QString &name) const
|
||||
@@ -57,6 +57,16 @@ namespace BlackMisc
|
||||
this->setValue("all/simulatorName", name);
|
||||
}
|
||||
|
||||
QString CSimulatorInternals::getSimulatorSwiftPluginName() const
|
||||
{
|
||||
return this->getStringValue("all/pluginName");
|
||||
}
|
||||
|
||||
void CSimulatorInternals::setSwiftPluginName(const QString &name)
|
||||
{
|
||||
this->setValue("all/pluginName", name);
|
||||
}
|
||||
|
||||
QString CSimulatorInternals::getSimulatorVersion() const
|
||||
{
|
||||
return this->getStringValue("all/versionInfo");
|
||||
@@ -82,30 +92,23 @@ namespace BlackMisc
|
||||
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexData:
|
||||
return CVariant::from(m_data);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexData: return CVariant::from(m_data);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexData:
|
||||
this->m_data = variant.to<CNameVariantPairList>();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexData: m_data = variant.to<CNameVariantPairList>(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace BlackMisc
|
||||
//! Set simulator name
|
||||
void setSimulatorName(const QString &name);
|
||||
|
||||
//! Plugin name
|
||||
QString getSimulatorSwiftPluginName() const;
|
||||
|
||||
//! Set plugin name
|
||||
void setSwiftPluginName(const QString &name);
|
||||
|
||||
//! Simulator version info, something like "10.3.2"
|
||||
QString getSimulatorVersion() const;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
m_fsuipc->connect(); // connect FSUIPC too
|
||||
}
|
||||
initSimulatorInternals();
|
||||
this->initSimulatorInternals();
|
||||
m_timerId = startTimer(50);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,17 +45,15 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorFsCommon::initSimulatorInternals()
|
||||
{
|
||||
CSimulatorInternals s;
|
||||
s.setSimulatorName(this->getSimulatorName());
|
||||
s.setSimulatorVersion(this->getSimulatorVersion());
|
||||
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||
CSimulatorPluginCommon::initSimulatorInternals();
|
||||
m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion());
|
||||
m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||
if (m_fsuipc)
|
||||
{
|
||||
const QString v(m_fsuipc->getVersion());
|
||||
if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); }
|
||||
s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
|
||||
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
|
||||
m_simulatorInternals.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
|
||||
}
|
||||
m_simulatorInternals = s;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace BlackSimPlugin
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Init the internal objects
|
||||
virtual void initSimulatorInternals();
|
||||
virtual void initSimulatorInternals() override;
|
||||
|
||||
//! \name When swift DB data are read
|
||||
//! @{
|
||||
|
||||
@@ -370,10 +370,10 @@ namespace BlackSimPlugin
|
||||
this->initSimulatorInternals();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
|
||||
// Internals depends on sim data which take a while to be read
|
||||
// Internals depends on simulator data which take a while to be read
|
||||
// this is a trick and I re-init again after a while (which is not really expensive)
|
||||
const QPointer<CSimulatorFsxCommon> myself(this);
|
||||
QTimer::singleShot(1000, this, [myself]
|
||||
QTimer::singleShot(2500, this, [myself]
|
||||
{
|
||||
if (myself.isNull()) { return; }
|
||||
myself->initSimulatorInternals();
|
||||
@@ -1833,13 +1833,8 @@ namespace BlackSimPlugin
|
||||
void CSimulatorFsxCommon::initSimulatorInternals()
|
||||
{
|
||||
CSimulatorFsCommon::initSimulatorInternals();
|
||||
CSimulatorInternals s = m_simulatorInternals;
|
||||
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX
|
||||
if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); }
|
||||
|
||||
s.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
|
||||
s.setValue("fsx/simConnectVersion", m_simConnectVersion);
|
||||
m_simulatorInternals = s;
|
||||
m_simulatorInternals.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
|
||||
m_simulatorInternals.setValue("fsx/simConnectVersion", m_simConnectVersion);
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::reset()
|
||||
|
||||
@@ -294,6 +294,7 @@ namespace BlackSimPlugin
|
||||
m_trafficProxy = new CXSwiftBusTrafficProxy(m_dBusConnection, this);
|
||||
m_weatherProxy = new CXSwiftBusWeatherProxy(m_dBusConnection, this);
|
||||
|
||||
bool ok = false;
|
||||
if (m_serviceProxy->isValid() && m_trafficProxy->isValid() && m_weatherProxy->isValid() && m_trafficProxy->initialize())
|
||||
{
|
||||
emitOwnAircraftModelChanged(m_serviceProxy->getAircraftModelPath(), m_serviceProxy->getAircraftModelFilename(), m_serviceProxy->getAircraftLivery(),
|
||||
@@ -308,13 +309,15 @@ namespace BlackSimPlugin
|
||||
m_trafficProxy->removeAllPlanes();
|
||||
this->loadCslPackages();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
return true;
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->disconnectFrom();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ok) { this->initSimulatorInternals(); }
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::disconnectFrom()
|
||||
|
||||
Reference in New Issue
Block a user