1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +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) 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. //todo: use User instead of Message when user_id is correctly populated.
return username_colours[message.UserId % username_colours.Length]; return username_colours[message.UserId % username_colours.Length];
} }
@ -91,7 +94,7 @@ namespace osu.Game.Online.Chat.Drawables
new OsuSpriteText new OsuSpriteText
{ {
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.User.Username}:", Text = $@"{Message.Sender.Username}:",
Colour = getUsernameColour(Message), Colour = getUsernameColour(Message),
TextSize = text_size, TextSize = text_size,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,

View File

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

View File

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