From 4e23cd138291a568bcd2e0fa72c5698c0120d3b4 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Wed, 26 Apr 2017 22:51:11 +0100 Subject: [PATCH] X-Plane model loader: support extra properties of .acf files Summary: There are optional fields in an X-Plane flyable aircraft that we can use if they are present: * Description * Name * Distributor If not present, the user has to edit them manually. @kbasan Any problem with constructing a `CDistributor` with empty db key? Reviewers: rwinklmeier, kbasan Reviewed By: rwinklmeier Subscribers: jenkins, kbasan Tags: #swift_pilot_client Differential Revision: https://dev.swift-project.org/D12 --- .../xplane/aircraftmodelloaderxplane.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp index 319d669d7..85554521f 100644 --- a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp +++ b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp @@ -186,19 +186,32 @@ namespace BlackMisc file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream ts(&file); - //! \todo Do you rely on case sensitive parsing, mabe case insensitive would be better? if (ts.readLine() == "I" && ts.readLine().contains("version") && ts.readLine() == "ACF") { while (!ts.atEnd()) { QString line = ts.readLine(); - QStringList tokens = line.split(' '); - if (tokens.size() != 3) { continue; } + QStringList tokens = line.split(' ', QString::SkipEmptyParts); + if (tokens.at(0) != "P" || tokens.size() < 3) { continue; } if (tokens.at(1) == "acf/_ICAO") { - CAircraftIcaoCode icao(tokens.at(2)); + const CAircraftIcaoCode icao(tokens.at(2)); model.setAircraftIcaoCode(icao); - break; + } + else if (tokens.at(1) == "acf/_descrip") + { + const QString desc(tokens.mid(2).join(' ')); + model.setDescription(desc); + } + else if (tokens.at(1) == "acf/_name") + { + const QString name(tokens.mid(2).join(' ')); + model.setName(name); + } + else if (tokens.at(1) == "acf/_studio") + { + const CDistributor dist({}, tokens.mid(2).join(' '), {}, {}, CSimulatorInfo::XPLANE); + model.setDistributor(dist); } } }