1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-08 15:52:53 +08:00

Add pill displaying current freestyle status

This commit is contained in:
Dan Balasescu 2025-01-27 18:45:52 +09:00
parent ca979d3542
commit fc73037d9f
No known key found for this signature in database
2 changed files with 69 additions and 0 deletions

View File

@ -169,6 +169,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
new FreeStyleStatusPill(Room)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
endDateInfo = new EndDateInfo(Room)
{
Anchor = Anchor.CentreLeft,

View File

@ -0,0 +1,64 @@
// 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.
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Online.Rooms;
using osuTK.Graphics;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
public class FreeStyleStatusPill : OnlinePlayPill
{
private readonly Room room;
[Resolved]
private OsuColour colours { get; set; } = null!;
protected override FontUsage Font => base.Font.With(weight: FontWeight.SemiBold);
public FreeStyleStatusPill(Room room)
{
this.room = room;
}
protected override void LoadComplete()
{
base.LoadComplete();
Pill.Background.Alpha = 1;
Pill.Background.Colour = colours.Yellow;
TextFlow.Text = "Freestyle";
TextFlow.Colour = Color4.Black;
room.PropertyChanged += onRoomPropertyChanged;
updateFreeStyleStatus();
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(Room.CurrentPlaylistItem):
case nameof(Room.Playlist):
updateFreeStyleStatus();
break;
}
}
private void updateFreeStyleStatus()
{
PlaylistItem? currentItem = room.Playlist.GetCurrentItem() ?? room.CurrentPlaylistItem;
Alpha = currentItem?.FreeStyle == true ? 1 : 0;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
room.PropertyChanged -= onRoomPropertyChanged;
}
}
}