mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #799, use message settings
This commit is contained in:
@@ -554,8 +554,12 @@ namespace BlackCore
|
||||
void CContextSimulator::ps_textMessagesReceived(const Network::CTextMessageList &textMessages)
|
||||
{
|
||||
if (!isSimulatorSimulating()) { return; }
|
||||
if (!this->getIContextOwnAircraft()) { return; }
|
||||
const CSettingsSimulatorMessages settings = m_messageSettings.getThreadLocal();
|
||||
const CSimulatedAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft();
|
||||
for (const auto &tm : textMessages)
|
||||
{
|
||||
if (!settings.relayThisTextMessage(tm, ownAircraft)) { continue; }
|
||||
m_simulatorPlugin.second->displayTextMessage(tm);
|
||||
}
|
||||
}
|
||||
@@ -598,8 +602,11 @@ namespace BlackCore
|
||||
void CContextSimulator::ps_relayStatusMessageToSimulator(const BlackMisc::CStatusMessage &message)
|
||||
{
|
||||
if (!isSimulatorSimulating()) { return; }
|
||||
//! \todo add settings and only relay messages as set in settings
|
||||
m_simulatorPlugin.second->displayStatusMessage(message);
|
||||
const CSettingsSimulatorMessages simMsg = m_messageSettings.getThreadLocal();
|
||||
if (simMsg.relayThisStatusMessage(message))
|
||||
{
|
||||
m_simulatorPlugin.second->displayStatusMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
void CContextSimulator::restoreSimulatorPlugins()
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKCORE_CONTEXT_CONTEXTSIMULATOR_IMPL_H
|
||||
#define BLACKCORE_CONTEXT_CONTEXTSIMULATOR_IMPL_H
|
||||
|
||||
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/simulationsettings.h"
|
||||
#include "blackmisc/worker.h"
|
||||
|
||||
#include <QObject>
|
||||
@@ -194,6 +196,7 @@ namespace BlackCore
|
||||
BlackCore::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; //!< load model set from caches
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages;
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
|
||||
bool m_initallyAddAircrafts = false;
|
||||
bool m_enableMatchingMessages = true;
|
||||
};
|
||||
|
||||
@@ -351,7 +351,16 @@ namespace BlackMisc
|
||||
return this->getRelayedTextMessageTypes().testFlag(TextMessagesCom2);
|
||||
}
|
||||
|
||||
bool CSettingsSimulatorMessages::isRelayedTextMessage(const Network::CTextMessage &msg, const BlackMisc::Simulation::CSimulatedAircraft &aircraft) const
|
||||
bool CSettingsSimulatorMessages::relayThisStatusMessage(const CStatusMessage &message) const
|
||||
{
|
||||
if (message.isEmpty()) { return false; }
|
||||
if (!this->isGloballyEnabled()) { return false; }
|
||||
if (!this->isRelayedTechnicalMessages()) { return false; }
|
||||
int s = static_cast<int>(message.getSeverity());
|
||||
return (s >= this->m_technicalLogLevel);
|
||||
}
|
||||
|
||||
bool CSettingsSimulatorMessages::relayThisTextMessage(const Network::CTextMessage &msg, const BlackMisc::Simulation::CSimulatedAircraft &aircraft) const
|
||||
{
|
||||
if (msg.isEmpty()) { return false; }
|
||||
if (!this->isGloballyEnabled()) { return false; }
|
||||
|
||||
@@ -246,15 +246,18 @@ namespace BlackMisc
|
||||
//! Relay UNICOM messages
|
||||
bool isRelayedUnicomTextMessages() const;
|
||||
|
||||
//! Relay given text message
|
||||
bool isRelayedTextMessage(const BlackMisc::Network::CTextMessage &msg, const BlackMisc::Simulation::CSimulatedAircraft &aircraft) const;
|
||||
|
||||
//! Relay COM1 text message
|
||||
bool isRelayedCom1TextMessages() const;
|
||||
|
||||
//! Relay COM2 text message
|
||||
bool isRelayedCom2TextMessages() const;
|
||||
|
||||
//! Relay given text message
|
||||
bool relayThisTextMessage(const BlackMisc::Network::CTextMessage &msg, const BlackMisc::Simulation::CSimulatedAircraft &aircraft) const;
|
||||
|
||||
//! Relay this particular message
|
||||
bool relayThisStatusMessage(const BlackMisc::CStatusMessage &message) const;
|
||||
|
||||
//! Relayed text messages
|
||||
CSettingsSimulatorMessages::TextMessageType getRelayedTextMessageTypes() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user