mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #369, adjusted plugins
* common base class for FS drivers * moved mapper into common base class * reflect changes for own aircraft provider ** removed member functions ** removed unused members
This commit is contained in:
@@ -7,13 +7,15 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FS9_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FS9_H
|
||||
|
||||
#include "fs9_host.h"
|
||||
#include "fs9_client.h"
|
||||
#include "lobby_client.h"
|
||||
#include "../fscommon/fsuipc.h"
|
||||
#include "../fscommon/simulator_fscommon.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackcore/interpolator_linear.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
@@ -26,8 +28,6 @@
|
||||
#include <QThread>
|
||||
#include <QHash>
|
||||
|
||||
//! \file
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fs9
|
||||
@@ -41,20 +41,20 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! \copydoc BlackCore::ISimulatorFactory::create()
|
||||
virtual BlackCore::ISimulator *create(QObject *parent) override;
|
||||
virtual BlackCore::ISimulator *create(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent) override;
|
||||
|
||||
//! Simulator info
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
};
|
||||
|
||||
//! FSX Simulator Implementation
|
||||
class CSimulatorFs9 : public BlackCore::ISimulator
|
||||
class CSimulatorFs9 : public BlackSimPlugin::FsCommon::CSimulatorFsCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorFs9(QObject *parent = nullptr);
|
||||
CSimulatorFs9(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSimulatorFs9();
|
||||
@@ -65,15 +65,9 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::canConnect()
|
||||
virtual bool canConnect() const override { return true; }
|
||||
|
||||
//! \copydoc ISimulator::isPaused
|
||||
virtual bool isPaused() const override { return m_simPaused; }
|
||||
|
||||
//! \copydoc ISimulator::isSimulating
|
||||
virtual bool isSimulating() const override { return isConnected(); }
|
||||
|
||||
//! Is time synchronization on?
|
||||
virtual bool isTimeSynchronized() const override { return m_syncTime; }
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc ISimulator::connectTo()
|
||||
@@ -85,9 +79,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::disconnectFrom()
|
||||
virtual bool disconnectFrom() override;
|
||||
|
||||
//! \copydoc ISimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const override { return m_ownAircraft; }
|
||||
|
||||
//! \copydoc ISimulator::addRemoteAircraft()
|
||||
virtual void addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
@@ -104,10 +95,7 @@ namespace BlackSimPlugin
|
||||
virtual int changeRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &changedAircraft, const BlackMisc::CPropertyIndexVariantMap &changeValues) override;
|
||||
|
||||
//! \copydoc ISimulator::updateOwnSimulatorCockpit()
|
||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
|
||||
//! \copydoc ISimulator::getSimulatorInfo()
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &ownAircraft, const QString &originator) override;
|
||||
|
||||
//! \copydoc ISimulator::displayStatusMessage()
|
||||
virtual void displayStatusMessage(const BlackMisc::CStatusMessage &message) const override;
|
||||
@@ -115,25 +103,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::displayTextMessage()
|
||||
virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const override;
|
||||
|
||||
//! \copydoc ISimulator::getAircraftModel()
|
||||
virtual BlackMisc::Simulation::CAircraftModel getOwnAircraftModel() const override { return m_ownAircraft.getModel(); }
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::getInstalledModels
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override { return {}; }
|
||||
|
||||
//! Airports in range
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! Set time synchronization between simulator and user's computer time
|
||||
//! \remarks not all drivers implement this, e.g. if it is an intrinsic simulator feature
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
//! Time synchronization offset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return m_syncTimeOffset; }
|
||||
|
||||
//! \copydoc ISimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
protected:
|
||||
//! Timer event
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
@@ -146,38 +115,22 @@ namespace BlackSimPlugin
|
||||
//! Process incoming FS9 message
|
||||
void ps_processFs9Message(const QByteArray &message);
|
||||
|
||||
//! Change own aircraft model string
|
||||
void ps_changeOwnAircraftModel(const QString &modelname);
|
||||
|
||||
//! Change DirectPlay host status
|
||||
void ps_changeHostStatus(BlackSimPlugin::Fs9::CFs9Host::HostStatus status);
|
||||
|
||||
private:
|
||||
|
||||
//! Called when data about our own aircraft are received
|
||||
void updateOwnAircraftFromSim(const BlackMisc::Aviation::CAircraft &ownAircraft);
|
||||
void updateOwnAircraftFromSimulator(const BlackMisc::Aviation::CAircraft &ownAircraft);
|
||||
|
||||
void disconnectAllClients();
|
||||
|
||||
// DirectPlay object handling
|
||||
QPointer<CFs9Host> m_fs9Host;
|
||||
bool m_isHosting = false; //!< Is sim connected
|
||||
bool m_startedLobbyConnection = false;
|
||||
bool m_syncTime = false; //!< Time synchronized?
|
||||
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
|
||||
bool m_isHosting = false; //!< Is sim connected
|
||||
bool m_startedLobbyConnection = false;
|
||||
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||
|
||||
CLobbyClient *m_lobbyClient;
|
||||
|
||||
BlackSim::CSimulatorInfo m_simulatorInfo;
|
||||
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< Object representing our own aircraft from simulator
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange;
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset;
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_remoteAircraft;
|
||||
|
||||
QScopedPointer<FsCommon::CFsuipc> m_fsuipc;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user