feat: Add MSFS support

Co-Authored-By: Roland Rossgotterer <roland.rossgotterer@gmail.com>
Co-Authored-By: tzobler <tzobler@t-online.de>
This commit is contained in:
Lars Toenning
2024-11-12 17:27:07 +01:00
parent 7b6568f3b9
commit 528b0cc255
50 changed files with 735 additions and 78 deletions

View File

@@ -56,6 +56,7 @@ namespace swift::gui::components
const bool p3d = (sims.isP3D() || !CFsDirectories::p3dDir().isEmpty()) && CBuildConfig::isCompiledWithP3DSupport();
const bool fsx = (sims.isFSX() || !CFsDirectories::fsxDir().isEmpty()) && CBuildConfig::isCompiledWithFsxSupport();
const bool fs9 = (sims.isFS9() || !CFsDirectories::fs9Dir().isEmpty()) && CBuildConfig::isCompiledWithFs9Support();
const bool msfs = (sims.isMSFS() || !CFsDirectories::msfsDir().isEmpty()) && CBuildConfig::isCompiledWithMSFSSupport();
const bool xp = sims.isXPlane() && CBuildConfig::isCompiledWithXPlaneSupport();
const bool fg = sims.isFG() && CBuildConfig::isCompiledWithFGSupport();
@@ -64,24 +65,28 @@ namespace swift::gui::components
ui->cb_FS9->setChecked(fs9);
ui->cb_XP->setChecked(xp);
ui->cb_FG->setChecked(fg);
ui->cb_MSFS->setChecked(msfs);
ui->cb_P3D->setEnabled(CBuildConfig::isCompiledWithP3DSupport());
ui->cb_FSX->setEnabled(CBuildConfig::isCompiledWithFsxSupport());
ui->cb_FS9->setEnabled(CBuildConfig::isCompiledWithFs9Support());
ui->cb_XP->setEnabled(CBuildConfig::isCompiledWithXPlaneSupport());
ui->cb_FG->setEnabled(CBuildConfig::isCompiledWithFGSupport());
ui->cb_MSFS->setEnabled(CBuildConfig::isCompiledWithMSFSSupport());
CGuiUtility::checkBoxReadOnly(ui->cb_P3D, !CBuildConfig::isCompiledWithP3DSupport());
CGuiUtility::checkBoxReadOnly(ui->cb_FSX, !CBuildConfig::isCompiledWithFsxSupport());
CGuiUtility::checkBoxReadOnly(ui->cb_FS9, !CBuildConfig::isCompiledWithFs9Support());
CGuiUtility::checkBoxReadOnly(ui->cb_XP, !CBuildConfig::isCompiledWithXPlaneSupport());
CGuiUtility::checkBoxReadOnly(ui->cb_FG, !CBuildConfig::isCompiledWithFGSupport());
CGuiUtility::checkBoxReadOnly(ui->cb_MSFS, !CBuildConfig::isCompiledWithMSFSSupport());
if (p3d) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::P3D)); }
else if (fsx) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::FSX)); }
else if (fs9) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::FS9)); }
else if (xp) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE)); }
else if (fg) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::FG)); }
else if (msfs) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS)); }
}
QStringList CConfigSimulatorComponent::selectedSimsToPluginIds()
@@ -94,6 +99,7 @@ namespace swift::gui::components
if (ui->cb_P3D->isChecked()) { ids << CSimulatorPluginInfo::p3dPluginIdentifier(); }
if (ui->cb_XP->isChecked()) { ids << CSimulatorPluginInfo::xplanePluginIdentifier(); }
if (ui->cb_FG->isChecked()) { ids << CSimulatorPluginInfo::fgPluginIdentifier(); }
if (ui->cb_MSFS->isChecked()) { ids << CSimulatorPluginInfo::msfsPluginIdentifier(); }
return ids;
}

View File

