1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 18:47:27 +08:00

Use correct fonts and colours in ChannelListingItem

This commit is contained in:
Jai Sharma 2022-03-09 00:33:46 +00:00
parent 7dd51a9c4a
commit 7daa2d0ea4

View File

@ -31,20 +31,18 @@ namespace osu.Game.Overlays.NewChat
private readonly Channel channel; private readonly Channel channel;
private const float TEXT_SIZE = 18;
private const float ICON_SIZE = 14;
private Colour4 selectedColour;
private Colour4 normalColour;
private Box hoverBox = null!; private Box hoverBox = null!;
private SpriteIcon checkbox = null!; private SpriteIcon checkbox = null!;
private OsuSpriteText channelText = null!; private OsuSpriteText channelText = null!;
private OsuSpriteText topicText = null!;
private IBindable<bool> channelJoined = null!; private IBindable<bool> channelJoined = null!;
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!; private OverlayColourProvider colourProvider { get; set; } = null!;
private const float text_size = 18;
private const float icon_size = 14;
public ChannelListingItem(Channel channel) public ChannelListingItem(Channel channel)
{ {
this.channel = channel; this.channel = channel;
@ -87,31 +85,30 @@ namespace osu.Game.Overlays.NewChat
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 15 }, Margin = new MarginPadding { Left = 15 },
Icon = FontAwesome.Solid.Check, Icon = FontAwesome.Solid.Check,
Size = new Vector2(ICON_SIZE), Size = new Vector2(icon_size),
}, },
channelText = new OsuSpriteText channelText = new OsuSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = $"# {channel.Name.Substring(1)}", Text = channel.Name,
Font = OsuFont.Torus.With(size: TEXT_SIZE, weight: FontWeight.Medium), Font = OsuFont.Torus.With(size: text_size, weight: FontWeight.SemiBold),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
}, },
new OsuSpriteText topicText = new OsuSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = channel.Topic, Text = channel.Topic,
Font = OsuFont.Torus.With(size: TEXT_SIZE), Font = OsuFont.Torus.With(size: text_size),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
Colour = Colour4.White,
}, },
new SpriteIcon new SpriteIcon
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Icon = FontAwesome.Solid.User, Icon = FontAwesome.Solid.User,
Size = new Vector2(ICON_SIZE), Size = new Vector2(icon_size),
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
Colour = colourProvider.Light3, Colour = colourProvider.Light3,
}, },
@ -120,7 +117,7 @@ namespace osu.Game.Overlays.NewChat
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = "0", Text = "0",
Font = OsuFont.Numeric.With(size: TEXT_SIZE, weight: FontWeight.Medium), Font = OsuFont.Torus.With(size: text_size),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
Colour = colourProvider.Light3, Colour = colourProvider.Light3,
}, },
@ -134,27 +131,23 @@ namespace osu.Game.Overlays.NewChat
{ {
base.LoadComplete(); base.LoadComplete();
// Set colours
normalColour = colourProvider.Light3;
selectedColour = Colour4.White;
// Set handlers for state display
channelJoined = channel.Joined.GetBoundCopy(); channelJoined = channel.Joined.GetBoundCopy();
channelJoined.BindValueChanged(change => channelJoined.BindValueChanged(change =>
{ {
if (change.NewValue) if (change.NewValue)
{ {
checkbox.Show(); checkbox.Show();
channelText.Colour = selectedColour; channelText.Colour = Colour4.White;
topicText.Colour = Colour4.White;
} }
else else
{ {
checkbox.Hide(); checkbox.Hide();
channelText.Colour = normalColour; channelText.Colour = colourProvider.Light3;
topicText.Colour = colourProvider.Content2;
} }
}, true); }, true);
// Set action on click
Action = () => (channelJoined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); Action = () => (channelJoined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(channel);
} }