Fix next queued item not selecting after gameplay

This commit is contained in:
Dan Balasescu 2022-05-09 17:55:40 +09:00
parent ab1d46b71c
commit a16f2349aa
2 changed files with 41 additions and 4 deletions

View File

@ -21,6 +21,7 @@ using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.Mods; using osu.Game.Rulesets.Taiko.Mods;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Match; using osu.Game.Screens.OnlinePlay.Match;
using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Screens.OnlinePlay.Multiplayer;
using osu.Game.Screens.OnlinePlay.Multiplayer.Match; using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
@ -176,5 +177,41 @@ namespace osu.Game.Tests.Visual.Multiplayer
.ChildrenOfType<ModPanel>() .ChildrenOfType<ModPanel>()
.SingleOrDefault(panel => !panel.Filtered.Value)?.Mod is OsuModDoubleTime); .SingleOrDefault(panel => !panel.Filtered.Value)?.Mod is OsuModDoubleTime);
} }
[Test]
public void TestNextPlaylistItemSelectedAfterCompletion()
{
AddStep("add two playlist items", () =>
{
SelectedRoom.Value.Playlist.AddRange(new[]
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
},
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo)
{
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
}
});
});
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
AddUntilStep("wait for join", () => RoomJoined);
ClickButtonWhenEnabled<MultiplayerReadyButton>();
ClickButtonWhenEnabled<MultiplayerReadyButton>();
AddStep("change user to loaded", () => MultiplayerClient.ChangeState(MultiplayerUserState.Loaded));
AddUntilStep("user playing", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Playing);
AddStep("abort gameplay", () => MultiplayerClient.AbortGameplay());
AddUntilStep("last playlist item selected", () =>
{
var lastItem = this.ChildrenOfType<DrawableRoomPlaylistItem>().Single(p => p.Item.ID == MultiplayerClient.APIRoom?.Playlist.Last().ID);
return lastItem.IsSelectedItem;
});
}
} }
} }

View File

@ -65,6 +65,8 @@ namespace osu.Game.Screens.OnlinePlay
public readonly PlaylistItem Item; public readonly PlaylistItem Item;
public bool IsSelectedItem => SelectedItem.Value?.ID == Item.ID;
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both }; private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
private readonly IBindable<bool> valid = new Bindable<bool>(); private readonly IBindable<bool> valid = new Bindable<bool>();
@ -128,12 +130,10 @@ namespace osu.Game.Screens.OnlinePlay
SelectedItem.BindValueChanged(selected => SelectedItem.BindValueChanged(selected =>
{ {
bool isCurrent = selected.NewValue == Model;
if (!valid.Value) if (!valid.Value)
{ {
// Don't allow selection when not valid. // Don't allow selection when not valid.
if (isCurrent) if (IsSelectedItem)
{ {
SelectedItem.Value = selected.OldValue; SelectedItem.Value = selected.OldValue;
} }
@ -142,7 +142,7 @@ namespace osu.Game.Screens.OnlinePlay
return; return;
} }
maskingContainer.BorderThickness = isCurrent ? 5 : 0; maskingContainer.BorderThickness = IsSelectedItem ? 5 : 0;
}, true); }, true);
valid.BindValueChanged(_ => Scheduler.AddOnce(refresh)); valid.BindValueChanged(_ => Scheduler.AddOnce(refresh));