mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:07:02 +08:00
Ref T775, special handling for "broadcast" messages
* identify broadcast messages * do NOT play sound * use "own" tab for text messages (group together)
This commit is contained in:
committed by
Mat Sutcliffe
parent
4de544a991
commit
00ed15f111
@@ -214,8 +214,18 @@ namespace BlackGui
|
||||
relevantForMe = true;
|
||||
}
|
||||
|
||||
// check message
|
||||
if (message.isRadioMessage())
|
||||
// check message, handle special cases first
|
||||
if (message.isServerMessage())
|
||||
{
|
||||
// void
|
||||
}
|
||||
else if (message.isBroadcastMessage())
|
||||
{
|
||||
// FAKE private message
|
||||
this->addPrivateChannelTextMessage(message);
|
||||
relevantForMe = true;
|
||||
}
|
||||
else if (message.isRadioMessage())
|
||||
{
|
||||
// check for own COM frequencies
|
||||
if (message.isSendToFrequency(ownAircraft.getCom1System().getFrequencyActive()))
|
||||
@@ -235,12 +245,17 @@ namespace BlackGui
|
||||
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextCallsignMentioned, false);
|
||||
}
|
||||
}
|
||||
else if (message.isPrivateMessage() && !message.isServerMessage())
|
||||
else if (message.isPrivateMessage())
|
||||
{
|
||||
// private message
|
||||
this->addPrivateChannelTextMessage(message);
|
||||
relevantForMe = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BLACK_AUDIT_X(false, Q_FUNC_INFO, "Wrong message type");
|
||||
continue;
|
||||
}
|
||||
|
||||
// message for me? right frequency? otherwise quit
|
||||
if (this->hasAllMessagesTab() && (relevantForMe || message.isServerMessage()))
|
||||
@@ -252,7 +267,10 @@ namespace BlackGui
|
||||
if (!relevantForMe) { continue; }
|
||||
|
||||
// overlay message if this channel is not selected
|
||||
if (!message.wasSent() && !message.isSendToUnicom() && !message.isServerMessage())
|
||||
if (message.isServerMessage()) { continue; }
|
||||
if (message.isBroadcastMessage()) { continue; }
|
||||
|
||||
if (!message.wasSent() && !message.isSendToUnicom())
|
||||
{
|
||||
// if the channel is selected, do nothing
|
||||
if (!this->isCorrespondingTextMessageTabSelected(message))
|
||||
@@ -526,8 +544,12 @@ namespace BlackGui
|
||||
void CTextMessageComponent::addPrivateChannelTextMessage(const CTextMessage &textMessage)
|
||||
{
|
||||
if (!textMessage.isPrivateMessage()) { return; }
|
||||
const CCallsign cs = textMessage.wasSent() ? textMessage.getRecipientCallsign() : textMessage.getSenderCallsign();
|
||||
CCallsign cs = textMessage.wasSent() ? textMessage.getRecipientCallsign() : textMessage.getSenderCallsign();
|
||||
if (cs.isEmpty()) { return; }
|
||||
|
||||
const bool isBroadcast = textMessage.isBroadcastMessage();
|
||||
if (isBroadcast) { cs.markAsBroadcastCallsign(); }
|
||||
|
||||
const QWidget *tab = this->findTextMessageTabByCallsign(cs);
|
||||
if (!tab) { tab = this->addNewTextMessageTab(cs); }
|
||||
Q_ASSERT_X(tab, Q_FUNC_INFO, "Missing tab");
|
||||
@@ -537,6 +559,9 @@ namespace BlackGui
|
||||
textEdit->insertTextMessage(textMessage);
|
||||
|
||||
// sound
|
||||
if (textMessage.isServerMessage()) { return; }
|
||||
if (isBroadcast) { return; }
|
||||
|
||||
const bool playSound = !textMessage.wasSent() && !m_usedAsOverlayWidget && sGui && !sGui->isShuttingDown() && sGui->getIContextAudio();
|
||||
if (sGui && sGui->getIContextAudio() && playSound)
|
||||
{
|
||||
|
||||
@@ -134,6 +134,17 @@ namespace BlackMisc
|
||||
return m_callsign.endsWith("SUP");
|
||||
}
|
||||
|
||||
bool CCallsign::isBroadcastCallsign() const
|
||||
{
|
||||
return m_callsignAsSet == "*" || m_callsign == "*" || m_callsignAsSet == "BROADCAST";
|
||||
}
|
||||
|
||||
void CCallsign::markAsBroadcastCallsign()
|
||||
{
|
||||
m_callsignAsSet = "BROADCAST";
|
||||
m_callsign = "BROADCAST";
|
||||
}
|
||||
|
||||
bool CCallsign::isMaybeCopilotCallsign(const CCallsign &pilotCallsign) const
|
||||
{
|
||||
return m_callsign.startsWith(pilotCallsign.asString()) &&
|
||||
|
||||
@@ -78,6 +78,14 @@ namespace BlackMisc
|
||||
//! Supervisor?
|
||||
bool isSupervisorCallsign() const;
|
||||
|
||||
//! Pseudo callsing for broadcast messages
|
||||
//! \remark hack, workaround for VATSIM using "*" as callsign for text messages
|
||||
bool isBroadcastCallsign() const;
|
||||
|
||||
//! Set a human readable name as "broadcast" callsign
|
||||
//! \remark hack, workaround for VATSIM using "*" as callsign for text messages
|
||||
void markAsBroadcastCallsign();
|
||||
|
||||
//! Returns true if this is a co-pilot callsign of pilot. The logic is that the callsign is the same as the pilot one
|
||||
//! but with a single character as suffix.
|
||||
//! e.g Pilot logged in as DLH123, observer logged in as DLH123A
|
||||
|
||||
@@ -62,6 +62,10 @@ namespace BlackMisc
|
||||
|
||||
bool CTextMessage::isSupervisorMessage() const
|
||||
{
|
||||
// ignore broadcast messages
|
||||
if (this->isBroadcastMessage()) { return false; }
|
||||
|
||||
// normal SUP message
|
||||
return m_senderCallsign.isSupervisorCallsign();
|
||||
}
|
||||
|
||||
@@ -79,6 +83,11 @@ namespace BlackMisc
|
||||
return m_relayedMessage || this->getMessage().startsWith(CTextMessage::swiftRelayMessage());
|
||||
}
|
||||
|
||||
void CTextMessage::markAsBroadcastMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CTextMessage::makeRelayedMessage(const CCallsign &partnerCallsign)
|
||||
{
|
||||
if (this->getMessage().startsWith(CTextMessage::swiftRelayMessage())) { return; }
|
||||
@@ -193,6 +202,12 @@ namespace BlackMisc
|
||||
return (cs.asString().startsWith("SERVER", Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
bool CTextMessage::isBroadcastMessage() const
|
||||
{
|
||||
const CCallsign cs = this->getRecipientCallsign();
|
||||
return cs.isBroadcastCallsign();
|
||||
}
|
||||
|
||||
QString CTextMessage::asString(bool withSender, bool withRecipient, const QString &separator) const
|
||||
{
|
||||
QString s(this->getFormattedUtcTimestampHms());
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace BlackMisc
|
||||
//! Initial message of server?
|
||||
bool isServerMessage() const;
|
||||
|
||||
//! Is this a broadcast message
|
||||
bool isBroadcastMessage() const;
|
||||
|
||||
//! Whole message as formatted string. Used to display message in a console window.
|
||||
//! \param withSender include sender information in string?
|
||||
//! \param withRecipient include recipient information in string?
|
||||
@@ -156,6 +159,9 @@ namespace BlackMisc
|
||||
//! Mark as relayed message
|
||||
void markAsRelayedMessage() { m_relayedMessage = true; }
|
||||
|
||||
//! Mark as broadcast message
|
||||
void markAsBroadcastMessage();
|
||||
|
||||
//! Mark as relayed and keep original sender
|
||||
void makeRelayedMessage(const Aviation::CCallsign &partnerCallsign);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user