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

@@ -195,7 +195,7 @@ namespace OpenRA.Mods.Common.Scripting
return;
var c = color.HasValue ? color.Value : Color.White;
Game.AddChatLine(c, prefix, text);
Game.AddChatLine(prefix, c, text);
}
[Desc("Displays a debug message to the player, if \"Show Map Debug Messages\" is checked in the settings.")]

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is defeated.");
Game.AddSystemLine("Battlefield Control", player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is victorious.");
Game.AddSystemLine("Battlefield Control", player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is defeated.");
Game.AddSystemLine("Battlefield Control", player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is victorious.");
Game.AddSystemLine("Battlefield Control", player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -43,12 +43,12 @@ namespace OpenRA.Mods.Common.Widgets
foreach (var line in recentLines.AsEnumerable().Reverse())
{
var inset = 0;
string owner = null;
string name = null;
if (!string.IsNullOrEmpty(line.Owner))
if (!string.IsNullOrEmpty(line.Name))
{
owner = line.Owner + ":";
inset = font.Measure(owner).X + 5;
name = line.Name + ":";
inset = font.Measure(name).X + 5;
}
var text = WidgetUtils.WrapText(line.Text, chatLogArea.Width - inset - 6, font);
@@ -57,24 +57,24 @@ namespace OpenRA.Mods.Common.Widgets
if (chatpos.Y < pos.Y)
break;
if (owner != null)
if (name != null)
{
if (UseContrast)
font.DrawTextWithContrast(owner, chatpos,
line.Color, BackgroundColorDark, BackgroundColorLight, 1);
font.DrawTextWithContrast(name, chatpos,
line.NameColor, BackgroundColorDark, BackgroundColorLight, 1);
else if (UseShadow)
font.DrawTextWithShadow(owner, chatpos,
line.Color, BackgroundColorDark, BackgroundColorLight, 1);
font.DrawTextWithShadow(name, chatpos,
line.NameColor, BackgroundColorDark, BackgroundColorLight, 1);
else
font.DrawText(owner, chatpos, line.Color);
font.DrawText(name, chatpos, line.NameColor);
}
if (UseContrast)
font.DrawTextWithContrast(text, chatpos + new int2(inset, 0),
Color.White, Color.Black, 1);
line.TextColor, Color.Black, 1);
else if (UseShadow)
font.DrawTextWithShadow(text, chatpos + new int2(inset, 0),
Color.White, Color.Black, 1);
line.TextColor, Color.Black, 1);
else
font.DrawText(text, chatpos + new int2(inset, 0), Color.White);
}
@@ -82,9 +82,9 @@ namespace OpenRA.Mods.Common.Widgets
Game.Renderer.DisableScissor();
}
public void AddLine(Color c, string from, string text)
public void AddLine(string name, Color nameColor, string text, Color textColor)
{
recentLines.Add(new ChatLine(from, text, Game.LocalTick + RemoveTime, c));
recentLines.Add(new ChatLine(name, nameColor, text, textColor, Game.LocalTick + RemoveTime));
if (Notification != null)
Game.Sound.Play(SoundType.UI, Notification);
@@ -112,16 +112,18 @@ namespace OpenRA.Mods.Common.Widgets
class ChatLine
{
public readonly Color Color;
public readonly string Owner, Text;
public readonly Color NameColor;
public readonly Color TextColor;
public readonly string Name, Text;
public readonly int Expiration;
public ChatLine(string owner, string text, int expiration, Color color)
public ChatLine(string name, Color nameColor, string text, Color textColor, int expiration)
{
Owner = owner;
Name = name;
Text = text;
Expiration = expiration;
Color = color;
NameColor = nameColor;
TextColor = textColor;
}
}
}

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;

View File

@@ -255,12 +255,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units
if (ownUnitsOnScreen.Count > World.Selection.Actors.Count())
Game.AddChatLine(Color.White, "Battlefield Control", "Selected across screen");
Game.AddSystemLine("Battlefield Control", "Selected across screen");
else
{
// Select actors in the world that have highest selection priority
ownUnitsOnScreen = SelectActorsInWorld(World, null, player).SubsetWithHighestSelectionPriority().ToList();
Game.AddChatLine(Color.White, "Battlefield Control", "Selected across map");
Game.AddSystemLine("Battlefield Control", "Selected across map");
}
World.Selection.Combine(World, ownUnitsOnScreen, false, false);
@@ -281,12 +281,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > World.Selection.Actors.Count())
Game.AddChatLine(Color.White, "Battlefield Control", "Selected across screen");
Game.AddSystemLine("Battlefield Control", "Selected across screen");
else
{
// Select actors in the world that have the same selection class as one of the already selected actors
newSelection = SelectActorsInWorld(World, selectedClasses, player).ToList();
Game.AddChatLine(Color.White, "Battlefield Control", "Selected across map");
Game.AddSystemLine("Battlefield Control", "Selected across map");
}
World.Selection.Combine(World, newSelection, true, false);