2019-02-07 16:52:40 +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.
|
|
|
|
|
2024-11-13 17:48:13 +08:00
|
|
|
using System.ComponentModel;
|
2019-02-07 16:52:40 +08:00
|
|
|
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;
|
2019-02-07 16:52:40 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2019-02-07 16:52:40 +08:00
|
|
|
{
|
|
|
|
public partial class StatusColouredContainer : Container
|
|
|
|
{
|
2024-11-13 17:48:13 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; } = null!;
|
2019-02-07 16:52:40 +08:00
|
|
|
|
2024-11-13 17:48:13 +08:00
|
|
|
private readonly double transitionDuration;
|
2024-11-13 17:27:32 +08:00
|
|
|
private readonly Room room;
|
2020-07-10 18:37:27 +08:00
|
|
|
|
2024-11-13 17:27:32 +08:00
|
|
|
public StatusColouredContainer(Room room, double transitionDuration = 100)
|
2019-02-07 16:52:40 +08:00
|
|
|
{
|
2024-11-13 17:27:32 +08:00
|
|
|
this.room = room;
|
2019-02-07 16:52:40 +08:00
|
|
|
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)
|
2019-02-07 16:52:40 +08:00
|
|
|
{
|
2024-11-13 17:48:13 +08:00
|
|
|
base.Dispose(isDisposing);
|
|
|
|
room.PropertyChanged -= onRoomPropertyChanged;
|
2019-02-07 16:52:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|