mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #917, fixed plugin ids in wizard
utility functions CSimulatorInfo -> plugin
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0942d007d5
commit
0544ab0193
@@ -8,10 +8,11 @@
|
||||
*/
|
||||
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/db/datastoreutility.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include <QJsonValue>
|
||||
#include <QtGlobal>
|
||||
#include <algorithm>
|
||||
@@ -136,7 +137,7 @@ namespace BlackMisc
|
||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
Simulator s = getSimulator();
|
||||
const Simulator s = getSimulator();
|
||||
QString str;
|
||||
if (s.testFlag(FSX)) { str.append("FSX "); }
|
||||
if (s.testFlag(FS9)) { str.append("FS9 "); }
|
||||
@@ -161,6 +162,18 @@ namespace BlackMisc
|
||||
return set;
|
||||
}
|
||||
|
||||
const QString &CSimulatorInfo::toPluginIdentifier() const
|
||||
{
|
||||
static const QString e;
|
||||
if (!this->isSingleSimulator()) { return e; }
|
||||
const Simulator s = getSimulator();
|
||||
if (s.testFlag(FSX)) { return CSimulatorPluginInfo::fsxPluginIndentifier(); }
|
||||
if (s.testFlag(FS9)) { return CSimulatorPluginInfo::fs9PluginIndentifier(); }
|
||||
if (s.testFlag(P3D)) { return CSimulatorPluginInfo::p3dPluginIndentifier(); }
|
||||
if (s.testFlag(XPLANE)) { return CSimulatorPluginInfo::xplanePluginIndentifier(); }
|
||||
return e;
|
||||
}
|
||||
|
||||
CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d)
|
||||
{
|
||||
Simulator s = fsx ? FSX : None;
|
||||
@@ -188,7 +201,7 @@ namespace BlackMisc
|
||||
{
|
||||
s |= XPLANE;
|
||||
}
|
||||
if (i.contains("3d") || i.contains("prepare") || i.contains("martin") || i.contains("lm") || i.contains("lock"))
|
||||
if (i.contains("3d") || i.contains("prepar") || i.contains("martin") || i.contains("lm") || i.contains("lock"))
|
||||
{
|
||||
s |= P3D;
|
||||
}
|
||||
@@ -260,7 +273,6 @@ namespace BlackMisc
|
||||
return sim;
|
||||
}
|
||||
|
||||
|
||||
CSimulatorInfo CSimulatorInfo::fromDatabaseJson(const QJsonObject &json, const QString prefix)
|
||||
{
|
||||
const bool fsx = CDatastoreUtility::dbBoolStringToBool(json.value(prefix + "simfsx").toString());
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace BlackMisc
|
||||
//! As a set of single simulator info objects
|
||||
QSet<CSimulatorInfo> asSingleSimulatorSet() const;
|
||||
|
||||
//! To plugin indentifier, empty string if not single simulator
|
||||
const QString &toPluginIdentifier() const;
|
||||
|
||||
//! Bool flags to enum
|
||||
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include <QJsonValue>
|
||||
#include <QtGlobal>
|
||||
@@ -49,5 +50,44 @@ namespace BlackMisc
|
||||
return QString("%1 (%2)").arg(m_name, m_identifier);
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::fsxPluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.fsx");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::p3dPluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.p3d");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::fs9PluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.fs9");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::xplanePluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.xplane");
|
||||
return s;
|
||||
}
|
||||
|
||||
QStringList CSimulatorPluginInfo::guessDefaultPlugins()
|
||||
{
|
||||
if (BlackConfig::CBuildConfig::isRunningOnUnixPlatform())
|
||||
{
|
||||
// On UNIX we likely run XP
|
||||
return QStringList { xplanePluginIndentifier() };
|
||||
}
|
||||
|
||||
return QStringList
|
||||
{
|
||||
fsxPluginIndentifier(),
|
||||
p3dPluginIndentifier(),
|
||||
xplanePluginIndentifier()
|
||||
};
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -64,6 +64,21 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Plugin identifier (FSX)
|
||||
static const QString &fsxPluginIndentifier();
|
||||
|
||||
//! Plugin identifier (P3D)
|
||||
static const QString &p3dPluginIndentifier();
|
||||
|
||||
//! Plugin identifier (FS9)
|
||||
static const QString &fs9PluginIndentifier();
|
||||
|
||||
//! Plugin identifier (XPlane)
|
||||
static const QString &xplanePluginIndentifier();
|
||||
|
||||
//! Guess default plugins
|
||||
static QStringList guessDefaultPlugins();
|
||||
|
||||
private:
|
||||
QString m_identifier;
|
||||
QString m_name;
|
||||
|
||||
Reference in New Issue
Block a user