Work around duplicated notification sound when the ingame menu is open.

This commit is contained in:
Paul Chote
2018-01-25 18:37:34 +00:00
committed by reaperrr
parent 73f5f1fa75
commit fc31fac1f0

View File

@@ -196,14 +196,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public void AddChatLineWrapper(Color c, string from, string text)
{
AddChatLine(c, from, text, false);
}
void AddChatLine(Color c, string from, string text, bool replayCache)
{
if (!replayCache && chatOverlayDisplay != null)
if (chatOverlayDisplay != null)
chatOverlayDisplay.AddLine(c, from, text);
// HACK: Force disable the chat notification sound for the in-menu chat dialog
// This works around our inability to disable the sounds for the in-game dialog when it is hidden
AddChatLine(c, from, text, chatOverlay == null);
}
void AddChatLine(Color c, string from, string text, bool suppressSound)
{
var template = chatTemplate.Clone();
var nameLabel = template.Get<LabelWidget>("NAME");
var textLabel = template.Get<LabelWidget>("TEXT");
@@ -236,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (scrolledToBottom)
chatScrollPanel.ScrollToBottom(smooth: true);
if (!replayCache)
if (!suppressSound)
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}