mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +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)
|
||||
|
||||
Reference in New Issue
Block a user