1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 05:52:56 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomStatusPill.cs

54 lines
1.5 KiB
C#
Raw Normal View History

2023-06-23 00:37:25 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2021-07-12 14:11:07 +08:00
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
2021-07-12 14:11:07 +08:00
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]
2023-06-23 00:37:25 +08:00
private OsuColour colours { get; set; } = null!;
2021-07-12 14:11:07 +08:00
protected override FontUsage Font => base.Font.With(weight: FontWeight.SemiBold);
2021-07-12 14:11:07 +08:00
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
}
}