mirror of
https://github.com/ppy/osu
synced 2025-01-23 06:13:12 +00:00
Improve design as requested
This commit is contained in:
parent
52acd23a5a
commit
e58ea97604
@ -8,8 +8,9 @@ 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;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
@ -61,6 +62,8 @@ namespace osu.Game.Overlays.Chat
|
||||
private const float message_padding = 200;
|
||||
private const float text_size = 20;
|
||||
|
||||
private Color4 customUsernameColour;
|
||||
|
||||
public ChatLine(Message message)
|
||||
{
|
||||
Message = message;
|
||||
@ -69,33 +72,58 @@ namespace osu.Game.Overlays.Chat
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Padding = new MarginPadding { Left = padding, Right = padding };
|
||||
}
|
||||
|
||||
bool hasBackground = !string.IsNullOrEmpty(message.Sender?.Colour);
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
customUsernameColour = colours.ChatBlue;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
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],
|
||||
Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"),
|
||||
Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length],
|
||||
TextSize = text_size,
|
||||
};
|
||||
|
||||
if (hasBackground)
|
||||
{
|
||||
// Background effect
|
||||
username = username.WithEffect(new EdgeEffect
|
||||
{
|
||||
CornerRadius = 4,
|
||||
Parameters = new EdgeEffectParameters
|
||||
{
|
||||
Radius = 1,
|
||||
Colour = OsuColour.FromHex(message.Sender.Colour),
|
||||
Colour = OsuColour.FromHex(Message.Sender.Colour),
|
||||
Type = EdgeEffectType.Shadow,
|
||||
}
|
||||
}, d =>
|
||||
{
|
||||
d.Padding = new MarginPadding { Top = -2 };
|
||||
d.Y = 2;
|
||||
d.Padding = new MarginPadding { Left = 3, Right = 3, Bottom = 1, Top = -3 };
|
||||
d.Y = 3;
|
||||
})
|
||||
// Drop shadow effect
|
||||
.WithEffect(new EdgeEffect
|
||||
{
|
||||
CornerRadius = 4,
|
||||
Parameters = new EdgeEffectParameters
|
||||
{
|
||||
Roundness = 1,
|
||||
Offset = new Vector2(0, 3),
|
||||
Radius = 3,
|
||||
Colour = Color4.Black.Opacity(0.3f),
|
||||
Type = EdgeEffectType.Shadow,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -104,7 +132,7 @@ namespace osu.Game.Overlays.Chat
|
||||
new Container
|
||||
{
|
||||
Size = new Vector2(message_padding, text_size),
|
||||
Children = new Drawable[]
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user