mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +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
|
||||
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
|
||||
static constexpr bool isPinned() { return true; }
|
||||
|
||||
@@ -117,6 +124,13 @@ namespace BlackMisc
|
||||
//! Last selection
|
||||
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
|
||||
static constexpr bool isPinned() { return true; }
|
||||
|
||||
|
||||
@@ -189,26 +189,46 @@ namespace BlackMisc
|
||||
{
|
||||
//! \todo add XP, ...
|
||||
CSimulatorInfo sim;
|
||||
bool fs9 =
|
||||
bool fs9 = false;
|
||||
bool fsx = false;
|
||||
bool p3d = false;
|
||||
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
fs9 =
|
||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||
!CFsCommonUtil::fs9AircraftDir().isEmpty() &&
|
||||
!CFsCommonUtil::fs9Dir().isEmpty();
|
||||
bool fsx =
|
||||
fsx =
|
||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||
!CFsCommonUtil::fsxSimObjectsDir().isEmpty() &&
|
||||
!CFsCommonUtil::fsxDir().isEmpty();
|
||||
bool p3d =
|
||||
p3d =
|
||||
CBuildConfig::isRunningOnWindowsNtPlatform() &&
|
||||
!CFsCommonUtil::p3dDir().isEmpty() &&
|
||||
!CFsCommonUtil::p3dSimObjectsDir().isEmpty();
|
||||
}
|
||||
bool xp = true; //! \todo XP resolution
|
||||
|
||||
sim.setSimulator(
|
||||
CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d)
|
||||
);
|
||||
sim.setSimulator(CSimulatorInfo::boolToFlag(fsx, fs9, xp, p3d));
|
||||
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)
|
||||
{
|
||||
const bool fsx = CDatastoreUtility::dbBoolStringToBool(json.value(prefix + "simfsx").toString());
|
||||
|
||||
@@ -155,6 +155,9 @@ namespace BlackMisc
|
||||
//! Locally installed simulators
|
||||
static const CSimulatorInfo getLocallyInstalledSimulators();
|
||||
|
||||
//! Guess a default simulator
|
||||
static const CSimulatorInfo guessDefaultSimulator();
|
||||
|
||||
//! From database JSON
|
||||
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString prefix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user