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
This commit is contained in:
Mathew Sutcliffe
2017-04-26 22:51:11 +01:00
parent 4a4dea8d4d
commit 4e23cd1382

View File

@@ -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);
}
}
}