mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
* set infobar status correctly when GUI connects after the core has been started * more detailed information in information statusbar * allow to obtain currently connected server in network context * made many network vatlib slots normal member functions * fixed rendered aircraft flag setting in FSX driver
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1d89862080
commit
3c15f2ad89
@@ -194,10 +194,13 @@ namespace BlackCore
|
||||
virtual BlackMisc::Aviation::CCallsignSet getFastPositionEnabledCallsigns() = 0;
|
||||
|
||||
//! Connect to Network
|
||||
//! \return messages gererated during connecting
|
||||
//! \return messages generated during connecting
|
||||
//! \see INetwork::LoginMode
|
||||
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint loginMode) = 0;
|
||||
|
||||
//! Server which is connected, if not connected empty default object.
|
||||
virtual BlackMisc::Network::CServer getConnectedServer() const = 0;
|
||||
|
||||
//! Disconnect from network
|
||||
//! \return messages generated during disconnecting
|
||||
virtual BlackMisc::CStatusMessage disconnectFromNetwork() = 0;
|
||||
|
||||
@@ -104,6 +104,13 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getConnectedServer
|
||||
virtual BlackMisc::Network::CServer getConnectedServer() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Network::CServer();
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::sendTextMessages()
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override
|
||||
{
|
||||
|
||||
@@ -189,6 +189,18 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
CServer CContextNetwork::getConnectedServer() const
|
||||
{
|
||||
if (this->isConnected())
|
||||
{
|
||||
return this->m_network->getPresetServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
return CServer();
|
||||
}
|
||||
}
|
||||
|
||||
CStatusMessage CContextNetwork::disconnectFromNetwork()
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
|
||||
@@ -127,6 +127,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::connectToNetwork()
|
||||
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override;
|
||||
|
||||
//! \copydoc IContextNetwork::getConnectedServer
|
||||
virtual BlackMisc::Network::CServer getConnectedServer() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::disconnectFromNetwork()
|
||||
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
|
||||
|
||||
@@ -256,13 +259,8 @@ namespace BlackCore
|
||||
//! Check if a supervisor message was received
|
||||
void ps_checkForSupervisiorTextMessage(const BlackMisc::Network::CTextMessageList &messages);
|
||||
|
||||
/*!
|
||||
* \brief Connection status changed?
|
||||
* \param from old status
|
||||
* \param to new status
|
||||
*/
|
||||
//! Connection status changed
|
||||
void ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,11 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isConnected"));
|
||||
}
|
||||
|
||||
CServer CContextNetworkProxy::getConnectedServer() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CServer>(QLatin1Literal("getConnectedServer"));
|
||||
}
|
||||
|
||||
bool CContextNetworkProxy::parseCommandLine(const QString &commandLine, const QString &originator)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("commandLineEntered"), commandLine, originator);
|
||||
|
||||
@@ -84,6 +84,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::getConnectedServer
|
||||
virtual BlackMisc::Network::CServer getConnectedServer() const override;
|
||||
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const QString &originator) override;
|
||||
|
||||
|
||||
@@ -139,23 +139,26 @@ namespace BlackCore
|
||||
status == DisconnectedFailed || status == DisconnectedLost;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//! \name Network slots
|
||||
//! @{
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
/*!
|
||||
* Returns true if the current ConnectionStatus is a connected state.
|
||||
*/
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
/*!
|
||||
* Get preset server.
|
||||
*/
|
||||
virtual BlackMisc::Network::CServer getPresetServer() const = 0;
|
||||
|
||||
/*!
|
||||
* Returns true if the current ConnectionStatus is in transition, e.g. connecting.
|
||||
*/
|
||||
virtual bool isPendingConnection() const = 0;
|
||||
|
||||
public slots:
|
||||
////////////////////////////////////////////////////////////////
|
||||
//! \name Network slots
|
||||
//! @{
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
/*!
|
||||
* Set the server which will be connected to.
|
||||
* \pre Network must be disconnected when calling this function.
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
||||
/********************************** INetwork slots ************************************/
|
||||
/********************************** INetwork functions ************************************/
|
||||
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
||||
|
||||
void CNetworkVatlib::presetServer(const CServer &server)
|
||||
|
||||
@@ -39,9 +39,10 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CNetworkVatlib();
|
||||
|
||||
//! \name Network slots
|
||||
//! \name Network functions
|
||||
//! @{
|
||||
virtual bool isConnected() const override { return m_status == vatStatusConnected; }
|
||||
virtual BlackMisc::Network::CServer getPresetServer() const override { return m_server; }
|
||||
virtual bool isPendingConnection() const override { return m_status == vatStatusConnecting; }
|
||||
virtual void presetLoginMode(LoginMode mode) override;
|
||||
virtual void presetServer(const BlackMisc::Network::CServer &server) override;
|
||||
@@ -62,12 +63,12 @@ namespace BlackCore
|
||||
virtual void sendAircraftConfigQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
//! @}
|
||||
|
||||
//! \name Text message slots
|
||||
//! \name Text message functions
|
||||
//! @{
|
||||
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &messages) override;
|
||||
//! @}
|
||||
|
||||
//! \name ATC slots
|
||||
//! \name ATC functions
|
||||
//! @{
|
||||
virtual void sendAtcQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void sendAtisQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
@@ -75,7 +76,7 @@ namespace BlackCore
|
||||
virtual void sendFlightPlanQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
//! @}
|
||||
|
||||
//! \name Aircraft slots
|
||||
//! \name Aircraft functions
|
||||
//! @{
|
||||
virtual void sendCapabilitiesQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void sendIcaoCodesQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
@@ -84,7 +85,7 @@ namespace BlackCore
|
||||
virtual void sendInterimPositions(const BlackMisc::Aviation::CCallsignSet &receiver) override;
|
||||
//! @}
|
||||
|
||||
//! \name Weather slots
|
||||
//! \name Weather functions
|
||||
//! @{
|
||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override;
|
||||
virtual void sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override;
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace BlackCore
|
||||
//! ISimulator status
|
||||
enum SimulatorStatus
|
||||
{
|
||||
Disconnected = 0,
|
||||
Connected = 1 << 0, //!< Is the plugin connected to the simulator?
|
||||
Running = 1 << 1, //!< Is the simulator actually simulating?
|
||||
Paused = 1 << 2, //!< Is the simulator paused?
|
||||
|
||||
@@ -78,11 +78,15 @@ namespace BlackGui
|
||||
{
|
||||
connect(this->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::ps_onSimulatorStatusChanged);
|
||||
connect(this->getIContextSimulator(), &IContextSimulator::installedAircraftModelsChanged, this, &CInfoBarStatusComponent::ps_onMapperReady);
|
||||
|
||||
// initial values
|
||||
this->ps_onMapperReady();
|
||||
bool connected = this->getIContextSimulator()->isConnected();
|
||||
this->ps_onSimulatorStatusChanged(connected ? ISimulator::Connected : ISimulator::Disconnected);
|
||||
}
|
||||
|
||||
if (this->getIContextNetwork())
|
||||
{
|
||||
this->ui->led_Simulator->setOn(this->getIContextSimulator()->isConnected());
|
||||
connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::ps_onNetworkConnectionChanged);
|
||||
}
|
||||
|
||||
@@ -98,19 +102,20 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(quint8 status)
|
||||
void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(int status)
|
||||
{
|
||||
// if (connected && running)
|
||||
if (status & (ISimulator::Connected | ISimulator::Running)) {
|
||||
if (status > 0)
|
||||
{
|
||||
this->ui->led_Simulator->setOn(true);
|
||||
} else if (status & ISimulator::Connected) {
|
||||
this->ui->led_Simulator->setTriState();
|
||||
} else {
|
||||
this->ui->led_Simulator->setOnToolTip(getIContextSimulator()->getSimulatorPluginInfo().getDescription());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->led_Simulator->setOn(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(uint from, uint to)
|
||||
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(int from, int to)
|
||||
{
|
||||
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
|
||||
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
|
||||
@@ -126,6 +131,7 @@ namespace BlackGui
|
||||
break;
|
||||
case INetwork::Connected:
|
||||
this->ui->led_Network->setOn(true);
|
||||
this->ui->led_Network->setOnToolTip("Connected: " + getIContextNetwork()->getConnectedServer().getName());
|
||||
break;
|
||||
case INetwork::Connecting:
|
||||
this->ui->led_Network->setTriStateColor(CLedWidget::Yellow);
|
||||
@@ -179,8 +185,14 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
|
||||
bool on = this->getIContextSimulator()->getInstalledModelsCount() > 0;
|
||||
int models = this->getIContextSimulator()->getInstalledModelsCount();
|
||||
bool on = (models > 0);
|
||||
this->ui->led_MapperReady->setOn(on);
|
||||
if (on)
|
||||
{
|
||||
QString m = QString("Mapper with %1 models").arg(models);
|
||||
this->ui->led_MapperReady->setToolTip(m);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -55,10 +55,10 @@ namespace BlackGui
|
||||
|
||||
private slots:
|
||||
//! Simulator connection has been changed
|
||||
void ps_onSimulatorStatusChanged(quint8 status);
|
||||
void ps_onSimulatorStatusChanged(int status);
|
||||
|
||||
//! Network connection has been changed
|
||||
void ps_onNetworkConnectionChanged(uint from, uint to);
|
||||
void ps_onNetworkConnectionChanged(int from, int to);
|
||||
|
||||
//! Context menu requested
|
||||
void ps_customAudioContextMenuRequested(const QPoint &position);
|
||||
|
||||
@@ -389,7 +389,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAircraftIcao::CAircraftIcao(const QString &icao, const QString &airline)
|
||||
: m_aircraftDesignator(icao.trimmed().toUpper()), m_airlineDesignator(airline.trimmed().toUpper())
|
||||
{}
|
||||
|
||||
QString CAircraftIcao::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -41,6 +45,12 @@ namespace BlackMisc
|
||||
return (this->hasAircraftDesignator() && this->getAircraftDesignator() != "ZZZZ");
|
||||
}
|
||||
|
||||
QString CAircraftIcao::getEngineType() const
|
||||
{
|
||||
if (this->m_aircraftCombinedType.length() != 3) return "";
|
||||
return this->m_aircraftCombinedType.right(1);
|
||||
}
|
||||
|
||||
QString CAircraftIcao::asString() const
|
||||
{
|
||||
if (this->m_aircraftDesignator.isEmpty()) { return ""; }
|
||||
|
||||
@@ -42,14 +42,10 @@ namespace BlackMisc
|
||||
//! Constructor.
|
||||
explicit CAircraftIcao(const QString &icao) : m_aircraftDesignator(icao.trimmed().toUpper()) {}
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param icao "B737"
|
||||
* \param airline "DLH"
|
||||
*/
|
||||
CAircraftIcao(const QString &icao, const QString &airline)
|
||||
: m_aircraftDesignator(icao.trimmed().toUpper()), m_airlineDesignator(airline.trimmed().toUpper())
|
||||
{}
|
||||
//! Constructor.
|
||||
//! \param icao "B737"
|
||||
//! \param airline "DLH"
|
||||
CAircraftIcao(const QString &icao, const QString &airline);
|
||||
|
||||
/*!
|
||||
* Constructor.
|
||||
@@ -115,16 +111,10 @@ namespace BlackMisc
|
||||
bool hasAircraftCombinedType() const { return this->getAircraftCombinedType().length() == 3; }
|
||||
|
||||
//! Get engine type, e.g. "J"
|
||||
QString getEngineType() const
|
||||
{
|
||||
if (this->m_aircraftCombinedType.length() != 3) return "";
|
||||
return this->m_aircraftCombinedType.right(1);
|
||||
}
|
||||
QString getEngineType() const;
|
||||
|
||||
/*!
|
||||
* \brief As string for GUI representation by index
|
||||
* \remarks Different from toQString()
|
||||
*/
|
||||
//! As string for GUI representation by index
|
||||
//! \remarks Different from toQString()
|
||||
QString asString() const;
|
||||
|
||||
//! Set type
|
||||
@@ -175,7 +165,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftIcao, (
|
||||
o.m_airlineDesignator,
|
||||
o.m_livery,
|
||||
o.m_aircraftColor
|
||||
))
|
||||
))
|
||||
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
CServer() : m_port(-1), m_isAcceptingConnections(true) {}
|
||||
|
||||
//! Constructor.
|
||||
CServer(const QString &name, const QString &description, const QString &address, qint32 port, const CUser &user, bool isAcceptingConnections = true)
|
||||
CServer(const QString &name, const QString &description, const QString &address, int port, const CUser &user, bool isAcceptingConnections = true)
|
||||
: m_name(name), m_description(description), m_address(address), m_port(port), m_user(user), m_isAcceptingConnections(isAcceptingConnections) {}
|
||||
|
||||
//! Get address.
|
||||
|
||||
@@ -164,7 +164,8 @@ namespace BlackSimPlugin
|
||||
// matched models
|
||||
CAircraftModel aircraftModel = modelMatching(newRemoteAircraftCopy);
|
||||
Q_ASSERT_X(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns");
|
||||
this->updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator());
|
||||
this->updateAircraftModel(callsign, aircraftModel, simulatorOriginator());
|
||||
this->updateAircraftRendered(callsign, true, simulatorOriginator());
|
||||
CSimulatedAircraft aircraftAfterModelApplied(getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign()));
|
||||
aircraftAfterModelApplied.setRendered(true);
|
||||
emit modelMatchingCompleted(aircraftAfterModelApplied);
|
||||
@@ -172,7 +173,7 @@ namespace BlackSimPlugin
|
||||
// create AI
|
||||
if (isSimulating())
|
||||
{
|
||||
//! \todo if exists, recreate (new model?, new ICAO code)
|
||||
//! \todo FSX driver if exists, recreate (new model?, new ICAO code)
|
||||
QByteArray m = aircraftModel.getModelString().toLocal8Bit();
|
||||
HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, m.constData(), qPrintable(callsign.toQString().left(12)), initialPosition, static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObj.getRequestId()));
|
||||
if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); }
|
||||
@@ -832,6 +833,8 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_CONSTEXPR int QueryInterval = 5 * 1000; // 5 seconds
|
||||
m_timer->setInterval(QueryInterval);
|
||||
this->setObjectName("CSimulatorFsxListener");
|
||||
this->m_timer->setObjectName(this->objectName().append(":m_timer"));
|
||||
|
||||
connect(m_timer, &QTimer::timeout, [this]()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user