1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00

Merge pull request #32607 from smoogipoo/fix-mp-panel-background

Fix background not showing in multiplayer room panel
This commit is contained in:
Bartłomiej Dach
2025-03-27 14:00:20 +01:00
committed by GitHub
Unverified
@@ -46,22 +46,26 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
[Resolved]
private OsuGame? game { get; set; }
[Resolved]
private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
public readonly Room Room;
protected readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
protected Container ButtonsContainer { get; private set; } = null!;
private readonly Bindable<MatchType> roomType = new Bindable<MatchType>();
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
private DrawableRoomParticipantsList? drawableRoomParticipantsList;
private RoomSpecialCategoryPill? specialCategoryPill;
private PasswordProtectedIcon? passwordIcon;
private EndDateInfo? endDateInfo;
private SpriteText? roomName;
private UpdateableBeatmapBackgroundSprite background = null!;
private DelayedLoadWrapper wrapper = null!;
private CancellationTokenSource? beatmapLookupCancellation;
/// <summary>
/// A fully-populated representation of the selected item's current beatmap.
/// </summary>
private readonly Bindable<IBeatmapInfo?> currentBeatmap = new Bindable<IBeatmapInfo?>();
protected RoomPanel(Room room)
{
@@ -99,9 +103,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
RelativeSizeAxes = Axes.Both,
Colour = colours.Background5,
},
background = CreateBackground().With(d =>
CreateBackground().With(d =>
{
d.RelativeSizeAxes = Axes.Both;
d.Beatmap.BindTarget = currentBeatmap;
}),
wrapper = new DelayedLoadWrapper(() =>
new Container
@@ -206,7 +211,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
},
new RoomStatusText(Room)
{
SelectedItem = { BindTarget = SelectedItem }
Beatmap = { BindTarget = currentBeatmap }
}
}
}
@@ -280,7 +285,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
updateRoomHasPassword();
};
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap, true);
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
@@ -305,6 +310,30 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
}
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem?> item)
{
if (item.NewValue?.Beatmap.OnlineID == item.OldValue?.Beatmap.OnlineID)
return;
beatmapLookupCancellation?.Cancel();
beatmapLookupCancellation?.Dispose();
if (item.NewValue?.Beatmap == null)
{
currentBeatmap.Value = null;
return;
}
var cancellationSource = beatmapLookupCancellation = new CancellationTokenSource();
beatmapLookupCache.GetBeatmapAsync(item.NewValue.Beatmap.OnlineID, cancellationSource.Token)
.ContinueWith(task => Schedule(() =>
{
if (!cancellationSource.IsCancellationRequested)
currentBeatmap.Value = task.GetResultSafely();
}), cancellationSource.Token);
}
private void updateRoomName()
{
if (roomName != null)
@@ -406,14 +435,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private partial class RoomStatusText : CompositeDrawable
{
public readonly IBindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
public readonly Bindable<IBeatmapInfo?> Beatmap = new Bindable<IBeatmapInfo?>();
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
private readonly Room room;
private SpriteText statusText = null!;
private LinkFlowContainer beatmapText = null!;
@@ -469,14 +495,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
protected override void LoadComplete()
{
base.LoadComplete();
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
Beatmap.BindValueChanged(onBeatmapChanged, true);
}
private CancellationTokenSource? beatmapLookupCancellation;
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem?> item)
private void onBeatmapChanged(ValueChangedEvent<IBeatmapInfo?> beatmap)
{
beatmapLookupCancellation?.Cancel();
beatmapText.Clear();
if (room.Type == MatchType.Playlists)
@@ -485,31 +509,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
return;
}
var beatmap = item.NewValue?.Beatmap;
if (beatmap == null)
return;
var cancellationSource = beatmapLookupCancellation = new CancellationTokenSource();
beatmapLookupCache.GetBeatmapAsync(beatmap.OnlineID, cancellationSource.Token)
.ContinueWith(task => Schedule(() =>
{
if (cancellationSource.IsCancellationRequested)
return;
var retrievedBeatmap = task.GetResultSafely();
statusText.Text = "Currently playing ";
if (retrievedBeatmap != null)
if (beatmap.NewValue != null)
{
beatmapText.AddLink(retrievedBeatmap.GetDisplayTitleRomanisable(),
beatmapText.AddLink(beatmap.NewValue.GetDisplayTitleRomanisable(),
LinkAction.OpenBeatmap,
retrievedBeatmap.OnlineID.ToString(),
beatmap.NewValue.OnlineID.ToString(),
creationParameters: s => s.Truncate = true);
}
else
beatmapText.AddText("unknown beatmap");
}), cancellationSource.Token);
}
}