mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Ref T357, function to copy FSX terrain probe, also in context for remote UI
This commit is contained in:
@@ -248,10 +248,10 @@ namespace BlackCore
|
|||||||
//! Request weather grid. Argument identifier is past in the signal to identify the requestor
|
//! Request weather grid. Argument identifier is past in the signal to identify the requestor
|
||||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0;
|
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0;
|
||||||
|
|
||||||
//! Repeat all mappings
|
//! Repeat all matchings
|
||||||
virtual int doMatchingsAgain() = 0;
|
virtual int doMatchingsAgain() = 0;
|
||||||
|
|
||||||
//! Repeat the mapping
|
//! Repeat the matching
|
||||||
virtual bool doMatchingAgain(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
virtual bool doMatchingAgain(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||||
|
|
||||||
//! Current matching statistics
|
//! Current matching statistics
|
||||||
@@ -263,6 +263,9 @@ namespace BlackCore
|
|||||||
//! Get matching setup
|
//! Get matching setup
|
||||||
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const = 0;
|
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const = 0;
|
||||||
|
|
||||||
|
//! Copy the terrain probe
|
||||||
|
virtual BlackMisc::CStatusMessageList copyFsxTerrainProbe(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
IContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
IContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||||
|
|||||||
@@ -331,6 +331,13 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
return BlackMisc::Simulation::CAircraftMatcherSetup();
|
return BlackMisc::Simulation::CAircraftMatcherSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \copydoc IContextSimulator::copyFsxTerrainProbe
|
||||||
|
virtual BlackMisc::CStatusMessageList copyFsxTerrainProbe(const BlackMisc::Simulation::CSimulatorInfo &simulator) override
|
||||||
|
{
|
||||||
|
Q_UNUSED(simulator);
|
||||||
|
return BlackMisc::CStatusMessageList();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "blackcore/pluginmanagersimulator.h"
|
#include "blackcore/pluginmanagersimulator.h"
|
||||||
#include "blackcore/simulator.h"
|
#include "blackcore/simulator.h"
|
||||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
||||||
|
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||||
#include "blackmisc/simulation/matchingutils.h"
|
#include "blackmisc/simulation/matchingutils.h"
|
||||||
#include "blackmisc/aviation/callsign.h"
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "blackmisc/compare.h"
|
#include "blackmisc/compare.h"
|
||||||
@@ -48,6 +49,7 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Simulation::XPlane;
|
using namespace BlackMisc::Simulation::XPlane;
|
||||||
|
using namespace BlackMisc::Simulation::FsCommon;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Simulation::Settings;
|
using namespace BlackMisc::Simulation::Settings;
|
||||||
@@ -811,6 +813,34 @@ namespace BlackCore
|
|||||||
return m_aircraftMatcher.getSetup();
|
return m_aircraftMatcher.getSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStatusMessageList CContextSimulator::copyFsxTerrainProbe(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << simulator.toQString(); }
|
||||||
|
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
if (!simulator.isFsxP3DFamily())
|
||||||
|
{
|
||||||
|
msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityError, "Wrong simulator " + simulator.toQString()));
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList modelDirs = m_simulatorSettings.getModelDirectoriesOrDefault(simulator);
|
||||||
|
if (modelDirs.isEmpty() || modelDirs.front().isEmpty())
|
||||||
|
{
|
||||||
|
msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityError, "No model directory"));
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int copied = CFsCommonUtil::copyFsxTerrainProbeFiles(modelDirs.front(), msgs);
|
||||||
|
if (copied < 1 && !msgs.hasWarningOrErrorMessages())
|
||||||
|
{
|
||||||
|
msgs.push_back(CStatusMessage(this, CStatusMessage::SeverityError, "No files copied"));
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
bool CContextSimulator::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
bool CContextSimulator::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||||
{
|
{
|
||||||
Q_UNUSED(originator);
|
Q_UNUSED(originator);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ namespace BlackCore
|
|||||||
virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
|
virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
|
||||||
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
||||||
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
||||||
|
virtual BlackMisc::CStatusMessageList copyFsxTerrainProbe(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \addtogroup swiftdotcommands
|
//! \addtogroup swiftdotcommands
|
||||||
|
|||||||
@@ -295,5 +295,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
return m_dBusInterface->callDBusRet<CAircraftMatcherSetup>(QLatin1String("getMatchingSetup"));
|
return m_dBusInterface->callDBusRet<CAircraftMatcherSetup>(QLatin1String("getMatchingSetup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStatusMessageList CContextSimulatorProxy::copyFsxTerrainProbe(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
return m_dBusInterface->callDBusRet<CStatusMessageList>(QLatin1String("copyFsxTerrainProbe"), simulator);
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ namespace BlackCore
|
|||||||
virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
|
virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const override;
|
||||||
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
||||||
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
||||||
|
virtual BlackMisc::CStatusMessageList copyFsxTerrainProbe(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
|
||||||
#include "blackmisc/fileutils.h"
|
|
||||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||||
|
#include "blackmisc/directoryutils.h"
|
||||||
|
#include "blackmisc/fileutils.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -347,6 +348,44 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CFsCommonUtil::copyFsxTerrainProbeFiles(const QString &simObjectDir, CStatusMessageList &messages)
|
||||||
|
{
|
||||||
|
static const CLogCategoryList cats({ CLogCategory::validation(), CLogCategory::driver() });
|
||||||
|
messages.clear();
|
||||||
|
if (!CDirectoryUtils::existsUnemptyDirectory(CDirectoryUtils::shareTerrainProbeDirectory()))
|
||||||
|
{
|
||||||
|
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, QString("No terrain probe source files in '%1'").arg(CDirectoryUtils::shareTerrainProbeDirectory())));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simObjectDir.isEmpty())
|
||||||
|
{
|
||||||
|
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "No simObject directory"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString targetDir = CFileUtils::appendFilePathsAndFixUnc(simObjectDir, "Misc");
|
||||||
|
QDir td(targetDir);
|
||||||
|
if (!td.exists())
|
||||||
|
{
|
||||||
|
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, QString("Cannot access target directory '%1'").arg(targetDir)));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString lastSegment = CFileUtils::lastPathSegment(CDirectoryUtils::shareTerrainProbeDirectory());
|
||||||
|
targetDir = CFileUtils::appendFilePathsAndFixUnc(targetDir, lastSegment);
|
||||||
|
const bool hasDir = td.mkpath(targetDir);
|
||||||
|
if (!hasDir)
|
||||||
|
{
|
||||||
|
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, QString("Cannot create target directory '%1'").arg(targetDir)));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int copied = CDirectoryUtils::copyDirectoryRecursively(CDirectoryUtils::shareTerrainProbeDirectory(), targetDir, true);
|
||||||
|
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityInfo, QString("Copied %1 files from '%2' to '%3'").arg(copied).arg(CDirectoryUtils::shareTerrainProbeDirectory(), targetDir)));
|
||||||
|
return copied;
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Adjust file directory
|
//! Adjust file directory
|
||||||
static bool adjustFileDirectory(CAircraftModel &model, const QStringList &simObjectsDirectories);
|
static bool adjustFileDirectory(CAircraftModel &model, const QStringList &simObjectsDirectories);
|
||||||
|
|
||||||
|
//! Copy the terrain probe
|
||||||
|
static int copyFsxTerrainProbeFiles(const QString &simObjectDir, CStatusMessageList &messages);
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user