mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #404 Added human-readable plugin names
* Added new "identifier" attribute in JSON metadata files * "identifier" is now the one that makes plugins unique * "name" attribute is a human-readable name
This commit is contained in:
@@ -138,7 +138,7 @@ namespace BlackCore
|
||||
CSimulatorSetup CContextSimulator::getSimulatorSetup() const
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (!m_simulatorPlugin || !m_simulatorPlugin->simulator)
|
||||
if (!m_simulatorPlugin)
|
||||
{
|
||||
return BlackMisc::Simulation::CSimulatorSetup();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace BlackGui
|
||||
Q_ASSERT(data.canConvert<CSimulatorPluginInfo>());
|
||||
CSimulatorPluginInfo p = data.value<CSimulatorPluginInfo>();
|
||||
|
||||
if (p.getName() == plugin.getName())
|
||||
if (p.getIdentifier() == plugin.getIdentifier())
|
||||
{
|
||||
if (i == this->ui->cb_Plugins->currentIndex())
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
QJsonObject data = json["MetaData"].toObject();
|
||||
if (data["name"].isUndefined() || data["simulator"].isUndefined())
|
||||
if (data.value("identifier").isUndefined() || data.value("simulator").isUndefined())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace BlackMisc
|
||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return QString("%1 (%2)").arg(m_name, m_simulator);
|
||||
return QString("%1 (%2)").arg(m_name, m_identifier);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -22,17 +22,20 @@ namespace BlackMisc
|
||||
//! Describing a simulator plugin
|
||||
class CSimulatorPluginInfo : public BlackMisc::CValueObject<CSimulatorPluginInfo>
|
||||
{
|
||||
//! The _name_ property identifies the plugin itself and must be uniqe.
|
||||
Q_PROPERTY(QString getName READ getName)
|
||||
//! The _identifier_ property identifies the plugin itself and must be uniqe.
|
||||
Q_PROPERTY(QString identifier READ getIdentifier)
|
||||
|
||||
//! The _name_ property is a human-readable plugin name.
|
||||
Q_PROPERTY(QString same READ getName)
|
||||
|
||||
//! The _simulator_ property specifies which simulator the plugin handles.
|
||||
//! There cannot be two plugins loaded for the same simulator.
|
||||
//! swift enables some features for particular simulators. Currently recognized are:
|
||||
//! fsx, fs9, xplane
|
||||
Q_PROPERTY(QString getSimulator READ getSimulator)
|
||||
Q_PROPERTY(QString simulator READ getSimulator)
|
||||
|
||||
//! The _description_ property provides a short, human-readable description of the plugin.
|
||||
Q_PROPERTY(QString getDescription READ getDescription)
|
||||
Q_PROPERTY(QString description READ getDescription)
|
||||
|
||||
public:
|
||||
//! Default constructor
|
||||
@@ -52,7 +55,10 @@ namespace BlackMisc
|
||||
bool isValid() const { return m_valid; }
|
||||
|
||||
//! Equals
|
||||
bool operator==(const CSimulatorPluginInfo &other) { return getName() == other.getName(); }
|
||||
bool operator==(const CSimulatorPluginInfo &other) { return getIdentifier() == other.getIdentifier(); }
|
||||
|
||||
//! Identifier
|
||||
const QString &getIdentifier() const { return m_identifier; }
|
||||
|
||||
//! Name
|
||||
const QString &getName() const { return m_name; }
|
||||
@@ -69,6 +75,7 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo)
|
||||
QString m_identifier;
|
||||
QString m_name;
|
||||
QString m_simulator;
|
||||
QString m_description;
|
||||
@@ -78,6 +85,7 @@ namespace BlackMisc
|
||||
} // ns
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, (
|
||||
attr(o.m_identifier),
|
||||
attr(o.m_name),
|
||||
attr(o.m_simulator),
|
||||
attr(o.m_description),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name" : "swift_generic_fs9",
|
||||
"identifier" : "swift_generic_fs9",
|
||||
"name" : "Microsoft Flight Simulator 2004",
|
||||
"simulator" : "fs9",
|
||||
"description" : "Microsoft Flight Simulator 2004"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name" : "swift_generic_fsx",
|
||||
"identifier" : "swift_generic_fsx",
|
||||
"name" : "Microsoft Flight Simulator X",
|
||||
"simulator" : "fsx",
|
||||
"description" : "Microsoft Flight Simulator X (2006)"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name" : "swift_generic_xplane",
|
||||
"identifier" : "swift_generic_xplane",
|
||||
"name" : "X-Plane",
|
||||
"simulator" : "xplane",
|
||||
"description" : "X-Plane support via the xbus plugin"
|
||||
}
|
||||
Reference in New Issue
Block a user