From 67652a6d8e20b407706ac09a96af07c1d646cd3d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2016 20:45:26 +0900 Subject: [PATCH] Improve formatting of chat lines. --- .../Tests/TestCaseChatDisplay.cs | 6 +-- osu.Game/Online/Chat/Display/ChatLine.cs | 53 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 osu.Game/Online/Chat/Display/ChatLine.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 8f939501c9..7c2092d614 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -15,6 +15,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Graphics.Sprites; +using osu.Game.Online.Chat.Display.osu.Online.Social; namespace osu.Desktop.Tests { @@ -105,10 +106,7 @@ namespace osu.Desktop.Tests // osu.Messages[0].Drawable.Expire(); // osu.Messages.RemoveAt(0); //} - flow.Add(new SpriteText - { - Text = $@"{m.User.Name}: {m.Content}" - }); + flow.Add(new ChatLine(m)); channel.Messages.Add(m); } diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs new file mode 100644 index 0000000000..024571809c --- /dev/null +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -0,0 +1,53 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Online.Chat.Display +{ + namespace osu.Online.Social + { + public class ChatLine : AutoSizeContainer + { + public ChatLine(Message msg) + { + SizeMode = InheritMode.X; + + Add(new Box + { + SizeMode = InheritMode.XY, + Colour = Color4.Aqua, + Alpha = 0.2f + }); + + Add(new SpriteText + { + Text = msg.Timestamp.ToLocalTime().ToLongTimeString(), + Colour = new Color4(128, 128, 128, 255) + }); + + Add(new SpriteText + { + Text = msg.User.Name, + Origin = Anchor.TopRight, + PositionMode = InheritMode.X, + Position = new Vector2(0.14f,0), + }); + + Add(new SpriteText + { + Text = msg.Content, + PositionMode = InheritMode.X, + Position = new Vector2(0.15f, 0), + SizeMode = InheritMode.X, + Size = new Vector2(0.85f, 1), + }); + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0d20b265cf..1264f22848 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -61,6 +61,7 @@ +