mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
refs #649, allow to guess used simulator (for default values)
This commit is contained in:
@@ -75,6 +75,13 @@ namespace BlackMisc
|
|||||||
//! Last selection
|
//! Last selection
|
||||||
struct ModelCacheLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
struct ModelCacheLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||||
{
|
{
|
||||||
|
//! Default value
|
||||||
|
static const BlackMisc::Simulation::CSimulatorInfo &defaultValue()
|
||||||
|
{
|
||||||
|
static const BlackMisc::Simulation::CSimulatorInfo s(BlackMisc::Simulation::CSimulatorInfo::guessDefaultSimulator());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
//! First load is synchronous
|
//! First load is synchronous
|
||||||
static constexpr bool isPinned() { return true; }
|
static constexpr bool isPinned() { return true; }
|
||||||
|
|
||||||
@@ -117,6 +124,13 @@ namespace BlackMisc
|
|||||||
//! Last selection
|
//! Last selection
|
||||||
struct ModelSetLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
struct ModelSetLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||||
{
|
{
|
||||||
|
//! Default value
|
||||||
|
static const BlackMisc::Simulation::CSimulatorInfo &defaultValue()
|
||||||
|
{
|
||||||
|
static const BlackMisc::Simulation::CSimulatorInfo s(BlackMisc::Simulation::CSimulatorInfo::guessDefaultSimulator());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
//! First load is synchronous
|
//! First load is synchronous
|
||||||
static constexpr bool isPinned() { return true; }
|
static constexpr bool isPinned() { return true; }
|
||||||
|
|
||||||
|
|||||||
@@ -189,26 +189,46 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
//! \todo add XP, ...
|
//! \todo add XP, ...
|
||||||
CSimulatorInfo sim;
|
CSimulatorInfo sim;
|
||||||
bool fs9 =
|
bool fs9 = false;
|
||||||
|
bool fsx = false;
|
||||||
|
bool p3d = false;
|
||||||
|
|
||||||
|
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||||
|
{
|
||||||
|
fs9 =
|
||||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||||
!CFsCommonUtil::fs9AircraftDir().isEmpty() &&
|
!CFsCommonUtil::fs9AircraftDir().isEmpty() &&
|
||||||
!CFsCommonUtil::fs9Dir().isEmpty();
|
!CFsCommonUtil::fs9Dir().isEmpty();
|
||||||
bool fsx =
|
fsx =
|
||||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||||
!CFsCommonUtil::fsxSimObjectsDir().isEmpty() &&
|
!CFsCommonUtil::fsxSimObjectsDir().isEmpty() &&
|
||||||
!CFsCommonUtil::fsxDir().isEmpty();
|
!CFsCommonUtil::fsxDir().isEmpty();
|
||||||
bool p3d =
|
p3d =
|
||||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||||
!CFsCommonUtil::p3dDir().isEmpty() &&
|
!CFsCommonUtil::p3dDir().isEmpty() &&
|
||||||
!CFsCommonUtil::p3dSimObjectsDir().isEmpty();
|
!CFsCommonUtil::p3dSimObjectsDir().isEmpty();
|
||||||
|
}
|
||||||
bool xp = true; //! \todo XP resolution
|
bool xp = true; //! \todo XP resolution
|
||||||
|
|
||||||
sim.setSimulator(
|
sim.setSimulator(CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d));
|
||||||
CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d)
|
|
||||||
);
|
|
||||||
return sim;
|
return sim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSimulatorInfo CSimulatorInfo::guessDefaultSimulator()
|
||||||
|
{
|
||||||
|
CSimulatorInfo locallyInstalled(getLocallyInstalledSimulators());
|
||||||
|
if (CBuildConfig::isRunningOnLinuxPlatform())
|
||||||
|
{
|
||||||
|
return CSimulatorInfo("XPLANE");
|
||||||
|
}
|
||||||
|
if (locallyInstalled.p3d()) { return CSimulatorInfo("P3D"); }
|
||||||
|
if (locallyInstalled.fsx()) { return CSimulatorInfo("FSX"); }
|
||||||
|
if (locallyInstalled.fs9()) { return CSimulatorInfo("FS9"); }
|
||||||
|
|
||||||
|
// fallback
|
||||||
|
return CSimulatorInfo("FSX");
|
||||||
|
}
|
||||||
|
|
||||||
CSimulatorInfo CSimulatorInfo::fromDatabaseJson(const QJsonObject &json, const QString prefix)
|
CSimulatorInfo CSimulatorInfo::fromDatabaseJson(const QJsonObject &json, const QString prefix)
|
||||||
{
|
{
|
||||||
const bool fsx = CDatastoreUtility::dbBoolStringToBool(json.value(prefix + "simfsx").toString());
|
const bool fsx = CDatastoreUtility::dbBoolStringToBool(json.value(prefix + "simfsx").toString());
|
||||||
|
|||||||
@@ -155,6 +155,9 @@ namespace BlackMisc
|
|||||||
//! Locally installed simulators
|
//! Locally installed simulators
|
||||||
static const CSimulatorInfo getLocallyInstalledSimulators();
|
static const CSimulatorInfo getLocallyInstalledSimulators();
|
||||||
|
|
||||||
|
//! Guess a default simulator
|
||||||
|
static const CSimulatorInfo guessDefaultSimulator();
|
||||||
|
|
||||||
//! From database JSON
|
//! From database JSON
|
||||||
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString prefix);
|
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString prefix);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user