1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-16 07:43:21 +08:00

Redesign RoomStatusInfo

This commit is contained in:
smoogipoo 2021-07-06 18:50:27 +09:00
parent 14b6949456
commit 2ddfa15a80

View File

@ -4,12 +4,16 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Online.Rooms.RoomStatuses; using osu.Game.Online.Rooms.RoomStatuses;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.OnlinePlay.Components namespace osu.Game.Screens.OnlinePlay.Components
{ {
@ -23,26 +27,28 @@ namespace osu.Game.Screens.OnlinePlay.Components
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
StatusPart statusPart; StatusPill statusPill;
EndDatePart endDatePart; EndDatePart endDatePart;
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Horizontal,
Spacing = new Vector2(2),
Children = new Drawable[] Children = new Drawable[]
{ {
statusPart = new StatusPart statusPill = new StatusPill(),
endDatePart = new EndDatePart
{ {
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14) Anchor = Anchor.CentreLeft,
}, Origin = Anchor.CentreLeft,
endDatePart = new EndDatePart { Font = OsuFont.GetFont(size: 14) } Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12)
}
} }
}; };
statusPart.EndDate.BindTo(EndDate); statusPill.EndDate.BindTo(EndDate);
statusPart.Status.BindTo(Status); statusPill.Status.BindTo(Status);
statusPart.Availability.BindTo(Availability);
endDatePart.EndDate.BindTo(EndDate); endDatePart.EndDate.BindTo(EndDate);
} }
@ -80,37 +86,49 @@ namespace osu.Game.Screens.OnlinePlay.Components
} }
} }
private class StatusPart : EndDatePart private class StatusPill : CompositeDrawable
{ {
public readonly IBindable<DateTimeOffset?> EndDate = new Bindable<DateTimeOffset?>();
public readonly IBindable<RoomStatus> Status = new Bindable<RoomStatus>(); public readonly IBindable<RoomStatus> Status = new Bindable<RoomStatus>();
public readonly IBindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
public StatusPart() private Drawable background;
private SpriteText statusText;
[BackgroundDependencyLoader]
private void load()
{ {
EndDate.BindValueChanged(_ => Format()); Size = new Vector2(60, 16);
Status.BindValueChanged(_ => Format());
Availability.BindValueChanged(_ => Format()); InternalChildren = new[]
{
background = new Circle { RelativeSizeAxes = Axes.Both },
statusText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
Colour = Color4.Black
}
};
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Text = Format(); EndDate.BindValueChanged(_ => updateDisplay());
Status.BindValueChanged(_ => updateDisplay(), true);
} }
protected override string Format() private void updateDisplay()
{ {
if (!IsLoaded) RoomStatus status = EndDate.Value < DateTimeOffset.Now ? new RoomStatusEnded() : Status.Value ?? new RoomStatusOpen();
return string.Empty;
RoomStatus status = Date < DateTimeOffset.Now ? new RoomStatusEnded() : Status.Value ?? new RoomStatusOpen(); background.FadeColour(status.GetAppropriateColour(colours), 100);
statusText.Text = status.Message;
this.FadeColour(status.GetAppropriateColour(colours), 100);
return $"{Availability.Value.GetDescription()}, {status.Message}";
} }
} }
} }