mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Issue #77 Break cyclic dependency between CSimulatorInfo and CSimulatorPluginInfo by moving a method from one to the other
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
||||
@@ -218,19 +217,6 @@ namespace BlackMisc
|
||||
m_simulator = (m_simulator ^ static_cast<int>(All)) & static_cast<int>(All);
|
||||
}
|
||||
|
||||
const QString &CSimulatorInfo::toPluginIdentifier() const
|
||||
{
|
||||
static const QString e;
|
||||
if (!this->isSingleSimulator()) { return e; }
|
||||
const Simulator s = getSimulator();
|
||||
if (s.testFlag(FSX)) { return CSimulatorPluginInfo::fsxPluginIdentifier(); }
|
||||
if (s.testFlag(FS9)) { return CSimulatorPluginInfo::fs9PluginIdentifier(); }
|
||||
if (s.testFlag(P3D)) { return CSimulatorPluginInfo::p3dPluginIdentifier(); }
|
||||
if (s.testFlag(XPLANE)) { return CSimulatorPluginInfo::xplanePluginIdentifier(); }
|
||||
if (s.testFlag(FG)) { return CSimulatorPluginInfo::fgPluginIdentifier(); }
|
||||
return e;
|
||||
}
|
||||
|
||||
CStatusMessage CSimulatorInfo::validateSimulatorsForModel() const
|
||||
{
|
||||
CStatusMessage m(this);
|
||||
|
||||
@@ -173,9 +173,6 @@ namespace BlackMisc
|
||||
//! All simulators selected become unselected and vice versa
|
||||
void invertSimulators();
|
||||
|
||||
//! To plugin indentifier, empty string if not single simulator
|
||||
const QString &toPluginIdentifier() const;
|
||||
|
||||
//! Validate simulators for an aircraft model
|
||||
CStatusMessage validateSimulatorsForModel() const;
|
||||
|
||||
|
||||
@@ -67,6 +67,19 @@ namespace BlackMisc
|
||||
return QStringLiteral("%1 (%2)").arg(m_name, m_identifier);
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::identifierFromSimulatorInfo(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
static const QString e;
|
||||
if (!simInfo.isSingleSimulator()) { return e; }
|
||||
const CSimulatorInfo::Simulator s = simInfo.getSimulator();
|
||||
if (s.testFlag(CSimulatorInfo::FSX)) { return CSimulatorPluginInfo::fsxPluginIdentifier(); }
|
||||
if (s.testFlag(CSimulatorInfo::FS9)) { return CSimulatorPluginInfo::fs9PluginIdentifier(); }
|
||||
if (s.testFlag(CSimulatorInfo::P3D)) { return CSimulatorPluginInfo::p3dPluginIdentifier(); }
|
||||
if (s.testFlag(CSimulatorInfo::XPLANE)) { return CSimulatorPluginInfo::xplanePluginIdentifier(); }
|
||||
if (s.testFlag(CSimulatorInfo::FG)) { return CSimulatorPluginInfo::fgPluginIdentifier(); }
|
||||
return e;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::fsxPluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.fsx");
|
||||
|
||||
@@ -70,6 +70,9 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Simulator info to plugin indentifier, empty string if not single simulator
|
||||
static const QString &identifierFromSimulatorInfo(const CSimulatorInfo &);
|
||||
|
||||
//! Plugin identifier (FSX)
|
||||
static const QString &fsxPluginIdentifier();
|
||||
|
||||
|
||||
@@ -486,7 +486,7 @@ namespace BlackSimPlugin
|
||||
// not all drivers are installed, like FS9/FSX on x64
|
||||
CLogMessage(this).validationError(u"No valid plugin in emulated driver for '%1'") << simulator.toQString();
|
||||
const QString sn = simulator.toQString(true);
|
||||
const CSimulatorPluginInfo fakedPlugin = CSimulatorPluginInfo(simulator.toPluginIdentifier(), sn, sn, QStringLiteral("Emulated, but uninstalled '%1'").arg(sn), false);
|
||||
const CSimulatorPluginInfo fakedPlugin = CSimulatorPluginInfo(CSimulatorPluginInfo::identifierFromSimulatorInfo(simulator), sn, sn, QStringLiteral("Emulated, but uninstalled '%1'").arg(sn), false);
|
||||
this->setNewPluginInfo(fakedPlugin, m_multiSettings.getSettings(simulator), settings.getDefaultModel());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user