1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-11 07:13:00 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Components/StatusColouredContainer.cs

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

53 lines
1.6 KiB
C#
Raw Normal View History

// 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.
2024-11-13 17:48:13 +08:00
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
2024-11-13 17:48:13 +08:00
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Screens.OnlinePlay.Components
{
public partial class StatusColouredContainer : Container
{
2024-11-13 17:48:13 +08:00
[Resolved]
private OsuColour colours { get; set; } = null!;
2024-11-13 17:48:13 +08:00
private readonly double transitionDuration;
2024-11-13 17:27:32 +08:00
private readonly Room room;
2024-11-13 17:27:32 +08:00
public StatusColouredContainer(Room room, double transitionDuration = 100)
{
2024-11-13 17:27:32 +08:00
this.room = room;
this.transitionDuration = transitionDuration;
}
2024-11-13 17:48:13 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
room.PropertyChanged += onRoomPropertyChanged;
updateRoomStatus();
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Room.Status))
updateRoomStatus();
}
private void updateRoomStatus()
{
this.FadeColour(colours.ForRoomCategory(room.Category) ?? room.Status.GetAppropriateColour(colours), transitionDuration);
}
protected override void Dispose(bool isDisposing)
{
2024-11-13 17:48:13 +08:00
base.Dispose(isDisposing);
room.PropertyChanged -= onRoomPropertyChanged;
}
}
}