2021-07-12 14:11:07 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-12 14:11:07 +08:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Online.Rooms.RoomStatuses;
|
|
|
|
|
2021-07-13 15:02:18 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
2021-07-12 14:11:07 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A pill that displays the room's current status.
|
|
|
|
/// </summary>
|
2023-05-16 15:53:11 +08:00
|
|
|
public partial class RoomStatusPill : OnlinePlayPill
|
2021-07-12 14:11:07 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
EndDate.BindValueChanged(_ => updateDisplay());
|
|
|
|
Status.BindValueChanged(_ => updateDisplay(), true);
|
2021-08-12 08:13:10 +08:00
|
|
|
|
|
|
|
FinishTransforms(true);
|
2023-05-16 16:22:52 +08:00
|
|
|
|
|
|
|
TextFlow.Colour = Colour4.Black;
|
2023-05-17 15:13:54 +08:00
|
|
|
Pill.Background.Alpha = 1;
|
2021-07-12 14:11:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateDisplay()
|
|
|
|
{
|
2021-08-09 15:21:12 +08:00
|
|
|
RoomStatus status = getDisplayStatus();
|
2021-07-12 14:11:07 +08:00
|
|
|
|
2023-05-16 16:06:48 +08:00
|
|
|
Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
2023-05-17 15:13:54 +08:00
|
|
|
TextFlow.Text = status.Message;
|
2021-07-12 14:11:07 +08:00
|
|
|
}
|
2021-08-09 15:21:12 +08:00
|
|
|
|
|
|
|
private RoomStatus getDisplayStatus()
|
|
|
|
{
|
|
|
|
if (EndDate.Value < DateTimeOffset.Now)
|
|
|
|
return new RoomStatusEnded();
|
|
|
|
|
2021-08-12 08:14:46 +08:00
|
|
|
return Status.Value;
|
2021-08-09 15:21:12 +08:00
|
|
|
}
|
2021-07-12 14:11:07 +08:00
|
|
|
}
|
|
|
|
}
|