Skip to content

Commit b8f6414

Browse files
committed
feat: loading the model set via SimConnect works
1 parent ca56932 commit b8f6414

19 files changed

+253
-163
lines changed

src/core/aircraftmatcher.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,6 @@ namespace swift::core
16211621
return icao;
16221622
}
16231623

1624-
// TODO TZ check when calling
16251624
int CAircraftMatcher::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator, bool forced)
16261625
{
16271626
if (!simulator.isSingleSimulator()) { return 0; }

src/core/application.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ namespace swift::core
315315
Q_ASSERT_X(m_setupReader && m_setupReader->isSetupAvailable(), Q_FUNC_INFO, "Setup not available");
316316

317317
// start hookin
318-
msgs.push_back(
319-
this->startHookIn()); // TODO TZ At this point, I also try to start the plugins for SwiftData.
318+
msgs.push_back(this->startHookIn());
320319
if (msgs.isFailure()) { break; }
321320

322321
// Settings if not already initialized

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/settingssimulatorbasicscomponent.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ namespace swift::gui::components
128128
{
129129
using namespace std::chrono_literals;
130130
const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue());
131-
// TODO TZ
132131
CSimulatorSettings s = this->getSettings(simulator).getGenericSettings();
133-
134132
const QString simulatorDir(ui->le_SimulatorDirectory->text().trimmed());
135133
const QStringList modelDirs(this->parseModelDirectories());
136134
const QStringList excludeDirs(this->parseDirectories(ui->pte_ExcludeDirectories->toPlainText()));

src/gui/models/aircraftmodellistmodel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ namespace swift::gui::models
4545
{
4646
case NotSet:
4747
case OwnAircraftModelClient:
48-
m_columns.addColumn(CColumn::standardString("model", { CAircraftModel::IndexModelString }));
48+
// m_columns.addColumn(CColumn::standardString("model", { CAircraftModel::IndexModelString }));
49+
m_columns.addColumn(CColumn::standardString("model", { CAircraftModel::IndexShortModelString }));
4950

5051
m_columns.addColumn(CColumn::standardString("liverypart", CAircraftModel::IndexModelLivery));
5152
m_columns.addColumn(
@@ -84,7 +85,7 @@ namespace swift::gui::models
8485

8586
case OwnAircraftModelMappingTool:
8687
case StashModel:
87-
m_columns.addColumn(CColumn::standardString("model", CAircraftModel::IndexModelString));
88+
m_columns.addColumn(CColumn::standardString("model", CAircraftModel::IndexShortModelString));
8889

8990
m_columns.addColumn(CColumn::standardString("liverypart", CAircraftModel::IndexModelLivery));
9091
m_columns.addColumn(

src/misc/simulation/aircraftmodel.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ namespace swift::misc::simulation
285285
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
286286
case IndexMembersDbStatus: return this->getMembersDbStatus();
287287
case IndexModelLivery: return QVariant(m_modelLivery);
288+
case IndexShortModelString: return QVariant(getShortModelString());
288289
default: return CValueObject::propertyByIndex(index);
289290
}
290291
}
@@ -595,6 +596,23 @@ namespace swift::misc::simulation
595596
return (sim.isFG()) ? this->getSwiftLiveryString(true, false, false) : this->getSwiftLiveryString();
596597
}
597598

599+
QString CAircraftModel::getShortModelString() const
600+
{
601+
602+
QString shortModelString = m_modelString;
603+
if (m_modelString.contains(m_modelLivery))
604+
{
605+
int lastIndex = m_modelString.lastIndexOf(m_modelLivery);
606+
607+
if (lastIndex != -1)
608+
{
609+
const QString newModelString = m_modelString.left(lastIndex);
610+
shortModelString = newModelString;
611+
}
612+
}
613+
return shortModelString;
614+
}
615+
598616
DBTripleIds CAircraftModel::parseNetworkLiveryString(const QString &liveryString)
599617
{
600618
// "swift_m22l33a11"

src/misc/simulation/aircraftmodel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ namespace swift::misc
128128
IndexHasQueriedModelString,
129129
IndexMembersDbStatus,
130130
IndexModelLivery, // MSFS2024
131+
IndexShortModelString,
131132
};
132133

133134
//! \copydoc swift::misc::CValueObject::registerMetadata
@@ -199,6 +200,9 @@ namespace swift::misc
199200
//! Model livery msfs2024
200201
void setModelLivery(const QString &modelLivery) { m_modelLivery = modelLivery.trimmed().toUpper(); }
201202

203+
//! Model livery whitout part for lifery msfs2024
204+
QString getShortModelString() const;
205+
202206
//! Model key, either queried or loaded from simulator model
203207
const QString &getModelStringAlias() const { return m_modelStringAlias; }
204208

@@ -592,6 +596,7 @@ namespace swift::misc
592596
QString m_description; //!< descriptive text
593597
QString m_fileName; //!< file name
594598
QString m_supportedParts; //!< supported parts
599+
QString m_shortModelString; //!< cached short model string
595600
qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable)
596601
ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...?
597602
ModelMode m_modelMode = Include; //!< model mode (include / exclude)

src/misc/simulation/fscommon/aircraftcfgparser.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@ namespace swift::misc::simulation::fscommon
154154
static const QString NoNameFilter;
155155
QDir dir(directory, NoNameFilter, QDir::Name, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
156156

157-
// TODO TZ: still have to figure out how msfs2024 handles this
158157
// for MSFS2020 we only need aircraft.cfg
159-
// MSFS2024 has aircraft.cfg only in communityfolder
160-
dir.setNameFilters(fileNameFilters(getSimulator().isMSFS(), getSimulator().isMSFS2024()));
158+
dir.setNameFilters(fileNameFilters(getSimulator().isMSFS()));
161159
if (!dir.exists())
162160
{
163161
return CAircraftCfgEntriesList(); // can happen if there are shortcuts or linked dirs not available
@@ -467,10 +465,9 @@ namespace swift::misc::simulation::fscommon
467465
return content;
468466
}
469467

470-
// TODO TZ: MSFS2024 currently has aircraft.cfg only in the community folder
471-
const QStringList &CAircraftCfgParser::fileNameFilters(bool isMSFS, bool isMSFS2024)
468+
const QStringList &CAircraftCfgParser::fileNameFilters(bool isMSFS)
472469
{
473-
if (CBuildConfig::buildWordSize() == 32 || isMSFS || isMSFS2024)
470+
if (CBuildConfig::buildWordSize() == 32 || isMSFS)
474471
{
475472
static const QStringList f({ "aircraft.cfg" });
476473
return f;

src/misc/simulation/fscommon/aircraftcfgparser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace swift::misc
8989
static QString getFixedIniLineContent(const QString &line);
9090

9191
//! Files to be used
92-
static const QStringList &fileNameFilters(bool isMSFS, bool isMSFS2024);
92+
static const QStringList &fileNameFilters(bool isMSFS);
9393

9494
//! Exclude the sub directories not to be parsed
9595
static bool isExcludedSubDirectory(const QString &excludeDirectory);

0 commit comments

Comments
 (0)