From 42c6b74e3cb0d71ea540673e0bde061ebddd1534 Mon Sep 17 00:00:00 2001 From: tzobler Date: Fri, 21 Nov 2025 14:48:49 +0100 Subject: [PATCH] refactor: rename the plugin msfs to msfs2020 --- CMakeLists.txt | 4 +- cmake/simconnect/CMakeLists.txt | 2 +- .../swift-plugin-simulators.xml | 8 +- src/config/buildconfig.cpp | 2 +- src/config/buildconfig.h | 6 +- src/config/buildconfig.inc | 2 +- src/config/buildconfig_gen.inc.in | 4 +- src/core/application/applicationsettings.h | 27 +- src/core/context/contextsimulatorimpl.h | 4 + src/core/fsd/enums.h | 2 +- src/core/fsd/fsdclient.cpp | 2 +- src/core/fsd/serializer.cpp | 4 +- src/gui/CMakeLists.txt | 9 + src/gui/components/automodelsetcomponent.cpp | 482 +++++++++ src/gui/components/automodelsetcomponent.h | 123 +++ src/gui/components/automodelsetcomponent.ui | 280 ++++++ .../components/configsimulatorcomponent.cpp | 84 +- src/gui/components/configsimulatorcomponent.h | 3 + .../components/configsimulatorcomponent.ui | 86 +- src/gui/components/configurationwizard.cpp | 119 ++- src/gui/components/configurationwizard.h | 9 +- src/gui/components/configurationwizard.ui | 945 ++++++++++-------- ...ymodelsfromotherswiftversionscomponent.cpp | 12 +- ...opymodelsfromotherswiftversionscomponent.h | 4 + .../copysettingsandcachescomponent.cpp | 61 ++ .../copysettingsandcachescomponent.h | 10 + .../copysettingsandcachescomponent.ui | 26 +- src/gui/components/dbownmodelsetcomponent.cpp | 10 +- src/gui/components/finishwizardcomponent.cpp | 33 + src/gui/components/finishwizardcomponent.h | 75 ++ src/gui/components/finishwizardcomponent.ui | 204 ++++ .../components/selectsimulatorcomponent.cpp | 183 ++++ src/gui/components/selectsimulatorcomponent.h | 106 ++ .../components/selectsimulatorcomponent.ui | 249 +++++ .../settingssimulatorbasicscomponent.cpp | 74 +- .../settingssimulatorbasicscomponent.h | 5 +- .../settingssimulatorbasicscomponent.ui | 10 + src/gui/components/simulatorselector.cpp | 58 +- src/gui/components/simulatorselector.h | 5 + src/gui/components/simulatorselector.ui | 9 +- src/misc/fileutils.cpp | 6 + src/misc/simulation/aircraftmodel.cpp | 2 +- src/misc/simulation/aircraftmodel.h | 2 +- src/misc/simulation/aircraftmodellist.h | 4 +- .../aircraftmodelloaderprovider.cpp | 4 +- src/misc/simulation/aircraftmodelutils.cpp | 2 +- src/misc/simulation/autopublishdata.cpp | 2 +- src/misc/simulation/data/modelcaches.cpp | 44 +- src/misc/simulation/data/modelcaches.h | 20 +- src/misc/simulation/distributor.cpp | 2 +- .../simulation/distributorlistpreferences.cpp | 4 +- .../simulation/fscommon/aircraftcfgparser.cpp | 2 +- src/misc/simulation/fscommon/fscommonutil.cpp | 2 +- .../simulation/fscommon/fsdirectories.cpp | 34 +- src/misc/simulation/fscommon/fsdirectories.h | 14 +- .../msfs2024/simconnectutilities.cpp | 2 - .../simulation/settings/simulatorsettings.cpp | 39 +- .../simulation/settings/simulatorsettings.h | 24 +- src/misc/simulation/simulatorinfo.cpp | 57 +- src/misc/simulation/simulatorinfo.h | 16 +- src/misc/simulation/simulatorinfolist.cpp | 2 +- src/misc/simulation/simulatorplugininfo.cpp | 17 +- src/misc/simulation/simulatorplugininfo.h | 2 +- src/misc/valuecache.cpp | 12 + src/plugins/simulator/CMakeLists.txt | 6 +- .../fsxcommon/simconnectdatadefinition.cpp | 4 +- .../simulator/fsxcommon/simconnectsymbols.cpp | 2 +- .../fsxcommon/simulatorfsxcommon.cpp | 14 +- .../simulator/fsxcommon/simulatorfsxcommon.h | 2 +- src/plugins/simulator/msfs/simulatormsfs.json | 6 +- .../simconnectdatadefinitionmsfs2024.h | 8 +- .../msfs2024/simulatormsfs2024common.cpp | 11 +- .../msfs2024/simulatormsfs2024common.h | 2 +- .../simulatormsfs2024simconnectproc.cpp | 2 +- 74 files changed, 2870 insertions(+), 843 deletions(-) create mode 100644 src/gui/components/automodelsetcomponent.cpp create mode 100644 src/gui/components/automodelsetcomponent.h create mode 100644 src/gui/components/automodelsetcomponent.ui create mode 100644 src/gui/components/finishwizardcomponent.cpp create mode 100644 src/gui/components/finishwizardcomponent.h create mode 100644 src/gui/components/finishwizardcomponent.ui create mode 100644 src/gui/components/selectsimulatorcomponent.cpp create mode 100644 src/gui/components/selectsimulatorcomponent.h create mode 100644 src/gui/components/selectsimulatorcomponent.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index cc8f841ac..143f748d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ option(SWIFT_BUILD_XPLANE_PLUGIN "Build X-Plane plugin" ON) cmake_dependent_option(SWIFT_BUILD_XSWIFTBUS "Build xswiftbus" ON "NOT SWIFT_WIN32" OFF) option(SWIFT_BUILD_FLIGHTGEAR_PLUGIN "Build Flightgear plugin" ON) option(SWIFT_BUILD_EMULATED_PLUGIN "Build Emulated plugin" ON) -cmake_dependent_option(SWIFT_BUILD_MSFS_PLUGIN "Build MSFS plugin" ON WIN32 OFF) +cmake_dependent_option(SWIFT_BUILD_MSFS2020_PLUGIN "Build MSFS2020 plugin" ON WIN32 OFF) cmake_dependent_option(SWIFT_BUILD_MSFS2024_PLUGIN "Build MSFS2024 plugin" ON WIN32 OFF) option(SWIFT_MINIFY_DEBUG_SYMBOLS "Minify debug symbols" OFF) option(SWIFT_ONLY_XSWIFTBUS_WORKAROUND "Only build xswiftbus (useful when compiling on ARM)" OFF) @@ -230,7 +230,7 @@ message(STATUS "Simulators:") message(STATUS "\t FS9: ${SWIFT_BUILD_FS9_PLUGIN}") message(STATUS "\t FSX: ${SWIFT_BUILD_FSX_PLUGIN}") message(STATUS "\t P3D: ${SWIFT_BUILD_P3D_PLUGIN}") -message(STATUS "\t MSFS: ${SWIFT_BUILD_MSFS_PLUGIN}") +message(STATUS "\t MSFS2020: ${SWIFT_BUILD_MSFS2020_PLUGIN}") message(STATUS "\t MSFS2024: ${SWIFT_BUILD_MSFS2024_PLUGIN}") message(STATUS "\t XPLANE: ${SWIFT_BUILD_XPLANE_PLUGIN}") message(STATUS "\t XSWIFTBUS: ${SWIFT_BUILD_XPLANE_PLUGIN}") diff --git a/cmake/simconnect/CMakeLists.txt b/cmake/simconnect/CMakeLists.txt index c2c7a29e6..a9b44a4bb 100644 --- a/cmake/simconnect/CMakeLists.txt +++ b/cmake/simconnect/CMakeLists.txt @@ -4,7 +4,7 @@ # Checks if variable for SDK path is set and SimConnect.h does exist in the include path. # If not, disable building the simulator plugin and emit warning message -if(SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS_PLUGIN OR SWIFT_BUILD_MSFS2024_PLUGIN) +if(SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS2020_PLUGIN OR SWIFT_BUILD_MSFS2024_PLUGIN) add_library(externals_simconnect INTERFACE IMPORTED GLOBAL) target_compile_definitions(externals_simconnect INTERFACE SIMCONNECT_H_NOMANIFEST) target_compile_definitions(externals_simconnect INTERFACE BUID_SIMCONNECT_LIB) diff --git a/installer/installbuilder/swift-plugin-simulators.xml b/installer/installbuilder/swift-plugin-simulators.xml index 47b2c4d98..042b108b9 100644 --- a/installer/installbuilder/swift-plugin-simulators.xml +++ b/installer/installbuilder/swift-plugin-simulators.xml @@ -78,12 +78,12 @@ - msfs - MSFS: Flight Sim 2020 + msfs2020 + MSFS2020: Flight Sim 2020 1 MS Flight Simulator 2020 Simulator Plugin - This plugin acts as the interface between swift and MSFS. + This plugin acts as the interface between swift and MSFS2020. 1 1 @@ -95,7 +95,7 @@ windows - ../../dist/bin/plugins/simulator/simulatormsfs.dll + ../../dist/bin/plugins/simulator/simulatormsfs2020.dll diff --git a/src/config/buildconfig.cpp b/src/config/buildconfig.cpp index a32b3e81a..2fb1a48f1 100644 --- a/src/config/buildconfig.cpp +++ b/src/config/buildconfig.cpp @@ -73,7 +73,7 @@ namespace swift::config QStringList sl; if constexpr (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; } if constexpr (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; } - if constexpr (CBuildConfig::isCompiledWithMSFSSupport()) { sl << "MSFS2020"; } + if constexpr (CBuildConfig::isCompiledWithMSFS2020Support()) { sl << "MSFS2020"; } if constexpr (CBuildConfig::isCompiledWithMSFS2024Support()) { sl << "MSFS2024"; } if constexpr (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; } if constexpr (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; } diff --git a/src/config/buildconfig.h b/src/config/buildconfig.h index 08551b0c3..912a7c251 100644 --- a/src/config/buildconfig.h +++ b/src/config/buildconfig.h @@ -27,8 +27,8 @@ namespace swift::config //! with FG support? static constexpr bool isCompiledWithFGSupport(); // defined in buildconfig_gen.inc.in - //! with MSFS support? - static constexpr bool isCompiledWithMSFSSupport(); // defined in buildconfig_gen.inc.in + //! with MSFS2020 support? + static constexpr bool isCompiledWithMSFS2020Support(); // defined in buildconfig_gen.inc.in //! with MSFS2024 support? static constexpr bool isCompiledWithMSFS2024Support(); // defined in buildconfig_gen.inc.in @@ -36,7 +36,7 @@ namespace swift::config //! with FSUIPC support? static constexpr bool isCompiledWithFsuipcSupport(); // defined in buildconfig_gen.inc.in - //! Compiled with any MS Flight Simulator support (P3D, FSX, FS9, MSFS, MSFS24) + //! Compiled with any MS Flight Simulator support (P3D, FSX, FS9, MSFS2020, MSFS24) static constexpr bool isCompiledWithMsFlightSimulatorSupport(); //! with XPlane support? diff --git a/src/config/buildconfig.inc b/src/config/buildconfig.inc index b9cc429d9..de08c0391 100644 --- a/src/config/buildconfig.inc +++ b/src/config/buildconfig.inc @@ -15,7 +15,7 @@ namespace swift::config constexpr bool CBuildConfig::isCompiledWithMsFlightSimulatorSupport() { return CBuildConfig::isCompiledWithFs9Support() || CBuildConfig::isCompiledWithFsxSupport() || - CBuildConfig::isCompiledWithP3DSupport() || isCompiledWithMSFSSupport() || + CBuildConfig::isCompiledWithP3DSupport() || isCompiledWithMSFS2020Support() || isCompiledWithMSFS2024Support(); } diff --git a/src/config/buildconfig_gen.inc.in b/src/config/buildconfig_gen.inc.in index 80daa5cbe..60a813af3 100644 --- a/src/config/buildconfig_gen.inc.in +++ b/src/config/buildconfig_gen.inc.in @@ -25,7 +25,7 @@ constexpr bool swift::config::CBuildConfig::isCompiledWithFsxSupport() constexpr bool swift::config::CBuildConfig::isCompiledWithFsuipcSupport() { - return isCompiledWithFsxSupport() || isCompiledWithP3DSupport() || isCompiledWithFs9Support() || isCompiledWithMSFSSupport() || isCompiledWithMSFS2024Support(); + return isCompiledWithFsxSupport() || isCompiledWithP3DSupport() || isCompiledWithFs9Support() || isCompiledWithMSFS2020Support() || isCompiledWithMSFS2024Support(); } constexpr bool swift::config::CBuildConfig::isCompiledWithXPlaneSupport() @@ -38,7 +38,7 @@ constexpr bool swift::config::CBuildConfig::isCompiledWithFGSupport() return SWIFTCONFIG_${SWIFT_BUILD_FLIGHTGEAR_PLUGIN}; } -constexpr bool swift::config::CBuildConfig::isCompiledWithMSFSSupport() +constexpr bool swift::config::CBuildConfig::isCompiledWithMSFS2020Support() { return SWIFTCONFIG_${SWIFT_BUILD_MSFS_PLUGIN}; } diff --git a/src/core/application/applicationsettings.h b/src/core/application/applicationsettings.h index b3fe5c5e3..5bda23dc4 100644 --- a/src/core/application/applicationsettings.h +++ b/src/core/application/applicationsettings.h @@ -61,9 +61,13 @@ namespace swift::core::application //! \copydoc swift::misc::TSettingTrait::isValid static bool isValid(const QStringList &pluginIdentifiers, QString &) { - return std::all_of(pluginIdentifiers.cbegin(), pluginIdentifiers.cend(), [](const auto &pluginIdentifier) { - return misc::simulation::CSimulatorPluginInfo::allIdentifiers().contains(pluginIdentifier); - }); + bool allPositiveNonEmpty = true; + return ( + allPositiveNonEmpty = + !pluginIdentifiers.empty() && + std::all_of(pluginIdentifiers.cbegin(), pluginIdentifiers.cend(), [](const auto &pluginIdentifier) { + return misc::simulation::CSimulatorPluginInfo::allIdentifiers().contains(pluginIdentifier); + })); } }; @@ -83,6 +87,23 @@ namespace swift::core::application //! \copydoc swift::misc::TSettingTrait::defaultValue static bool defaultValue() { return false; } }; + + //! Selected configuration options + struct TEnabledConfigOptions : misc::TSettingTrait + { + //! \copydoc swift::misc::TSettingTrait::key + static const char *key() { return "application/enabledconfigoptions"; } + + //! \copydoc swift::misc::TSettingTrait::humanReadable + static const QString &humanReadable() + { + static const QString name("Config Settings"); + return name; + } + + //! \copydoc swift::misc::TSettingTrait::defaultValue + static const QStringList &defaultValue() { return QStringList {}; } + }; } // namespace swift::core::application #endif // SWIFT_CORE_APPLICATION_APPLICATIONSETTINGS_H diff --git a/src/core/context/contextsimulatorimpl.h b/src/core/context/contextsimulatorimpl.h index f05511936..7d961f641 100644 --- a/src/core/context/contextsimulatorimpl.h +++ b/src/core/context/contextsimulatorimpl.h @@ -415,6 +415,10 @@ namespace swift::core swift::misc::CSettingReadOnly m_messageSettings { this }; //!< settings for messages (all simulators) + + swift::misc::CSettingReadOnly m_enabledConfigOptions { + this + }; //!< genearal enabled config options }; } // namespace context } // namespace swift::core diff --git a/src/core/fsd/enums.h b/src/core/fsd/enums.h index 86e0c747f..503aac718 100644 --- a/src/core/fsd/enums.h +++ b/src/core/fsd/enums.h @@ -52,7 +52,7 @@ namespace swift::core::fsd MSCFS3, /*!< MS Combat Flight Simulator 3 */ MSFS2004, /*!< MS Flight Simulator 2004 */ MSFSX, /*!< MS Flight Simulator X */ - MSFS, /*!< MS Flight Simulator 2020 */ + MSFS2020, /*!< MS Flight Simulator 2020 */ MSFS2024, /*!< MS Flight Simulator 2024 */ XPLANE8, /*!< X-Plane 8 */ XPLANE9, /*!< X-Plane 9 */ diff --git a/src/core/fsd/fsdclient.cpp b/src/core/fsd/fsdclient.cpp index bc4bb8c6b..21a2859f4 100644 --- a/src/core/fsd/fsdclient.cpp +++ b/src/core/fsd/fsdclient.cpp @@ -207,7 +207,7 @@ namespace swift::core::fsd case CSimulatorInfo::FS9: m_simType = SimType::MSFS2004; break; case CSimulatorInfo::FG: m_simType = SimType::FlightGear; break; case CSimulatorInfo::XPLANE: m_simType = SimType::XPLANE11; break; - case CSimulatorInfo::MSFS: m_simType = SimType::MSFS; break; + case CSimulatorInfo::MSFS2020: m_simType = SimType::MSFS2020; break; case CSimulatorInfo::MSFS2024: m_simType = SimType::MSFS2024; break; default: m_simType = SimType::Unknown; break; } diff --git a/src/core/fsd/serializer.cpp b/src/core/fsd/serializer.cpp index d8dfd39b3..edc0c6671 100644 --- a/src/core/fsd/serializer.cpp +++ b/src/core/fsd/serializer.cpp @@ -168,7 +168,7 @@ namespace swift::core::fsd case SimType::MSCFS3: return "7"; case SimType::MSFS2004: return "8"; case SimType::MSFSX: return "9"; - case SimType::MSFS: return "10"; + case SimType::MSFS2020: return "10"; case SimType::MSFS2024: return "11"; case SimType::XPLANE8: return "12"; case SimType::XPLANE9: return "13"; @@ -217,7 +217,7 @@ namespace swift::core::fsd else if (str == "9") return SimType::MSFSX; else if (str == "10") - return SimType::MSFS; + return SimType::MSFS2020; else if (str == "11") return SimType::MSFS2024; else if (str == "12") diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 3152aafe9..7e8e3875c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -65,6 +65,9 @@ add_library(gui SHARED components/audionotificationcomponent.cpp components/audionotificationcomponent.h components/audionotificationcomponent.ui + components/automodelsetcomponent.cpp + components/automodelsetcomponent.h + components/automodelsetcomponent.ui components/autopublishcomponent.cpp components/autopublishcomponent.h components/autopublishcomponent.ui @@ -249,6 +252,9 @@ add_library(gui SHARED components/downloaddialog.cpp components/downloaddialog.h components/downloaddialog.ui + components/finishwizardcomponent.cpp + components/finishwizardcomponent.h + components/finishwizardcomponent.ui components/firstmodelsetcomponent.cpp components/firstmodelsetcomponent.h components/firstmodelsetcomponent.ui @@ -381,6 +387,9 @@ add_library(gui SHARED components/selcalcodeselector.cpp components/selcalcodeselector.h components/selcalcodeselector.ui + components/selectsimulatorcomponent.cpp + components/selectsimulatorcomponent.h + components/selectsimulatorcomponent.ui components/serverlistselector.cpp components/serverlistselector.h components/settingsadvancedcomponent.cpp diff --git a/src/gui/components/automodelsetcomponent.cpp b/src/gui/components/automodelsetcomponent.cpp new file mode 100644 index 000000000..635cab0df --- /dev/null +++ b/src/gui/components/automodelsetcomponent.cpp @@ -0,0 +1,482 @@ +// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +#include "gui/components/automodelsetcomponent.h" + +#include +#include +#include +#include +#include + +#include "ui_automodelsetcomponent.h" + +#include "config/buildconfig.h" +#include "core/aircraftmatcher.h" +#include "core/webdataservices.h" +#include "gui/components/dbownmodelscomponent.h" +#include "gui/components/dbownmodelsdialog.h" +#include "gui/components/dbownmodelsetcomponent.h" +#include "gui/components/dbownmodelsetdialog.h" +#include "gui/guiapplication.h" +#include "gui/views/distributorview.h" +#include "misc/directoryutils.h" +#include "misc/verify.h" +// #include "core/application.h" +#include "core/modelsetbuilder.h" + +// #include "core/webdataservices.h" +// #include "core/webdataservicesms.h" +// #include "gui/components/dbmappingcomponent.h" +// #include "gui/guiapplication.h" +// #include "gui/models/distributorlistmodel.h" + +using namespace swift::config; +using namespace swift::core; + +using namespace swift::misc; +using namespace swift::misc::network; +using namespace swift::misc::simulation; +using namespace swift::misc::simulation::data; +using namespace swift::misc::simulation::settings; + +namespace swift::gui::components +{ + const QStringList &CAutoModelSetComponent::getLogCategories() + { + static const QStringList cats { CLogCategories::modelGui() }; + return cats; + } + + CAutoModelSetComponent::CAutoModelSetComponent(QWidget *parent) + : COverlayMessagesFrame(parent), ui(new Ui::CAutoModelSetComponent) + { + ui->setupUi(this); + this->preselectOptions(); + // ui->comp_Distributors->view()->setSelectionMode(QAbstractItemView::MultiSelection); + ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons); + ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection(); + + // we use the powerful component to access own models + m_modelsDialog.reset(new CDbOwnModelsDialog(this)); + m_modelSetDialog.reset(new CDbOwnModelSetDialog(this)); + + this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); + + bool s = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, + &CAutoModelSetComponent::onSimulatorChanged); + Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect selector signal"); + connect(&m_simulatorSettings, &CMultiSimulatorSettings::settingsChanged, this, + &CAutoModelSetComponent::onSettingsChanged, Qt::QueuedConnection); + Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect settings signal"); + connect(m_modelsDialog.data(), &CDbOwnModelsDialog::successfullyLoadedModels, this, + &CAutoModelSetComponent::onModelsLoaded, Qt::QueuedConnection); + Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect models signal"); + + connect(ui->pb_ModelSet, &QPushButton::clicked, this, &CAutoModelSetComponent::openOwnModelSetDialog); + connect(ui->pb_Models, &QPushButton::clicked, this, &CAutoModelSetComponent::openOwnModelsDialog); + connect(ui->pb_ModelsTriggerReload, &QPushButton::clicked, this, &CAutoModelSetComponent::openOwnModelsDialog); + connect(ui->pb_ChangeModelDir, &QPushButton::clicked, this, &CAutoModelSetComponent::changeModelDirectory); + connect(ui->pb_ClearModelDir, &QPushButton::clicked, this, &CAutoModelSetComponent::changeModelDirectory); + connect(ui->pb_CreateModelSet, &QPushButton::clicked, this, &CAutoModelSetComponent::createModelSet); + + connect(ui->pb_CreateAutoModelSet, &QPushButton::clicked, this, &CAutoModelSetComponent::createAutoModelsets); + connect(ui->pb_ShowExpertMode, &QPushButton::clicked, this, &CAutoModelSetComponent::toggleExportMode); + + ui->gb_Distributors->setVisible(m_expertmode); + ui->fr_ModelsAndSimulator->setVisible(m_expertmode); + } + + CAutoModelSetComponent::~CAutoModelSetComponent() = default; + + void CAutoModelSetComponent::onSimulatorChanged(const CSimulatorInfo &simulator) + { + if (!simulator.isSingleSimulator()) + { + //! \fixme KB 2019-01 reported by RR/crash dump sometimes happening and leading to ASSERT/CTD avoiding the + //! "crash" for better infos + if (CBuildConfig::isLocalDeveloperDebugBuild()) + { + SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Need single simulator"); + } + CLogMessage(this).error(u"Changing to non-single simulator %1 ignored") << simulator.toQString(); + return; + } + + Q_ASSERT_X(m_modelsDialog, Q_FUNC_INFO, "No models dialog"); + m_modelsDialog->setSimulator(simulator); + + Q_ASSERT_X(m_modelSetDialog, Q_FUNC_INFO, "No model set dialog"); + m_modelSetDialog->setSimulator(simulator); + + // distributor component + // ui->comp_Distributors->filterBySimulator(simulator); + + const QStringList dirs = m_simulatorSettings.getModelDirectoriesOrDefault(simulator); + ui->le_ModelDirectories->setText(dirs.join(", ")); + + // kind of hack, but simplest solution + // we us the loader of the components directly, + // avoid to fully init a loader logic here + static const QString modelsNo("No models so far"); + const int modelsCount = this->modelLoader()->getCachedModelsCount(simulator); + if (modelsCount > 0) + { + static const QString modelsInfo("%1 included %2 DB key %3"); + const CAircraftModelList modelsInCache = this->modelLoader()->getCachedModels(simulator); + const int modelsIncluded = modelsInCache.countByMode(CAircraftModel::Include); + const int modelsDbKey = modelsInCache.countWithValidDbKey(true); + ui->le_ModelsInfo->setText(modelsInfo.arg(this->modelLoader()->getCacheCountAndTimestamp(simulator)) + .arg(modelsIncluded) + .arg(modelsDbKey)); + } + else { ui->le_ModelsInfo->setText(modelsNo); } + + ui->pb_CreateModelSet->setEnabled(modelsCount > 0); + + static const QString modelsSetNo("Model set is empty"); + const int modelsSetCount = m_modelSetDialog->modelSetComponent()->getModelSetCount(); + ui->le_ModelSetInfo->setText( + modelsSetCount > 0 ? m_modelSetDialog->modelSetComponent()->getModelCacheCountAndTimestamp() : modelsSetNo); + } + + void CAutoModelSetComponent::onSettingsChanged(const CSimulatorInfo &simulator) + { + const CSimulatorInfo currentSimulator = ui->comp_SimulatorSelector->getValue(); + if (simulator != currentSimulator) { return; } // ignore changes not for my selected simulator + this->onSimulatorChanged(simulator); + } + + void CAutoModelSetComponent::onModelsLoaded(const CSimulatorInfo &simulator, int count) + { + Q_UNUSED(count); + const CSimulatorInfo currentSimulator = ui->comp_SimulatorSelector->getValue(); + if (simulator != currentSimulator) { return; } // ignore changes not for my selected simulator + this->onSimulatorChanged(simulator); + } + + void CAutoModelSetComponent::triggerSettingsChanged(const CSimulatorInfo &simulator) + { + if (!sGui || sGui->isShuttingDown()) { return; } + QPointer myself(this); + QTimer::singleShot(0, this, [=] { + if (!myself || !sGui || sGui->isShuttingDown()) { return; } + myself->onSettingsChanged(simulator); + }); + } + + const CDbOwnModelsComponent *CAutoModelSetComponent::modelsComponent() const + { + Q_ASSERT_X(m_modelsDialog, Q_FUNC_INFO, "No models dialog"); + Q_ASSERT_X(m_modelsDialog->modelsComponent(), Q_FUNC_INFO, "No models component"); + return m_modelsDialog->modelsComponent(); + } + + const CDbOwnModelSetComponent *CAutoModelSetComponent::modelSetComponent() const + { + Q_ASSERT_X(m_modelSetDialog, Q_FUNC_INFO, "No model set dialog"); + Q_ASSERT_X(m_modelSetDialog->modelSetComponent(), Q_FUNC_INFO, "No model set component"); + return m_modelSetDialog->modelSetComponent(); + } + + IAircraftModelLoader *CAutoModelSetComponent::modelLoader() const + { + Q_ASSERT_X(m_modelsDialog->modelsComponent()->modelLoader(), Q_FUNC_INFO, "No model loader"); + return m_modelsDialog->modelsComponent()->modelLoader(); + } + + void CAutoModelSetComponent::openOwnModelsDialog() + { + if (!m_modelsDialog) { return; } + if (!sGui || sGui->isShuttingDown() || !sGui->getWebDataServices()) { return; } + const bool reload = (QObject::sender() == ui->pb_ModelsTriggerReload); + + const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue(); + m_modelsDialog->setSimulator(simulator); + + if (reload) + { + if (!sGui->getWebDataServices()->hasDbModelData()) + { + const QMessageBox::StandardButton reply = QMessageBox::warning( + this->mainWindow(), "DB data", "No DB data, models cannot be consolidated. Load anyway?", + QMessageBox::Yes | QMessageBox::No); + if (reply != QMessageBox::Yes) { return; } + } + + bool loadOnlyIfNotEmpty = true; + if (m_modelsDialog->getOwnModelsCount() > 0) + { + const QMessageBox::StandardButton reply = + QMessageBox::warning(this->mainWindow(), "Model loading", + "Reload the models?\nThe existing cache data will we overridden.", + QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::Yes) { loadOnlyIfNotEmpty = false; } + } + m_modelsDialog->requestModelsInBackground(simulator, loadOnlyIfNotEmpty); + } + m_modelsDialog->exec(); + + // force UI update + this->triggerSettingsChanged(simulator); + } + + void CAutoModelSetComponent::openOwnModelSetDialog() + { + CSimulatorInfo simulator; + if (!m_GenerateModelsets) + simulator = ui->comp_SimulatorSelector->getValue(); + else + simulator = m_simulator; + m_modelSetDialog->setSimulator(simulator); + m_modelSetDialog->enableButtons(false, false); + m_modelSetDialog->exec(); + + // force UI update + this->triggerSettingsChanged(simulator); + } + + void CAutoModelSetComponent::changeModelDirectory() + { + using namespace std::chrono_literals; + + if (!sGui || sGui->isShuttingDown()) { return; } + const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue(); + CSpecializedSimulatorSettings settings = m_simulatorSettings.getSpecializedSettings(simulator); + const bool clear = (QObject::sender() == ui->pb_ClearModelDir); + + if (clear) { settings.clearModelDirectories(); } + else + { + const QString dirOld = settings.getFirstModelDirectoryOrDefault(); + const QString newDir = + QFileDialog::getExistingDirectory(this->mainWindow(), tr("Open model directory"), dirOld, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if (newDir.isEmpty() || CDirectoryUtils::isSameExistingDirectory(dirOld, newDir)) { return; } + settings.addModelDirectory(newDir); + } + + const CStatusMessage msg = m_simulatorSettings.setAndSaveSettings(settings, simulator); + if (msg.isSuccess()) { this->triggerSettingsChanged(simulator); } + else { this->showOverlayMessage(msg, 4s); } + } + + void CAutoModelSetComponent::createModelSet() + { + using namespace std::chrono_literals; + CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue(); + + if (m_GenerateModelsets) simulator = m_simulator; + m_simulator = simulator; + if (m_simulator == 64) + { + this->showOverlayHTMLMessage( + CStatusMessage(this).info(u"Automatic model set creation not supported for MSFS2024 yet. Start the " + u"swiftgui or mapping tool to create a model set."), + std::chrono::seconds(10)); + + return; + } + + const int modelsCount = this->modelLoader()->getCachedModelsCount(simulator); + if (modelsCount < 1) + { + static const CStatusMessage msg = + CStatusMessage(this).validationError(u"No models indexed so far. Try 'reload'!"); + this->showOverlayMessage(msg, 4s); + return; + } + + bool useAllModels = false; + // if (!ui->comp_Distributors->hasSelectedDistributors()) + if (!m_GenerateModelsets) + { + const QMessageBox::StandardButton reply = + QMessageBox::question(this->mainWindow(), "Models", "No distributors selected, use all models?", + QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::Yes) { useAllModels = true; } + else + { + static const CStatusMessage msg = CStatusMessage(this).validationError(u"No distributors selected"); + this->showOverlayMessage(msg, 4s); + return; + } + } + else + useAllModels = true; + + CAircraftModelList modelsForSet = this->modelLoader()->getCachedModels(simulator); + if (!useAllModels) + { + // const CDistributorList distributors = ui->comp_Distributors->getSelectedDistributors(); + // modelsForSet = modelsForSet.findByDistributors(distributors); + } + + if (ui->cb_DbDataOnly->isChecked() || m_GenerateModelsets) { modelsForSet.removeObjectsWithoutDbKey(); } + if (modelsForSet.isEmpty()) + { + this->showOverlayHTMLMessage("Selection yielded no result!"); + return; + } + + // just in case, paranoia + if (!m_modelSetDialog || !m_modelSetDialog->modelSetComponent()) + { + this->showOverlayHTMLMessage("No model set dialog, cannot continue"); + return; + } + + const int modelsSetCount = m_modelSetDialog->modelSetComponent()->getModelSetCount(); + if (modelsSetCount > 0 && !m_GenerateModelsets) + { + QMessageBox::StandardButton override = QMessageBox::question( + this, "Override", "Override existing model set?", QMessageBox::Yes | QMessageBox::No); + if (override != QMessageBox::Yes) { return; } + } + + m_modelSetDialog->modelSetComponent()->setModelSet(modelsForSet, simulator); + + if (!m_GenerateModelsets) + { + ui->pb_ModelSet->click(); + return; + }; + + // TODO TZ store modelset + // modelsForSet + CAircraftModelList newModelList; + CAircraftModelList currentSet; + CAircraftModelList NewSet; + + // store the model in the new list + newModelList.replaceOrAddModelsWithString(modelsForSet, Qt::CaseInsensitive); + + if (!newModelList.isEmpty()) + { + + /* m_simulatorInfo = this->getSimulatorInfo();*/ + + bool givenDistributorsOnly = false; + bool dbDataOnly = true; + bool dbIcaoOnly = false; + bool incremnental = false; + bool sortByDistributor = true; + bool consolidateWithDb = true; + bool ShowAllInstalledModells = true; // msfs20424 always show all installed models + + // CDistributorList distributorList; + // for (const QString &name : distributorNames) { distributorList.push_back(CDistributor(name)); } + CDistributorList distributorList = sGui->getWebDataServices()->getDistributors(); + + CModelSetBuilder builder(nullptr); + CModelSetBuilder::Builder options = + givenDistributorsOnly ? CModelSetBuilder::GivenDistributorsOnly : CModelSetBuilder::NoOptions; + if (dbDataOnly) { options |= CModelSetBuilder::OnlyDbData; } + if (dbIcaoOnly) { options |= CModelSetBuilder::OnlyDbIcaoCodes; } + if (incremnental) { options |= CModelSetBuilder::Incremental; } + if (sortByDistributor) { options |= CModelSetBuilder::SortByDistributors; } + if (consolidateWithDb) { options |= CModelSetBuilder::ConsolidateWithDb; } + if (ShowAllInstalledModells) { options |= CModelSetBuilder::ShowAllInstalledModells; } + + CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator); + currentSet = CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator); + + NewSet = builder.buildModelSet(simulator, newModelList, currentSet, options, distributorList); + + swift::core::CAircraftMatcher matcher; + swift::misc::simulation::CAircraftMatcherSetup mSetup = matcher.getSetup(); + + NewSet.setSimulatorInfo(simulator); + matcher.setModelSet(NewSet, simulator, true); + + const QDateTime latestDbModelsTs = + NewSet.isEmpty() ? sApp->getWebDataServices()->getCacheTimestamp(CEntityFlags::ModelEntity) : + NewSet.latestTimestamp(); + if (!latestDbModelsTs.isValid()) { return; } + + // for swiftgui it is enough to set the cache here + // if (gui_application) + CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().setModelsForSimulator(NewSet, + simulator); + + CCentralMultiSimulatorModelCachesProvider::modelCachesInstance().setCachedModels(NewSet, simulator); + + const CStatusMessage m = CStatusMessage(this, CStatusMessage::SeverityInfo, + u"Loading SimObjects and Liveries from the Simulator completed"); + + CLogMessage(this).info(u"%1 SimObjects and Liveries in DbModelList") << NewSet.size(); + } + + this->showOverlayHTMLMessage(CStatusMessage(this).info(u"Modelset for simulator: '%1' created ") + << simulator.getSimulator(), + std::chrono::seconds(2)); + } + + void CAutoModelSetComponent::createAutoModelsets() + { + + m_expertmode = false; + ui->gb_Distributors->setVisible(m_expertmode); // hide for now + ui->fr_ModelsAndSimulator->setVisible(m_expertmode); // hide for now} + m_GenerateModelsets = true; + + // loop for all enabled simulators + CSimulatorInfo sims = this->m_enabledSimulators.get(); + unsigned int number = 96; + + // Iteriere + // for (const auto &simInfo : number) + //{ + // m_simulator = simInfo; + // // this->createModelSet(); + //} + + const int totalBits = sizeof(number) * 8; + for (int i = 0; i < totalBits; ++i) + { + if (number & (1u << i)) + { // Prüfen, ob Bit i gesetzt ist + m_simulator = std::pow(2.0, i); + this->createModelSet(); + } + } + } + + void CAutoModelSetComponent::toggleExportMode() + { + if (m_expertmode) { m_expertmode = false; } + else + { + m_expertmode = true; + m_GenerateModelsets = false; + } + ui->gb_Distributors->setVisible(m_expertmode); // hide for now + ui->fr_ModelsAndSimulator->setVisible(m_expertmode); // hide for now + } + + QWidget *CAutoModelSetComponent::mainWindow() + { + QWidget *pw = CGuiApplication::mainApplicationWidget(); + return pw ? pw : this; + } + + void CAutoModelSetComponent::preselectOptions() + { + QStringList opt = this->m_enabledConfigOptions.get(); // force reload + QString cb_GenerateModelsets = "false"; + QString cb_PTT = "false"; + QString cb_SetExportMode = "false"; + if (!opt.isEmpty()) + { + cb_GenerateModelsets = opt.first(); + opt.removeFirst(); + if (!opt.isEmpty()) cb_PTT = opt.first(); + opt.removeFirst(); + if (!opt.isEmpty()) cb_SetExportMode = opt.first(); + } + m_expertmode = cb_SetExportMode.contains("true") ? true : false; + m_GenerateModelsets = cb_GenerateModelsets.contains("true") ? true : false; + } + + bool CAutoModelSetWizardPage::validatePage() { return true; } +} // namespace swift::gui::components diff --git a/src/gui/components/automodelsetcomponent.h b/src/gui/components/automodelsetcomponent.h new file mode 100644 index 000000000..1ea1befcb --- /dev/null +++ b/src/gui/components/automodelsetcomponent.h @@ -0,0 +1,123 @@ +// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +//! \file + +#ifndef SWIFT_GUI_COMPONENTS_AUTOMODELSETCOMPONENT_H +#define SWIFT_GUI_COMPONENTS_AUTOMODELSETCOMPONENT_H + +#include +#include + +#include "core/application/applicationsettings.h" +#include "gui/overlaymessagesframe.h" +#include "gui/swiftguiexport.h" +#include "misc/logcategories.h" +#include "misc/simulation/aircraftmodelloader.h" +#include "misc/simulation/settings/simulatorsettings.h" +#include "misc/simulation/simulatorinfo.h" + +namespace Ui +{ + class CAutoModelSetComponent; +} +namespace swift::gui::components +{ + class CDbOwnModelsDialog; + class CDbOwnModelsComponent; + class CDbOwnModelSetDialog; + class CDbOwnModelSetComponent; + + //! Create a first model set + class CAutoModelSetComponent : public COverlayMessagesFrame + { + Q_OBJECT + + public: + //! Log categories + static const QStringList &getLogCategories(); + + //! Constructor + explicit CAutoModelSetComponent(QWidget *parent = nullptr); + + //! Destructor + ~CAutoModelSetComponent() override; + + private: + QScopedPointer ui; + QScopedPointer m_modelsDialog; + QScopedPointer m_modelSetDialog; + swift::misc::simulation::settings::CMultiSimulatorSettings m_simulatorSettings { this }; + swift::misc::CSetting m_enabledConfigOptions { this }; + swift::misc::CSetting m_enabledSimulators { this }; + + //! Simulator has been changed + void onSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator); + + //! Simulator settings changed + void onSettingsChanged(const swift::misc::simulation::CSimulatorInfo &simulator); + + //! Models have been loaded + void onModelsLoaded(const swift::misc::simulation::CSimulatorInfo &simulator, int count); + + //! Asynchronously call onSettingsChanged + void triggerSettingsChanged(const swift::misc::simulation::CSimulatorInfo &simulator); + + //! Direct access to component + const CDbOwnModelsComponent *modelsComponent() const; + + //! Direct access to component + const CDbOwnModelSetComponent *modelSetComponent() const; + + //! Direct access to component's loader + swift::misc::simulation::IAircraftModelLoader *modelLoader() const; + + //! Open own models dialog + void openOwnModelsDialog(); + + //! Own model set dialog + void openOwnModelSetDialog(); + + //! Change model directory + void changeModelDirectory(); + + //! Create the model set + void createModelSet(); + + //! Create automatic model sets + void createAutoModelsets(); + + //! Set expert mode for modelset creation + void toggleExportMode(); + + void preselectOptions(); + + bool m_expertmode; + bool m_GenerateModelsets = false; + bool m_SetExportMode = false; + swift::misc::simulation::CSimulatorInfo m_simulator; + + //! Main window or this + QWidget *mainWindow(); + }; + + //! Wizard page for CAutoModelSetComponent + class CAutoModelSetWizardPage : public QWizardPage + { + Q_OBJECT + + public: + //! Constructors + using QWizardPage::QWizardPage; + + //! Set config + void setAutoModelSet(CAutoModelSetComponent *firstModelSet) { m_firstModelSet = firstModelSet; } + + //! \copydoc QWizardPage::validatePage + bool validatePage() override; + + private: + CAutoModelSetComponent *m_firstModelSet = nullptr; + }; +} // namespace swift::gui::components +#endif // SWIFT_GUI_COMPONENTS_AUTOMODELSETCOMPONENT_H diff --git a/src/gui/components/automodelsetcomponent.ui b/src/gui/components/automodelsetcomponent.ui new file mode 100644 index 000000000..2b055418b --- /dev/null +++ b/src/gui/components/automodelsetcomponent.ui @@ -0,0 +1,280 @@ + + + CAutoModelSetComponent + + + + 0 + 0 + 481 + 279 + + + + Configure a 1st model set + + + + + + + + + Yes, please generate the model sets automatically now! + + + + + + + I am an expert and would like to customize. + + + + + + + + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Simulator + + + + + + + 100 + 0 + + + + + + + + + + + Selection + + + + + + with DB data only + + + true + + + + + + + + + + Models + + + + + + true + + + model directory from settings + + + + + + + Models: + + + + + + + Model set + + + + + + + Model dir.: + + + + + + + clear directory or multiple directories + + + clear + + + + + + + + 100 + 0 + + + + display + + + + + + + display + + + + + + + create + + + + :/diagona/icons/diagona/icons/tick-white.png:/diagona/icons/diagona/icons/tick-white.png + + + + false + + + + + + + true + + + model info + + + + + + + true + + + model set info + + + + + + + reload + + + + + + + change + + + + + + + + + + + + + + 0 + 0 + + + + Distributions + + + + + + + + + + + + + + + + swift::gui::components::CSimulatorSelector + QFrame +
gui/components/simulatorselector.h
+ 1 +
+ + swift::gui::components::CDbDistributorComponent + QFrame +
gui/components/dbdistributorcomponent.h
+ 1 +
+
+ + le_ModelDirectories + pb_ClearModelDir + pb_ChangeModelDir + le_ModelsInfo + pb_Models + pb_ModelsTriggerReload + cb_DbDataOnly + le_ModelSetInfo + pb_ModelSet + pb_CreateModelSet + + + + + +
diff --git a/src/gui/components/configsimulatorcomponent.cpp b/src/gui/components/configsimulatorcomponent.cpp index 2c875470f..b88369590 100644 --- a/src/gui/components/configsimulatorcomponent.cpp +++ b/src/gui/components/configsimulatorcomponent.cpp @@ -26,12 +26,13 @@ namespace swift::gui::components CConfigSimulatorComponent::~CConfigSimulatorComponent() = default; - void CConfigSimulatorComponent::save() + void CConfigSimulatorComponent::save() { ui->comp_SettingsSimulator->save(); } + + void CConfigSimulatorComponent::load() { - ui->comp_SettingsSimulator->save(); - const QStringList sims = this->selectedSimsToPluginIds(); - const CStatusMessage msg = m_enabledSimulators.setAndSave(sims); - CLogMessage::preformatted(msg); + // CSimulatorInfo sims = this->m_enabledSimulators.get(); + // ui->comp_SimulatorSelector->setSimulatorVisible(sims); + this->preselectSimulators(); } bool CConfigSimulatorComponent::hasUnsavedChanges() const @@ -44,11 +45,13 @@ namespace swift::gui::components void CConfigSimulatorComponent::preselectSimulators() { CSimulatorInfo sims = m_enabledSimulators.get(); - if (!sims.isAnySimulator()) - { - CSimulatorInfo simWithModels = m_modelSets.simulatorsWithModels(); - sims = simWithModels; - } + // if (!sims.isAnySimulator()) + //{ + CSimulatorInfo simWithModels = m_modelSets.simulatorsWithModels(); + // sims = simWithModels; + //} + if (sims > 127 || sims == 0) sims = CSimulatorInfo::allSimulators(); + // sims = 0; // reset to none if invalid (happens if no enabledsimulators.json exists) // no x64 check as we would allow to config 32bit with launcher x64 and vice versa const bool p3d = @@ -57,64 +60,37 @@ namespace swift::gui::components (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 msfs2024 = (sims.isMSFS2024() || !CFsDirectories::msfs2024Dir().isEmpty()) && - CBuildConfig::isCompiledWithMSFS2024Support(); + + // const bool msfs2020 = (sims.isMSFS2020() || !CFsDirectories::msfs2020Dir().isEmpty()) && + // CBuildConfig::isCompiledWithMSFS2020Support(); + // const bool msfs2024 = (sims.isMSFS2024() || !CFsDirectories::msfs2024Dir().isEmpty()) && + // CBuildConfig::isCompiledWithMSFS2024Support(); + + const bool msfs2020 = (sims.isMSFS2020() && CBuildConfig::isCompiledWithMSFS2020Support()); + + const bool msfs2024 = (sims.isMSFS2024() && CBuildConfig::isCompiledWithMSFS2024Support()); + const bool xp = sims.isXPlane() && CBuildConfig::isCompiledWithXPlaneSupport(); const bool fg = sims.isFG() && CBuildConfig::isCompiledWithFGSupport(); - ui->cb_P3D->setChecked(p3d); - ui->cb_FSX->setChecked(fsx); - ui->cb_FS9->setChecked(fs9); - ui->cb_XP->setChecked(xp); - ui->cb_FG->setChecked(fg); - ui->cb_MSFS->setChecked(msfs); - ui->cb_MSFS2024->setChecked(msfs2024); - - 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()); - ui->cb_MSFS2024->setEnabled(CBuildConfig::isCompiledWithMSFS2024Support()); - - 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()); - CGuiUtility::checkBoxReadOnly(ui->cb_MSFS2024, !CBuildConfig::isCompiledWithMSFS2024Support()); - 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)); } + else if (msfs2020) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS2020)); } else if (msfs2024) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS2024)); } + + ui->comp_SettingsSimulator->hideSelector(sims); } - QStringList CConfigSimulatorComponent::selectedSimsToPluginIds() + void CConfigSimulatorWizardPage::initializePage() { - QStringList ids; - - // have to match full canonical ids from swift-plugin-simulators.xml - if (ui->cb_FS9->isChecked()) { ids << CSimulatorPluginInfo::fs9PluginIdentifier(); } - if (ui->cb_FSX->isChecked()) { ids << CSimulatorPluginInfo::fsxPluginIdentifier(); } - 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(); } - if (ui->cb_MSFS2024->isChecked()) { ids << CSimulatorPluginInfo::msfs2024PluginIdentifier(); } - - return ids; + m_config->resetUnsavedChanges(); + Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config"); + m_config->load(); } - void CConfigSimulatorWizardPage::initializePage() { m_config->resetUnsavedChanges(); } - bool CConfigSimulatorWizardPage::validatePage() { Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config"); diff --git a/src/gui/components/configsimulatorcomponent.h b/src/gui/components/configsimulatorcomponent.h index 54289593e..8442f396c 100644 --- a/src/gui/components/configsimulatorcomponent.h +++ b/src/gui/components/configsimulatorcomponent.h @@ -36,6 +36,9 @@ namespace swift::gui::components //! Save data void save(); + //! Load data + void load(); + //! Has unsaved changes bool hasUnsavedChanges() const; diff --git a/src/gui/components/configsimulatorcomponent.ui b/src/gui/components/configsimulatorcomponent.ui index bbdc0879b..68fe1df4b 100644 --- a/src/gui/components/configsimulatorcomponent.ui +++ b/src/gui/components/configsimulatorcomponent.ui @@ -26,82 +26,7 @@ 4 - - - - Select your simulator(s) - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - XPlane (32,64-bit) - - - - - - - P3D (64-bit) - - - - - - - FSX (32-bit) - - - - - - - FS9 (32-bit) - - - - 64 - 64 - - - - - - - - FlightGear (64-bit) - - - - - - - MSFS (64-bit) - - - - - - - MSFS2024 (64-bit) - - - - - - + @@ -166,13 +91,6 @@ 1 - - cb_P3D - cb_FSX - cb_FS9 - cb_XP - cb_FG - - + diff --git a/src/gui/components/configurationwizard.cpp b/src/gui/components/configurationwizard.cpp index ddb00b251..943915b70 100644 --- a/src/gui/components/configurationwizard.cpp +++ b/src/gui/components/configurationwizard.cpp @@ -23,19 +23,25 @@ namespace swift::gui::components this->setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); - ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); - ui->wp_CopySettingsAndCaches->setConfigComponent(ui->comp_CopySettingsAndCachesComponent); - ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); - ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_InstallXSwiftBus, ui->comp_InstallFsxTerrainProbe); - ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad); - ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys); ui->wp_Legal->setConfigComponent(ui->comp_LegalInformation); + + ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad); + ui->wp_CopySettingsAndCaches->setConfigComponent(ui->comp_CopySettingsAndCachesComponent); + ui->wp_SelectSimulator->setConfigComponent(ui->comp_SelectSimulator); + ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); + ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); + + ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_InstallXSwiftBus, ui->comp_InstallFsxTerrainProbe); + ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys); + ui->wp_Finish->setConfigComponent(ui->comp_FinishWizard); + ui->comp_Hotkeys->registerDummyPttEntry(); + this->setButtonText(CustomButton1, "skip"); // no other versions, skip copy pages // disabled afetr discussion with RP as it is confusing - // if (!CApplicationInfoList::hasOtherSwiftDataDirectories()) { this->setStartId(ConfigSimulator); } + // if (!CApplicationInfoList::hasOtherSwiftDataDirectories()) { this->setStartId(SelectSimulator); } ui->tb_SimulatorSpecific->setCurrentWidget(ui->comp_InstallXSwiftBus); @@ -46,6 +52,7 @@ namespace swift::gui::components connect(this, &QWizard::currentIdChanged, this, &CConfigurationWizard::wizardCurrentIdChanged); connect(this, &QWizard::customButtonClicked, this, &CConfigurationWizard::clickedCustomButton); + connect(this, &QWizard::rejected, this, &CConfigurationWizard::ended); connect(this, &QWizard::accepted, this, &CConfigurationWizard::ended); @@ -73,15 +80,97 @@ namespace swift::gui::components void CConfigurationWizard::wizardCurrentIdChanged(int id) { + // Remember previous ID const int previousId = m_previousId; - const bool backward = id < previousId; - const bool skipped = m_skipped; - m_previousId = id; // update - m_skipped = false; // reset - Q_UNUSED(skipped); - Q_UNUSED(backward); + // Update state: Save previous ID, determine forward + m_previousId = id; + m_forward = (id > previousId); + + // reset skipped flag + m_skipped = false; + + // Load selected simulators and activated options + const swift::misc::simulation::CSimulatorInfo selectedSims = ui->comp_SelectSimulator->getSelectedSimulators(); + + bool showModelGenerationPage = false; + bool showPttPage = false; + QStringList enabledOptions = m_enabledConfigOptions.get(); // force reload + if (!enabledOptions.isEmpty()) + { + showModelGenerationPage = enabledOptions.takeFirst().contains("true"); + if (!enabledOptions.isEmpty()) { showPttPage = enabledOptions.first().contains("true"); } + } + + // display semi-transparent this->setParentOpacity(0.5); + + // If no other data directories exist, skip certain pages. + if (!CApplicationInfoList::hasOtherSwiftDataDirectories() && (id == 2 || id == 3)) + { + if (!m_forward) + { + id = DataLoad; + m_previousId = SelectSimulator; + } + else + { + id = SelectSimulator; + m_previousId = DataLoad; + } + } + + // If we have just passed SelectSimulator, make sure a simulator is selected. + if (previousId == SelectSimulator && id > SelectSimulator) + { + if (!selectedSims.isAnySimulator()) + { + // return to selection, validation message and cancel + id = SelectSimulator; + m_previousId = SelectSimulator; + this->setCurrentId(SelectSimulator); + static const CStatusMessage msg = CStatusMessage().validationError( + u"Please select at least one simulator to continue the configuration."); + CLogMessage::preformatted(msg); + } + } + + // Skip AutoModelSet if disabled + if (id == AutoModelSet && !showModelGenerationPage) { ++id; } + + if (id == XSwiftBus && !selectedSims.isXPlane()) + { + if (m_forward) + { + id = ConfigHotkeys; + m_previousId = AutoModelSet; + } + else + { + id = AutoModelSet; + m_previousId = ConfigHotkeys; + } + } + + // Skip ConfigHotkeys when PTT is disabled + if (id == ConfigHotkeys && !showPttPage) + { + if (m_forward) + { + id = FinshWizard; + m_previousId = XSwiftBus; + } + else + { + id = XSwiftBus; + m_previousId = FinshWizard; + } + } + + // final adjustments + // jump to a specific page + this->setCurrentId(id); + const QWizardPage *page = this->currentPage(); Q_UNUSED(page); @@ -90,7 +179,8 @@ namespace swift::gui::components void CConfigurationWizard::clickedCustomButton(int which) { - if (which == static_cast(CustomButton1)) + + if (which == static_cast(CustomButton1)) // skip { m_skipped = true; this->next(); @@ -125,4 +215,5 @@ namespace swift::gui::components const int h = qMin(750, calcH); this->resize(w, h); } + } // namespace swift::gui::components diff --git a/src/gui/components/configurationwizard.h b/src/gui/components/configurationwizard.h index d20cd60b9..aa5539a87 100644 --- a/src/gui/components/configurationwizard.h +++ b/src/gui/components/configurationwizard.h @@ -32,10 +32,12 @@ namespace swift::gui::components DataLoad, CopyModels, CopySettingsAndCaches, + SelectSimulator, ConfigSimulator, - FirstModelSet, + AutoModelSet, XSwiftBus, - ConfigHotkeys + ConfigHotkeys, + FinshWizard }; //! Constructor @@ -71,6 +73,9 @@ namespace swift::gui::components int m_minId = -1; int m_maxId = -1; bool m_skipped = false; + bool m_forward = true; + + swift::misc::CSetting m_enabledConfigOptions { this }; }; } // namespace swift::gui::components #endif // SWIFT_GUI_COMPONENTS_CONFIGURATIONWIZARD_H diff --git a/src/gui/components/configurationwizard.ui b/src/gui/components/configurationwizard.ui index adb36b8c1..8c4b7c60d 100644 --- a/src/gui/components/configurationwizard.ui +++ b/src/gui/components/configurationwizard.ui @@ -1,462 +1,531 @@ - CConfigurationWizard - - - Qt::ApplicationModal - - - - 0 - 0 - 700 - 600 - - - - - 700 - 600 - - - - swift configuration wizard - - - true - - - QWizard::ClassicStyle - - - QWizard::HaveCustomButton1 - - - - Legal - - - Please confirm you know and understand our license and privacy policy - - - - 4 + CConfigurationWizard + + + Qt::ApplicationModal - - 4 + + + 0 + 0 + 700 + 600 + - - 4 + + + 700 + 600 + - - 4 + + swift configuration wizard - - - - - - - - Data loading - - - Caches model and ICAO data - - - - 4 + + true - - 4 + + QWizard::ClassicStyle - - 4 + + QWizard::HaveCustomButton1 - - 4 - - - - - - 0 - 150 - + + + Legal - - - - - - - Copy models - - - Copy model data from other swift versions. Here you can copy your model set or model cache from another swift version. - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - - - - Copy settings and caches - - - Copy settings and caches from other swift versions - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - true + + Please confirm you know and understand our license and privacy policy - - - - 0 - 0 - 90 - 20 - - - + - 0 + 4 - 0 + 4 - 0 + 4 - 0 + 4 - + - - - - - - - - - Simulator - - - Simulator(s) you are using - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - 0 - 125 - - - - - - - - - First model set - - - Create a simple model set (for a start) - - - - - - I do this later / do not need this - - - - - - - - 0 - 175 - - - - - - - - - Simulator specific installations - - - Install xswiftbus (X-Plane only) or swift terrain probe (FSX/P3D only) - - - - - - 1 - - - - - 0 - 0 - 89 - 64 - - - - Install FSX terrain probe - - - - - - - 0 - 50 - - - - - - - - - - 0 - 0 - 75 - 64 - - - - XPlane: Install xswiftbus - - - - - - - 0 - 50 - - - - - - - - - - - - - Hotkeys - - - Configure (at least) your PTT key - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - 0 - 200 - - - - Hotkeys - - - - - - - - + + + + Data loading + + + Caches model and ICAO data + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 0 + 150 + + + + + + + + + Copy settings and caches + + + Copy settings and caches from other swift versions + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + true + + + + + 0 + 0 + 90 + 20 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + Copy models + + + Copy model data from other swift versions. Here you can copy your model set or model cache from another swift version. + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + + + + Simulator + + + Simulator(s) you are using with swift and other options + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 0 + 125 + + + + + + + + + Simulator + + + Simulator(s) you are using with swift + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 0 + 125 + + + + + + + + + Create a first model set + + + Create a simple model set for each simulator to get started. + + + + + + + 0 + 175 + + + + + + + + + + Simulator specific installations + + + Install xswiftbus (X-Plane only) or swift terrain probe (FSX/P3D only) + + + + + + 1 + + + + + 0 + 0 + 89 + 64 + + + + Install FSX terrain probe + + + + + + + 0 + 50 + + + + + + + + + + 0 + 0 + 75 + 64 + + + + XPlane: Install xswiftbus + + + + + + + 0 + 50 + + + + + + + + + + + + + Hotkeys + + + Configure (at least) your PTT key + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 0 + 200 + + + + Hotkeys + + + + + + + + + + + + + + + + You have successfully completed the installation. + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + - - - - swift::gui::components::CFirstModelSetComponent - QFrame -
gui/components/firstmodelsetcomponent.h
- 1 -
- - swift::gui::components::CConfigSimulatorComponent - QFrame -
gui/components/configsimulatorcomponent.h
- 1 -
- - swift::gui::components::CConfigSimulatorWizardPage - QWizardPage -
gui/components/configsimulatorcomponent.h
- 1 -
- - swift::gui::components::CInitialDataLoadWizardPage - QWizardPage -
gui/components/initialdataloadcomponent.h
- 1 -
- - swift::gui::components::CInitialDataLoadComponent - QFrame -
gui/components/initialdataloadcomponent.h
- 1 -
- - swift::gui::components::CSettingsHotkeyComponent - QFrame -
gui/components/settingshotkeycomponent.h
- 1 -
- - swift::gui::components::CConfigHotkeyWizardPage - QWizardPage -
gui/components/settingshotkeycomponent.h
- 1 -
- - swift::gui::components::CInstallXSwiftBusComponent - QFrame -
gui/components/installxswiftbuscomponent.h
- 1 -
- - swift::gui::components::CFirstModelSetWizardPage - QWizardPage -
gui/components/firstmodelsetcomponent.h
- 1 -
- - swift::gui::components::CCopyModelsFromOtherSwiftVersionsWizardPage - QWizardPage -
gui/components/copymodelsfromotherswiftversionscomponent.h
- 1 -
- - swift::gui::components::CCopyModelsFromOtherSwiftVersionsComponent - QFrame -
gui/components/copymodelsfromotherswiftversionscomponent.h
- 1 -
- - swift::gui::components::CLegalInfoComponent - QFrame -
gui/components/legalinfocomponent.h
- 1 -
- - swift::gui::components::CLegalInfoWizardPage - QWizardPage -
gui/components/legalinfocomponent.h
- 1 -
- - swift::gui::components::CCopySettingsAndCachesComponent - QFrame -
gui/components/copysettingsandcachescomponent.h
- 1 -
- - swift::gui::components::CCopySettingsAndCachesWizardPage - QWizardPage -
gui/components/copysettingsandcachescomponent.h
- 1 -
- - swift::gui::components::CInstallSimulatorSpecificWizardPage - QWizardPage -
gui/components/installsimulatorspecificwizardpage.h
- 1 -
- - swift::gui::components::CInstallFsxTerrainProbeComponent - QFrame -
gui/components/installfsxterrainprobecomponent.h
- 1 -
-
- - - - pb_SkipFirstModelSet - clicked() - CConfigurationWizard - next() - - - 678 - 67 - - - 804 - 121 - - - - + + + swift::gui::components::CAutoModelSetComponent + QFrame +
gui/components/automodelsetcomponent.h
+ 1 +
+ + swift::gui::components::CSelectSimulatorComponent + QFrame +
gui/components/selectsimulatorcomponent.h
+ 1 +
+ + swift::gui::components::CSelectSimulatorWizardPage + QWizardPage +
gui/components/selectsimulatorcomponent.h
+ 1 +
+ + swift::gui::components::CConfigSimulatorComponent + QFrame +
gui/components/configsimulatorcomponent.h
+ 1 +
+ + swift::gui::components::CConfigSimulatorWizardPage + QWizardPage +
gui/components/configsimulatorcomponent.h
+ 1 +
+ + swift::gui::components::CInitialDataLoadWizardPage + QWizardPage +
gui/components/initialdataloadcomponent.h
+ 1 +
+ + swift::gui::components::CInitialDataLoadComponent + QFrame +
gui/components/initialdataloadcomponent.h
+ 1 +
+ + swift::gui::components::CSettingsHotkeyComponent + QFrame +
gui/components/settingshotkeycomponent.h
+ 1 +
+ + swift::gui::components::CConfigHotkeyWizardPage + QWizardPage +
gui/components/settingshotkeycomponent.h
+ 1 +
+ + swift::gui::components::CInstallXSwiftBusComponent + QFrame +
gui/components/installxswiftbuscomponent.h
+ 1 +
+ + swift::gui::components::CAutoModelSetWizardPage + QWizardPage +
gui/components/automodelsetcomponent.h
+ 1 +
+ + swift::gui::components::CCopyModelsFromOtherSwiftVersionsWizardPage + QWizardPage +
gui/components/copymodelsfromotherswiftversionscomponent.h
+ 1 +
+ + swift::gui::components::CCopyModelsFromOtherSwiftVersionsComponent + QFrame +
gui/components/copymodelsfromotherswiftversionscomponent.h
+ 1 +
+ + swift::gui::components::CLegalInfoComponent + QFrame +
gui/components/legalinfocomponent.h
+ 1 +
+ + swift::gui::components::CLegalInfoWizardPage + QWizardPage +
gui/components/legalinfocomponent.h
+ 1 +
+ + swift::gui::components::CCopySettingsAndCachesComponent + QFrame +
gui/components/copysettingsandcachescomponent.h
+ 1 +
+ + swift::gui::components::CCopySettingsAndCachesWizardPage + QWizardPage +
gui/components/copysettingsandcachescomponent.h
+ 1 +
+ + swift::gui::components::CInstallSimulatorSpecificWizardPage + QWizardPage +
gui/components/installsimulatorspecificwizardpage.h
+ 1 +
+ + swift::gui::components::CInstallFsxTerrainProbeComponent + QFrame +
gui/components/installfsxterrainprobecomponent.h
+ 1 +
+ + swift::gui::components::CFinishWizardPage + QFrame +
gui/components/finishwizardcomponent.h
+ 1 +
+
+ + + + pb_SkipAutoModelSet + clicked() + CConfigurationWizard + next() + + + 678 + 67 + + + 804 + 121 + + + + diff --git a/src/gui/components/copymodelsfromotherswiftversionscomponent.cpp b/src/gui/components/copymodelsfromotherswiftversionscomponent.cpp index f62468841..4d77da0f9 100644 --- a/src/gui/components/copymodelsfromotherswiftversionscomponent.cpp +++ b/src/gui/components/copymodelsfromotherswiftversionscomponent.cpp @@ -38,6 +38,12 @@ namespace swift::gui::components CCopyModelsFromOtherSwiftVersionsComponent::~CCopyModelsFromOtherSwiftVersionsComponent() = default; + void CCopyModelsFromOtherSwiftVersionsComponent::load() + { + CSimulatorInfo sims = this->m_enabledSimulators.get(); + ui->comp_SimulatorSelector->setSimulatorVisible(sims); + } + void CCopyModelsFromOtherSwiftVersionsComponent::copy() { using namespace std::chrono_literals; @@ -201,7 +207,11 @@ namespace swift::gui::components void CCopyModelsFromOtherSwiftVersionsWizardPage::initializePage() { // force reload as the other version could be changed - if (m_copyModels) { m_copyModels->reloadOtherVersions(1000); } + if (m_copyModels) + { + m_copyModels->reloadOtherVersions(1000); + m_copyModels->load(); + } } bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage() diff --git a/src/gui/components/copymodelsfromotherswiftversionscomponent.h b/src/gui/components/copymodelsfromotherswiftversionscomponent.h index ef1917a1a..230d6bd8d 100644 --- a/src/gui/components/copymodelsfromotherswiftversionscomponent.h +++ b/src/gui/components/copymodelsfromotherswiftversionscomponent.h @@ -37,6 +37,9 @@ namespace swift::gui::components //! Reload other versions void reloadOtherVersions(int deferMs = -1); + //! Load enabled sims + void load(); + private: //! Copy as per UI settings void copy(); @@ -57,6 +60,7 @@ namespace swift::gui::components // caches will be explicitly initialized in copy swift::misc::simulation::data::CModelCaches m_modelCaches { false, this }; swift::misc::simulation::data::CModelSetCaches m_modelSetCaches { false, this }; + swift::misc::CSetting m_enabledSimulators { this }; }; /*! diff --git a/src/gui/components/copysettingsandcachescomponent.cpp b/src/gui/components/copysettingsandcachescomponent.cpp index 413449e37..65117394a 100644 --- a/src/gui/components/copysettingsandcachescomponent.cpp +++ b/src/gui/components/copysettingsandcachescomponent.cpp @@ -80,9 +80,18 @@ namespace swift::gui::components !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorFsx.getFilename())); readOnlyCheckbox(ui->cb_SettingsSimulatorP3D, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorP3D.getFilename())); + readOnlyCheckbox(ui->cb_SettingsSimulatorXPlane, !CCacheSettingsUtils::hasOtherVersionSettingsFile( info, m_settingsSimulatorXPlane.getFilename())); + readOnlyCheckbox(ui->cb_SettingsSimulatorFG, + !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorFG.getFilename())); + + readOnlyCheckbox(ui->cb_SettingsSimulatorMSFS2020, !CCacheSettingsUtils::hasOtherVersionSettingsFile( + info, m_settingsSimulatorMSFS2020.getFilename())); + readOnlyCheckbox(ui->cb_SettingsSimulatorMSFS2024, !CCacheSettingsUtils::hasOtherVersionSettingsFile( + info, m_settingsSimulatorMSFS2024.getFilename())); + readOnlyCheckbox(ui->cb_SettingsActionHotkeys, !CCacheSettingsUtils::hasOtherVersionSettingsFile( info, m_settingsActionHotkeys.getFilename())); readOnlyCheckbox(ui->cb_SettingsTextMessages, @@ -133,6 +142,9 @@ namespace swift::gui::components ui->cb_SettingsSimulatorFSX->setText(checkBoxText(TSimulatorFsx::humanReadable(), true)); ui->cb_SettingsSimulatorP3D->setText(checkBoxText(TSimulatorP3D::humanReadable(), true)); ui->cb_SettingsSimulatorXPlane->setText(checkBoxText(TSimulatorXP::humanReadable(), true)); + ui->cb_SettingsSimulatorFG->setText(checkBoxText(TSimulatorFG::humanReadable(), true)); + ui->cb_SettingsSimulatorMSFS2020->setText(checkBoxText(TSimulatorMsfs2020::humanReadable(), true)); + ui->cb_SettingsSimulatorMSFS2024->setText(checkBoxText(TSimulatorMsfs2024::humanReadable(), true)); } void CCopySettingsAndCachesComponent::initMisc() @@ -148,6 +160,8 @@ namespace swift::gui::components ui->cb_SettingsConsolidation->setText(checkBoxText(TBackgroundConsolidation::humanReadable(), true)); } + // after copying, we have to reload settings in the application. Otherwise, the changes won't take effect until the + // next restart. int CCopySettingsAndCachesComponent::copy() { ui->le_Status->clear(); @@ -370,6 +384,53 @@ namespace swift::gui::components } } + if (ui->cb_SettingsSimulatorFG->isChecked()) + { + const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent( + otherVersionInfo, m_settingsSimulatorFG.getFilename()); + if (!joStr.isEmpty()) + { + const CSimulatorSettings settings = CSimulatorSettings::fromJsonNoThrow(joStr, true, success, errMsg); + if (this->parsingMessage(success, errMsg, m_settingsSimulatorFG.getKey())) + { + this->displayStatusMessage(m_settingsSimulatorFG.setAndSave(settings), settings.toQString(true)); + } + copied++; + } + } + + if (ui->cb_SettingsSimulatorMSFS2020->isChecked()) + { + const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent( + otherVersionInfo, m_settingsSimulatorMSFS2020.getFilename()); + if (!joStr.isEmpty()) + { + const CSimulatorSettings settings = CSimulatorSettings::fromJsonNoThrow(joStr, true, success, errMsg); + if (this->parsingMessage(success, errMsg, m_settingsSimulatorMSFS2020.getKey())) + { + this->displayStatusMessage(m_settingsSimulatorMSFS2020.setAndSave(settings), + settings.toQString(true)); + } + copied++; + } + } + + if (ui->cb_SettingsSimulatorMSFS2024->isChecked()) + { + const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent( + otherVersionInfo, m_settingsSimulatorMSFS2024.getFilename()); + if (!joStr.isEmpty()) + { + const CSimulatorSettings settings = CSimulatorSettings::fromJsonNoThrow(joStr, true, success, errMsg); + if (this->parsingMessage(success, errMsg, m_settingsSimulatorMSFS2024.getKey())) + { + this->displayStatusMessage(m_settingsSimulatorMSFS2024.setAndSave(settings), + settings.toQString(true)); + } + copied++; + } + } + // ------ model ------ if (ui->cb_SettingsModel->isChecked()) { diff --git a/src/gui/components/copysettingsandcachescomponent.h b/src/gui/components/copysettingsandcachescomponent.h index 1a3869f32..9febac13a 100644 --- a/src/gui/components/copysettingsandcachescomponent.h +++ b/src/gui/components/copysettingsandcachescomponent.h @@ -135,6 +135,16 @@ namespace swift::gui::components swift::misc::CSetting m_settingsSimulatorXPlane { this }; //!< XP settings + swift::misc::CSetting m_settingsSimulatorFG { + this + }; //!< XP settings + swift::misc::CSetting m_settingsSimulatorMSFS2020 { + this + }; //!< MSFS2020 settings + swift::misc::CSetting m_settingsSimulatorMSFS2024 { + this + }; //!< MSFS2024 settings + swift::misc::CSetting m_settingsModel { this }; //!< model setting swift::misc::CData m_cacheLastVatsimServer { diff --git a/src/gui/components/copysettingsandcachescomponent.ui b/src/gui/components/copysettingsandcachescomponent.ui index bdeed111c..7093d4a01 100644 --- a/src/gui/components/copysettingsandcachescomponent.ui +++ b/src/gui/components/copysettingsandcachescomponent.ui @@ -181,7 +181,28 @@
- + + + + FG + + + + + + + MSFS2020 + + + + + + + MSFS2024 + + + + @@ -340,6 +361,9 @@ cb_SettingsSimulatorP3D cb_SettingsSimulatorFSX cb_SettingsSimulatorXPlane + cb_SettingsSimulatorFG + cb_SettingsSimulatorMSFS2020 + cb_SettingsSimulatorMSFS2020 cb_SettingsModel cb_SettingsConsolidation cb_SettingsActionHotkeys diff --git a/src/gui/components/dbownmodelsetcomponent.cpp b/src/gui/components/dbownmodelsetcomponent.cpp index 1ed96968d..5616e3e24 100644 --- a/src/gui/components/dbownmodelsetcomponent.cpp +++ b/src/gui/components/dbownmodelsetcomponent.cpp @@ -585,19 +585,19 @@ namespace swift::gui::components }); m_setNewActions.append(a); } - if (sims.isMSFS()) + if (sims.isMSFS2020()) { - auto *a = new QAction(CIcons::appModels16(), "MSFS models", this); + auto *a = new QAction(CIcons::appModels16(), "MSFS2020 models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) { Q_UNUSED(checked) - ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS)); + ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::MSFS2020)); }); m_setActions.append(a); - a = new QAction(CIcons::appModels16(), "New set MSFS models", this); + a = new QAction(CIcons::appModels16(), "New set MSFS2020 models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) { Q_UNUSED(checked) - ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::MSFS)); + ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::MSFS2020)); }); m_setNewActions.append(a); } diff --git a/src/gui/components/finishwizardcomponent.cpp b/src/gui/components/finishwizardcomponent.cpp new file mode 100644 index 000000000..f66d91915 --- /dev/null +++ b/src/gui/components/finishwizardcomponent.cpp @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +#include "finishwizardcomponent.h" + +#include + +#include "ui_finishwizardcomponent.h" + +#include "config/buildconfig.h" +#include "core/data/globalsetup.h" +#include "gui/guiapplication.h" +#include "misc/logmessage.h" +#include "misc/network/url.h" +#include "misc/statusmessage.h" + +using namespace swift::misc; +using namespace swift::misc::network; +using namespace swift::core::data; +using namespace swift::config; + +namespace swift::gui::components +{ + CFinishWizardComponent::CFinishWizardComponent(QWidget *parent) + : COverlayMessagesFrame(parent), ui(new Ui::CFinishWizardComponent) + { + ui->setupUi(this); + } + + CFinishWizardComponent::~CFinishWizardComponent() = default; + + bool CFinishWizardPage::validatePage() { return m_finishwizard; } +} // namespace swift::gui::components diff --git a/src/gui/components/finishwizardcomponent.h b/src/gui/components/finishwizardcomponent.h new file mode 100644 index 000000000..b82af6234 --- /dev/null +++ b/src/gui/components/finishwizardcomponent.h @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +//! \file + +#ifndef SWIFT_GUI_COMPONENTS_FINISHWIZARDCOMPONENT_H +#define SWIFT_GUI_COMPONENTS_FINISHWIZARDCOMPONENT_H + +#include +#include +#include + +#include "core/application/applicationsettings.h" +#include "gui/overlaymessagesframe.h" + +namespace Ui +{ + class CFinishWizardComponent; +} +namespace swift::gui::components +{ + /*! + * swift legal information + */ + class CFinishWizardComponent : public COverlayMessagesFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CFinishWizardComponent(QWidget *parent = nullptr); + + //! Destructor + ~CFinishWizardComponent() override; + + //! Agreed with? + bool isAgreedTo() const; + + //! Validate that the agreement is accepted + bool validateAgreement(); + + private: + //! Allow crash dumps + void onAllowCrashDumps(bool checked); + + //! Set the checklist info + void setChecklistInfo(); + + QScopedPointer ui; + swift::misc::CSetting m_crashDumpUploadEnabled { this }; + }; + + /*! + * Wizard page for CFinishWizardComponent + */ + class CFinishWizardPage : public QWizardPage + { + Q_OBJECT + + public: + //! Constructors + using QWizardPage::QWizardPage; + + //! Set config + void setConfigComponent(CFinishWizardComponent *config) { m_finishwizard = config; } + + //! \copydoc QWizardPage::validatePage + bool validatePage() override; + + private: + CFinishWizardComponent *m_finishwizard = nullptr; + }; +} // namespace swift::gui::components + +#endif // SWIFT_GUI_COMPONENTS_FINISHWIZARDCOMPONENT_H diff --git a/src/gui/components/finishwizardcomponent.ui b/src/gui/components/finishwizardcomponent.ui new file mode 100644 index 000000000..9bbddc153 --- /dev/null +++ b/src/gui/components/finishwizardcomponent.ui @@ -0,0 +1,204 @@ + + + CFinishWizardComponent + + + + 0 + 0 + 542 + 285 + + + + swift finish information + + + + + + + + + + + + :/pastel/icons/pastel/32/exclamation.png + + + + + + + HINT: Click here for our online documentation + <html><head/><body><p><span style=" font-weight:600;">Loading the setup file (bootstrap.json) has failed!</span> This file is required for <span style=" font-style:italic;">swift</span> to work properly. Fix the errors mentioned below and restart swift. You can also replace your bootstrap.json with the latest version available <a href="https://swift-project.org/;><span style=" text-decoration: underline; color:#0000ff;">from GitHub.</span></a></p></body></html> + + + + + + + + + + + 0 + 0 + 467 + 134 + + + + Start application + + + + 3 + + + 3 + + + 3 + + + 3 + + + 1 + + + + + start swift GUI + + + swift GUI + + + + :/own/icons/own/swift3D/sw3DBlue-256.png:/own/icons/own/swift3D/sw3DBlue-256.png + + + + + 64 + 64 + + + + + + 1 + + + + + start swift core + + + swift core + + + + :/own/icons/own/swift3D/sw3DOrange-256.png:/own/icons/own/swift3D/sw3DOrange-256.png + + + + + 64 + 64 + + + + + + 1 + + + + + start swift data (the mapping tool) + + + mapping tool + + + + :/own/icons/own/swift3D/sw3DGreen-256.png:/own/icons/own/swift3D/sw3DGreen-256.png + + + + + 64 + 64 + + + + + + 1 + + + + + start swift launcher + + + config tool + + + + :/own/icons/own/swift3D/sw3DBlack-256.png:/own/icons/own/swift3D/sw3DBlack-256.png + + + + + 64 + 64 + + + + + + + + + + + GUI the link between simulation and network during the online connection + + + + + + + core component for networked computers + + + + + + + mapping tool for creating customized model sets + + + + + + + config tool to adjust basic settings + + + + + + + + + + + + + + diff --git a/src/gui/components/selectsimulatorcomponent.cpp b/src/gui/components/selectsimulatorcomponent.cpp new file mode 100644 index 000000000..cb2ef1e32 --- /dev/null +++ b/src/gui/components/selectsimulatorcomponent.cpp @@ -0,0 +1,183 @@ +// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +#include "selectsimulatorcomponent.h" + +#include "ui_selectsimulatorcomponent.h" + +#include "config/buildconfig.h" +#include "gui/components/configurationwizard.h" +#include "gui/guiutility.h" +#include "misc/logmessage.h" +#include "misc/simulation/fscommon/fsdirectories.h" + +using namespace swift::misc; +using namespace swift::misc::simulation; +using namespace swift::misc::simulation::fscommon; +using namespace swift::config; + +namespace swift::gui::components +{ + CSelectSimulatorComponent::CSelectSimulatorComponent(QWidget *parent) + : QFrame(parent), ui(new Ui::CSelectSimulatorComponent) + { + ui->setupUi(this); + this->preselectSimulators(); + this->preselectOptions(); + } + + CSelectSimulatorComponent::~CSelectSimulatorComponent() = default; + + CSimulatorInfo CSelectSimulatorComponent::getSelectedSimulators() + { + int sims = ui->cb_FS9->isChecked() ? 1 : 0; + sims += ui->cb_FSX->isChecked() ? 2 : 0; + sims += ui->cb_P3D->isChecked() ? 4 : 0; + sims += ui->cb_XP->isChecked() ? 8 : 0; + sims += ui->cb_FG->isChecked() ? 16 : 0; + sims += ui->cb_MSFS2020->isChecked() ? 32 : 0; + sims += ui->cb_MSFS2024->isChecked() ? 64 : 0; + return sims; + } + + void CSelectSimulatorComponent::save() + { + const QStringList sims = this->selectedSimsToPluginIds(); + const CStatusMessage msg = this->m_enabledSimulators.setAndSave(sims); + CLogMessage::preformatted(msg); + + const QStringList opt = this->selectedOptions(); + CLogMessage::preformatted(m_enabledConfigOptions.setAndSave(opt)); + CLogMessage::preformatted(msg); + } + + void CSelectSimulatorComponent::load() { this->preselectSimulators(); } + + void CSelectSimulatorComponent::preselectOptions() + { + QStringList opt = this->m_enabledConfigOptions.get(); // force reload + QString cb_GenerateModelsets = "false"; + QString cb_PTT = "false"; + QString cb_SetExportMode = "false"; + if (!opt.isEmpty()) + { + cb_GenerateModelsets = opt.first(); + opt.removeFirst(); + if (!opt.isEmpty()) cb_PTT = opt.first(); + opt.removeFirst(); + if (!opt.isEmpty()) cb_SetExportMode = opt.first(); + } + m_PTT = cb_PTT.contains("true") ? true : false; + m_SetExportMode = cb_SetExportMode.contains("true") ? true : false; + m_GenerateModelsets = cb_GenerateModelsets.contains("true") ? true : false; + } + void CSelectSimulatorComponent::preselectSimulators() + { + CSimulatorInfo sims = this->m_enabledSimulators.get(); + // if (!sims.isAnySimulator()) + //{ + CSimulatorInfo simWithModels = m_modelSets.simulatorsWithModels(); + // sims = simWithModels; + //} + + if (sims > 127) sims = 0; // reset to none if invalid (happens if no enabledsimulators.json exists) + + // no x64 check as we would allow to config 32bit with launcher x64 and vice versa + 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 msfs2020 = + ((sims.isMSFS2020() || simWithModels.isMSFS2020()) && !CFsDirectories::msfs2020Dir().isEmpty()) && + CBuildConfig::isCompiledWithMSFS2020Support(); + + const bool msfs2024 = + ((sims.isMSFS2024() || simWithModels.isMSFS2024()) && !CFsDirectories::msfs2024Dir().isEmpty()) && + CBuildConfig::isCompiledWithMSFS2024Support(); + + const bool xp = sims.isXPlane() && CBuildConfig::isCompiledWithXPlaneSupport(); + const bool fg = sims.isFG() && CBuildConfig::isCompiledWithFGSupport(); + + ui->cb_P3D->setChecked(p3d); + ui->cb_FSX->setChecked(fsx); + ui->cb_FS9->setChecked(fs9); + ui->cb_XP->setChecked(xp); + ui->cb_FG->setChecked(fg); + ui->cb_MSFS2020->setChecked(msfs2020); + ui->cb_MSFS2024->setChecked(msfs2024); + + 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_MSFS2020->setEnabled(CBuildConfig::isCompiledWithMSFS2020Support()); + ui->cb_MSFS2024->setEnabled(CBuildConfig::isCompiledWithMSFS2024Support()); + + 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_MSFS2020, !CBuildConfig::isCompiledWithMSFS2020Support()); + CGuiUtility::checkBoxReadOnly(ui->cb_MSFS2024, !CBuildConfig::isCompiledWithMSFS2024Support()); + + ui->cb_PTT->setChecked(m_PTT); + ui->cb_SetExportMode->setChecked(m_SetExportMode); + + if (simWithModels.isAnySimulator()) + { + ui->cb_GenerateModelsets->setText("Create first model sets. Since you have already imported model sets " + "from an existing installation, you can skip this step"); + ui->cb_GenerateModelsets->setChecked(m_GenerateModelsets); + } + else + { + ui->cb_GenerateModelsets->setText("Create first model sets."); + ui->cb_GenerateModelsets->setChecked(true); + } + } + + QStringList CSelectSimulatorComponent::selectedSimsToPluginIds() + { + QStringList ids; + + // have to match full canonical ids from swift-plugin-simulators.xml + if (ui->cb_FS9->isChecked()) { ids << CSimulatorPluginInfo::fs9PluginIdentifier(); } + if (ui->cb_FSX->isChecked()) { ids << CSimulatorPluginInfo::fsxPluginIdentifier(); } + 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_MSFS2020->isChecked()) { ids << CSimulatorPluginInfo::msfs2020PluginIdentifier(); } + if (ui->cb_MSFS2024->isChecked()) { ids << CSimulatorPluginInfo::msfs2024PluginIdentifier(); } + + return ids; + } + + QStringList CSelectSimulatorComponent::selectedOptions() + { + QString cb_PTT = ui->cb_PTT->isChecked() ? "true" : "false"; + QString cb_GenerateModelsets = ui->cb_GenerateModelsets->isChecked() ? "true" : "false"; + QString cb_SetExportMode = ui->cb_SetExportMode->isChecked() ? "true" : "false"; + + QStringList options = { cb_GenerateModelsets, cb_PTT, cb_SetExportMode }; + + return options; + } + + void CSelectSimulatorWizardPage::initializePage() + { + Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config"); + m_config->load(); + } + + bool CSelectSimulatorWizardPage::validatePage() + { + Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config"); + m_config->save(); + return true; + } +} // namespace swift::gui::components diff --git a/src/gui/components/selectsimulatorcomponent.h b/src/gui/components/selectsimulatorcomponent.h new file mode 100644 index 000000000..891dd67b8 --- /dev/null +++ b/src/gui/components/selectsimulatorcomponent.h @@ -0,0 +1,106 @@ +// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 + +//! \file + +#ifndef SWIFT_GUI_COMPONENTS_SELECTSIMULATORCOMPONENT_H +#define SWIFT_GUI_COMPONENTS_SELECTSIMULATORCOMPONENT_H + +#include +#include +#include + +#include "core/actionbind.h" +#include "core/application/applicationsettings.h" +#include "gui/models/actionhotkeylistmodel.h" +#include "gui/swiftguiexport.h" +#include "misc/icons.h" +#include "misc/identifierlist.h" +#include "misc/settingscache.h" +#include "misc/simulation/data/modelcaches.h" + +namespace Ui +{ + class CSelectSimulatorComponent; +} +namespace swift::gui::components +{ + /*! + * Simulator configuration + */ + class CSelectSimulatorComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CSelectSimulatorComponent(QWidget *parent = nullptr); + + //! Destructor + ~CSelectSimulatorComponent() override; + + //! Save data + void save(); + + //! Load data + void load(); + + //! Has unsaved changes + bool hasUnsavedChanges() const; + + //! Reset the flag + void resetUnsavedChanges(); + + swift::misc::simulation::CSimulatorInfo getSelectedSimulators(); + + private: + //! Preselect simulators + void preselectSimulators(); + + void preselectOptions(); + + //! Get the plugin ids + QStringList selectedSimsToPluginIds(); + + //! Get selected options + QStringList selectedOptions(); + + bool m_GenerateModelsets = false; + bool m_PTT = false; + bool m_SetExportMode = false; + + swift::misc::CSetting m_enabledSimulators { this }; + swift::misc::CSetting m_enabledConfigOptions { this }; + swift::misc::simulation::data::CModelSetCaches m_modelSets { true, this }; + QScopedPointer ui; + }; + + /*! + * Wizard page for CConfigSimulatorComponent + */ + class CSelectSimulatorWizardPage : public QWizardPage + { + Q_OBJECT + + public: + //! Constructors + using QWizardPage::QWizardPage; + + explicit CSelectSimulatorWizardPage(CSelectSimulatorComponent *config, QWidget *parent = nullptr) + : QWizardPage(parent), m_config(config) + {} + + //! Set config + void setConfigComponent(CSelectSimulatorComponent *config) { m_config = config; } + + //! \copydoc QWizardPage::initializePage + void initializePage() override; + + //! \copydoc QWizardPage::validatePage + bool validatePage() override; + + private: + CSelectSimulatorComponent *m_config = nullptr; + }; +} // namespace swift::gui::components +#endif // SWIFT_GUI_COMPONENTS_SELECTSIMULATORCOMPONENT_H diff --git a/src/gui/components/selectsimulatorcomponent.ui b/src/gui/components/selectsimulatorcomponent.ui new file mode 100644 index 000000000..3c39b6084 --- /dev/null +++ b/src/gui/components/selectsimulatorcomponent.ui @@ -0,0 +1,249 @@ + + + CSelectSimulatorComponent + + + + 0 + 0 + 640 + 480 + + + + Frame + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + To keep the configuration simple, please select only the simulators you have installed and for which you want to configure swift. + + + true + + + + + + + Select your simulator(s) + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + FS9 (32-bit) + + + + 64 + 64 + + + + + + + + + FSX (32-bit) + + + + + + + P3D (64-bit) + + + + + + + XPlane (32,64-bit) + + + + + + + FlightGear (64-bit) + + + + + + + MSFS2020 (64-bit) + + + + + + + MSFS2024 (64-bit) + + + + + + + + + + + + + Please select your options to keep the configuration simple. + + + true + + + + + + + + + Choose your options + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + I want to assign a button for PTT (push-to-talk). You can do that later. If you are not flying on the VATSIM network, you do not need this option. + + + If you are flying on the VATSIM network, you can assign a PTT (push to talk) button. + + + + 64 + 64 + + + + + + + + + Create first model sets. + + + If you have already imported model sets from an existing installation, you can skip this step. + + + + 64 + 64 + + + + + + + + + I want to use swift in expert mode. + + + This will activate control options that may make the user interface appear cluttered!. + + + + 64 + 64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + cb_P3D + cb_FSX + cb_FS9 + cb_XP + cb_FG + cb_MSFS2020 + cb_MSFS2024 + + + + diff --git a/src/gui/components/settingssimulatorbasicscomponent.cpp b/src/gui/components/settingssimulatorbasicscomponent.cpp index 97fb0ad05..11ceb9ac2 100644 --- a/src/gui/components/settingssimulatorbasicscomponent.cpp +++ b/src/gui/components/settingssimulatorbasicscomponent.cpp @@ -60,7 +60,10 @@ namespace swift::gui::components CSettingsSimulatorBasicsComponent::~CSettingsSimulatorBasicsComponent() = default; - void CSettingsSimulatorBasicsComponent::hideSelector(bool show) { ui->comp_SimulatorSelector->setVisible(show); } + void CSettingsSimulatorBasicsComponent::hideSelector(CSimulatorInfo sims) + { + ui->comp_SimulatorSelector->setSimulatorVisible(sims); + } bool CSettingsSimulatorBasicsComponent::hasAnyValues() const { @@ -229,10 +232,20 @@ namespace swift::gui::components void CSettingsSimulatorBasicsComponent::onSimulatorChanged() { + if (m_unsavedChanges) + { + // heare we could prompt to save changes + ui->comp_SimulatorSelector->setValue(m_lastsim); // restore previous selection + this->showOverlayHTMLMessage("There are unsaved changes.", std::chrono::seconds(2)); + return; + } + const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue()); + m_settings.getSettings(simulator); + m_lastsim = ui->comp_SimulatorSelector->getValue(); // to restore the selection properly this->displaySettings(simulator); - // special handling for MSFS 2024 only visual changes + // special handling for MSFS2024 only visual changes if (simulator == CSimulatorInfo::msfs2024()) { ui->gb_ModelSet->setVisible(true); @@ -265,13 +278,17 @@ namespace swift::gui::components ui->lbl_ModelDirsInfo->setText(html); } - this->displayDefaultValuesAsPlaceholder(simulator); + // this->displayDefaultValuesAsPlaceholder(simulator); } void CSettingsSimulatorBasicsComponent::onSimulatorSettingsChanged(const CSimulatorInfo &simulator) { const CSimulatorInfo selectedSimulator(ui->comp_SimulatorSelector->getValue()); - if (selectedSimulator == simulator) { this->displaySettings(simulator); } + if (selectedSimulator == simulator) + { + m_settings.getSettings(simulator); + this->displaySettings(simulator); + } } QStringList CSettingsSimulatorBasicsComponent::parseModelDirectories() const @@ -351,9 +368,10 @@ namespace swift::gui::components QStringList cleanedDirs(dirs); cleanedDirs.removeDuplicates(); cleanedDirs.sort(m_fileCaseSensitivity); + const QString d = cleanedDirs.join("\n"); ui->pte_ModelDirectories->setPlainText(d); - this->displayDefaultValuesAsPlaceholder(ui->comp_SimulatorSelector->getValue()); + // this->displayDefaultValuesAsPlaceholder(ui->comp_SimulatorSelector->getValue()); } CSpecializedSimulatorSettings CSettingsSimulatorBasicsComponent::getSettings(const CSimulatorInfo &simulator) const @@ -364,33 +382,37 @@ namespace swift::gui::components void CSettingsSimulatorBasicsComponent::displaySettings(const CSimulatorInfo &simulator) { - // if (simulator.isMSFS2024()) - //{ + const CSimulatorSettings s = m_settings.getSettings(simulator); + const QString es = s.getSimulatorDirectory(); - // //CSpecializedSimulatorSettings settings = this->getSimulatorSettings(simulator.isMSFS2024()); - // //CSimulatorSettings m_generic = settings.getGenericSettings(); - // //QStringList excludePatterns = m_generic.getModelExcludeDirectoryPatterns(); - // //QStringList filterPatterns = m_generic.getModelDirectories(); + ui->pte_ModelDirectories->clear(); + ui->pte_ExcludeDirectories->clear(); - // //const CSimulatorSettings s = m_settings.getSettings(simulator); - // //const QString es = s.getSimulatorDirectory(); - // ui->pte_ModelDirectories->clear(); - // ui->pte_ExcludeDirectories->clear(); + if (simulator.isMSFS2024()) + { + CSpecializedSimulatorSettings settings = this->getSimulatorSettings(simulator); + CSimulatorSettings m_generic = settings.getGenericSettings(); + QStringList excludePatterns = m_generic.getModelExcludeDirectoryPatterns(); + QStringList filterPatterns = m_generic.getModelDirectories(); - // //this->displayModelDirectories(excludePatterns); - // //this->displayExcludeDirectoryPatterns(filterPatterns); - //} - // else - //{ - // this->displayModelDirectories(m_settings.getModelDirectoriesIfNotDefault(simulator)); - // this->displayExcludeDirectoryPatterns(m_settings.getModelExcludeDirectoryPatternsIfNotDefault(simulator)); - //} + ui->le_SimulatorDirectory->setText(s.getSimulatorDirectory()); + this->displayModelDirectories(filterPatterns); + this->displayExcludeDirectoryPatterns(excludePatterns); + } + else + { + ui->le_SimulatorDirectory->setText(s.getSimulatorDirectory()); + + this->displayModelDirectories(s.getModelDirectories()); + // this->displayModelDirectories(m_settings.getModelDirectoriesIfNotDefault(simulator)); + this->displayExcludeDirectoryPatterns(m_settings.getModelExcludeDirectoryPatternsIfNotDefault(simulator)); + } // ui->le_SimulatorDirectory->setText(m_settings.getSimulatorDirectoryIfNotDefault(simulator)); // based on discussion here, always display: // https://discordapp.com/channels/539048679160676382/594962359441948682/700483609361907842 - const CSimulatorSettings s = m_settings.getSettings(simulator); - ui->le_SimulatorDirectory->setText(s.getSimulatorDirectory()); + // const CSimulatorSettings s = m_settings.getSettings(simulator); + // ui->le_SimulatorDirectory->setText(s.getSimulatorDirectory()); } void CSettingsSimulatorBasicsComponent::displayDefaultValuesAsPlaceholder(const CSimulatorInfo &simulator) @@ -435,6 +457,7 @@ namespace swift::gui::components else { const QStringList m = settings.getModelDirectoriesFromSimulatorDirectoryOrDefault(); + ui->pte_ModelDirectories->clear(); if (m.isEmpty()) { ui->pte_ModelDirectories->setPlaceholderText("Model directories"); } else { @@ -443,6 +466,7 @@ namespace swift::gui::components } const QStringList e = settings.getDefaultModelExcludePatterns(); + ui->pte_ExcludeDirectories->clear(); if (e.isEmpty()) { ui->pte_ExcludeDirectories->setPlaceholderText("Exclude directories"); } else { diff --git a/src/gui/components/settingssimulatorbasicscomponent.h b/src/gui/components/settingssimulatorbasicscomponent.h index fffacc031..400faa32a 100644 --- a/src/gui/components/settingssimulatorbasicscomponent.h +++ b/src/gui/components/settingssimulatorbasicscomponent.h @@ -39,7 +39,7 @@ namespace swift::gui::components ~CSettingsSimulatorBasicsComponent() override; //! Show / hide selector - void hideSelector(bool show); + void hideSelector(swift::misc::simulation::CSimulatorInfo sims); //! Any values filled in bool hasAnyValues() const; @@ -138,6 +138,9 @@ namespace swift::gui::components //! Simulator directory either from input or settings or default QString getFileBrowserSimulatorDirectory() const; + + //! Last simulator displayed + swift::misc::simulation::CSimulatorInfo m_lastsim; }; } // namespace swift::gui::components diff --git a/src/gui/components/settingssimulatorbasicscomponent.ui b/src/gui/components/settingssimulatorbasicscomponent.ui index 08f847500..8e70b2244 100644 --- a/src/gui/components/settingssimulatorbasicscomponent.ui +++ b/src/gui/components/settingssimulatorbasicscomponent.ui @@ -31,7 +31,17 @@ Model directories + + Model directory patterns + + + QPlainTextEdit::NoWrap + + + + + diff --git a/src/gui/components/simulatorselector.cpp b/src/gui/components/simulatorselector.cpp index 5c22e0bda..3d15bac3f 100644 --- a/src/gui/components/simulatorselector.cpp +++ b/src/gui/components/simulatorselector.cpp @@ -37,7 +37,7 @@ 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->rb_MSFS2020, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged); connect(ui->rb_MSFS2024, &QRadioButton::toggled, this, &CSimulatorSelector::radioButtonChanged); connect(ui->cb_FS9, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged); @@ -45,7 +45,7 @@ namespace swift::gui::components 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_MSFS2020, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged); connect(ui->cb_MSFS2024, &QRadioButton::toggled, this, &CSimulatorSelector::checkBoxChanged); connect(ui->cb_Simulators, &QComboBox::currentTextChanged, this, &CSimulatorSelector::comboBoxChanged); @@ -53,6 +53,30 @@ namespace swift::gui::components CSimulatorSelector::~CSimulatorSelector() = default; + void CSimulatorSelector::setSimulatorVisible(CSimulatorInfo sims) + { + ui->cb_FS9->setVisible(sims.isFS9()); + ui->rb_FS9->setVisible(sims.isFS9()); + + ui->cb_FSX->setVisible(sims.isFSX()); + ui->rb_FSX->setVisible(sims.isFSX()); + + ui->cb_P3D->setVisible(sims.isP3D()); + ui->rb_P3D->setVisible(sims.isP3D()); + + ui->cb_FG->setVisible(sims.isFG()); + ui->rb_FG->setVisible(sims.isFG()); + + ui->cb_XPlane->setVisible(sims.isXPlane()); + ui->rb_XPlane->setVisible(sims.isXPlane()); + + ui->cb_MSFS2020->setVisible(sims.isMSFS2020()); + ui->rb_MSFS2020->setVisible(sims.isMSFS2020()); + + ui->cb_MSFS2024->setVisible(sims.isMSFS2024()); + ui->rb_MSFS2024->setVisible(sims.isMSFS2024()); + } + void CSimulatorSelector::setMode(CSimulatorSelector::Mode mode, bool forced) { if (m_mode == mode && !forced) { return; } @@ -69,6 +93,12 @@ namespace swift::gui::components case RadioButtons: ui->wi_RadioButtons->setVisible(true); break; case ComboBox: ui->wi_ComboBox->setVisible(true); break; } + + // suppress uninstalled simulators + CSimulatorInfo sims = m_enabledSimulators.getThreadLocal(); + + setSimulatorVisible(sims); + this->setToLastSelection(); } @@ -81,11 +111,11 @@ namespace swift::gui::components default: case CheckBoxes: return { ui->cb_FSX->isChecked(), ui->cb_FS9->isChecked(), ui->cb_XPlane->isChecked(), - ui->cb_P3D->isChecked(), ui->cb_FG->isChecked(), ui->cb_MSFS->isChecked(), + ui->cb_P3D->isChecked(), ui->cb_FG->isChecked(), ui->cb_MSFS2020->isChecked(), ui->cb_MSFS2024->isChecked() }; case RadioButtons: return { ui->rb_FSX->isChecked(), ui->rb_FS9->isChecked(), ui->rb_XPlane->isChecked(), - ui->rb_P3D->isChecked(), ui->rb_FG->isChecked(), ui->rb_MSFS->isChecked(), + ui->rb_P3D->isChecked(), ui->rb_FG->isChecked(), ui->rb_MSFS2020->isChecked(), ui->rb_MSFS2024->isChecked() }; case ComboBox: return { ui->cb_Simulators->currentText() }; } @@ -102,7 +132,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()); + ui->cb_MSFS2020->setChecked(simulator.isMSFS2020()); ui->cb_MSFS2024->setChecked(simulator.isMSFS2024()); // Combo @@ -134,9 +164,9 @@ namespace swift::gui::components ui->rb_FG->setChecked(simulator.isFG()); return; } - if (simulator.isMSFS()) + if (simulator.isMSFS2020()) { - ui->rb_MSFS->setChecked(simulator.isMSFS()); + ui->rb_MSFS2020->setChecked(simulator.isMSFS2020()); return; } if (simulator.isMSFS2024()) @@ -220,7 +250,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); + ui->cb_MSFS2020->setChecked(true); ui->cb_MSFS2024->setChecked(true); // radio @@ -235,7 +265,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); + ui->cb_MSFS2020->setChecked(false); ui->cb_MSFS2024->setChecked(false); } @@ -247,12 +277,12 @@ 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() || ui->cb_MSFS->isChecked() || + ui->cb_P3D->isChecked() || ui->cb_FG->isChecked() || ui->cb_MSFS2020->isChecked() || ui->cb_MSFS2024->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() || ui->rb_MSFS->isChecked() || + ui->rb_P3D->isChecked() || ui->rb_FG->isChecked() || ui->rb_MSFS2020->isChecked() || ui->rb_MSFS2024->isChecked(); break; case ComboBox: @@ -271,7 +301,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() && ui->cb_MSFS->isChecked() && + ui->cb_P3D->isChecked() && ui->cb_FG->isChecked() && ui->cb_MSFS2020->isChecked() && ui->cb_MSFS2024->isChecked(); break; case RadioButtons: @@ -318,7 +348,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->rb_MSFS2020->setEnabled(!readOnly); ui->rb_MSFS2024->setEnabled(!readOnly); ui->cb_Simulators->setEnabled(!readOnly); @@ -412,7 +442,7 @@ 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()); + ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::msfs2020().toQString()); ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::msfs2024().toQString()); } } // namespace swift::gui::components diff --git a/src/gui/components/simulatorselector.h b/src/gui/components/simulatorselector.h index ceabdc3cb..f0b72336c 100644 --- a/src/gui/components/simulatorselector.h +++ b/src/gui/components/simulatorselector.h @@ -46,6 +46,9 @@ namespace swift::gui::components //! How to display void setMode(Mode mode, bool forced = false); + //! Set visible simulators + void setSimulatorVisible(swift::misc::simulation::CSimulatorInfo sims); + //! Get mode Mode getMode() { return m_mode; } @@ -111,6 +114,8 @@ namespace swift::gui::components void changed(const swift::misc::simulation::CSimulatorInfo &simulator); private: + swift::misc::CSetting m_enabledSimulators { this }; + //! Radio button changed void radioButtonChanged(bool checked); diff --git a/src/gui/components/simulatorselector.ui b/src/gui/components/simulatorselector.ui index 0879059bc..96984f8a2 100644 --- a/src/gui/components/simulatorselector.ui +++ b/src/gui/components/simulatorselector.ui @@ -56,6 +56,7 @@ FSX + @@ -89,7 +90,7 @@ - + MSFS2020 @@ -174,7 +175,7 @@ - + MSFS2020 @@ -222,11 +223,15 @@ cb_FS9 cb_XPlane cb_FG + cb_MSFS2020 + cb_MSFS2024 rb_P3D rb_FSX rb_FS9 rb_XPlane rb_FG + rb_MSFS2020 + rb_MSFS2024 cb_Simulators diff --git a/src/misc/fileutils.cpp b/src/misc/fileutils.cpp index c88714f87..9984ed7a6 100644 --- a/src/misc/fileutils.cpp +++ b/src/misc/fileutils.cpp @@ -4,6 +4,8 @@ #include "misc/fileutils.h" #include +#include +#include #include #include @@ -18,6 +20,7 @@ #include #include "config/buildconfig.h" +#include "misc/logmessage.h" #include "misc/setbuilder.h" #include "misc/stringutils.h" @@ -68,6 +71,9 @@ namespace swift::misc QString CFileUtils::readFileToString(const QString &fileNameAndPath) { QFile file(fileNameAndPath); + const QString filePathNormalized = CFileUtils::normalizeFilePathToQtStandard(fileNameAndPath); + printf("Reading file: '%s'\n", filePathNormalized.toUtf8().constData()); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return {}; } QTextStream stream(&file); const QString content(stream.readAll()); diff --git a/src/misc/simulation/aircraftmodel.cpp b/src/misc/simulation/aircraftmodel.cpp index 7a335aef0..1f43392c9 100644 --- a/src/misc/simulation/aircraftmodel.cpp +++ b/src/misc/simulation/aircraftmodel.cpp @@ -108,7 +108,7 @@ namespace swift::misc::simulation obj.insert("simp3d", QJsonValue(flag)); flag = CDatastoreUtility::boolToDbYN(sim.isFS9()); obj.insert("simfs9", QJsonValue(flag)); - flag = CDatastoreUtility::boolToDbYN(sim.isMSFS()); + flag = CDatastoreUtility::boolToDbYN(sim.isMSFS2020()); obj.insert("simmsfs", QJsonValue(flag)); flag = CDatastoreUtility::boolToDbYN(sim.isMSFS2024()); obj.insert("simmsfs2024", QJsonValue(flag)); diff --git a/src/misc/simulation/aircraftmodel.h b/src/misc/simulation/aircraftmodel.h index 74373b7a6..b94809391 100644 --- a/src/misc/simulation/aircraftmodel.h +++ b/src/misc/simulation/aircraftmodel.h @@ -186,7 +186,7 @@ namespace swift::misc //! Model key, either queried or loaded from simulator model const QString &getModelString() const { return m_modelString; } - //! Model Livery, part of model string in MSFS 2024 + //! Model Livery, part of model string in MSFS2024 const QString &getModelLivery() const { return m_modelLivery; } //! Model string and DB key (if available) diff --git a/src/misc/simulation/aircraftmodellist.h b/src/misc/simulation/aircraftmodellist.h index b1ab05a18..651eb4b7d 100644 --- a/src/misc/simulation/aircraftmodellist.h +++ b/src/misc/simulation/aircraftmodellist.h @@ -270,10 +270,10 @@ namespace swift::misc //! Find duplicate model strings and return those models with at least 1 duplicate model string CAircraftModelList findDuplicateModelStrings() const; - //! All models of the FS (FSX, P3D, FS9, MSFS) family + //! All models of the FS (FSX, P3D, FS9, MSFS2020, MSFS2024) family CAircraftModelList findFsFamilyModels() const; - //! All models NOT of the FS (FSX, P3D, FS9, MSFS) family + //! All models NOT of the FS (FSX, P3D, FS9, MSFS2020, MSFS2024) family CAircraftModelList findNonFsFamilyModels() const; //! @{ diff --git a/src/misc/simulation/aircraftmodelloaderprovider.cpp b/src/misc/simulation/aircraftmodelloaderprovider.cpp index ebf5c169e..88869562c 100644 --- a/src/misc/simulation/aircraftmodelloaderprovider.cpp +++ b/src/misc/simulation/aircraftmodelloaderprovider.cpp @@ -67,9 +67,9 @@ namespace swift::misc::simulation if (!m_loaderFG) { m_loaderFG = this->initLoader(CSimulatorInfo::fg()); } return m_loaderFG; } - case CSimulatorInfo::MSFS: + case CSimulatorInfo::MSFS2020: { - if (!m_loaderMsfs) { m_loaderMsfs = this->initLoader(CSimulatorInfo::msfs()); } + if (!m_loaderMsfs) { m_loaderMsfs = this->initLoader(CSimulatorInfo::msfs2020()); } return m_loaderMsfs; } case CSimulatorInfo::MSFS2024: diff --git a/src/misc/simulation/aircraftmodelutils.cpp b/src/misc/simulation/aircraftmodelutils.cpp index be8a908b0..4e1f7912d 100644 --- a/src/misc/simulation/aircraftmodelutils.cpp +++ b/src/misc/simulation/aircraftmodelutils.cpp @@ -191,7 +191,7 @@ namespace swift::misc::simulation models, validModels, invalidModels, ignoreEmpty, stopAtFailedFiles, wasStopped, simulatorDir); specificTests.push_back(specificTests2); } - else if (simulator.isMSFS()) + else if (simulator.isMSFS2020()) { const CStatusMessageList specificTests2 = fscommon::CFsCommonUtil::validateMSFSSimObjectsPath( models, validModels, invalidModels, ignoreEmpty, stopAtFailedFiles, wasStopped, simulatorDir); diff --git a/src/misc/simulation/autopublishdata.cpp b/src/misc/simulation/autopublishdata.cpp index 5b8b4d697..b7c2c1e61 100644 --- a/src/misc/simulation/autopublishdata.cpp +++ b/src/misc/simulation/autopublishdata.cpp @@ -220,7 +220,7 @@ namespace swift::misc::simulation this->insert("testModelString4", CSimulatorInfo::p3d()); this->insert("testModelString5", CSimulatorInfo::fsx()); this->insert("testModelString6", CSimulatorInfo::fsx()); - this->insert("testModelString7", CSimulatorInfo::msfs()); + this->insert("testModelString7", CSimulatorInfo::msfs2020()); this->insert("testModelString8", CSimulatorInfo::msfs2024()); } diff --git a/src/misc/simulation/data/modelcaches.cpp b/src/misc/simulation/data/modelcaches.cpp index a33bd6c2d..b514caec3 100644 --- a/src/misc/simulation/data/modelcaches.cpp +++ b/src/misc/simulation/data/modelcaches.cpp @@ -42,11 +42,11 @@ namespace swift::misc::simulation::data QString IMultiSimulatorModelCaches::getInfoStringFsFamily() const { - static const QString is("FSX: %1, P3D: %2, FS9: %3, MSFS: %4, MSFS2024: %5"); + static const QString is("FSX: %1, P3D: %2, FS9: %3, MSFS2020: %4, MSFS2024: %5"); return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)) .arg(this->getCachedModelsCount(CSimulatorInfo::P3D)) .arg(this->getCachedModelsCount(CSimulatorInfo::FS9)) - .arg(this->getCachedModelsCount(CSimulatorInfo::MSFS)) + .arg(this->getCachedModelsCount(CSimulatorInfo::MSFS2020)) .arg(this->getCachedModelsCount(CSimulatorInfo::MSFS2024)); } @@ -72,7 +72,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: m_syncP3D = synchronized; break; case CSimulatorInfo::XPLANE: m_syncXPlane = synchronized; break; case CSimulatorInfo::FG: m_syncFG = synchronized; break; - case CSimulatorInfo::MSFS: m_syncMsfs = synchronized; break; + case CSimulatorInfo::MSFS2020: m_syncMsfs2020 = synchronized; break; case CSimulatorInfo::MSFS2024: m_syncMsfs2024 = synchronized; break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -103,7 +103,7 @@ namespace swift::misc::simulation::data if (this->hasOtherVersionFile(info, CSimulatorInfo::fs9())) { sim.addSimulator(CSimulatorInfo::fs9()); } if (this->hasOtherVersionFile(info, CSimulatorInfo::fg())) { sim.addSimulator(CSimulatorInfo::fg()); } if (this->hasOtherVersionFile(info, CSimulatorInfo::xplane())) { sim.addSimulator(CSimulatorInfo::xplane()); } - if (this->hasOtherVersionFile(info, CSimulatorInfo::msfs())) { sim.addSimulator(CSimulatorInfo::msfs()); } + if (this->hasOtherVersionFile(info, CSimulatorInfo::msfs2020())) { sim.addSimulator(CSimulatorInfo::msfs2020()); } if (this->hasOtherVersionFile(info, CSimulatorInfo::msfs2024())) { sim.addSimulator(CSimulatorInfo::msfs2024()); @@ -119,7 +119,7 @@ namespace swift::misc::simulation::data this->getFilename(CSimulatorInfo::P3D), this->getFilename(CSimulatorInfo::XPLANE), this->getFilename(CSimulatorInfo::FG), - this->getFilename(CSimulatorInfo::MSFS), + this->getFilename(CSimulatorInfo::MSFS2020), this->getFilename(CSimulatorInfo::MSFS2024), }); } @@ -213,7 +213,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.get(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.get(); case CSimulatorInfo::FG: return m_modelCacheFG.get(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.get(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.get(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.get(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return {}; } @@ -233,7 +233,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: msg = m_modelCacheP3D.set(setModels); break; case CSimulatorInfo::XPLANE: msg = m_modelCacheXP.set(setModels); break; case CSimulatorInfo::FG: msg = m_modelCacheFG.set(setModels); break; - case CSimulatorInfo::MSFS: msg = m_modelCacheMsfs.set(setModels); break; + case CSimulatorInfo::MSFS2020: msg = m_modelCacheMsfs2020.set(setModels); break; case CSimulatorInfo::MSFS2024: msg = m_modelCacheMsfs2024.set(setModels); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return {}; } @@ -257,7 +257,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_syncP3D; case CSimulatorInfo::XPLANE: return m_syncXPlane; case CSimulatorInfo::FG: return m_syncFG; - case CSimulatorInfo::MSFS: return m_syncMsfs; + case CSimulatorInfo::MSFS2020: return m_syncMsfs2020; case CSimulatorInfo::MSFS2024: return m_syncMsfs2024; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -290,7 +290,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.getAvailableTimestamp(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.getAvailableTimestamp(); case CSimulatorInfo::FG: return m_modelCacheFG.getAvailableTimestamp(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.getAvailableTimestamp(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.getAvailableTimestamp(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.getAvailableTimestamp(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return {}; } @@ -310,7 +310,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.set(m_modelCacheP3D.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::XPLANE: return m_modelCacheXP.set(m_modelCacheXP.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::FG: return m_modelCacheFG.set(m_modelCacheFG.get(), ts.toMSecsSinceEpoch()); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.set(m_modelCacheMsfs.get(), ts.toMSecsSinceEpoch()); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.set(m_modelCacheMsfs2020.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.set(m_modelCacheMsfs2024.get(), ts.toMSecsSinceEpoch()); default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; @@ -332,7 +332,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.getFilename(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.getFilename(); case CSimulatorInfo::FG: return m_modelCacheFG.getFilename(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.getFilename(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.getFilename(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.getFilename(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -349,7 +349,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.isSaved(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.isSaved(); case CSimulatorInfo::FG: return m_modelCacheFG.isSaved(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.isSaved(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.isSaved(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.isSaved(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -368,7 +368,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: m_modelCacheP3D.synchronize(); break; case CSimulatorInfo::XPLANE: m_modelCacheXP.synchronize(); break; case CSimulatorInfo::FG: m_modelCacheFG.synchronize(); break; - case CSimulatorInfo::MSFS: m_modelCacheMsfs.synchronize(); break; + case CSimulatorInfo::MSFS2020: m_modelCacheMsfs2020.synchronize(); break; case CSimulatorInfo::MSFS2024: m_modelCacheMsfs2024.synchronize(); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -388,7 +388,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: m_modelCacheP3D.admit(); break; case CSimulatorInfo::XPLANE: m_modelCacheXP.admit(); break; case CSimulatorInfo::FG: m_modelCacheFG.admit(); break; - case CSimulatorInfo::MSFS: m_modelCacheMsfs.admit(); break; + case CSimulatorInfo::MSFS2020: m_modelCacheMsfs2020.admit(); break; case CSimulatorInfo::MSFS2024: m_modelCacheMsfs2024.admit(); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); break; } @@ -430,7 +430,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.get(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.get(); case CSimulatorInfo::FG: return m_modelCacheFG.get(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.get(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.get(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.get(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return {}; } @@ -461,7 +461,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: msg = m_modelCacheP3D.set(orderedModels); break; case CSimulatorInfo::XPLANE: msg = m_modelCacheXP.set(orderedModels); break; case CSimulatorInfo::FG: msg = m_modelCacheFG.set(orderedModels); break; - case CSimulatorInfo::MSFS: msg = m_modelCacheMsfs.set(orderedModels); break; + case CSimulatorInfo::MSFS2020: msg = m_modelCacheMsfs2020.set(orderedModels); break; case CSimulatorInfo::MSFS2024: msg = m_modelCacheMsfs2024.set(orderedModels); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return {}; } @@ -479,7 +479,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.getAvailableTimestamp(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.getAvailableTimestamp(); case CSimulatorInfo::FG: return m_modelCacheFG.getAvailableTimestamp(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.getAvailableTimestamp(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.getAvailableTimestamp(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.getAvailableTimestamp(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); return {}; } @@ -499,7 +499,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.set(m_modelCacheP3D.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::XPLANE: return m_modelCacheXP.set(m_modelCacheXP.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::FG: return m_modelCacheFG.set(m_modelCacheFG.get(), ts.toMSecsSinceEpoch()); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.set(m_modelCacheMsfs.get(), ts.toMSecsSinceEpoch()); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.set(m_modelCacheMsfs2020.get(), ts.toMSecsSinceEpoch()); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.set(m_modelCacheMsfs2024.get(), ts.toMSecsSinceEpoch()); default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; @@ -521,7 +521,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.getFilename(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.getFilename(); case CSimulatorInfo::FG: return m_modelCacheFG.getFilename(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.getFilename(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.getFilename(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.getFilename(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } @@ -538,7 +538,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: return m_modelCacheP3D.isSaved(); case CSimulatorInfo::XPLANE: return m_modelCacheXP.isSaved(); case CSimulatorInfo::FG: return m_modelCacheFG.isSaved(); - case CSimulatorInfo::MSFS: return m_modelCacheMsfs.isSaved(); + case CSimulatorInfo::MSFS2020: return m_modelCacheMsfs2020.isSaved(); case CSimulatorInfo::MSFS2024: return m_modelCacheMsfs2024.isSaved(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } @@ -557,7 +557,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: m_modelCacheP3D.synchronize(); break; case CSimulatorInfo::XPLANE: m_modelCacheXP.synchronize(); break; case CSimulatorInfo::FG: m_modelCacheFG.synchronize(); break; - case CSimulatorInfo::MSFS: m_modelCacheMsfs.synchronize(); break; + case CSimulatorInfo::MSFS2020: m_modelCacheMsfs2020.synchronize(); break; case CSimulatorInfo::MSFS2024: m_modelCacheMsfs2024.synchronize(); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } @@ -577,7 +577,7 @@ namespace swift::misc::simulation::data case CSimulatorInfo::P3D: m_modelCacheP3D.admit(); break; case CSimulatorInfo::XPLANE: m_modelCacheXP.admit(); break; case CSimulatorInfo::FG: m_modelCacheFG.admit(); break; - case CSimulatorInfo::MSFS: m_modelCacheMsfs.admit(); break; + case CSimulatorInfo::MSFS2020: m_modelCacheMsfs2020.admit(); break; case CSimulatorInfo::MSFS2024: m_modelCacheMsfs2024.admit(); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } diff --git a/src/misc/simulation/data/modelcaches.h b/src/misc/simulation/data/modelcaches.h index 7927cc340..9b9935b82 100644 --- a/src/misc/simulation/data/modelcaches.h +++ b/src/misc/simulation/data/modelcaches.h @@ -67,11 +67,11 @@ namespace swift::misc::simulation::data static const char *key() { return "modelcachefg"; } }; - //! MSFS - struct TModelCacheMsfs : public TModelCache + //! MSFS2020 + struct TModelCacheMsfs2020 : public TModelCache { //! Key in data cache - static const char *key() { return "modelcachemsfs"; } + static const char *key() { return "modelcachemsfs2020"; } }; //! MSFS2024 @@ -133,11 +133,11 @@ namespace swift::misc::simulation::data static const char *key() { return "modelsetfg"; } }; - //! MSFS - struct TModelSetCacheMsfs : public TModelCache + //! MSFS2020 + struct TModelSetCacheMsfs2020 : public TModelCache { //! Key in data cache - static const char *key() { return "modelsetmsfs"; } + static const char *key() { return "modelsetmsfs2020"; } }; //! MSFS2024 @@ -309,7 +309,7 @@ namespace swift::misc::simulation::data void changedP3D() { this->emitCacheChanged(CSimulatorInfo::p3d()); } void changedXP() { this->emitCacheChanged(CSimulatorInfo::xplane()); } void changedFG() { this->emitCacheChanged(CSimulatorInfo::fg()); } - void changedMsfs() { this->emitCacheChanged(CSimulatorInfo::msfs()); } + void changedMsfs2020() { this->emitCacheChanged(CSimulatorInfo::msfs2020()); } void changedMsfs2024() { this->emitCacheChanged(CSimulatorInfo::msfs2024()); } //! @} @@ -328,7 +328,7 @@ namespace swift::misc::simulation::data std::atomic_bool m_syncFS9 { false }; std::atomic_bool m_syncFG { false }; std::atomic_bool m_syncXPlane { false }; - std::atomic_bool m_syncMsfs { false }; + std::atomic_bool m_syncMsfs2020 { false }; std::atomic_bool m_syncMsfs2024 { false }; //! @} }; @@ -365,7 +365,7 @@ namespace swift::misc::simulation::data CData m_modelCacheP3D { this, &CModelCaches::changedP3D }; //!< P3D cache CData m_modelCacheXP { this, &CModelCaches::changedXP }; //!< XP cache CData m_modelCacheFG { this, &CModelCaches::changedFG }; //!< XP cache - CData m_modelCacheMsfs { this, &CModelCaches::changedMsfs }; //!< MSFS cache + CData m_modelCacheMsfs2020 { this, &CModelCaches::changedMsfs2020 }; //!< MSFS2020 cache CData m_modelCacheMsfs2024 { this, &CModelCaches::changedMsfs2024 }; //!< MSFS2024 cache //! Non virtual version (can be used in ctor) @@ -408,7 +408,7 @@ namespace swift::misc::simulation::data CData m_modelCacheP3D { this, &CModelSetCaches::changedP3D }; //!< P3D cache CData m_modelCacheXP { this, &CModelSetCaches::changedXP }; //!< XP cache CData m_modelCacheFG { this, &CModelSetCaches::changedFG }; //!< FG cache - CData m_modelCacheMsfs { this, &CModelSetCaches::changedMsfs }; //!< MSFS cache + CData m_modelCacheMsfs2020 { this, &CModelSetCaches::changedMsfs2020 }; //!< MSFS2020 cache CData m_modelCacheMsfs2024 { this, &CModelSetCaches::changedMsfs2024 }; //!< MSFS2024 cache diff --git a/src/misc/simulation/distributor.cpp b/src/misc/simulation/distributor.cpp index 96821623c..d17c45aa6 100644 --- a/src/misc/simulation/distributor.cpp +++ b/src/misc/simulation/distributor.cpp @@ -252,7 +252,7 @@ namespace swift::misc::simulation const QString &CDistributor::standardMsfs() { - static const QString k("MSFS"); + static const QString k("MSFS2020"); return k; } diff --git a/src/misc/simulation/distributorlistpreferences.cpp b/src/misc/simulation/distributorlistpreferences.cpp index 13658da14..5800098a9 100644 --- a/src/misc/simulation/distributorlistpreferences.cpp +++ b/src/misc/simulation/distributorlistpreferences.cpp @@ -19,7 +19,7 @@ namespace swift::misc::simulation case CSimulatorInfo::FS9: return m_distributorsFs9; case CSimulatorInfo::FG: return m_distributorsFG; case CSimulatorInfo::XPLANE: return m_distributorsXPlane; - case CSimulatorInfo::MSFS: return m_distributorsMsfs; + case CSimulatorInfo::MSFS2020: return m_distributorsMsfs; case CSimulatorInfo::MSFS2024: return m_distributorsMsfs2024; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } @@ -48,7 +48,7 @@ namespace swift::misc::simulation case CSimulatorInfo::FS9: m_distributorsFs9 = d; break; case CSimulatorInfo::FG: m_distributorsFG = d; break; case CSimulatorInfo::XPLANE: m_distributorsXPlane = d; break; - case CSimulatorInfo::MSFS: m_distributorsMsfs = d; break; + case CSimulatorInfo::MSFS2020: m_distributorsMsfs = d; break; case CSimulatorInfo::MSFS2024: m_distributorsMsfs2024 = d; break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong simulator"); break; } diff --git a/src/misc/simulation/fscommon/aircraftcfgparser.cpp b/src/misc/simulation/fscommon/aircraftcfgparser.cpp index dc03414c1..89b26e3b0 100644 --- a/src/misc/simulation/fscommon/aircraftcfgparser.cpp +++ b/src/misc/simulation/fscommon/aircraftcfgparser.cpp @@ -155,7 +155,7 @@ namespace swift::misc::simulation::fscommon QDir dir(directory, NoNameFilter, QDir::Name, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot); // for MSFS2020 we only need aircraft.cfg - dir.setNameFilters(fileNameFilters(getSimulator().isMSFS())); + dir.setNameFilters(fileNameFilters(getSimulator().isMSFS2020())); if (!dir.exists()) { return {}; // can happen if there are shortcuts or linked dirs not available diff --git a/src/misc/simulation/fscommon/fscommonutil.cpp b/src/misc/simulation/fscommon/fscommonutil.cpp index bd14ae5eb..e2d9bc170 100644 --- a/src/misc/simulation/fscommon/fscommonutil.cpp +++ b/src/misc/simulation/fscommon/fscommonutil.cpp @@ -224,7 +224,7 @@ namespace swift::misc::simulation::fscommon std::atomic_bool &stopped, const QString &simulatorDir) { Q_UNUSED(simulatorDir) - const QStringList simObjectPaths = CFsDirectories::msfsSimObjectsDirPath(); + const QStringList simObjectPaths = CFsDirectories::msfs2020SimObjectsDirPath(); return CFsCommonUtil::validateSimObjectsPath(QSet(simObjectPaths.begin(), simObjectPaths.end()), models, validModels, invalidModels, ignoreEmptyFileNames, stopAtFailedFiles, stopped); diff --git a/src/misc/simulation/fscommon/fsdirectories.cpp b/src/misc/simulation/fscommon/fsdirectories.cpp index c2e883d23..d5b437552 100644 --- a/src/misc/simulation/fscommon/fsdirectories.cpp +++ b/src/misc/simulation/fscommon/fsdirectories.cpp @@ -93,7 +93,7 @@ namespace swift::misc::simulation::fscommon return dir; } - static QString msfsDirImpl() + static QString msfs2020DirImpl() { // first we look for a standard installation const QStringList locations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); @@ -120,17 +120,17 @@ namespace swift::misc::simulation::fscommon return {}; } - const QString &CFsDirectories::msfsDir() + const QString &CFsDirectories::msfs2020Dir() { - static const QString dir(msfsDirImpl()); + static const QString dir(msfs2020DirImpl()); return dir; } - QString msfsPackagesDirImpl() + QString msfs2020PackagesDirImpl() { QString userCfg = ""; - QString msfsDirectory(CFsDirectories::msfsDir()); + QString msfsDirectory(CFsDirectories::msfs2020Dir()); // for Steam edition if (msfsDirectory.contains("Roaming", Qt::CaseInsensitive)) @@ -164,9 +164,9 @@ namespace swift::misc::simulation::fscommon return {}; } - const QString &CFsDirectories::msfsPackagesDir() + const QString &CFsDirectories::msfs2020PackagesDir() { - static const QString dir(msfsPackagesDirImpl()); + static const QString dir(msfs2020PackagesDirImpl()); return dir; } @@ -267,9 +267,9 @@ namespace swift::misc::simulation::fscommon QString msfsSimObjectsDirImpl() { - QString dir(CFsDirectories::msfsDir()); + QString dir(CFsDirectories::msfs2020Dir()); if (dir.isEmpty()) { return {}; } - return CFileUtils::normalizeFilePathToQtStandard(msfsPackagesDirImpl()); + return CFileUtils::normalizeFilePathToQtStandard(msfs2020PackagesDirImpl()); } QString msfs2024SimObjectsDirImpl() @@ -285,7 +285,7 @@ namespace swift::misc::simulation::fscommon return dir; } - const QString &CFsDirectories::msfsSimObjectsDir() + const QString &CFsDirectories::msfs2020SimObjectsDir() { static const QString dir(msfsSimObjectsDirImpl()); return dir; @@ -309,7 +309,7 @@ namespace swift::misc::simulation::fscommon return exclude; } - const QStringList &CFsDirectories::msfs20SimObjectsExcludeDirectoryPatterns() + const QStringList &CFsDirectories::msfs2020SimObjectsExcludeDirectoryPatterns() { static const QStringList exclude { "OneStore/asobo-discovery", @@ -441,10 +441,10 @@ namespace swift::misc::simulation::fscommon return allPaths; } - QStringList CFsDirectories::msfsSimObjectsDirPath(const QString &simObjectsDir) + QStringList CFsDirectories::msfs2020SimObjectsDirPath(const QString &simObjectsDir) { Q_UNUSED(simObjectsDir); - static const QStringList Path { CFsDirectories::msfsSimObjectsDir() }; + static const QStringList Path { CFsDirectories::msfs2020SimObjectsDir() }; return Path; } @@ -758,12 +758,12 @@ namespace swift::misc::simulation::fscommon return paths; } - QSet CFsDirectories::msfsSimObjectsPaths(const QStringList &msfsFiles, bool checked) + QSet CFsDirectories::msfs2020SimObjectsPaths(const QStringList &msfsFiles, bool checked) { QSet paths; for (const QString &msfsFile : msfsFiles) { - paths.unite(CFsDirectories::msfsSimObjectsPaths(msfsFile, checked)); + paths.unite(CFsDirectories::msfs2020SimObjectsPaths(msfsFile, checked)); } return paths; } @@ -834,7 +834,7 @@ namespace swift::misc::simulation::fscommon return paths; } - QSet CFsDirectories::msfsSimObjectsPaths(const QString &msfsFile, bool checked) + QSet CFsDirectories::msfs2020SimObjectsPaths(const QString &msfsFile, bool checked) { const QString fileContent = CFileUtils::readFileToString(msfsFile); if (fileContent.isEmpty()) { return {}; } @@ -854,7 +854,7 @@ namespace swift::misc::simulation::fscommon const QStringView path = line.mid(i2 + 1); QString soPath = QDir::fromNativeSeparators(path.toString()); - CLogMessage(static_cast(nullptr)).info(u"MSFS SimObjects path checked: '%1' in '%2'") + CLogMessage(static_cast(nullptr)).info(u"MSFS2020 SimObjects path checked: '%1' in '%2'") << line << msfsFile; // ignore exclude patterns diff --git a/src/misc/simulation/fscommon/fsdirectories.h b/src/misc/simulation/fscommon/fsdirectories.h index db00b5f91..ed432cf49 100644 --- a/src/misc/simulation/fscommon/fsdirectories.h +++ b/src/misc/simulation/fscommon/fsdirectories.h @@ -36,7 +36,7 @@ namespace swift::misc::simulation::fscommon static const QString &fsxSimObjectsDir(); //! MSFS's simobject dir, resolved from multiple sources - static const QString &msfsSimObjectsDir(); + static const QString &msfs2020SimObjectsDir(); //! MSFS's simobject dir, resolved from multiple sources static const QString &msfs2024SimObjectsDir(); @@ -48,7 +48,7 @@ namespace swift::misc::simulation::fscommon static const QStringList &fsxSimObjectsExcludeDirectoryPatterns(); //! Exclude directories for simObjects - static const QStringList &msfs20SimObjectsExcludeDirectoryPatterns(); + static const QStringList &msfs2020SimObjectsExcludeDirectoryPatterns(); //! Exclude directories for simObjects static const QStringList &msfs2024SimObjectsExcludeDirectoryPatterns(); @@ -57,7 +57,7 @@ namespace swift::misc::simulation::fscommon static QStringList fsxSimObjectsDirPlusAddOnXmlSimObjectsPaths(const QString &simObjectsDir = ""); //! MSFS's simObject dir and the add on dirs - static QStringList msfsSimObjectsDirPath(const QString &simObjectsDir = ""); + static QStringList msfs2020SimObjectsDirPath(const QString &simObjectsDir = ""); //! MSFS2024's simObject dir and the add on dirs static QStringList msfs2024SimObjectsDirPath(const QString &simObjectsDir = ""); @@ -88,10 +88,10 @@ namespace swift::misc::simulation::fscommon static const QStringList &p3dSimObjectsExcludeDirectoryPatterns(); //! MSFS directory from different sources - static const QString &msfsDir(); + static const QString &msfs2020Dir(); //! MSFS's packages dir - static const QString &msfsPackagesDir(); + static const QString &msfs2020PackagesDir(); //! MSFS directory from different sources static const QString &msfs2024Dir(); @@ -151,7 +151,7 @@ namespace swift::misc::simulation::fscommon //! Get all the SimObjects paths from msfs.cfg // SimObjectPaths.0=SimObjects\Airplanes - static QSet msfsSimObjectsPaths(const QStringList &msfsFiles, bool checked); + static QSet msfs2020SimObjectsPaths(const QStringList &msfsFiles, bool checked); //! Get all the SimObjects files from fsx.cfg // SimObjectPaths.0=SimObjects\Airplanes @@ -159,7 +159,7 @@ namespace swift::misc::simulation::fscommon //! Get all the SimObjects files from fsx.cfg // SimObjectPaths.0=SimObjects\Airplanes - static QSet msfsSimObjectsPaths(const QString &msfsFile, bool checked); + static QSet msfs2020SimObjectsPaths(const QString &msfsFile, bool checked); //! .air file filter static const QString &airFileFilter(); diff --git a/src/misc/simulation/msfs2024/simconnectutilities.cpp b/src/misc/simulation/msfs2024/simconnectutilities.cpp index c4cc398c3..2f57cb08f 100644 --- a/src/misc/simulation/msfs2024/simconnectutilities.cpp +++ b/src/misc/simulation/msfs2024/simconnectutilities.cpp @@ -15,8 +15,6 @@ using namespace swift::misc::aviation; namespace swift::misc::simulation::msfs2024 { - CSimConnectUtilities::CSimConnectUtilities() {} - QString CSimConnectUtilities::resolveEnumToString(const DWORD id, const char *enumName) { const int i = CSimConnectUtilities::staticMetaObject.indexOfEnumerator(enumName); diff --git a/src/misc/simulation/settings/simulatorsettings.cpp b/src/misc/simulation/settings/simulatorsettings.cpp index 05f242536..ce70afd5d 100644 --- a/src/misc/simulation/settings/simulatorsettings.cpp +++ b/src/misc/simulation/settings/simulatorsettings.cpp @@ -152,15 +152,9 @@ namespace swift::misc::simulation::settings } } - void CSimulatorSettings::setPropertyModelSet(bool value) { value ? m_modelSet = true : m_modelSet = false; } - void CSimulatorSettings::setPropertyWithDbEntry(bool value) - { - value ? m_withDbEntry = true : m_withDbEntry = false; - } - void CSimulatorSettings::setPropertyDistributorFiltered(bool value) - { - value ? m_distributorFiltered = true : m_distributorFiltered = false; - } + void CSimulatorSettings::setPropertyModelSet(bool value) { m_modelSet = value; } + void CSimulatorSettings::setPropertyWithDbEntry(bool value) { m_withDbEntry = value; } + void CSimulatorSettings::setPropertyDistributorFiltered(bool value) { m_distributorFiltered = value; } void CSimulatorSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant) { @@ -204,7 +198,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: return m_simSettingsFs9.get(); case CSimulatorInfo::FSX: return m_simSettingsFsx.get(); case CSimulatorInfo::P3D: return m_simSettingsP3D.get(); - case CSimulatorInfo::MSFS: return m_simSettingsMsfs.get(); + case CSimulatorInfo::MSFS2020: return m_simSettingsMsfs2020.get(); case CSimulatorInfo::MSFS2024: return m_simSettingsMsfs2024.get(); case CSimulatorInfo::XPLANE: return m_simSettingsXP.get(); @@ -228,7 +222,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: return m_simSettingsFs9.set(settings); case CSimulatorInfo::FSX: return m_simSettingsFsx.set(settings); case CSimulatorInfo::P3D: return m_simSettingsP3D.set(settings); - case CSimulatorInfo::MSFS: return m_simSettingsMsfs.set(settings); + case CSimulatorInfo::MSFS2020: return m_simSettingsMsfs2020.set(settings); case CSimulatorInfo::MSFS2024: return m_simSettingsMsfs2024.set(settings); case CSimulatorInfo::XPLANE: return m_simSettingsXP.set(settings); default: Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); break; @@ -266,7 +260,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: break; case CSimulatorInfo::FSX: break; case CSimulatorInfo::P3D: break; - case CSimulatorInfo::MSFS: break; + case CSimulatorInfo::MSFS2020: break; case CSimulatorInfo::MSFS2024: break; case CSimulatorInfo::XPLANE: { @@ -292,7 +286,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: return m_simSettingsFs9.setAndSave(settings); case CSimulatorInfo::FSX: return m_simSettingsFsx.setAndSave(settings); case CSimulatorInfo::P3D: return m_simSettingsP3D.setAndSave(settings); - case CSimulatorInfo::MSFS: return m_simSettingsMsfs.setAndSave(settings); + case CSimulatorInfo::MSFS2020: return m_simSettingsMsfs2020.setAndSave(settings); case CSimulatorInfo::MSFS2024: return m_simSettingsMsfs2024.setAndSave(settings); case CSimulatorInfo::XPLANE: return m_simSettingsXP.setAndSave(settings); default: Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); break; @@ -315,7 +309,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: return m_simSettingsFs9.save(); case CSimulatorInfo::FSX: return m_simSettingsFsx.save(); case CSimulatorInfo::P3D: return m_simSettingsP3D.save(); - case CSimulatorInfo::MSFS: return m_simSettingsMsfs.save(); + case CSimulatorInfo::MSFS2020: return m_simSettingsMsfs2020.save(); case CSimulatorInfo::MSFS2024: return m_simSettingsMsfs2024.save(); case CSimulatorInfo::XPLANE: return m_simSettingsXP.save(); default: Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); break; @@ -385,7 +379,7 @@ namespace swift::misc::simulation::settings void CMultiSimulatorSettings::onFs9SettingsChanged() { this->emitSettingsChanged(CSimulatorInfo::fs9()); } - void CMultiSimulatorSettings::onMsfsSettingsChanged() { this->emitSettingsChanged(CSimulatorInfo::msfs()); } + void CMultiSimulatorSettings::onMsfs2020SettingsChanged() { this->emitSettingsChanged(CSimulatorInfo::msfs2020()); } void CMultiSimulatorSettings::onMsfs2024SettingsChanged() { this->emitSettingsChanged(CSimulatorInfo::msfs2024()); } @@ -599,7 +593,7 @@ namespace swift::misc::simulation::settings } break; case CSimulatorInfo::XPLANE: dirs = QStringList({ CXPlaneUtil::modelDirectoriesFromSimDir(s) }); break; - case CSimulatorInfo::MSFS: dirs = QStringList({ CFsDirectories::msfsSimObjectsDir() }); break; + case CSimulatorInfo::MSFS2020: dirs = QStringList({ CFsDirectories::msfs2020SimObjectsDir() }); break; case CSimulatorInfo::MSFS2024: dirs = QStringList({ CFsDirectories::msfs2024SimObjectsDir() }); break; default: break; } @@ -693,11 +687,12 @@ namespace swift::misc::simulation::settings static const QStringList md = CFsDirectories::p3dSimObjectsDirPlusAddOnXmlSimObjectsPaths(p3d, versionHint); return md; } - case CSimulatorInfo::MSFS: + case CSimulatorInfo::MSFS2020: { - static const QString msfs = CFileUtils::normalizeFilePathToQtStandard(CFsDirectories::msfsPackagesDir()); - if (msfs.isEmpty()) { return e; } - static const QStringList md { msfs }; + static const QString msfs2020 = + CFileUtils::normalizeFilePathToQtStandard(CFsDirectories::msfs2020PackagesDir()); + if (msfs2020.isEmpty()) { return e; } + static const QStringList md { msfs2020 }; return md; } case CSimulatorInfo::MSFS2024: @@ -727,7 +722,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FS9: return CFsDirectories::fs9Dir(); case CSimulatorInfo::FSX: return CFsDirectories::fsxDir(); case CSimulatorInfo::P3D: return CFsDirectories::p3dDir(); - case CSimulatorInfo::MSFS: return CFsDirectories::msfsDir(); + case CSimulatorInfo::MSFS2020: return CFsDirectories::msfs2020Dir(); case CSimulatorInfo::MSFS2024: return CFsDirectories::msfs2024Dir(); case CSimulatorInfo::XPLANE: return CXPlaneUtil::xplaneRootDir(); default: Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); break; @@ -747,7 +742,7 @@ namespace swift::misc::simulation::settings case CSimulatorInfo::FSX: return CFsDirectories::fsxSimObjectsExcludeDirectoryPatterns(); case CSimulatorInfo::P3D: return CFsDirectories::p3dSimObjectsExcludeDirectoryPatterns(); case CSimulatorInfo::XPLANE: return CXPlaneUtil::xplaneModelExcludeDirectoryPatterns(); - case CSimulatorInfo::MSFS: return CFsDirectories::msfs20SimObjectsExcludeDirectoryPatterns(); + case CSimulatorInfo::MSFS2020: return CFsDirectories::msfs2020SimObjectsExcludeDirectoryPatterns(); case CSimulatorInfo::MSFS2024: return CFsDirectories::msfs2024SimObjectsExcludeDirectoryPatterns(); default: Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); break; } diff --git a/src/misc/simulation/settings/simulatorsettings.h b/src/misc/simulation/settings/simulatorsettings.h index 9ef89a76a..25588cd66 100644 --- a/src/misc/simulation/settings/simulatorsettings.h +++ b/src/misc/simulation/settings/simulatorsettings.h @@ -121,9 +121,9 @@ namespace swift::misc::simulation::settings bool setRecordedGndRadius(const swift::misc::physical_quantities::CLength &radius); //! Reads the settings for automatic loading when starting swiftgui - bool getPropertyWithDbEntry() { return m_withDbEntry; } - bool getPropertyModelSet() { return m_modelSet; } - bool getPropertyDistributorFiltered() { return m_distributorFiltered; } + bool getPropertyWithDbEntry() const { return m_withDbEntry; } + bool getPropertyModelSet() const { return m_modelSet; } + bool getPropertyDistributorFiltered() const { return m_distributorFiltered; } //! Reset the paths void resetPaths(); @@ -358,15 +358,15 @@ namespace swift::misc::simulation::settings }; //! Trait for simulator settings - struct TSimulatorMsfs : public TSettingTrait + struct TSimulatorMsfs2020 : public TSettingTrait { //! \copydoc swift::misc::TSettingTrait::key - static const char *key() { return "settingssimulatormsfs"; } + static const char *key() { return "settingssimulatormsfs2020"; } //! \copydoc swift::misc::TSettingTrait::humanReadable static const QString &humanReadable() { - static const QString name("MSFS settings"); + static const QString name("MSFS2020 settings"); return name; } }; @@ -573,13 +573,13 @@ namespace swift::misc::simulation::settings &CMultiSimulatorSettings::onFs9SettingsChanged }; //!< FS9 settings CSetting m_simSettingsP3D { this, &CMultiSimulatorSettings::onP3DSettingsChanged }; //!< P3D settings - CSetting m_simSettingsMsfs { - this, &CMultiSimulatorSettings::onMsfsSettingsChanged - }; //!< MSFS settings + CSetting m_simSettingsXP { this, &CMultiSimulatorSettings::onXPSettingsChanged }; //!< XP settings + CSetting m_simSettingsMsfs2020 { + this, &CMultiSimulatorSettings::onMsfs2020SettingsChanged + }; //!< MSFS2020 settings CSetting m_simSettingsMsfs2024 { this, &CMultiSimulatorSettings::onMsfs2024SettingsChanged - }; //!< MSFS settings - CSetting m_simSettingsXP { this, &CMultiSimulatorSettings::onXPSettingsChanged }; //!< XP settings + }; //!< MSFS2024 settings CSetting m_simSettingsFG { this, &CMultiSimulatorSettings::onFGSettingsChanged }; //!< FG settings //! @{ @@ -587,7 +587,7 @@ namespace swift::misc::simulation::settings void onFsxSettingsChanged(); void onFs9SettingsChanged(); void onP3DSettingsChanged(); - void onMsfsSettingsChanged(); + void onMsfs2020SettingsChanged(); void onMsfs2024SettingsChanged(); void onXPSettingsChanged(); void onFGSettingsChanged(); diff --git a/src/misc/simulation/simulatorinfo.cpp b/src/misc/simulation/simulatorinfo.cpp index ee44265d3..a0571a2bb 100644 --- a/src/misc/simulation/simulatorinfo.cpp +++ b/src/misc/simulation/simulatorinfo.cpp @@ -39,8 +39,8 @@ namespace swift::misc::simulation CSimulatorInfo::CSimulatorInfo(Simulator simulator) : m_simulator(static_cast(simulator)) {} - CSimulatorInfo::CSimulatorInfo(bool fsx, bool fs9, bool xp, bool p3d, bool fg, bool msfs, bool msfs2024) - : m_simulator(boolToFlag(fsx, fs9, xp, p3d, fg, msfs, msfs2024)) + CSimulatorInfo::CSimulatorInfo(bool fsx, bool fs9, bool xp, bool p3d, bool fg, bool msfs2020, bool msfs2024) + : m_simulator(boolToFlag(fsx, fs9, xp, p3d, fg, msfs2020, msfs2024)) {} CSimulatorInfo::CSimulatorInfo(int flagsAsInt) : m_simulator(flagsAsInt) {} @@ -57,13 +57,13 @@ namespace swift::misc::simulation bool CSimulatorInfo::isFG() const { return getSimulator().testFlag(FG); } - bool CSimulatorInfo::isMSFS() const { return getSimulator().testFlag(MSFS); } + bool CSimulatorInfo::isMSFS2020() const { return getSimulator().testFlag(MSFS2020); } bool CSimulatorInfo::isMSFS2024() const { return getSimulator().testFlag(MSFS2024); } bool CSimulatorInfo::isAnySimulator() const { - return isFSX() || isFS9() || isXPlane() || isP3D() || isFG() || isMSFS() || isMSFS2024(); + return isFSX() || isFS9() || isXPlane() || isP3D() || isFG() || isMSFS2020() || isMSFS2024(); } bool CSimulatorInfo::isSingleSimulator() const { return this->numberSimulators() == 1; } @@ -74,14 +74,14 @@ namespace swift::misc::simulation bool CSimulatorInfo::isAllSimulators() const { - return isFSX() && isFS9() && isXPlane() && isP3D() && isFG() && isMSFS() && isMSFS2024(); + return isFSX() && isFS9() && isXPlane() && isP3D() && isFG() && isMSFS2020() && isMSFS2024(); } - bool CSimulatorInfo::isMicrosoftSimulator() const { return isFSX() || isFS9() || isMSFS() || isMSFS2024(); } + bool CSimulatorInfo::isMicrosoftSimulator() const { return isFSX() || isFS9() || isMSFS2020() || isMSFS2024(); } bool CSimulatorInfo::isMicrosoftOrPrepare3DSimulator() const { return isMicrosoftSimulator() || isP3D(); } - bool CSimulatorInfo::isFsxP3DFamily() const { return isFSX() || isP3D() || isMSFS() || isMSFS2024(); } + bool CSimulatorInfo::isFsxP3DFamily() const { return isFSX() || isP3D() || isMSFS2020() || isMSFS2024(); } int CSimulatorInfo::numberSimulators() const { @@ -90,7 +90,7 @@ namespace swift::misc::simulation if (isXPlane()) { c++; } if (isP3D()) { c++; } if (isFG()) { c++; } - if (isMSFS()) { c++; } + if (isMSFS2020()) { c++; } if (isMSFS2024()) { c++; } return c; } @@ -126,7 +126,7 @@ namespace swift::misc::simulation (s.testFlag(P3D) ? QStringLiteral("P3D ") : QString()) % (s.testFlag(XPLANE) ? QStringLiteral("XPlane ") : QString()) % (s.testFlag(FG) ? QStringLiteral("FG ") : QString()) % - (s.testFlag(MSFS) ? QStringLiteral("MSFS ") : QString()) % + (s.testFlag(MSFS2020) ? QStringLiteral("MSFS2020 ") : QString()) % (s.testFlag(MSFS2024) ? QStringLiteral("MSFS2024 ") : QString()); return str.trimmed(); } @@ -152,7 +152,7 @@ namespace swift::misc::simulation if (m_simulator & P3D) { set.insert(CSimulatorInfo(P3D)); } if (m_simulator & FG) { set.insert(CSimulatorInfo(FG)); } if (m_simulator & XPLANE) { set.insert(CSimulatorInfo(XPLANE)); } - if (m_simulator & MSFS) { set.insert(CSimulatorInfo(MSFS)); } + if (m_simulator & MSFS2020) { set.insert(CSimulatorInfo(MSFS2020)); } if (m_simulator & MSFS2024) { set.insert(CSimulatorInfo(MSFS2024)); } return set; } @@ -178,7 +178,7 @@ namespace swift::misc::simulation return m.info(u"Simulators OK for model"); } - CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d, bool fg, bool msfs, + CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d, bool fg, bool msfs2020, bool msfs2024) { Simulator s = fsx ? FSX : None; @@ -186,7 +186,7 @@ namespace swift::misc::simulation if (xp) { s |= XPLANE; } if (p3d) { s |= P3D; } if (fg) { s |= FG; } - if (msfs) { s |= MSFS; } + if (msfs2020) { s |= MSFS2020; } if (msfs2024) { s |= MSFS2024; } return s; } @@ -205,13 +205,9 @@ namespace swift::misc::simulation { s |= P3D; } - if (i.contains("msfs2024")) - { - s |= MSFS2024; - return s; - } + if (i.contains("msfs2024")) { s |= MSFS2024; } - if (i.contains("msfs")) { s |= MSFS; } + if (i.contains("msfs2020")) { s |= MSFS2020; } return s; } @@ -251,7 +247,7 @@ namespace swift::misc::simulation bool fsx = false; bool p3d = false; bool fg = false; - bool msfs = false; + bool msfs2020 = false; bool msfs2024 = false; if (CBuildConfig::isRunningOnWindowsNtPlatform()) @@ -259,13 +255,13 @@ namespace swift::misc::simulation fs9 = !CFsDirectories::fs9AircraftDir().isEmpty() && !CFsDirectories::fs9Dir().isEmpty(); fsx = !CFsDirectories::fsxSimObjectsDir().isEmpty() && !CFsDirectories::fsxDir().isEmpty(); p3d = !CFsDirectories::p3dDir().isEmpty() && !CFsDirectories::p3dSimObjectsDir().isEmpty(); - msfs = !CFsDirectories::msfsDir().isEmpty() && !CFsDirectories::msfsPackagesDir().isEmpty(); + msfs2020 = !CFsDirectories::msfs2020Dir().isEmpty() && !CFsDirectories::msfs2020PackagesDir().isEmpty(); msfs2024 = !CFsDirectories::msfs2024Dir().isEmpty() && !CFsDirectories::msfs2024PackagesDir().isEmpty(); } const bool xp = !CXPlaneUtil::xplaneRootDir().isEmpty(); - sim.setSimulator(CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d, fg, msfs, msfs2024)); + sim.setSimulator(CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d, fg, msfs2020, msfs2024)); return sim; } @@ -299,7 +295,7 @@ namespace swift::misc::simulation const QJsonValue jxp = json.value(prefix % u"simxplane"); const QJsonValue jp3d = json.value(prefix % u"simp3d"); const QJsonValue jfg = json.value(prefix % u"simfg"); - const QJsonValue jmsfs = json.value(prefix % u"simmsfs"); + const QJsonValue jmsfs2020 = json.value(prefix % u"simmsfs2020"); const QJsonValue jmsfs2024 = json.value(prefix % u"simmsfs2024"); // we handle bool JSON values and bool as string @@ -308,11 +304,12 @@ namespace swift::misc::simulation const bool xp = jxp.isBool() ? jxp.toBool() : CDatastoreUtility::dbBoolStringToBool(jxp.toString()); const bool p3d = jp3d.isBool() ? jp3d.toBool() : CDatastoreUtility::dbBoolStringToBool(jp3d.toString()); const bool fg = jfg.isBool() ? jfg.toBool() : CDatastoreUtility::dbBoolStringToBool(jfg.toString()); - const bool msfs = jmsfs.isBool() ? jmsfs.toBool() : CDatastoreUtility::dbBoolStringToBool(jmsfs.toString()); + const bool msfs = + jmsfs2020.isBool() ? jmsfs2020.toBool() : CDatastoreUtility::dbBoolStringToBool(jmsfs2020.toString()); const bool msfs2024 = jmsfs2024.isBool() ? jmsfs2024.toBool() : CDatastoreUtility::dbBoolStringToBool(jmsfs2024.toString()); - const CSimulatorInfo simInfo(fsx, fs9, xp, p3d, fg, msfs, msfs2024); + const CSimulatorInfo simInfo(fsx, fs9, xp, p3d, fg, msfs2020, msfs2024); return simInfo; } @@ -335,14 +332,14 @@ namespace swift::misc::simulation int CCountPerSimulator::getCountForFsFamilySimulators() const { return this->getCount(CSimulatorInfo::fsx()) + this->getCount(CSimulatorInfo::p3d()) + - this->getCount(CSimulatorInfo::fs9()) + this->getCount(CSimulatorInfo::msfs()) + + this->getCount(CSimulatorInfo::fs9()) + this->getCount(CSimulatorInfo::msfs2020()) + this->getCount(CSimulatorInfo::msfs2024()); } int CCountPerSimulator::getCountForFsxFamilySimulators() const { return this->getCount(CSimulatorInfo::fsx()) + this->getCount(CSimulatorInfo::p3d()) + - this->getCount(CSimulatorInfo::msfs()) + this->getCount(CSimulatorInfo::msfs2024()); + this->getCount(CSimulatorInfo::msfs2020()) + this->getCount(CSimulatorInfo::msfs2024()); } int CCountPerSimulator::getMaximum() const { return *std::min_element(m_counts.begin(), m_counts.end()); } @@ -370,7 +367,7 @@ namespace swift::misc::simulation { return u"FSX: " % QString::number(m_counts[0]) % u" P3D: " % QString::number(m_counts[1]) % u" FS9: " % QString::number(m_counts[2]) % u" XPlane: " % QString::number(m_counts[3]) % u" FG: " % - QString::number(m_counts[4]) % u" MSFS: " % QString::number(m_counts[5]) % u" MSFS2024: " % + QString::number(m_counts[4]) % u" MSFS2020: " % QString::number(m_counts[5]) % u" MSFS2024: " % QString::number(m_counts[6]); } @@ -392,7 +389,7 @@ namespace swift::misc::simulation if (simulator.isFS9()) { m_counts[2]++; } if (simulator.isXPlane()) { m_counts[3]++; } if (simulator.isFG()) { m_counts[4]++; } - if (simulator.isMSFS()) { m_counts[5]++; } + if (simulator.isMSFS2020()) { m_counts[5]++; } if (simulator.isMSFS2024()) { m_counts[6]++; } } @@ -406,7 +403,7 @@ namespace swift::misc::simulation case CSimulatorInfo::FS9: return 2; case CSimulatorInfo::XPLANE: return 3; case CSimulatorInfo::FG: return 4; - case CSimulatorInfo::MSFS: return 5; + case CSimulatorInfo::MSFS2020: return 5; case CSimulatorInfo::MSFS2024: return 6; default: return CSimulatorInfo::NumberOfSimulators; // unknown } @@ -421,7 +418,7 @@ namespace swift::misc::simulation case 2: return { CSimulatorInfo::FS9 }; case 3: return { CSimulatorInfo::XPLANE }; case 4: return { CSimulatorInfo::FG }; - case 5: return { CSimulatorInfo::MSFS }; + case 5: return { CSimulatorInfo::MSFS2020 }; case 6: return { CSimulatorInfo::MSFS2024 }; default: return { CSimulatorInfo::None }; } diff --git a/src/misc/simulation/simulatorinfo.h b/src/misc/simulation/simulatorinfo.h index e54c3cff1..cb2bedd8d 100644 --- a/src/misc/simulation/simulatorinfo.h +++ b/src/misc/simulation/simulatorinfo.h @@ -49,11 +49,11 @@ namespace swift::misc::simulation XPLANE = 1 << 2, P3D = 1 << 3, FG = 1 << 4, - MSFS = 1 << 5, + MSFS2020 = 1 << 5, MSFS2024 = 1 << 6, FSX_P3D = FSX | P3D, - AllFsFamily = FSX | FS9 | P3D | MSFS | MSFS2024, - All = FSX | FS9 | XPLANE | P3D | FG | MSFS | MSFS2024 + AllFsFamily = FSX | FS9 | P3D | MSFS2020 | MSFS2024, + All = FSX | FS9 | XPLANE | P3D | FG | MSFS2020 | MSFS2024 }; Q_DECLARE_FLAGS(Simulator, SimulatorFlag) @@ -76,7 +76,7 @@ namespace swift::misc::simulation CSimulatorInfo(int flagsAsInt); //! Constructor - CSimulatorInfo(bool isFSX, bool isFS9, bool xp, bool isP3D, bool fg, bool msfs, bool msfs2024); + CSimulatorInfo(bool isFSX, bool isFS9, bool xp, bool isP3D, bool fg, bool msfs2020, bool msfs2024); //! Unspecified simulator bool isUnspecified() const; @@ -97,7 +97,7 @@ namespace swift::misc::simulation bool isFG() const; //! MSFS? - bool isMSFS() const; + bool isMSFS2020() const; //! MSFS2024? bool isMSFS2024() const; @@ -176,7 +176,7 @@ namespace swift::misc::simulation CStatusMessage validateSimulatorsForModel() const; //! Bool flags to enum - static Simulator boolToFlag(bool isFSX, bool isFS9, bool xp, bool isP3D, bool fg, bool msfs, bool msfs2024); + static Simulator boolToFlag(bool isFSX, bool isFS9, bool xp, bool isP3D, bool fg, bool msfs2020, bool msfs2024); //! Identifer, as provided by plugin static Simulator identifierToSimulator(const QString &identifier); @@ -229,9 +229,9 @@ namespace swift::misc::simulation static const CSimulatorInfo s(XPLANE); return s; } - static const CSimulatorInfo &msfs() + static const CSimulatorInfo &msfs2020() { - static const CSimulatorInfo s(MSFS); + static const CSimulatorInfo s(MSFS2020); return s; } static const CSimulatorInfo &msfs2024() diff --git a/src/misc/simulation/simulatorinfolist.cpp b/src/misc/simulation/simulatorinfolist.cpp index d89c3d2e9..3b1e485a0 100644 --- a/src/misc/simulation/simulatorinfolist.cpp +++ b/src/misc/simulation/simulatorinfolist.cpp @@ -47,7 +47,7 @@ namespace swift::misc::simulation 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.isMSFS()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::MSFS)); } + if (sim.isMSFS2020()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::MSFS2020)); } if (sim.isMSFS2024()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::MSFS2024)); } if (sim.isXPlane()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::XPLANE)); } return sims; diff --git a/src/misc/simulation/simulatorplugininfo.cpp b/src/misc/simulation/simulatorplugininfo.cpp index 9d922ace8..3392c170d 100644 --- a/src/misc/simulation/simulatorplugininfo.cpp +++ b/src/misc/simulation/simulatorplugininfo.cpp @@ -64,7 +64,7 @@ namespace swift::misc::simulation if (s.testFlag(CSimulatorInfo::P3D)) { return CSimulatorPluginInfo::p3dPluginIdentifier(); } if (s.testFlag(CSimulatorInfo::XPLANE)) { return CSimulatorPluginInfo::xplanePluginIdentifier(); } if (s.testFlag(CSimulatorInfo::FG)) { return CSimulatorPluginInfo::fgPluginIdentifier(); } - if (s.testFlag(CSimulatorInfo::MSFS)) { return CSimulatorPluginInfo::msfsPluginIdentifier(); } + if (s.testFlag(CSimulatorInfo::MSFS2020)) { return CSimulatorPluginInfo::msfs2020PluginIdentifier(); } if (s.testFlag(CSimulatorInfo::MSFS2024)) { return CSimulatorPluginInfo::msfs2024PluginIdentifier(); } return e; @@ -100,9 +100,9 @@ namespace swift::misc::simulation return s; } - const QString &CSimulatorPluginInfo::msfsPluginIdentifier() + const QString &CSimulatorPluginInfo::msfs2020PluginIdentifier() { - static const QString s("org.swift-project.plugins.simulator.msfs"); + static const QString s("org.swift-project.plugins.simulator.msfs2020"); return s; } @@ -122,7 +122,7 @@ namespace swift::misc::simulation { static const QStringList identifiers({ fsxPluginIdentifier(), p3dPluginIdentifier(), xplanePluginIdentifier(), fs9PluginIdentifier(), emulatedPluginIdentifier(), fgPluginIdentifier(), - msfsPluginIdentifier(), msfs2024PluginIdentifier() }); + msfs2020PluginIdentifier(), msfs2024PluginIdentifier() }); return identifiers; } @@ -134,9 +134,10 @@ namespace swift::misc::simulation return QStringList { xplanePluginIdentifier(), fgPluginIdentifier() }; } - return QStringList { - fsxPluginIdentifier(), msfsPluginIdentifier(), p3dPluginIdentifier(), - xplanePluginIdentifier(), fgPluginIdentifier(), msfs2024PluginIdentifier(), - }; + return QStringList {}; + // return QStringList { + // fsxPluginIdentifier(), msfs2020PluginIdentifier(), p3dPluginIdentifier(), + // xplanePluginIdentifier(), fgPluginIdentifier(), msfs2024PluginIdentifier(), + // }; } } // namespace swift::misc::simulation diff --git a/src/misc/simulation/simulatorplugininfo.h b/src/misc/simulation/simulatorplugininfo.h index cc898197e..8416b96d0 100644 --- a/src/misc/simulation/simulatorplugininfo.h +++ b/src/misc/simulation/simulatorplugininfo.h @@ -84,7 +84,7 @@ namespace swift::misc::simulation static const QString &fgPluginIdentifier(); //! Plugin identifier (MSFS 2020) - static const QString &msfsPluginIdentifier(); + static const QString &msfs2020PluginIdentifier(); //! Plugin identifier (MSFS 2024) static const QString &msfs2024PluginIdentifier(); diff --git a/src/misc/valuecache.cpp b/src/misc/valuecache.cpp index a0c09e3d4..4f09de05e 100644 --- a/src/misc/valuecache.cpp +++ b/src/misc/valuecache.cpp @@ -361,6 +361,7 @@ namespace swift::misc return status; } + CStatusMessage CValueCache::saveToFiles(const QString &dir, const CVariantMap &values, const QString &keysMessage) const { @@ -378,6 +379,10 @@ namespace swift::misc { return CStatusMessage(this).error(u"Failed to create directory '%1'") << QFileInfo(file).path(); } + + // TODO TZ + CLogMessage(this).info(u"Read data '%1' ") << QFile::Text; + if (!file.open(QFile::ReadWrite | QFile::Text)) { return CStatusMessage(this).error(u"Failed to open %1: %2") << file.fileName() << file.errorString(); @@ -420,6 +425,9 @@ namespace swift::misc return CStatusMessage(this).error(u"Failed to read from directory '%1'") << dir; } + // TODO TZ + CLogMessage(this).info(u"Read data '%1' ") << dir; + QMap keysInFiles; for (const auto &key : keys) { @@ -435,6 +443,10 @@ namespace swift::misc { QFile file(QDir(dir).absoluteFilePath(it.key())); if (!file.exists()) { continue; } + + // TODO TZ + CLogMessage(this).info(u"Read data '%1' ") << QFile::Text; + if (!file.open(QFile::ReadOnly | QFile::Text)) { return CStatusMessage(this).error(u"Failed to open %1: %2") << file.fileName() << file.errorString(); diff --git a/src/plugins/simulator/CMakeLists.txt b/src/plugins/simulator/CMakeLists.txt index 17c1c4039..2e7a872cf 100644 --- a/src/plugins/simulator/CMakeLists.txt +++ b/src/plugins/simulator/CMakeLists.txt @@ -18,11 +18,11 @@ if(SWIFT_BUILD_XPLANE_PLUGIN) add_subdirectory(xplaneconfig) endif() -if(SWIFT_BUILD_FS9_PLUGIN OR SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS_PLUGIN OR SWIFT_BUILD_MSFS2024_PLUGIN) +if(SWIFT_BUILD_FS9_PLUGIN OR SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS2020_PLUGIN OR SWIFT_BUILD_MSFS2024_PLUGIN) add_subdirectory(fscommon) endif() -if(SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS_PLUGIN) +if(SWIFT_BUILD_FSX_PLUGIN OR SWIFT_BUILD_P3D_PLUGIN OR SWIFT_BUILD_MSFS2020_PLUGIN) add_subdirectory(fsxcommon) endif() @@ -35,7 +35,7 @@ if(SWIFT_BUILD_P3D_PLUGIN) add_subdirectory(p3dconfig) endif() -if(SWIFT_BUILD_MSFS_PLUGIN) +if(SWIFT_BUILD_MSFS2020_PLUGIN) add_subdirectory(msfs) endif() diff --git a/src/plugins/simulator/fsxcommon/simconnectdatadefinition.cpp b/src/plugins/simulator/fsxcommon/simconnectdatadefinition.cpp index fd273e546..b99090280 100644 --- a/src/plugins/simulator/fsxcommon/simconnectdatadefinition.cpp +++ b/src/plugins/simulator/fsxcommon/simconnectdatadefinition.cpp @@ -81,7 +81,7 @@ namespace swift::simplugin::fsxcommon hr += initRemoteAircraftSimDataSet(hSimConnect); hr += initSimulatorEnvironment(hSimConnect); hr += initSbDataArea(hSimConnect); - if (simInfo.isMSFS()) { hr += initMSFSTransponder(hSimConnect); } + if (simInfo.isMSFS2020()) { hr += initMSFSTransponder(hSimConnect); } // if (simInfo.isMSFS2024()) { hr += initMSFS2024Transponder(hSimConnect); } return hr; } @@ -417,7 +417,7 @@ namespace swift::simplugin::fsxcommon if (isFailure(hr)) { CLogMessage(static_cast(nullptr)) - .error(u"SimConnect error: MSFS transponder data definitions %1") + .error(u"SimConnect error: MSFS2020 transponder data definitions %1") << hr; } return hr; diff --git a/src/plugins/simulator/fsxcommon/simconnectsymbols.cpp b/src/plugins/simulator/fsxcommon/simconnectsymbols.cpp index 3857f565d..e015034b4 100644 --- a/src/plugins/simulator/fsxcommon/simconnectsymbols.cpp +++ b/src/plugins/simulator/fsxcommon/simconnectsymbols.cpp @@ -339,7 +339,7 @@ bool loadAndResolveMSFSimConnect() return false; } - CLogMessage(CLogCategories::driver()).info(u"Loaded and resolved MSFS symbols from SimConnect.dll: '%1'") + CLogMessage(CLogCategories::driver()).info(u"Loaded and resolved MSFS2020 symbols from SimConnect.dll: '%1'") << simConnectFileName; return resolvedCommon; } diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index 2e9966fdb..d55ce6105 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -200,7 +200,7 @@ namespace swift::simplugin::fsxcommon } changed = true; } - else if (this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS()) + else if (this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2020()) { DataDefinitionMSFSTransponderMode t; t.transponderMode = (newTransponder.isInStandby() ? 1 : 4); @@ -212,7 +212,7 @@ namespace swift::simplugin::fsxcommon SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0, sizeof(DataDefinitionMSFSTransponderMode), &t); - if (isFailure(hr)) { CLogMessage(this).warning(u"Setting transponder mode failed (MSFS)"); } + if (isFailure(hr)) { CLogMessage(this).warning(u"Setting transponder mode failed (MSFS2020)"); } changed = true; } @@ -509,10 +509,10 @@ namespace swift::simplugin::fsxcommon const CFsxP3DSettings settings = m_detailsSettings.getSettings(this->getSimulatorInfo()); m_useAddSimulatedObj = settings.isAddingAsSimulatedObjectEnabled(); m_useSbOffsets = settings.isSbOffsetsEnabled(); - if (this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS() || + if (this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2020() || this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2024()) { - m_useSbOffsets = false; // Always disable SbOffsets for MSFS. Using new transponder mode property directly + m_useSbOffsets = false; // Always disable SbOffsets for MSFS2020. Using new transponder mode property directly } HRESULT hr = s_ok(); @@ -528,7 +528,7 @@ namespace swift::simplugin::fsxcommon SIMCONNECT_PERIOD_SECOND, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED), "Cannot request title", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject"); - if (!this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS() && + if (!this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2020() && !this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2024()) { // Request the data from SB only when its changed and only ONCE so we don't have to run a 1sec event to @@ -548,7 +548,7 @@ namespace swift::simplugin::fsxcommon CSimConnectDefinitions::DataTransponderModeMSFS, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED), - "Cannot request MSFS transponder data", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject"); + "Cannot request MSFS2020 transponder data", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject"); } if (isFailure(hr)) { return; } @@ -3015,7 +3015,7 @@ namespace swift::simplugin::fsxcommon return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x"); } - else if (pluginSim.isMSFS()) + else if (pluginSim.isMSFS2020()) { // MSFS 2020 drivers only works with MSFS return connectedSimName.contains("kittyhawk"); diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index 5cb1976eb..d067bd508 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -514,7 +514,7 @@ namespace swift::simplugin::fsxcommon //! \threadsafe void updateTransponderMode(const misc::aviation::CTransponder::TransponderMode xpdrMode); - //! Update transponder mode from MSFS + //! Update transponder mode from MSFS2020 void updateMSFSTransponderMode(const DataDefinitionMSFSTransponderMode transponderMode); //! An AI aircraft was added in the simulator diff --git a/src/plugins/simulator/msfs/simulatormsfs.json b/src/plugins/simulator/msfs/simulatormsfs.json index 2cf116d54..0419cb783 100644 --- a/src/plugins/simulator/msfs/simulatormsfs.json +++ b/src/plugins/simulator/msfs/simulatormsfs.json @@ -1,7 +1,7 @@ { - "identifier" : "org.swift-project.plugins.simulator.msfs", + "identifier" : "org.swift-project.plugins.simulator.msfs2020", "name" : "Flight Simulator 2020", - "simulator" : "msfs", + "simulator" : "msfs2020", "description" : "Microsoft Flight Simulator 2020", - "config" : "org.swift-project.plugins.simulator.msfs.config" + "config" : "org.swift-project.plugins.simulator.msfs2020.config" } diff --git a/src/plugins/simulator/msfs2024/simconnectdatadefinitionmsfs2024.h b/src/plugins/simulator/msfs2024/simconnectdatadefinitionmsfs2024.h index c1d1e730e..39c82d430 100644 --- a/src/plugins/simulator/msfs2024/simconnectdatadefinitionmsfs2024.h +++ b/src/plugins/simulator/msfs2024/simconnectdatadefinitionmsfs2024.h @@ -267,7 +267,7 @@ namespace swift::simplugin::msfs2024common QString toQString() const; }; - //! Data structure for MSFS transponder mode information + //! Data structure for MSFS2024 transponder mode information struct DataDefinitionMSFSTransponderMode { double transponderMode = 1; //!< transponder state simvar @@ -311,7 +311,7 @@ namespace swift::simplugin::msfs2024common RequestOwnAircraftTitle, RequestOwnAircraftLivery, RequestSbData, //!< SB client area / XPDR mode - RequestMSFSTransponder, //!< MSFS XPDR mode/ident + RequestMSFS2024Transponder, //!< MSFS XPDR mode/ident RequestFacility, RequestEndMarker, //!< free request ids can start here @@ -380,10 +380,10 @@ namespace swift::simplugin::msfs2024common //! Initialize the SB data are static HRESULT initSbDataArea(const HANDLE hSimConnect); - //! Initialize data definition for MSFS transponder + //! Initialize data definition for MSFS2024 transponder // static HRESULT initMSFSTransponder(const HANDLE hSimConnect); - //! Initialize data definition for MSFS transponder + //! Initialize data definition for MSFS2024 transponder static HRESULT initMSFS2024Transponder(const HANDLE hSimConnect); }; } // namespace swift::simplugin::msfs2024common diff --git a/src/plugins/simulator/msfs2024/simulatormsfs2024common.cpp b/src/plugins/simulator/msfs2024/simulatormsfs2024common.cpp index 6385e5376..a4bf66b1a 100644 --- a/src/plugins/simulator/msfs2024/simulatormsfs2024common.cpp +++ b/src/plugins/simulator/msfs2024/simulatormsfs2024common.cpp @@ -663,6 +663,7 @@ namespace swift::simplugin::msfs2024common bool CSimulatorMsfs2024::testSendSituationAndParts(const CCallsign &callsign, const CAircraftSituation &situation, const CAircraftParts &parts) { + Q_UNUSED(situation); if (!m_simConnectObjects.contains(callsign)) { return false; } CSimConnectObject simObject = m_simConnectObjects.value(callsign); int u = 0; @@ -742,7 +743,7 @@ namespace swift::simplugin::msfs2024common m_useSbOffsets = settings.isSbOffsetsEnabled(); if (this->getSimulatorPluginInfo().getSimulatorInfo().isMSFS2024()) { - m_useSbOffsets = false; // Always disable SbOffsets for MSFS. Using new transponder mode property directly + m_useSbOffsets = false; // Always disable SbOffsets for MSFS2024. Using new transponder mode property directly } HRESULT hr = s_ok(); @@ -759,10 +760,10 @@ namespace swift::simplugin::msfs2024common "Cannot request title and livery", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObjectType"); hr += this->logAndTraceSendId(SimConnect_RequestDataOnSimObject( - m_hSimConnect, CSimConnectDefinitions::RequestMSFSTransponder, + m_hSimConnect, CSimConnectDefinitions::RequestMSFS2024Transponder, CSimConnectDefinitions::DataTransponderModeMSFS, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED), - "Cannot request MSFS transponder data", Q_FUNC_INFO, + "Cannot request MSFS2024 transponder data", Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject"); if (isFailure(hr)) { return; } @@ -2595,7 +2596,7 @@ namespace swift::simplugin::msfs2024common position.Altitude = alt.value(CLengthUnit::ft()); } - // MSFS has inverted pitch and bank angles + // MSFS2024 has inverted pitch and bank angles position.Pitch = -situation.getPitch().value(CAngleUnit::deg()); position.Bank = -situation.getBank().value(CAngleUnit::deg()); position.Heading = situation.getHeading().value(CAngleUnit::deg()); @@ -2652,7 +2653,7 @@ namespace swift::simplugin::msfs2024common SIMCONNECT_DATA_PBH CSimulatorMsfs2024::aircraftSituationToFsxPBH(const CAircraftSituation &situation) { - // MSFS has inverted pitch and bank angles + // MSFS2024 has inverted pitch and bank angles SIMCONNECT_DATA_PBH pbh; pbh.Pitch = -situation.getPitch().value(CAngleUnit::deg()); pbh.Bank = -situation.getBank().value(CAngleUnit::deg()); diff --git a/src/plugins/simulator/msfs2024/simulatormsfs2024common.h b/src/plugins/simulator/msfs2024/simulatormsfs2024common.h index a54d34001..71786496e 100644 --- a/src/plugins/simulator/msfs2024/simulatormsfs2024common.h +++ b/src/plugins/simulator/msfs2024/simulatormsfs2024common.h @@ -517,7 +517,7 @@ namespace swift::simplugin::msfs2024common //! \threadsafe void updateTransponderMode(const misc::aviation::CTransponder::TransponderMode xpdrMode); - //! Update transponder mode from MSFS + //! Update transponder mode from MSFS2024 void updateMSFS2024TransponderMode(const DataDefinitionMSFSTransponderMode transponderMode); //! An AI aircraft was added in the simulator diff --git a/src/plugins/simulator/msfs2024/simulatormsfs2024simconnectproc.cpp b/src/plugins/simulator/msfs2024/simulatormsfs2024simconnectproc.cpp index c245cfd74..f471b23e3 100644 --- a/src/plugins/simulator/msfs2024/simulatormsfs2024simconnectproc.cpp +++ b/src/plugins/simulator/msfs2024/simulatormsfs2024simconnectproc.cpp @@ -288,7 +288,7 @@ namespace swift::simplugin::msfs2024common simulatorMsfs2024->updateOwnAircraftFromSimulator(*ownAircaft); break; } - case CSimConnectDefinitions::RequestMSFSTransponder: + case CSimConnectDefinitions::RequestMSFS2024Transponder: { const DataDefinitionMSFSTransponderMode *transponderMode = reinterpret_cast(&pObjData->dwData);