1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

Add user colour support.

This commit is contained in:
Dean Herbert 2017-04-19 19:07:38 +09:00
parent 3129708ccb
commit dda3fb85ee
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
3 changed files with 7 additions and 4 deletions

View File

@ -55,6 +55,9 @@ namespace osu.Game.Online.Chat.Drawables
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];
}
@ -91,7 +94,7 @@ namespace osu.Game.Online.Chat.Drawables
new OsuSpriteText
{
Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.User.Username}:",
Text = $@"{Message.Sender.Username}:",
Colour = getUsernameColour(Message),
TextSize = text_size,
Origin = Anchor.TopRight,

View File

@ -14,7 +14,7 @@ namespace osu.Game.Online.Chat
public readonly long Id;
//todo: this should be inside sender.
[JsonProperty(@"user_id")]
[JsonProperty(@"sender_id")]
public int UserId;
[JsonProperty(@"target_type")]
@ -30,7 +30,7 @@ namespace osu.Game.Online.Chat
public string Content;
[JsonProperty(@"sender")]
public User User;
public User Sender;
[JsonConstructor]
public Message()

View File

@ -101,7 +101,7 @@ namespace osu.Game.Overlays
var message = new Message
{
User = api.LocalUser.Value,
Sender = api.LocalUser.Value,
Timestamp = DateTimeOffset.Now,
TargetType = TargetType.Channel, //TODO: read this from currentChannel
TargetId = currentChannel.Id,