mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #585, adjusted samples to use settings
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
||||
#include "blackmisc/simulation/settings/settingssimulator.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
|
||||
#include <QByteArray>
|
||||
@@ -27,17 +28,26 @@
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
|
||||
namespace BlackSample
|
||||
{
|
||||
void CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
const QString fsxDir = CSampleUtils::selectDirectory({"C:/Program Files (x86)/Microsoft Games/Microsoft Flight Simulator X/SimObjects",
|
||||
"C:/Flight Simulator 9/Aircraft"}, streamOut, streamIn);
|
||||
const QString fsDir = CSampleUtils::selectDirectory(
|
||||
{
|
||||
"C:/Program Files (x86)/Microsoft Games/Microsoft Flight Simulator X/SimObjects",
|
||||
"C:/Flight Simulator 9/Aircraft"
|
||||
}, streamOut, streamIn);
|
||||
|
||||
CAircraftCfgParser parser(CSimulatorInfo(CSimulatorInfo::FSX), fsxDir);
|
||||
parser.changeRootDirectory(fsxDir);
|
||||
const CSimulatorInfo sim = fsDir.toLower().contains("simobjects") ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSimulatorSettings multiSettings;
|
||||
const CSettingsSimulator originalSettings = multiSettings.getSettings(sim);
|
||||
CSettingsSimulator newSettings(originalSettings);
|
||||
newSettings.setModelDirectory(fsDir);
|
||||
multiSettings.setSettings(newSettings, sim); // set, but do NOT(!) save
|
||||
|
||||
CAircraftCfgParser parser(sim);
|
||||
streamOut << "start reading, press RETURN" << endl;
|
||||
QString input = streamIn.readLine();
|
||||
Q_UNUSED(input);
|
||||
@@ -45,7 +55,7 @@ namespace BlackSample
|
||||
streamOut << "reading directly" << endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
streamOut << "reading " << parser.getRootDirectory() << endl;
|
||||
streamOut << "reading " << parser.getModelDirectory() << endl;
|
||||
parser.startLoading();
|
||||
streamOut << "read entries: " << parser.getAircraftCfgEntriesList().size() << " in " << time.restart() << "ms" << endl;
|
||||
|
||||
@@ -68,5 +78,8 @@ namespace BlackSample
|
||||
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
||||
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||
tempFile.close();
|
||||
|
||||
// restore settings: DO NOT SAVE !!!
|
||||
multiSettings.setSettings(originalSettings, sim);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blackmisc/simulation/settings/settingssimulator.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
@@ -32,6 +33,7 @@ using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackSample
|
||||
@@ -44,20 +46,21 @@ namespace BlackSample
|
||||
streamOut << "loaded: " << BlackMisc::boolToYesNo(s) << " size: " << vpRulesReader.getAsModelsFromCache().size() << endl;
|
||||
|
||||
// mapper with rule set, handing over ownership
|
||||
QString fsxDir = CSampleUtils::selectDirectory(
|
||||
QString fsDir = CSampleUtils::selectDirectory(
|
||||
{
|
||||
QStringLiteral("P:/FlightSimulatorX (MSI)/SimObjects"),
|
||||
QStringLiteral("P:/Temp/SimObjects"),
|
||||
QStringLiteral("C:/Flight Simulator 9/Aircraft")
|
||||
}, streamOut, streamIn);
|
||||
|
||||
CAircraftCfgParser cfgParser(CSimulatorInfo(CSimulatorInfo::FSX), fsxDir);
|
||||
if (!cfgParser.changeRootDirectory(fsxDir))
|
||||
{
|
||||
streamOut << "Wrong or empty directoy " << fsxDir << endl;
|
||||
return;
|
||||
}
|
||||
const CSimulatorInfo sim = fsDir.toLower().contains("simobjects") ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSimulatorSettings multiSettings;
|
||||
const CSettingsSimulator originalSettings = multiSettings.getSettings(sim);
|
||||
CSettingsSimulator newSettings(originalSettings);
|
||||
newSettings.setModelDirectory(fsDir);
|
||||
multiSettings.setSettings(newSettings, sim); // set, but do NOT(!) save
|
||||
|
||||
CAircraftCfgParser cfgParser(sim);
|
||||
streamOut << "Start reading models" << endl;
|
||||
cfgParser.startLoading(CAircraftCfgParser::CacheSkipped | CAircraftCfgParser::LoadDirectly);
|
||||
streamOut << "Read models: " << cfgParser.getAircraftCfgEntriesList().size() << endl;
|
||||
@@ -70,5 +73,8 @@ namespace BlackSample
|
||||
CAircraftIcaoCode icao("C172");
|
||||
streamOut << "Searching for " << icao << endl;
|
||||
streamOut << matcher.getModelSet().findByIcaoDesignators(icao, CAirlineIcaoCode()) << endl;
|
||||
|
||||
// restore settings: DO NOT SAVE !!!
|
||||
multiSettings.setSettings(originalSettings, sim);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user