Skip to content

Commit 53d069a

Browse files
committed
feat: new method for loading models via SimConnect MSFS2024
1 parent ff45b56 commit 53d069a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+8526
-714
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ env:
2222
bitrock_version: qt-professional-24.7.0
2323
bitrock_url: https://releases.installbuilder.com/installbuilder
2424
externals: swift-project/externals
25-
externals_sha: dfe49bbeb8f0ca664afa293ad3f454cffe751acf
25+
externals_sha: e1f1743ba159e11b0c065ea8f1ae1a0e91e3bf39
26+
27+
2628
use_externals: ${{ secrets.EXTERNALS_PAT != '' }}
2729

2830
jobs:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ cmake-build-*/
5252
/dist/
5353
CMakeUserPresets.json
5454
/third_party/externals
55+
/src/plugins/simulator/msfs2024/simulatormsfs2024.cpp_
56+
/src/plugins/simulator/msfs2024/simulatormsfs2024.h_

src/core/db/databaseutils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace swift::core::db
7575
dbModelModified.updateMissingParts(model);
7676
dbModelModified.setDistributorOrder(distributorOrder);
7777
dbModelModified.setSimulator(dbModel.getSimulator()); // DB simulator settings have priority
78+
dbModelModified.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
7879
return dbModelModified;
7980
}
8081

@@ -88,6 +89,7 @@ namespace swift::core::db
8889
{
8990
if (modified) { *modified = true; }
9091
consolidatedModel.setLivery(dbLivery);
92+
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
9193
}
9294
}
9395
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
@@ -99,6 +101,7 @@ namespace swift::core::db
99101
{
100102
if (modified) { *modified = true; }
101103
consolidatedModel.setAircraftIcaoCode(dbIcao);
104+
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
102105
}
103106
}
104107

@@ -108,6 +111,7 @@ namespace swift::core::db
108111
{
109112
if (modified) { *modified = true; }
110113
consolidatedModel.setDistributor(dbDistributor);
114+
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
111115
}
112116
consolidatedModel.updateLocalFileNames(model);
113117
consolidatedModel.setDistributorOrder(distributorOrder);

src/core/modelsetbuilder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ namespace swift::core
4949
}
5050
else
5151
{
52-
// without any information we can not use them
53-
modelSet = modelSet.findWithKnownAircraftDesignator();
52+
if (!options.testFlag(ShowAllInstalledModells))
53+
// without any information we can not use them
54+
modelSet = modelSet.findWithKnownAircraftDesignator();
5455
}
5556

5657
// Include only

src/core/modelsetbuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace swift::core
3434
OnlyDbIcaoCodes = 1 << 2,
3535
Incremental = 1 << 3,
3636
SortByDistributors = 1 << 4,
37-
ConsolidateWithDb = 1 << 5
37+
ConsolidateWithDb = 1 << 5,
38+
ShowAllInstalledModells = 1 << 6,
3839
};
3940
Q_DECLARE_FLAGS(Builder, BuilderFlag)
4041

src/gui/components/dbownmodelscomponent.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ namespace swift::gui::components
280280
{
281281
QMessageBox msgBox(QMessageBox::Question, "Reload models from disk",
282282
QStringLiteral("Completely reload '%1' models from disk?").arg(simulator.toQString(true)),
283-
QMessageBox::Ok | QMessageBox::Cancel, this);
283+
QMessageBox::Yes | QMessageBox::No, this);
284284
msgBox.setDefaultButton(QMessageBox::Cancel);
285285
const QMessageBox::StandardButton reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
286-
if (reply != QMessageBox::Ok) { return; }
286+
if (reply != QMessageBox::Yes) { return; }
287287

288288
this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundNoCache);
289289
}
@@ -335,6 +335,21 @@ namespace swift::gui::components
335335
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->getOwnModels());
336336
}
337337

338+
// TODO TZ this is a stub for SimConnect loading
339+
void CDbOwnModelsComponent::loadInstalledModelsSimConnect(const CSimulatorInfo &simulator,
340+
IAircraftModelLoader::LoadMode mode,
341+
const QStringList &modelDirectories)
342+
{
343+
Q_UNUSED(mode);
344+
Q_UNUSED(modelDirectories);
345+
346+
using namespace std::chrono_literals;
347+
const CStatusMessage msg = CLogMessage(this).info(u"Start loading models for %1") << simulator.toQString();
348+
this->showOverlayHTMLMessage(msg, 2s);
349+
350+
return;
351+
}
352+
338353
void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator,
339354
IAircraftModelLoader::LoadMode mode,
340355
const QStringList &modelDirectories)
@@ -515,7 +530,11 @@ namespace swift::gui::components
515530
IAircraftModelLoader::LoadMode mode,
516531
const QStringList &modelDirectories)
517532
{
518-
this->loadInstalledModels(simulator, mode, modelDirectories);
533+
// At this point, we switch how the models should be loaded: SimConnect or classic file search
534+
if (simulator.isMSFS2024())
535+
this->loadInstalledModelsSimConnect(simulator, mode, modelDirectories);
536+
else
537+
this->loadInstalledModels(simulator, mode, modelDirectories);
519538
}
520539

521540
void CDbOwnModelsComponent::requestSimulatorModelsWithCacheInBackground(const CSimulatorInfo &simulator)

src/gui/components/dbownmodelscomponent.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ namespace swift::gui
153153
void ownModelsSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator);
154154

155155
private:
156+
static constexpr std::chrono::milliseconds OverlayMsgTimeout { 5000 }; //!< how long overlay is displayed
157+
156158
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
157159
swift::misc::simulation::IAircraftModelLoader *m_modelLoader =
158160
nullptr; //!< read own aircraft models, aka models on disk
@@ -167,7 +169,12 @@ namespace swift::gui
167169
//! Request own models
168170
void requestOwnModelsUpdate();
169171

170-
//! Load the models
172+
//! Load the models via SimConnect
173+
void loadInstalledModelsSimConnect(const swift::misc::simulation::CSimulatorInfo &simulator,
174+
swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
175+
const QStringList &modelDirectories = {});
176+
177+
//! Load the models via disk
171178
void loadInstalledModels(const swift::misc::simulation::CSimulatorInfo &simulator,
172179
swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
173180
const QStringList &modelDirectories = {});

0 commit comments

Comments
 (0)