@@ -85,6 +85,13 @@
</property>
</widget>
</item>
<item row="1" column="5" alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="cb_MSFS">
<property name="text">
<string>MSFS (64-bit)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -309,7 +309,7 @@ namespace swift::gui::components
QPointer<CDbOwnModelsComponent> ownModelsComp(qobject_cast<CDbOwnModelsComponent *>(this->parent()));
Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent");
if (m_loadActions.isEmpty()) { m_loadActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr }); }
if (m_loadActions.isEmpty()) { m_loadActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }); }
menuActions.addMenuSimulator();
if (sims.isFSX())
{
@@ -376,12 +376,25 @@ namespace swift::gui::components
}
menuActions.addAction(m_loadActions[4], CMenuAction::pathSimulator());
}
if (sims.isMSFS())
{
if (!m_loadActions[5])
{
m_loadActions[5] = new QAction(CIcons::appModels16(), "MSFS models", this);
connect(m_loadActions[5], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
if (!ownModelsComp) { return; }
Q_UNUSED(checked)
ownModelsComp->setSimulator(CSimulatorInfo::msfs(), true);
});
}
menuActions.addAction(m_loadActions[5], CMenuAction::pathSimulator());
}
// with models loaded I allow a refresh reload
// I need those models because I want to merge with DB data in the loader
if (sGui && sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0)
{
if (m_reloadActions.isEmpty()) { m_reloadActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }); }
if (m_reloadActions.isEmpty()) { m_reloadActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }); }
menuActions.addMenu(CIcons::refresh16(), "Force model reload", CMenuAction::pathSimulatorModelsReload());
if (sims.isFSX())
{
@@ -512,6 +525,31 @@ namespace swift::gui::components
menuActions.addAction(m_reloadActions[8], CMenuAction::pathSimulatorModelsReload());
menuActions.addAction(m_reloadActions[9], CMenuAction::pathSimulatorModelsReload());
}
if (sims.isMSFS())
{
if (!m_reloadActions[10])
{
m_reloadActions[10] = new QAction(CIcons::appModels16(), "MSFS models", this);
connect(m_reloadActions[10], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
if (!ownModelsComp) { return; }
Q_UNUSED(checked)
ownModelsComp->requestSimulatorModels(CSimulatorInfo::msfs(), IAircraftModelLoader::InBackgroundNoCache);
});
m_reloadActions[11] = new QAction(CIcons::appModels16(), "MSFS models from directoy", this);
connect(m_reloadActions[11], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
if (!ownModelsComp) { return; }
Q_UNUSED(checked)
const CSimulatorInfo sim(CSimulatorInfo::MSFS);
const QString dir = ownModelsComp->directorySelector(sim);
if (!dir.isEmpty())
{
ownModelsComp->requestSimulatorModels(sim, IAircraftModelLoader::InBackgroundNoCache, QStringList(dir));
}
});
}
menuActions.addAction(m_reloadActions[10], CMenuAction::pathSimulatorModelsReload());
menuActions.addAction(m_reloadActions[11], CMenuAction::pathSimulatorModelsReload());
}
}
else
{
@@ -520,7 +558,7 @@ namespace swift::gui::components
a.setActionEnabled(false); // gray out
}
if (m_clearCacheActions.isEmpty()) { m_clearCacheActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr }); }
if (m_clearCacheActions.isEmpty()) { m_clearCacheActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }); }
menuActions.addMenu(CIcons::delete16(), "Clear model caches", CMenuAction::pathSimulatorModelsClearCache());
if (sims.isFSX())
{
@@ -587,6 +625,19 @@ namespace swift::gui::components
}
menuActions.addAction(m_clearCacheActions[4], CMenuAction::pathSimulatorModelsClearCache());
}
if (sims.isMSFS())
{
if (!m_clearCacheActions[5])
{
m_clearCacheActions[5] = new QAction(CIcons::appModels16(), "Clear MSFS cache", this);
connect(m_clearCacheActions[5], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
if (!ownModelsComp) { return; }
Q_UNUSED(checked)
ownModelsComp->clearSimulatorCache(CSimulatorInfo::msfs());
});
}
menuActions.addAction(m_clearCacheActions[5], CMenuAction::pathSimulatorModelsClearCache());
}
if (sims.isXPlane() && CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::buildWordSize() == 64)
{

View File

@@ -590,6 +590,22 @@ namespace swift::gui::components
});
m_setNewActions.append(a);
}
if (sims.isMSFS())
{
QAction *a = new QAction(CIcons::appModels16(), "MSFS models", this);
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) {
Q_UNUSED(checked)
ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS));
});
m_setActions.append(a);
a = new QAction(CIcons::appModels16(), "New set MSFS models", this);
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) {
Q_UNUSED(checked)
ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::MSFS));
});
m_setNewActions.append(a);
}
QAction *a = new QAction(CIcons::appDistributors16(), "Apply distributor preferences", this);
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::distributorPreferencesChanged, Qt::QueuedConnection);

View File

@@ -121,6 +121,14 @@ namespace swift::gui::components
preferences.setDistributors(distributors, simulator);
const CStatusMessage m = m_distributorPreferences.setAndSave(preferences);
CLogMessage::preformatted(m);
if (m.isSuccess())
{
this->showOverlayHTMLMessage("Saved settings", 5000);
}
else
{
this->showOverlayMessage(m);
}
}
void CDistributorPreferencesComponent::onSimulatorChanged(const CSimulatorInfo &simulator)

View File

