1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 14:12:54 +08:00

Highlight custom-named users

This commit is contained in:
Thomas Müller 2017-07-18 10:53:41 +03:00
parent aa15d369c3
commit e72c009dd7
2 changed files with 33 additions and 19 deletions

@ -1 +1 @@
Subproject commit 991177da4fbed2dd8260c215f2d341ebc858b03e
Subproject commit 9669c3e06715330e1c8544676caf7fbc0328e92d

View File

@ -8,6 +8,8 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Effects;
namespace osu.Game.Overlays.Chat
{
@ -53,15 +55,6 @@ namespace osu.Game.Overlays.Chat
OsuColour.FromHex("992861"),
};
private Color4 getUsernameColour(Message message)
{
if (!string.IsNullOrEmpty(message.Sender?.Colour))
return OsuColour.FromHex(message.Sender.Colour);
//todo: use User instead of Message when user_id is correctly populated.
return username_colours[message.UserId % username_colours.Length];
}
public const float LEFT_PADDING = message_padding + padding * 2;
private const float padding = 15;
@ -77,6 +70,35 @@ namespace osu.Game.Overlays.Chat
Padding = new MarginPadding { Left = padding, Right = padding };
bool hasBackground = !string.IsNullOrEmpty(message.Sender?.Colour);
Drawable username = new OsuSpriteText
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.Sender.Username}:",
Colour = hasBackground ? Color4.Black : username_colours[message.UserId % username_colours.Length],
TextSize = text_size,
};
if (hasBackground)
{
username = username.WithEffect(new EdgeEffect
{
CornerRadius = 4,
Parameters = new EdgeEffectParameters
{
Radius = 1,
Colour = OsuColour.FromHex(message.Sender.Colour),
Type = EdgeEffectType.Shadow,
}
}, d =>
{
d.Padding = new MarginPadding { Top = -2 };
d.Y = 2;
});
}
Children = new Drawable[]
{
new Container
@ -94,15 +116,7 @@ namespace osu.Game.Overlays.Chat
TextSize = text_size * 0.75f,
Alpha = 0.4f,
},
new OsuSpriteText
{
Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.Sender.Username}:",
Colour = getUsernameColour(Message),
TextSize = text_size,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
}
username
}
},
new Container