mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
JSON plugin metadata initial
* Added json files along with FILE macro for all drivers * Get CSimulatorInfo from JSON rather than from ISimulatorFactory
This commit is contained in:
committed by
Roland Winklmeier
parent
c5a1a6048b
commit
afc22397bb
@@ -573,13 +573,15 @@ namespace BlackCore
|
||||
CLogMessage(this).info("Try to load plugin: %1") << fileName;
|
||||
QString pluginPath = m_pluginsDir.absoluteFilePath(fileName);
|
||||
QPluginLoader loader(pluginPath);
|
||||
QJsonObject json = loader.metaData();
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin)
|
||||
{
|
||||
ISimulatorFactory *factory = qobject_cast<ISimulatorFactory *>(plugin);
|
||||
if (factory)
|
||||
{
|
||||
CSimulatorInfo simulatorInfo = factory->getSimulatorInfo();
|
||||
// CSimulatorInfo simulatorInfo = factory->getSimulatorInfo();
|
||||
CSimulatorInfo simulatorInfo(json);
|
||||
m_simulatorFactories.insert(factory);
|
||||
|
||||
ISimulatorListener *listener = factory->createListener(this);
|
||||
|
||||
@@ -257,6 +257,7 @@ namespace BlackCore
|
||||
|
||||
//! Simulator listener instance
|
||||
virtual ISimulatorListener *createListener(QObject *parent = nullptr) = 0;
|
||||
|
||||
};
|
||||
|
||||
//! Common base class with providers, interface and some base functionality
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace BlackSim
|
||||
|
||||
CSimulatorInfo::CSimulatorInfo() : m_fullName("Unknown"), m_shortName("Unknown")
|
||||
{}
|
||||
|
||||
CSimulatorInfo::CSimulatorInfo(const QJsonObject &json)
|
||||
{
|
||||
Q_ASSERT(json["IID"].toString() == "net.vatsim.PilotClient.BlackCore.SimulatorInterface");
|
||||
QJsonObject data = json["MetaData"].toObject();
|
||||
m_fullName = data["full_name"].toString("Unknown");
|
||||
m_shortName = data["short_name"].toString("Unknown");
|
||||
}
|
||||
|
||||
CVariant CSimulatorInfo::getSimulatorSetupValue(int index) const
|
||||
{
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace BlackSim
|
||||
|
||||
//! Constructor
|
||||
CSimulatorInfo(const QString &shortname, const QString &fullname);
|
||||
|
||||
//! This constructor takes a JSON object that comes with the driver.
|
||||
CSimulatorInfo(const QJsonObject& json);
|
||||
|
||||
//! Unspecified simulator
|
||||
bool isUnspecified() const { return this->m_shortName.isEmpty() || this->m_shortName.startsWith("Unspecified", Qt::CaseInsensitive); }
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace BlackSimPlugin
|
||||
class CSimulatorFs9Factory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface" FILE "simulator_fs9.json")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
4
src/plugins/simulator/fs9/simulator_fs9.json
Normal file
4
src/plugins/simulator/fs9/simulator_fs9.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"short_name" : "FS9",
|
||||
"full_name" : "Microsoft Flight Simulator 2004"
|
||||
}
|
||||
4
src/plugins/simulator/fsx/simulator_fsx.json
Normal file
4
src/plugins/simulator/fsx/simulator_fsx.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"short_name" : "FSX",
|
||||
"full_name" : "Microsoft Flight Simulator X (2006)"
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// TODO: @RW, move this string into CProject please
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface" FILE "simulator_fsx.json")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace BlackSimPlugin
|
||||
class CSimulatorXPlaneFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface")
|
||||
Q_PLUGIN_METADATA(IID "org.swift.pilotclient.BlackCore.SimulatorInterface" FILE "simulator_xplane.json")
|
||||
Q_INTERFACES(BlackCore::ISimulatorFactory)
|
||||
|
||||
public:
|
||||
|
||||
4
src/plugins/simulator/xplane/simulator_xplane.json
Normal file
4
src/plugins/simulator/xplane/simulator_xplane.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"short_name" : "XP",
|
||||
"full_name" : "X-Plane"
|
||||
}
|
||||
Reference in New Issue
Block a user