From ca1e0b4c4899e1ff7658a90ea9273a45c1d559f8 Mon Sep 17 00:00:00 2001 From: Carko Date: Tue, 1 Jan 2013 17:56:53 +0100 Subject: [PATCH] Added word wrapping to in-game chat (fixes #2093) --- OpenRA.Game/Widgets/ChatDisplayWidget.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Widgets/ChatDisplayWidget.cs b/OpenRA.Game/Widgets/ChatDisplayWidget.cs index d44eae8305..9a132b8339 100644 --- a/OpenRA.Game/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Game/Widgets/ChatDisplayWidget.cs @@ -46,19 +46,26 @@ namespace OpenRA.Widgets foreach (var line in recentLines.AsEnumerable().Reverse()) { - chatpos.Y -= 20; var inset = 0; + string owner = null; if (!string.IsNullOrEmpty(line.Owner)) { - var owner = line.Owner + ":"; + owner = line.Owner + ":"; inset = font.Measure(owner).X + 10; + } + var text = WidgetUtils.WrapText(line.Text, chatLogArea.Width - inset, font); + var textLines = text.Split(new[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries).Count(); + chatpos.Y -= 20 * textLines; + + if (owner != null) + { font.DrawTextWithContrast(owner, chatpos, line.Color, Color.Black, UseContrast ? 1 : 0); } - font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0), + font.DrawTextWithContrast(text, chatpos + new int2(inset, 0), Color.White, Color.Black, UseContrast ? 1 : 0); }