1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 21:57:25 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.4 KiB
C#
Raw Normal View History

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>
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;
Pill.Background.Alpha = 1;
2021-07-12 14:11:07 +08:00
}
private void updateDisplay()
{
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);
TextFlow.Text = status.Message;
2021-07-12 14:11:07 +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-07-12 14:11:07 +08:00
}
}