mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 00:47:24 +08:00
Fix lounge screen content not matching current room playlist item
This commit is contained in:
parent
a59583ee09
commit
a5a9922f81
@ -19,7 +19,7 @@ namespace osu.Game.Tests.OnlinePlay
|
|||||||
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var nextItem = items.GetNextItem();
|
var nextItem = items.GetCurrentItem();
|
||||||
|
|
||||||
Assert.That(nextItem, Is.EqualTo(items[0]));
|
Assert.That(nextItem, Is.EqualTo(items[0]));
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Tests.OnlinePlay
|
|||||||
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var nextItem = items.GetNextItem();
|
var nextItem = items.GetCurrentItem();
|
||||||
|
|
||||||
Assert.That(nextItem, Is.EqualTo(items[1]));
|
Assert.That(nextItem, Is.EqualTo(items[1]));
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ namespace osu.Game.Tests.OnlinePlay
|
|||||||
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
var nextItem = items.GetNextItem();
|
var nextItem = items.GetCurrentItem();
|
||||||
|
|
||||||
Assert.That(nextItem, Is.EqualTo(items[2]));
|
Assert.That(nextItem, Is.EqualTo(items[2]));
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ namespace osu.Game.Tests.OnlinePlay
|
|||||||
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3, Expired = true },
|
new PlaylistItem { ID = 3, BeatmapID = 1003, PlaylistOrder = 3, Expired = true },
|
||||||
};
|
};
|
||||||
|
|
||||||
var nextItem = items.GetNextItem();
|
var nextItem = items.GetCurrentItem();
|
||||||
|
|
||||||
Assert.That(nextItem, Is.Null);
|
Assert.That(nextItem, Is.Null);
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ namespace osu.Game.Online.Rooms
|
|||||||
public static class PlaylistExtensions
|
public static class PlaylistExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the next <see cref="PlaylistItem"/> to be played from the supplied <paramref name="playlist"/>,
|
/// Returns the first non-expired <see cref="PlaylistItem"/> in playlist order from the supplied <paramref name="playlist"/>,
|
||||||
/// or <see langword="null"/> if all items are expired.
|
/// or <see langword="null"/> if all items are expired.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static PlaylistItem? GetNextItem(this IEnumerable<PlaylistItem> playlist) =>
|
public static PlaylistItem? GetCurrentItem(this IEnumerable<PlaylistItem> playlist) =>
|
||||||
playlist.OrderBy(item => item.PlaylistOrder).FirstOrDefault(item => !item.Expired);
|
playlist.OrderBy(item => item.PlaylistOrder).FirstOrDefault(item => !item.Expired);
|
||||||
|
|
||||||
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist) =>
|
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist) =>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Components
|
namespace osu.Game.Screens.OnlinePlay.Components
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
private void updateBeatmap()
|
private void updateBeatmap()
|
||||||
{
|
{
|
||||||
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
|
sprite.Beatmap.Value = Playlist.GetCurrentItem()?.Beatmap.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
@ -20,7 +19,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
public LoungeBackgroundScreen()
|
public LoungeBackgroundScreen()
|
||||||
{
|
{
|
||||||
SelectedRoom.BindValueChanged(onSelectedRoomChanged);
|
SelectedRoom.BindValueChanged(onSelectedRoomChanged);
|
||||||
playlist.BindCollectionChanged((_, __) => PlaylistItem = playlist.FirstOrDefault());
|
playlist.BindCollectionChanged((_, __) => PlaylistItem = playlist.GetCurrentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSelectedRoomChanged(ValueChangedEvent<Room> room)
|
private void onSelectedRoomChanged(ValueChangedEvent<Room> room)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -73,7 +72,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the last item from <see cref="Playlist"/>
|
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the current item from <see cref="Playlist"/>
|
||||||
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
|
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||||
@ -88,7 +87,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
|
|
||||||
protected virtual void UpdateSelectedItem()
|
protected virtual void UpdateSelectedItem()
|
||||||
=> SelectedItem.Value = RoomID.Value == null || subScreenSelectedItem == null
|
=> SelectedItem.Value = RoomID.Value == null || subScreenSelectedItem == null
|
||||||
? Playlist.LastOrDefault()
|
? Playlist.GetCurrentItem()
|
||||||
: subScreenSelectedItem.Value;
|
: subScreenSelectedItem.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user