mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 20:33:35 +08:00
Fix background not showing in multiplayer room panel
This commit is contained in:
@@ -46,6 +46,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuGame? game { get; set; }
|
private OsuGame? game { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
|
||||||
|
|
||||||
public readonly Room Room;
|
public readonly Room Room;
|
||||||
|
|
||||||
protected readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
|
protected readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
|
||||||
@@ -56,8 +59,13 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
private PasswordProtectedIcon? passwordIcon;
|
private PasswordProtectedIcon? passwordIcon;
|
||||||
private EndDateInfo? endDateInfo;
|
private EndDateInfo? endDateInfo;
|
||||||
private SpriteText? roomName;
|
private SpriteText? roomName;
|
||||||
private UpdateableBeatmapBackgroundSprite background = null!;
|
|
||||||
private DelayedLoadWrapper wrapper = 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)
|
protected RoomPanel(Room room)
|
||||||
{
|
{
|
||||||
@@ -95,9 +103,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Background5,
|
Colour = colours.Background5,
|
||||||
},
|
},
|
||||||
background = CreateBackground().With(d =>
|
CreateBackground().With(d =>
|
||||||
{
|
{
|
||||||
d.RelativeSizeAxes = Axes.Both;
|
d.RelativeSizeAxes = Axes.Both;
|
||||||
|
d.Beatmap.BindTarget = currentBeatmap;
|
||||||
}),
|
}),
|
||||||
wrapper = new DelayedLoadWrapper(() =>
|
wrapper = new DelayedLoadWrapper(() =>
|
||||||
new Container
|
new Container
|
||||||
@@ -202,7 +211,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
},
|
},
|
||||||
new RoomStatusText(Room)
|
new RoomStatusText(Room)
|
||||||
{
|
{
|
||||||
SelectedItem = { BindTarget = SelectedItem }
|
Beatmap = { BindTarget = currentBeatmap }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +285,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
updateRoomHasPassword();
|
updateRoomHasPassword();
|
||||||
};
|
};
|
||||||
|
|
||||||
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap, true);
|
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
@@ -301,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()
|
private void updateRoomName()
|
||||||
{
|
{
|
||||||
if (roomName != null)
|
if (roomName != null)
|
||||||
@@ -402,14 +435,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
|
|
||||||
private partial class RoomStatusText : CompositeDrawable
|
private partial class RoomStatusText : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly IBindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
|
public readonly Bindable<IBeatmapInfo?> Beatmap = new Bindable<IBeatmapInfo?>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; } = null!;
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
|
|
||||||
|
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
private SpriteText statusText = null!;
|
private SpriteText statusText = null!;
|
||||||
private LinkFlowContainer beatmapText = null!;
|
private LinkFlowContainer beatmapText = null!;
|
||||||
@@ -465,14 +495,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
|
|
||||||
|
Beatmap.BindValueChanged(onBeatmapChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource? beatmapLookupCancellation;
|
private void onBeatmapChanged(ValueChangedEvent<IBeatmapInfo?> beatmap)
|
||||||
|
|
||||||
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem?> item)
|
|
||||||
{
|
{
|
||||||
beatmapLookupCancellation?.Cancel();
|
|
||||||
beatmapText.Clear();
|
beatmapText.Clear();
|
||||||
|
|
||||||
if (room.Type == MatchType.Playlists)
|
if (room.Type == MatchType.Playlists)
|
||||||
@@ -481,31 +509,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var beatmap = item.NewValue?.Beatmap;
|
statusText.Text = "Currently playing ";
|
||||||
if (beatmap == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var cancellationSource = beatmapLookupCancellation = new CancellationTokenSource();
|
if (beatmap.NewValue != null)
|
||||||
beatmapLookupCache.GetBeatmapAsync(beatmap.OnlineID, cancellationSource.Token)
|
{
|
||||||
.ContinueWith(task => Schedule(() =>
|
beatmapText.AddLink(beatmap.NewValue.GetDisplayTitleRomanisable(),
|
||||||
{
|
LinkAction.OpenBeatmap,
|
||||||
if (cancellationSource.IsCancellationRequested)
|
beatmap.NewValue.OnlineID.ToString(),
|
||||||
return;
|
creationParameters: s => s.Truncate = true);
|
||||||
|
}
|
||||||
var retrievedBeatmap = task.GetResultSafely();
|
else
|
||||||
|
beatmapText.AddText("unknown beatmap");
|
||||||
statusText.Text = "Currently playing ";
|
|
||||||
|
|
||||||
if (retrievedBeatmap != null)
|
|
||||||
{
|
|
||||||
beatmapText.AddLink(retrievedBeatmap.GetDisplayTitleRomanisable(),
|
|
||||||
LinkAction.OpenBeatmap,
|
|
||||||
retrievedBeatmap.OnlineID.ToString(),
|
|
||||||
creationParameters: s => s.Truncate = true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
beatmapText.AddText("unknown beatmap");
|
|
||||||
}), cancellationSource.Token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user