-
Notifications
You must be signed in to change notification settings - Fork 37
MSFS2024 new plugin and modelloader #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -547,6 +547,12 @@ namespace swift::core | |
| if (!this->isConnectedAndNotShuttingDown()) { return; } | ||
| Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign"); | ||
|
|
||
| CStatusMessageList reverseLookupMessages; | ||
| CCallsign::addLogDetailsToList(&reverseLookupMessages, callsign, | ||
| QStringLiteral("CAirspaceMonitor::sendReadyForModelMatching Flag: %1").arg(rf), | ||
| CAirspaceMonitor::getLogCategories()); | ||
| // TODO remove | ||
|
|
||
|
Comment on lines
+550
to
+555
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be removed now? |
||
| // set flag and init ts | ||
| Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf); | ||
|
|
||
|
|
@@ -863,13 +869,18 @@ namespace swift::core | |
| CAirspaceMonitor::getLogCategories()); | ||
|
|
||
| const CClient client = this->getClientOrDefaultForCallsign(callsign); | ||
| this->addOrUpdateAircraftInRange(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, | ||
| client.getQueriedModelString(), CAircraftModel::TypeQueriedFromNetwork, | ||
| pReverseLookupMessages); | ||
| this->addReverseLookupMessages(callsign, reverseLookupMessages); | ||
| this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received | ||
| const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange( | ||
| callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(), | ||
| CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages); | ||
|
|
||
| emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery); | ||
| // we do not change manually assigned models | ||
| if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet) | ||
|
Comment on lines
+876
to
+877
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wasn't this previously required? Was it a bug or is this case only reached with MSFS24? |
||
| { | ||
| this->addReverseLookupMessages(callsign, reverseLookupMessages); | ||
| this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received | ||
|
|
||
| emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery); | ||
| } | ||
| } | ||
|
|
||
| CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData( | ||
|
|
@@ -1176,8 +1187,8 @@ namespace swift::core | |
| const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign); | ||
| if (aircraft.hasValidCallsign()) | ||
| { | ||
| // only if we do not have a DB model yet | ||
| if (!aircraft.getModel().hasValidDbKey()) | ||
| // we do not change manually assigned models (msfs2024) | ||
| if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet) | ||
|
Comment on lines
-1179
to
+1191
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wasn't this previously required? Was it a bug or is this case only reached with MSFS24? |
||
| { | ||
| CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao, | ||
| livery, modelString, modelType, log); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,7 +241,7 @@ namespace swift::core::context | |
| { | ||
| Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); | ||
| if (isDebugEnabled()) { CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO; } | ||
| if (this->isSimulatorAvailable()) { return; } // if a plugin is loaded, do ignore this | ||
| if (this->isSimulatorAvailable() && !simulator.isMSFS2024()) return; // if a plugin is loaded, do ignore this | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extend the comment why MSFS2024 is not skipped here. |
||
| m_modelSetSimulator.set(simulator); | ||
| const CAircraftModelList models = this->getModelSet(); // cache synced | ||
| m_aircraftMatcher.setModelSet(models, simulator, false); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ namespace swift::core::db | |
| dbModelModified.updateMissingParts(model); | ||
| dbModelModified.setDistributorOrder(distributorOrder); | ||
| dbModelModified.setSimulator(dbModel.getSimulator()); // DB simulator settings have priority | ||
| dbModelModified.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why couldn't we take the livery string data from the database? Why to keep the local settings? |
||
| return dbModelModified; | ||
| } | ||
|
|
||
|
|
@@ -88,6 +89,7 @@ namespace swift::core::db | |
| { | ||
| if (modified) { *modified = true; } | ||
| consolidatedModel.setLivery(dbLivery); | ||
| consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this call required? |
||
| } | ||
| } | ||
| if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator()) | ||
|
|
@@ -99,6 +101,7 @@ namespace swift::core::db | |
| { | ||
| if (modified) { *modified = true; } | ||
| consolidatedModel.setAircraftIcaoCode(dbIcao); | ||
| consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this call required? |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -108,6 +111,7 @@ namespace swift::core::db | |
| { | ||
| if (modified) { *modified = true; } | ||
| consolidatedModel.setDistributor(dbDistributor); | ||
| consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this call required? |
||
| } | ||
| consolidatedModel.updateLocalFileNames(model); | ||
| consolidatedModel.setDistributorOrder(distributorOrder); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,8 +49,9 @@ namespace swift::core | |
| } | ||
| else | ||
| { | ||
| // without any information we can not use them | ||
| modelSet = modelSet.findWithKnownAircraftDesignator(); | ||
| if (!options.testFlag(ShowAllInstalledModels)) | ||
| // without any information we can not use them | ||
| modelSet = modelSet.findWithKnownAircraftDesignator(); | ||
| } | ||
|
Comment on lines
+52
to
55
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want all installed models in a modelset, even with unknown aircraft designator? Is there a use case for it with MSFS24 or was it just a general bug? |
||
|
|
||
| // Include only | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -332,6 +332,22 @@ namespace swift::gui::components | |||||
| ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->getOwnModels()); | ||||||
| } | ||||||
|
|
||||||
| // TODO TZ this is a stub for SimConnect loading | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this TODO be removed? |
||||||
| void CDbOwnModelsComponent::loadInstalledModelsSimConnect(const CSimulatorInfo &simulator, | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename to: |
||||||
| IAircraftModelLoader::LoadMode mode, | ||||||
| const QStringList &modelDirectories) | ||||||
| { | ||||||
| Q_UNUSED(mode); | ||||||
| Q_UNUSED(modelDirectories); | ||||||
|
|
||||||
| using namespace std::chrono_literals; | ||||||
| const CStatusMessage msg = CLogMessage(this).info(u"Triiger loading models for %1 from SimConnect") | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| << simulator.toQString(); | ||||||
| this->showOverlayHTMLMessage(msg, 2s); | ||||||
|
|
||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator, | ||||||
| IAircraftModelLoader::LoadMode mode, | ||||||
| const QStringList &modelDirectories) | ||||||
|
|
@@ -512,6 +528,9 @@ namespace swift::gui::components | |||||
| IAircraftModelLoader::LoadMode mode, | ||||||
| const QStringList &modelDirectories) | ||||||
| { | ||||||
| // TODO TZ add SimConnect loading | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this TODO be removed? |
||||||
| if (simulator.isMSFS2024()) this->loadInstalledModelsSimConnect(simulator, mode, modelDirectories); | ||||||
|
|
||||||
| this->loadInstalledModels(simulator, mode, modelDirectories); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,8 @@ namespace swift::gui | |
| void ownModelsSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator); | ||
|
|
||
| private: | ||
| static constexpr std::chrono::milliseconds OverlayMsgTimeout { 5000 }; //!< how long overlay is displayed | ||
|
|
||
| QScopedPointer<Ui::CDbOwnModelsComponent> ui; | ||
| swift::misc::simulation::IAircraftModelLoader *m_modelLoader = | ||
| nullptr; //!< read own aircraft models, aka models on disk | ||
|
|
@@ -167,7 +169,12 @@ namespace swift::gui | |
| //! Request own models | ||
| void requestOwnModelsUpdate(); | ||
|
|
||
| //! Load the models | ||
| //! Load the models via SimConnect | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this should stay a stub just to display message. Adjust the comment and describe what this function will do and that it does not actually load the models itself. |
||
| void loadInstalledModelsSimConnect(const swift::misc::simulation::CSimulatorInfo &simulator, | ||
| swift::misc::simulation::IAircraftModelLoader::LoadMode mode, | ||
| const QStringList &modelDirectories = {}); | ||
|
|
||
| //! Load the models via disk | ||
| void loadInstalledModels(const swift::misc::simulation::CSimulatorInfo &simulator, | ||
| swift::misc::simulation::IAircraftModelLoader::LoadMode mode, | ||
| const QStringList &modelDirectories = {}); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -333,6 +333,8 @@ namespace swift::gui::components | |
| } | ||
| const CCallsign callsign(this->validateRenderedCallsign()); | ||
| if (callsign.isEmpty()) { return; } | ||
|
|
||
| // Because of msfs2024, the model string contains the combination of title and livery. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code does not seem to be specific about MSFS2024. Remove it? |
||
| const QString modelString = ui->completer_ModelStrings->getModelString(); | ||
| if (modelString.isEmpty()) | ||
| { | ||
|
|
@@ -375,6 +377,7 @@ namespace swift::gui::components | |
| } | ||
|
|
||
| CAircraftModel model(models.front()); | ||
| // found more than one model? | ||
| if (models.size() > 1) | ||
| { | ||
| if (models.containsModelString(modelString)) | ||
|
|
@@ -391,8 +394,10 @@ namespace swift::gui::components | |
| model.setModelType(CAircraftModel::TypeManuallySet); | ||
| CLogMessage(this).info(u"Requesting changes for '%1'") << callsign.asString(); | ||
|
|
||
| // enable in any case | ||
| // rendering-flag enable in any case | ||
| sGui->getIContextNetwork()->updateAircraftEnabled(aircraftFromBackend.getCallsign(), true); | ||
|
|
||
| // trigger model change | ||
| changed = | ||
| sGui->getIContextNetwork()->updateAircraftModel(aircraftFromBackend.getCallsign(), model, identifier()); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can TODO be removed?