mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T650, save FSX/P3D specific settings
This commit is contained in:
@@ -641,6 +641,45 @@ namespace BlackMisc
|
||||
{
|
||||
return CFileUtils::appendFilePathsAndFixUnc(this->getSimulatorDirectoryOrDefault(), CXPlaneUtil::xplanePluginPathName());
|
||||
}
|
||||
|
||||
QString CFsxP3DSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return u"SimulatedObject: " % boolToYesNo(m_useSimulatedObjectAdding);
|
||||
}
|
||||
|
||||
CVariant CFsxP3DSettings::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return {};
|
||||
}
|
||||
|
||||
void CFsxP3DSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(variant);
|
||||
}
|
||||
|
||||
CFsxP3DSettings CMultiSimulatorDetailsSettings::getSettings(const CSimulatorInfo &sim) const
|
||||
{
|
||||
Q_ASSERT_X(sim.isFsxP3DFamily(), Q_FUNC_INFO, "Only for FSX/P3D");
|
||||
if (sim == CSimulatorInfo::p3d()) { return m_simP3D.get(); }
|
||||
return m_simFsx.get();
|
||||
}
|
||||
|
||||
CStatusMessage CMultiSimulatorDetailsSettings::setSettings(const CFsxP3DSettings &settings, const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isFsxP3DFamily(), Q_FUNC_INFO, "Only for FSX/P3D");
|
||||
if (simulator == CSimulatorInfo::p3d()) { return m_simP3D.set(settings); }
|
||||
return m_simFsx.set(settings);
|
||||
}
|
||||
|
||||
CStatusMessage CMultiSimulatorDetailsSettings::setAndSaveSettings(const CFsxP3DSettings &settings, const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isFsxP3DFamily(), Q_FUNC_INFO, "Only for FSX/P3D");
|
||||
if (simulator == CSimulatorInfo::p3d()) { return m_simP3D.setAndSave(settings); }
|
||||
return m_simFsx.setAndSave(settings);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016
|
||||
/* Copyright (C) 2016
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
@@ -30,7 +30,7 @@ namespace BlackMisc
|
||||
namespace Settings
|
||||
{
|
||||
//! Settings for simulator
|
||||
//! Driver independent part also used in loaders (such as directories)
|
||||
//! Driver independent parts (such as directories), also used in model loaders
|
||||
class BLACKMISC_EXPORT CSimulatorSettings : public CValueObject<CSimulatorSettings>
|
||||
{
|
||||
public:
|
||||
@@ -121,6 +121,37 @@ namespace BlackMisc
|
||||
);
|
||||
};
|
||||
|
||||
//! Some P3D/FSX settings
|
||||
class BLACKMISC_EXPORT CFsxP3DSettings : public CValueObject<CFsxP3DSettings>
|
||||
{
|
||||
public:
|
||||
//! Default constructor
|
||||
CFsxP3DSettings() {}
|
||||
|
||||
//! Use simulated object adding
|
||||
void setAddingAsSimulatedObjectEnabled(bool enable) { m_useSimulatedObjectAdding = enable; }
|
||||
|
||||
//! Use simulated object adding
|
||||
bool isAddingAsSimulatedObjectEnabled() const { return m_useSimulatedObjectAdding; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
private:
|
||||
bool m_useSimulatedObjectAdding = false; //!< COM integration
|
||||
|
||||
BLACK_METACLASS(
|
||||
CFsxP3DSettings,
|
||||
BLACK_METAMEMBER(useSimulatedObjectAdding)
|
||||
);
|
||||
};
|
||||
|
||||
//! Allows to have specific utility functions for each simulator
|
||||
class BLACKMISC_EXPORT CSpecializedSimulatorSettings
|
||||
{
|
||||
@@ -254,11 +285,45 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static const QString &defaultValue()
|
||||
{
|
||||
static const QString version("4.2");
|
||||
static const QString version("4.3");
|
||||
return version;
|
||||
}
|
||||
};
|
||||
|
||||
//! Some details for FSX
|
||||
struct TFsxDetailsSettings : public TSettingTrait<CFsxP3DSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "simulator/fsxdetailsettings"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("FSX details"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static const CFsxP3DSettings &defaultValue()
|
||||
{
|
||||
static const CFsxP3DSettings d;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
//! Some details for P3D
|
||||
struct TP3DDetailsSettings : public TSettingTrait<CFsxP3DSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "simulator/p3ddetailsettings"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("P3D details"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static const CFsxP3DSettings &defaultValue()
|
||||
{
|
||||
static const CFsxP3DSettings d;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
//! Trait for simulator settings
|
||||
struct TSimulatorXP : public TSettingTrait<CSimulatorSettings>
|
||||
{
|
||||
@@ -279,6 +344,24 @@ namespace BlackMisc
|
||||
static const QString &humanReadable() { static const QString name("FG settings"); return name; }
|
||||
};
|
||||
|
||||
//! Bundle of detail settings
|
||||
class BLACKMISC_EXPORT CMultiSimulatorDetailsSettings : public QObject
|
||||
{
|
||||
public:
|
||||
//! Settings per simulator
|
||||
CFsxP3DSettings getSettings(const CSimulatorInfo &sim) const;
|
||||
|
||||
//! Set settings per simulator
|
||||
CStatusMessage setSettings(const CFsxP3DSettings &settings, const CSimulatorInfo &simulator);
|
||||
|
||||
//! Set settings per simulator
|
||||
CStatusMessage setAndSaveSettings(const CFsxP3DSettings &settings, const CSimulatorInfo &simulator);
|
||||
|
||||
private:
|
||||
CSetting<TFsxDetailsSettings> m_simFsx { this }; //!< FSX settings
|
||||
CSetting<TP3DDetailsSettings> m_simP3D { this }; //!< P3D settings
|
||||
};
|
||||
|
||||
//! Bundle of settings for all simulators
|
||||
class BLACKMISC_EXPORT CMultiSimulatorSettings : public QObject
|
||||
{
|
||||
@@ -502,6 +585,7 @@ namespace BlackMisc
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSimulatorSettings)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CFsxP3DSettings)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Simulation::Settings::CSimulatorSettings>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Simulation::Settings::CSimulatorSettings>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSimulatorMessagesSettings)
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace BlackMisc
|
||||
//! Difference of network and (rendered) livery code
|
||||
QString getNetworkModelLiveryDifference() const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CAircraftModel::getIconPath
|
||||
//! \copydoc BlackMisc::Simulation::CAircraftModel::getIconFile
|
||||
const QString &getIconFile() const { return m_models[CurrentModel].getIconFile(); }
|
||||
|
||||
//! Get model string
|
||||
|
||||
@@ -338,6 +338,15 @@ namespace BlackSimPlugin
|
||||
m_traceAutoUntilTs = -1;
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::setAddingAsSimulatedObjectEnabled(bool enabled)
|
||||
{
|
||||
m_useAddSimulatedObj = enabled;
|
||||
const CSimulatorInfo sim = this->getSimulatorInfo();
|
||||
CFsxP3DSettings settings = m_detailsSettings.getSettings(sim);
|
||||
settings.setAddingAsSimulatedObjectEnabled(enabled);
|
||||
m_detailsSettings.setSettings(settings, sim);
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::resetAircraftStatistics()
|
||||
{
|
||||
m_dispatchProcCount = 0;
|
||||
@@ -440,6 +449,8 @@ namespace BlackSimPlugin
|
||||
if (referenceTs != m_simulatingChangedTs) { return; } // changed, so no longer valid
|
||||
m_simSimulating = true; // only place where this should be set to true
|
||||
m_simConnected = true;
|
||||
m_useAddSimulatedObj = m_detailsSettings.getSettings(this->getSimulatorInfo()).isAddingAsSimulatedObjectEnabled();
|
||||
|
||||
HRESULT hr1 = this->logAndTraceSendId(
|
||||
SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestOwnAircraft,
|
||||
CSimConnectDefinitions::DataOwnAircraft, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME),
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace BlackSimPlugin
|
||||
bool isAddingAsSimulatedObjectEnabled() const { return m_useAddSimulatedObj; }
|
||||
|
||||
//! Allow adding as simulated object instead of non ATC
|
||||
void setAddingAsSimulatedObjectEnabled(bool enabled) { m_useAddSimulatedObj = enabled; }
|
||||
void setAddingAsSimulatedObjectEnabled(bool enabled);
|
||||
|
||||
//! Request for sim data (request in range of sim data)?
|
||||
static bool isRequestForSimObjAircraft(DWORD requestId) { return requestId >= RequestSimObjAircraftStart && requestId <= RequestSimObjAircraftRangeEnd; }
|
||||
@@ -609,6 +609,9 @@ namespace BlackSimPlugin
|
||||
int m_receiveExceptionCount = 0; //!< exceptions
|
||||
int m_requestSimObjectDataCount = 0; //!< requested SimObjects
|
||||
|
||||
// settings
|
||||
BlackMisc::Simulation::Settings::CMultiSimulatorDetailsSettings m_detailsSettings;
|
||||
|
||||
// objects
|
||||
CSimConnectObjects m_simConnectObjectsPositionAndPartsTraces; //!< position/parts received, but object not yet added, excluded, disabled etc.
|
||||
CSimConnectObjects m_addPendingAircraft; //!< aircraft/probes awaiting to be added;
|
||||
|
||||
Reference in New Issue
Block a user