mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Ref T286, renaming / adding utility functions in simulator info
This commit is contained in:
@@ -81,13 +81,13 @@ namespace BlackMisc
|
||||
|
||||
// sims
|
||||
const CSimulatorInfo sim(getSimulator());
|
||||
QString flag = CDatastoreUtility::boolToDbYN(sim.fsx());
|
||||
QString flag = CDatastoreUtility::boolToDbYN(sim.isFSX());
|
||||
obj.insert("simfsx", QJsonValue(flag));
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.p3d());
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.isP3D());
|
||||
obj.insert("simp3d", QJsonValue(flag));
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.fs9());
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.isFS9());
|
||||
obj.insert("simfs9", QJsonValue(flag));
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.xplane());
|
||||
flag = CDatastoreUtility::boolToDbYN(sim.isXPlane());
|
||||
obj.insert("simxplane", QJsonValue(flag));
|
||||
|
||||
// foreign keys
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace BlackMisc
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Single simulator");
|
||||
std::unique_ptr<IAircraftModelLoader> loader;
|
||||
if (simulator.xplane())
|
||||
if (simulator.isXPlane())
|
||||
{
|
||||
loader = std::make_unique<CAircraftModelLoaderXPlane>();
|
||||
}
|
||||
|
||||
@@ -170,16 +170,16 @@ namespace BlackMisc
|
||||
if (docDir.isEmpty()) { return ""; }
|
||||
if (!simulator.isSingleSimulator() || !simulator.isFsxP3DFamily()) return "";
|
||||
|
||||
const QString iniDir = CFileUtils::appendFilePaths(docDir, simulator.p3d() ? "Prepar3D v4 Files" : "Flight Simulator X Files");
|
||||
const QString iniDir = CFileUtils::appendFilePaths(docDir, simulator.isP3D() ? "Prepar3D v4 Files" : "Flight Simulator X Files");
|
||||
if (getSimConnectIniFileDirectories().isEmpty()) { return iniDir; }
|
||||
|
||||
for (const QString &dir : getSimConnectIniFileDirectories())
|
||||
{
|
||||
if (simulator.p3d())
|
||||
if (simulator.isP3D())
|
||||
{
|
||||
if (dir.contains("Prepar3D", Qt::CaseInsensitive)) { return dir; }
|
||||
}
|
||||
else if (simulator.fsx())
|
||||
else if (simulator.isFSX())
|
||||
{
|
||||
if (dir.contains("Flight Simulator", Qt::CaseInsensitive)) { return dir; }
|
||||
}
|
||||
|
||||
@@ -58,29 +58,29 @@ namespace BlackMisc
|
||||
return m_simulator < 1;
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::fsx() const
|
||||
bool CSimulatorInfo::isFSX() const
|
||||
{
|
||||
return getSimulator().testFlag(FSX);
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::fs9() const
|
||||
bool CSimulatorInfo::isFS9() const
|
||||
{
|
||||
return getSimulator().testFlag(FS9);
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::xplane() const
|
||||
bool CSimulatorInfo::isXPlane() const
|
||||
{
|
||||
return getSimulator().testFlag(XPLANE);
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::p3d() const
|
||||
bool CSimulatorInfo::isP3D() const
|
||||
{
|
||||
return getSimulator().testFlag(P3D);
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::isAnySimulator() const
|
||||
{
|
||||
return fsx() || fs9() || xplane() || p3d();
|
||||
return isFSX() || isFS9() || isXPlane() || isP3D();
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::isSingleSimulator() const
|
||||
@@ -100,30 +100,30 @@ namespace BlackMisc
|
||||
|
||||
bool CSimulatorInfo::isAllSimulators() const
|
||||
{
|
||||
return fsx() && fs9() && xplane() && p3d();
|
||||
return isFSX() && isFS9() && isXPlane() && isP3D();
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::isMicrosoftSimulator() const
|
||||
{
|
||||
return fsx() || fs9();
|
||||
return isFSX() || isFS9();
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::isMicrosoftOrPrepare3DSimulator() const
|
||||
{
|
||||
return isMicrosoftSimulator() || p3d();
|
||||
return isMicrosoftSimulator() || isP3D();
|
||||
}
|
||||
|
||||
bool CSimulatorInfo::isFsxP3DFamily() const
|
||||
{
|
||||
return fsx() || p3d();
|
||||
return isFSX() || isP3D();
|
||||
}
|
||||
|
||||
int CSimulatorInfo::numberSimulators() const
|
||||
{
|
||||
int c = fs9() ? 1 : 0;
|
||||
if (fsx()) { c++; }
|
||||
if (xplane()) { c++; }
|
||||
if (p3d()) { c++; }
|
||||
int c = isFS9() ? 1 : 0;
|
||||
if (isFSX()) { c++; }
|
||||
if (isXPlane()) { c++; }
|
||||
if (isP3D()) { c++; }
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -265,9 +265,9 @@ namespace BlackMisc
|
||||
{
|
||||
return CSimulatorInfo("XPLANE");
|
||||
}
|
||||
if (locallyInstalled.p3d()) { return CSimulatorInfo("P3D"); }
|
||||
if (locallyInstalled.fsx()) { return CSimulatorInfo("FSX"); }
|
||||
if (locallyInstalled.fs9()) { return CSimulatorInfo("FS9"); }
|
||||
if (locallyInstalled.isP3D()) { return CSimulatorInfo("P3D"); }
|
||||
if (locallyInstalled.isFSX()) { return CSimulatorInfo("FSX"); }
|
||||
if (locallyInstalled.isFS9()) { return CSimulatorInfo("FS9"); }
|
||||
|
||||
// fallback
|
||||
return CSimulatorInfo("P3D");
|
||||
@@ -367,10 +367,10 @@ namespace BlackMisc
|
||||
m_counts[4] = m_counts[4] + 1;
|
||||
return;
|
||||
}
|
||||
if (simulator.fsx()) { m_counts[0]++; }
|
||||
if (simulator.p3d()) { m_counts[1]++; }
|
||||
if (simulator.fs9()) { m_counts[2]++; }
|
||||
if (simulator.xplane()) { m_counts[3]++; }
|
||||
if (simulator.isFSX()) { m_counts[0]++; }
|
||||
if (simulator.isP3D()) { m_counts[1]++; }
|
||||
if (simulator.isFS9()) { m_counts[2]++; }
|
||||
if (simulator.isXPlane()) { m_counts[3]++; }
|
||||
}
|
||||
|
||||
int CCountPerSimulator::internalIndex(const CSimulatorInfo &simulator)
|
||||
|
||||
@@ -78,22 +78,22 @@ namespace BlackMisc
|
||||
CSimulatorInfo(int flagsAsInt);
|
||||
|
||||
//! Constructor
|
||||
CSimulatorInfo(bool fsx, bool fs9, bool xp, bool p3d);
|
||||
CSimulatorInfo(bool isFSX, bool isFS9, bool xp, bool isP3D);
|
||||
|
||||
//! Unspecified simulator
|
||||
bool isUnspecified() const;
|
||||
|
||||
//! FSX?
|
||||
bool fsx() const;
|
||||
bool isFSX() const;
|
||||
|
||||
//! FS9?
|
||||
bool fs9() const;
|
||||
bool isFS9() const;
|
||||
|
||||
//! XPlane
|
||||
bool xplane() const;
|
||||
bool isXPlane() const;
|
||||
|
||||
//! P3D?
|
||||
bool p3d() const;
|
||||
bool isP3D() const;
|
||||
|
||||
//! Any simulator?
|
||||
bool isAnySimulator() const;
|
||||
@@ -138,7 +138,7 @@ namespace BlackMisc
|
||||
void addSimulator(Simulator s) { m_simulator |= static_cast<int>(s); }
|
||||
|
||||
//! Add simulator
|
||||
void addSimulator(CSimulatorInfo simulatorInfo) { this->addSimulator(simulatorInfo.getSimulator()); }
|
||||
void addSimulator(const CSimulatorInfo &simulatorInfo) { this->addSimulator(simulatorInfo.getSimulator()); }
|
||||
|
||||
//! All simulators
|
||||
void setAllSimulators() { setSimulator(All); }
|
||||
@@ -162,7 +162,7 @@ namespace BlackMisc
|
||||
const QString &toPluginIdentifier() const;
|
||||
|
||||
//! Bool flags to enum
|
||||
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
|
||||
static Simulator boolToFlag(bool isFSX, bool isFS9, bool xp, bool isP3D);
|
||||
|
||||
//! Identifer, as provided by plugin
|
||||
static Simulator identifierToSimulator(const QString &identifier);
|
||||
@@ -185,6 +185,13 @@ namespace BlackMisc
|
||||
//! From database JSON
|
||||
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix);
|
||||
|
||||
//! Const simulator info objects @{
|
||||
static const CSimulatorInfo &fsx() { static const CSimulatorInfo s(FSX); return s; }
|
||||
static const CSimulatorInfo &p3d() { static const CSimulatorInfo s(P3D); return s; }
|
||||
static const CSimulatorInfo &fs9() { static const CSimulatorInfo s(FS9); return s; }
|
||||
static const CSimulatorInfo &xplane() { static const CSimulatorInfo s(XPLANE); return s; }
|
||||
//! @}
|
||||
|
||||
private:
|
||||
int m_simulator = static_cast<int>(None);
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ namespace BlackMisc
|
||||
CSimulatorInfoList CSimulatorInfoList::splitIntoSingleSimulators(const CSimulatorInfo &sim)
|
||||
{
|
||||
CSimulatorInfoList sims;
|
||||
if (sim.fs9()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FS9)); }
|
||||
if (sim.fsx()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FSX)); }
|
||||
if (sim.p3d()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::P3D)); }
|
||||
if (sim.xplane()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::XPLANE)); }
|
||||
if (sim.isFS9()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FS9)); }
|
||||
if (sim.isFSX()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FSX)); }
|
||||
if (sim.isP3D()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::P3D)); }
|
||||
if (sim.isXPlane()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::XPLANE)); }
|
||||
return sims;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user