mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
refs #207, added simulator setup to CSimulatorInfo
* setup will provide some metadata about the flight simulator, such as path, version etc. * there will be a sim independent setup class, providing common information such as path, is simulator installed, etc. * a sim dependent class on top will provide the values specific to one sim * setup will contain the logic to fetch its values: setup->init
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
#include "blacksimfreefunctions.h"
|
#include "blacksimfreefunctions.h"
|
||||||
|
#include "fsx/simconnectutilities.h"
|
||||||
#include "fscommon/aircraftcfgentrieslist.h"
|
#include "fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "fscommon/aircraftmappinglist.h"
|
#include "fscommon/aircraftmappinglist.h"
|
||||||
#include "fsx/simconnectutilities.h"
|
#include "simulatorinfo.h"
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
|
|
||||||
void registerMetadata()
|
void registerMetadata()
|
||||||
{
|
{
|
||||||
|
BlackSim::CSimulatorInfo::registerMetadata();
|
||||||
BlackSim::FsCommon::CAircraftCfgEntries::registerMetadata();
|
BlackSim::FsCommon::CAircraftCfgEntries::registerMetadata();
|
||||||
BlackSim::FsCommon::CAircraftMapping::registerMetadata();
|
BlackSim::FsCommon::CAircraftMapping::registerMetadata();
|
||||||
BlackSim::FsCommon::CAircraftCfgEntriesList::registerMetadata();
|
BlackSim::FsCommon::CAircraftCfgEntriesList::registerMetadata();
|
||||||
|
|||||||
14
src/blacksim/fsx/fsxsimulatorsetup.cpp
Normal file
14
src/blacksim/fsx/fsxsimulatorsetup.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "fsxsimulatorsetup.h"
|
||||||
|
#include "../fsx/simconnectutilities.h"
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace Fsx
|
||||||
|
{
|
||||||
|
void CFsxSimulatorSetup::init()
|
||||||
|
{
|
||||||
|
CSimulatorSetup::init();
|
||||||
|
this->m_setup.addValue(SetupSimConnectCfgFile, CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/blacksim/fsx/fsxsimulatorsetup.h
Normal file
43
src/blacksim/fsx/fsxsimulatorsetup.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIM_FSX_SIMSETUP_H
|
||||||
|
#define BLACKSIM_FSX_SIMSETUP_H
|
||||||
|
|
||||||
|
#include "../simulatorsetup.h"
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
namespace Fsx
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Simulator settings for FSX Flight sims
|
||||||
|
*/
|
||||||
|
class CFsxSimulatorSetup : public BlackSim::CSimulatorSetup
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SetupSimConnectCfgFile = 1000
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
|
CFsxSimulatorSetup() : BlackSim::CSimulatorSetup() {}
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CFsxSimulatorSetup(const BlackMisc::CIndexVariantMap &map) : BlackSim::CSimulatorSetup(map) {}
|
||||||
|
|
||||||
|
//! Init, to be used where FSX runs
|
||||||
|
void init();
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -27,8 +27,12 @@ namespace BlackSimPlugin
|
|||||||
m_isConnected(false),
|
m_isConnected(false),
|
||||||
m_simRunning(false),
|
m_simRunning(false),
|
||||||
m_hSimConnect(nullptr),
|
m_hSimConnect(nullptr),
|
||||||
m_nextObjID(1)
|
m_nextObjID(1),
|
||||||
|
m_simulatorInfo(CSimulatorInfo::FSX())
|
||||||
{
|
{
|
||||||
|
CFsxSimulatorSetup setup;
|
||||||
|
setup.init(); // this fetches important setting on local side
|
||||||
|
this->m_simulatorInfo.setSimulatorSetup(setup.getSettings());
|
||||||
QTimer::singleShot(5000, this, SLOT(checkConnection()));
|
QTimer::singleShot(5000, this, SLOT(checkConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +85,11 @@ namespace BlackSimPlugin
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimulatorInfo CSimulatorFSX::getSimulatorInfo() const
|
||||||
|
{
|
||||||
|
return this->m_simulatorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
void CALLBACK CSimulatorFSX::SimConnectProc(SIMCONNECT_RECV *pData, DWORD /* cbData */, void *pContext)
|
void CALLBACK CSimulatorFSX::SimConnectProc(SIMCONNECT_RECV *pData, DWORD /* cbData */, void *pContext)
|
||||||
{
|
{
|
||||||
CSimulatorFSX *simulatorFsx = static_cast<CSimulatorFSX *>(pContext);
|
CSimulatorFSX *simulatorFsx = static_cast<CSimulatorFSX *>(pContext);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using namespace BlackMisc;
|
|||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
|
|
||||||
CSimulatorInfo::CSimulatorInfo(const QString &shortname, const QString &fullname) : m_fullname(fullname), m_shortname(shortname)
|
CSimulatorInfo::CSimulatorInfo(const QString &shortname, const QString &fullname) : m_fullname(fullname), m_shortname(shortname)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -17,6 +16,23 @@ namespace BlackSim
|
|||||||
return qHash(TupleConverter<CSimulatorInfo>::toTuple(*this));
|
return qHash(TupleConverter<CSimulatorInfo>::toTuple(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant CSimulatorInfo::getSimulatorSetupValue(int index) const
|
||||||
|
{
|
||||||
|
return this->m_simsetup.value(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSimulatorInfo::getSimulatorSetupValueAsString(int index) const
|
||||||
|
{
|
||||||
|
QVariant qv = getSimulatorSetupValue(index);
|
||||||
|
Q_ASSERT(qv.canConvert<QString>());
|
||||||
|
return qv.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorInfo::setSimulatorSetup(const BlackMisc::CIndexVariantMap &setup)
|
||||||
|
{
|
||||||
|
this->m_simsetup = setup;
|
||||||
|
}
|
||||||
|
|
||||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef BLACKSIM_SIMULATORINFO_H
|
#ifndef BLACKSIM_SIMULATORINFO_H
|
||||||
#define BLACKSIM_SIMULATORINFO_H
|
#define BLACKSIM_SIMULATORINFO_H
|
||||||
|
|
||||||
|
#include "blackmisc/indexvariantmap.h"
|
||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
|
|
||||||
//! \brief Describing a simulator
|
//! \brief Describing a simulator
|
||||||
class CSimulatorInfo : public BlackMisc::CValueObject
|
class CSimulatorInfo : public BlackMisc::CValueObject
|
||||||
{
|
{
|
||||||
@@ -34,6 +34,15 @@ namespace BlackSim
|
|||||||
//! \copydoc CValueObject::getValueHash()
|
//! \copydoc CValueObject::getValueHash()
|
||||||
virtual uint getValueHash() const override;
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
|
//! Single setting value
|
||||||
|
QVariant getSimulatorSetupValue(int index) const;
|
||||||
|
|
||||||
|
//! Single setting value
|
||||||
|
QString getSimulatorSetupValueAsString(int index) const;
|
||||||
|
|
||||||
|
//! Set single settings
|
||||||
|
void setSimulatorSetup(const BlackMisc::CIndexVariantMap &setup);
|
||||||
|
|
||||||
//! \brief Simulator is FS9 - Microsoft Flight Simulator 2004
|
//! \brief Simulator is FS9 - Microsoft Flight Simulator 2004
|
||||||
static const CSimulatorInfo &FS9()
|
static const CSimulatorInfo &FS9()
|
||||||
{
|
{
|
||||||
@@ -85,10 +94,11 @@ namespace BlackSim
|
|||||||
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
|
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
|
||||||
QString m_fullname;
|
QString m_fullname;
|
||||||
QString m_shortname;
|
QString m_shortname;
|
||||||
|
BlackMisc::CIndexVariantMap m_simsetup; //!< allows to access simulator keys requried on remote side
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorInfo, (o.m_fullname, o.m_shortname))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorInfo, (o.m_fullname, o.m_shortname, o.m_simsetup))
|
||||||
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
14
src/blacksim/simulatorsetup.cpp
Normal file
14
src/blacksim/simulatorsetup.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "simulatorsetup.h"
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
void CSimulatorSetup::setSettings(const BlackMisc::CIndexVariantMap &map)
|
||||||
|
{
|
||||||
|
this->m_setup = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorSetup::init()
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/blacksim/simulatorsetup.h
Normal file
49
src/blacksim/simulatorsetup.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIM_SIMSETUP_H
|
||||||
|
#define BLACKSIM_SIMSETUP_H
|
||||||
|
|
||||||
|
#include "blackmisc/indexvariantmap.h"
|
||||||
|
#include <QMap>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackSim
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Simulator settings for MS Flight sims
|
||||||
|
*/
|
||||||
|
class CSimulatorSetup
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
BlackMisc::CIndexVariantMap m_setup; //!< values describing the simulator setup (path, config files)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Default constructor
|
||||||
|
CSimulatorSetup() {}
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CSimulatorSetup(const BlackMisc::CIndexVariantMap &map) : m_setup(map) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SetupSimPath
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Settings
|
||||||
|
BlackMisc::CIndexVariantMap getSettings() const { return this->m_setup;}
|
||||||
|
|
||||||
|
//! Settings
|
||||||
|
void setSettings(const BlackMisc::CIndexVariantMap &map);
|
||||||
|
|
||||||
|
//! Init, to be used where simulator runs
|
||||||
|
void init();
|
||||||
|
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user