System messages should be yellow to distinguish them from normal

This commit is contained in:
teinarss
2019-03-27 19:17:02 +01:00
committed by abcdefg30
parent db487e1264
commit d9d2202599
16 changed files with 87 additions and 61 deletions

View File

@@ -206,7 +206,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatScrollPanel.ScrollToBottom();
foreach (var chatLine in orderManager.ChatCache)
AddChatLine(chatLine.Color, chatLine.Name, chatLine.Text, true);
AddChatLine(chatLine.Name, chatLine.Color, chatLine.Text, chatLine.TextColor, true);
orderManager.AddChatLine += AddChatLineWrapper;
@@ -255,17 +255,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatOverlay.Visible = true;
}
public void AddChatLineWrapper(Color c, string from, string text)
public void AddChatLineWrapper(string name, Color nameColor, string text, Color textColor)
{
if (chatOverlayDisplay != null)
chatOverlayDisplay.AddLine(c, from, text);
chatOverlayDisplay.AddLine(name, nameColor, text, textColor);
// 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);
AddChatLine(name, nameColor, text, textColor, chatOverlay == null);
}
void AddChatLine(Color c, string from, string text, bool suppressSound)
void AddChatLine(string @from, Color nameColor, string text, Color textColor, bool suppressSound)
{
var template = chatTemplate.Clone();
var nameLabel = template.Get<LabelWidget>("NAME");
@@ -278,9 +278,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var font = Game.Renderer.Fonts[nameLabel.Font];
var nameSize = font.Measure(from);
nameLabel.GetColor = () => c;
nameLabel.GetColor = () => nameColor;
nameLabel.GetText = () => name;
nameLabel.Bounds.Width = nameSize.X;
textLabel.GetColor = () => textColor;
textLabel.Bounds.X += nameSize.X;
textLabel.Bounds.Width -= nameSize.X;

View File

@@ -475,10 +475,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
panel = PanelType.Players;
}
void AddChatLine(Color c, string from, string text)
void AddChatLine(string name, Color nameColor, string text, Color textColor)
{
var template = (ContainerWidget)chatTemplate.Clone();
LobbyUtils.SetupChatLine(template, c, DateTime.Now, from, text);
LobbyUtils.SetupChatLine(template, DateTime.Now, name, nameColor, text, textColor);
var scrolledToBottom = lobbyChatPanel.ScrolledToBottom;
lobbyChatPanel.AddChild(template);

View File

@@ -621,21 +621,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return address;
}
public static void SetupChatLine(ContainerWidget template, Color c, DateTime time, string from, string text)
public static void SetupChatLine(ContainerWidget template, DateTime time, string name, Color nameColor, string text, Color textColor)
{
var nameLabel = template.Get<LabelWidget>("NAME");
var timeLabel = template.Get<LabelWidget>("TIME");
var textLabel = template.Get<LabelWidget>("TEXT");
var name = from + ":";
var nameText = name + ":";
var font = Game.Renderer.Fonts[nameLabel.Font];
var nameSize = font.Measure(from);
var nameSize = font.Measure(nameText);
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
nameLabel.GetColor = () => c;
nameLabel.GetText = () => name;
nameLabel.GetColor = () => nameColor;
nameLabel.GetText = () => nameText;
nameLabel.Bounds.Width = nameSize.X;
textLabel.GetColor = () => textColor;
textLabel.Bounds.X += nameSize.X;
textLabel.Bounds.Width -= nameSize.X;

View File

@@ -30,12 +30,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Game.Settings.Sound.Mute)
{
Game.Sound.MuteAudio();
Game.AddChatLine(Color.White, "Battlefield Control", "Audio muted");
Game.AddChatLine("Battlefield Control", Color.White, "Audio muted");
}
else
{
Game.Sound.UnmuteAudio();
Game.AddChatLine(Color.White, "Battlefield Control", "Audio unmuted");
Game.AddChatLine("Battlefield Control", Color.White, "Audio unmuted");
}
return true;