@@ -36,12 +36,14 @@ namespace swift::gui::components
connect(ui->rb_P3D, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged);
connect(ui->rb_FG, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged);
connect(ui->rb_XPlane, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged);
connect(ui->rb_MSFS, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged);
connect(ui->cb_FS9, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_FSX, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_P3D, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_FG, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_XPlane, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_MSFS, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged);
connect(ui->cb_Simulators, &QComboBox::currentTextChanged, this, &CSimulatorSelector::comboBoxChanged);
}
@@ -75,8 +77,8 @@ namespace swift::gui::components
switch (m_mode)
{
default:
case CheckBoxes: return CSimulatorInfo(ui->cb_FSX->isChecked(), ui->cb_FS9->isChecked(), ui->cb_XPlane->isChecked(), ui->cb_P3D->isChecked(), ui->cb_FG->isChecked());
case RadioButtons: return CSimulatorInfo(ui->rb_FSX->isChecked(), ui->rb_FS9->isChecked(), ui->rb_XPlane->isChecked(), ui->rb_P3D->isChecked(), ui->rb_FG->isChecked());
case CheckBoxes: return CSimulatorInfo(ui->cb_FSX->isChecked(), ui->cb_FS9->isChecked(), ui->cb_XPlane->isChecked(), ui->cb_P3D->isChecked(), ui->cb_FG->isChecked(), ui->cb_MSFS->isChecked());
case RadioButtons: return CSimulatorInfo(ui->rb_FSX->isChecked(), ui->rb_FS9->isChecked(), ui->rb_XPlane->isChecked(), ui->rb_P3D->isChecked(), ui->rb_FG->isChecked(), ui->rb_MSFS->isChecked());
case ComboBox: return CSimulatorInfo(ui->cb_Simulators->currentText());
}
}
@@ -92,6 +94,7 @@ namespace swift::gui::components
ui->cb_XPlane->setChecked(simulator.isXPlane());
ui->cb_P3D->setChecked(simulator.isP3D());
ui->cb_FG->setChecked(simulator.isFG());
ui->cb_MSFS->setChecked(simulator.isMSFS());
// Combo
ui->cb_Simulators->setCurrentText(simulator.toQString(true));
@@ -122,6 +125,11 @@ namespace swift::gui::components
ui->rb_FG->setChecked(simulator.isFG());
return;
}
if (simulator.isMSFS())
{
ui->rb_MSFS->setChecked(simulator.isMSFS());
return;
}
}
void CSimulatorSelector::setToLastSelection()
@@ -202,6 +210,7 @@ namespace swift::gui::components
ui->cb_XPlane->setChecked(true);
ui->cb_P3D->setChecked(true);
ui->cb_FG->setChecked(true);
ui->cb_MSFS->setChecked(true);
// radio
ui->rb_P3D->setChecked(true);
@@ -215,6 +224,7 @@ namespace swift::gui::components
ui->cb_XPlane->setChecked(false);
ui->cb_P3D->setChecked(false);
ui->cb_FG->setChecked(false);
ui->cb_MSFS->setChecked(false);
}
bool CSimulatorSelector::isUnselected() const
@@ -224,10 +234,10 @@ namespace swift::gui::components
{
default:
case CheckBoxes:
c = ui->cb_FSX->isChecked() || ui->cb_FS9->isChecked() || ui->cb_XPlane->isChecked() || ui->cb_P3D->isChecked() || ui->cb_FG->isChecked();
c = ui->cb_FSX->isChecked() || ui->cb_FS9->isChecked() || ui->cb_XPlane->isChecked() || ui->cb_P3D->isChecked() || ui->cb_FG->isChecked() || ui->cb_MSFS->isChecked();
break;
case RadioButtons:
c = ui->rb_FSX->isChecked() || ui->rb_FS9->isChecked() || ui->rb_XPlane->isChecked() || ui->rb_P3D->isChecked() || ui->rb_FG->isChecked();
c = ui->rb_FSX->isChecked() || ui->rb_FS9->isChecked() || ui->rb_XPlane->isChecked() || ui->rb_P3D->isChecked() || ui->rb_FG->isChecked() || ui->rb_MSFS->isChecked();
break;
case ComboBox:
const int i = ui->cb_Simulators->currentIndex();
@@ -244,7 +254,7 @@ namespace swift::gui::components
{
default:
case CheckBoxes:
c = ui->cb_FSX->isChecked() && ui->cb_FS9->isChecked() && ui->cb_XPlane->isChecked() && ui->cb_P3D->isChecked() && ui->cb_FG->isChecked();
c = ui->cb_FSX->isChecked() && ui->cb_FS9->isChecked() && ui->cb_XPlane->isChecked() && ui->cb_P3D->isChecked() && ui->cb_FG->isChecked() && ui->cb_MSFS->isChecked();
break;
case RadioButtons:
// actually this should never be true
@@ -296,6 +306,7 @@ namespace swift::gui::components
ui->rb_XPlane->setEnabled(!readOnly);
ui->rb_P3D->setEnabled(!readOnly);
ui->rb_FG->setEnabled(!readOnly);
ui->rb_MSFS->setEnabled(!readOnly);
ui->cb_Simulators->setEnabled(!readOnly);
@@ -385,5 +396,6 @@ namespace swift::gui::components
ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::p3d().toQString());
ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::xplane().toQString());
ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::fg().toQString());
ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::msfs().toQString());
}
} // ns

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>188</width>
<height>66</height>
<width>271</width>
<height>74</height>
</rect>
</property>
<property name="windowTitle">
@@ -88,6 +88,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_MSFS">
<property name="text">
<string>MSFS2020</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -159,6 +166,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_MSFS">
<property name="text">
<string>MSFS2020</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>