mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T286, renaming / adding utility functions in simulator info
This commit is contained in:
@@ -209,7 +209,7 @@ namespace BlackCore
|
||||
{
|
||||
msgs.push_back(CStatusMessage(this).error("No model set so far, you need at least one model set. Hint: You can create a model set in the mapping tool, or copy an existing set in the launcher."));
|
||||
}
|
||||
else if (sims.xplane() || CSimulatorInfo(m_enabledSimulators.get()).xplane())
|
||||
else if (sims.isXPlane() || CSimulatorInfo(m_enabledSimulators.get()).isXPlane())
|
||||
{
|
||||
// ever used with XPlane
|
||||
const QString pluginDir = CXPlaneUtil::pluginDirFromRootDir(m_simulatorSettings.getSimulatorDirectoryOrDefault(CSimulatorInfo::XPLANE));
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace BlackGui
|
||||
sims = m_modelSets.simulatorsWithInitializedCache();
|
||||
}
|
||||
|
||||
const bool p3d = (sims.p3d() || !CFsCommonUtil::p3dDir().isEmpty()) && CBuildConfig::isCompiledWithP3DSupport();
|
||||
const bool fsx = (sims.fsx() || !CFsCommonUtil::fsxDir().isEmpty()) && CBuildConfig::isCompiledWithFsxSupport();
|
||||
const bool fs9 = (sims.fs9() || !CFsCommonUtil::fs9Dir().isEmpty()) && CBuildConfig::isCompiledWithFs9Support();
|
||||
const bool xp = sims.xplane() && CBuildConfig::isCompiledWithXPlaneSupport();
|
||||
const bool p3d = (sims.isP3D() || !CFsCommonUtil::p3dDir().isEmpty()) && CBuildConfig::isCompiledWithP3DSupport();
|
||||
const bool fsx = (sims.isFSX() || !CFsCommonUtil::fsxDir().isEmpty()) && CBuildConfig::isCompiledWithFsxSupport();
|
||||
const bool fs9 = (sims.isFS9() || !CFsCommonUtil::fs9Dir().isEmpty()) && CBuildConfig::isCompiledWithFs9Support();
|
||||
const bool xp = sims.isXPlane() && CBuildConfig::isCompiledWithXPlaneSupport();
|
||||
|
||||
ui->cb_P3D->setChecked(p3d);
|
||||
ui->cb_FSX->setChecked(fsx);
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace BlackGui
|
||||
|
||||
if (m_loadActions.isEmpty()) { m_loadActions = QList<QAction *>({nullptr, nullptr, nullptr, nullptr}); }
|
||||
menuActions.addMenuSimulator();
|
||||
if (sims.fsx())
|
||||
if (sims.isFSX())
|
||||
{
|
||||
if (!m_loadActions[0])
|
||||
{
|
||||
@@ -269,7 +269,7 @@ namespace BlackGui
|
||||
}
|
||||
menuActions.addAction(m_loadActions[0], CMenuAction::pathSimulator());
|
||||
}
|
||||
if (sims.p3d())
|
||||
if (sims.isP3D())
|
||||
{
|
||||
if (!m_loadActions[1])
|
||||
{
|
||||
@@ -282,7 +282,7 @@ namespace BlackGui
|
||||
}
|
||||
menuActions.addAction(m_loadActions[1], CMenuAction::pathSimulator());
|
||||
}
|
||||
if (sims.fs9())
|
||||
if (sims.isFS9())
|
||||
{
|
||||
if (!m_loadActions[2])
|
||||
{
|
||||
@@ -295,7 +295,7 @@ namespace BlackGui
|
||||
}
|
||||
menuActions.addAction(m_loadActions[2], CMenuAction::pathSimulator());
|
||||
}
|
||||
if (sims.xplane())
|
||||
if (sims.isXPlane())
|
||||
{
|
||||
if (!m_loadActions[3])
|
||||
{
|
||||
@@ -315,7 +315,7 @@ namespace BlackGui
|
||||
{
|
||||
if (m_reloadActions.isEmpty()) { m_reloadActions = QList<QAction *>({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}); }
|
||||
menuActions.addMenu(CIcons::refresh16(), "Force model reload", CMenuAction::pathSimulatorModelsReload());
|
||||
if (sims.fsx())
|
||||
if (sims.isFSX())
|
||||
{
|
||||
if (!m_reloadActions[0])
|
||||
{
|
||||
@@ -341,7 +341,7 @@ namespace BlackGui
|
||||
menuActions.addAction(m_reloadActions[0], CMenuAction::pathSimulatorModelsReload());
|
||||
menuActions.addAction(m_reloadActions[1], CMenuAction::pathSimulatorModelsReload());
|
||||
}
|
||||
if (sims.p3d())
|
||||
if (sims.isP3D())
|
||||
{
|
||||
if (!m_reloadActions[2])
|
||||
{
|
||||
@@ -367,7 +367,7 @@ namespace BlackGui
|
||||
menuActions.addAction(m_reloadActions[2], CMenuAction::pathSimulatorModelsReload());
|
||||
menuActions.addAction(m_reloadActions[3], CMenuAction::pathSimulatorModelsReload());
|
||||
}
|
||||
if (sims.fs9())
|
||||
if (sims.isFS9())
|
||||
{
|
||||
if (!m_reloadActions[4])
|
||||
{
|
||||
@@ -393,7 +393,7 @@ namespace BlackGui
|
||||
menuActions.addAction(m_reloadActions[4], CMenuAction::pathSimulatorModelsReload());
|
||||
menuActions.addAction(m_reloadActions[5], CMenuAction::pathSimulatorModelsReload());
|
||||
}
|
||||
if (sims.xplane())
|
||||
if (sims.isXPlane())
|
||||
{
|
||||
if (!m_reloadActions[6])
|
||||
{
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(ownModelSetComp, Q_FUNC_INFO, "Cannot access parent");
|
||||
if (m_setActions.isEmpty())
|
||||
{
|
||||
if (sims.fsx())
|
||||
if (sims.isFSX())
|
||||
{
|
||||
QAction *a = new QAction(CIcons::appModels16(), "FSX models", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
|
||||
@@ -435,7 +435,7 @@ namespace BlackGui
|
||||
});
|
||||
m_setNewActions.append(a);
|
||||
}
|
||||
if (sims.p3d())
|
||||
if (sims.isP3D())
|
||||
{
|
||||
QAction *a = new QAction(CIcons::appModels16(), "P3D models", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
|
||||
@@ -453,7 +453,7 @@ namespace BlackGui
|
||||
});
|
||||
m_setNewActions.append(a);
|
||||
}
|
||||
if (sims.fs9())
|
||||
if (sims.isFS9())
|
||||
{
|
||||
QAction *a = new QAction(CIcons::appModels16(), "FS9 models", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
|
||||
@@ -471,7 +471,7 @@ namespace BlackGui
|
||||
});
|
||||
m_setNewActions.append(a);
|
||||
}
|
||||
if (sims.xplane())
|
||||
if (sims.isXPlane())
|
||||
{
|
||||
QAction *a = new QAction(CIcons::appModels16(), "XPlane models", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
|
||||
|
||||
@@ -87,16 +87,16 @@ namespace BlackGui
|
||||
if (simulator == current) { return; } // avoid unnecessary signals
|
||||
|
||||
// checkboxes
|
||||
ui->cb_FSX->setChecked(simulator.fsx());
|
||||
ui->cb_FS9->setChecked(simulator.fs9());
|
||||
ui->cb_XPlane->setChecked(simulator.xplane());
|
||||
ui->cb_P3D->setChecked(simulator.p3d());
|
||||
ui->cb_FSX->setChecked(simulator.isFSX());
|
||||
ui->cb_FS9->setChecked(simulator.isFS9());
|
||||
ui->cb_XPlane->setChecked(simulator.isXPlane());
|
||||
ui->cb_P3D->setChecked(simulator.isP3D());
|
||||
|
||||
// radio buttons
|
||||
if (simulator.fsx()) { ui->rb_FSX->setChecked(simulator.fsx()); return; }
|
||||
if (simulator.fs9()) { ui->rb_FS9->setChecked(simulator.fs9()); return; }
|
||||
if (simulator.xplane()) { ui->rb_XPlane->setChecked(simulator.xplane()); return; }
|
||||
if (simulator.p3d()) { ui->rb_P3D->setChecked(simulator.p3d()); return; }
|
||||
if (simulator.isFSX()) { ui->rb_FSX->setChecked(simulator.isFSX()); return; }
|
||||
if (simulator.isFS9()) { ui->rb_FS9->setChecked(simulator.isFS9()); return; }
|
||||
if (simulator.isXPlane()) { ui->rb_XPlane->setChecked(simulator.isXPlane()); return; }
|
||||
if (simulator.isP3D()) { ui->rb_P3D->setChecked(simulator.isP3D()); return; }
|
||||
}
|
||||
|
||||
void CSimulatorSelector::setToLastSelection()
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackGui
|
||||
if (sGui->getIContextSimulator()->isSimulatorAvailable())
|
||||
{
|
||||
// do not show if already connected with another simulator
|
||||
if (!sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulatorInfo().xplane()) { return 0; }
|
||||
if (!sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulatorInfo().isXPlane()) { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2075,12 +2075,12 @@ namespace BlackSimPlugin
|
||||
const QString connectedSimName = m_simulatorName.toLower().trimmed();
|
||||
|
||||
if (connectedSimName.isEmpty()) { return false; }
|
||||
if (pluginSim.p3d())
|
||||
if (pluginSim.isP3D())
|
||||
{
|
||||
// P3D drivers only works with P3D
|
||||
return connectedSimName.contains("lockheed") || connectedSimName.contains("martin") || connectedSimName.contains("p3d") || connectedSimName.contains("prepar");
|
||||
}
|
||||
else if (pluginSim.fsx())
|
||||
else if (pluginSim.isFSX())
|
||||
{
|
||||
// FSX drivers only works with FSX
|
||||
return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x");
|
||||
|
||||
Reference in New Issue
Block a user