mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 17:02:58 +08:00
Merge pull request #16045 from smoogipoo/multiplayer-local-beatmap-query
Rework multiplayer's current item tracking
This commit is contained in:
commit
cebfeb5220
@ -45,8 +45,6 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
AddRepeatStep("add some users", () => Client.AddUser(new APIUser { Id = id++ }), 5);
|
AddRepeatStep("add some users", () => Client.AddUser(new APIUser { Id = id++ }), 5);
|
||||||
checkPlayingUserCount(0);
|
checkPlayingUserCount(0);
|
||||||
|
|
||||||
AddAssert("playlist item is available", () => Client.CurrentMatchPlayingItem.Value != null);
|
|
||||||
|
|
||||||
changeState(3, MultiplayerUserState.WaitingForLoad);
|
changeState(3, MultiplayerUserState.WaitingForLoad);
|
||||||
checkPlayingUserCount(3);
|
checkPlayingUserCount(3);
|
||||||
|
|
||||||
@ -64,8 +62,6 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
|
|
||||||
AddStep("leave room", () => Client.LeaveRoom());
|
AddStep("leave room", () => Client.LeaveRoom());
|
||||||
checkPlayingUserCount(0);
|
checkPlayingUserCount(0);
|
||||||
|
|
||||||
AddAssert("playlist item is null", () => Client.CurrentMatchPlayingItem.Value == null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFirstItemSelectedByDefault()
|
public void TestFirstItemSelectedByDefault()
|
||||||
{
|
{
|
||||||
AddAssert("first item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("first item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -27,13 +27,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
addItem(() => OtherBeatmap);
|
addItem(() => OtherBeatmap);
|
||||||
AddAssert("playlist has 2 items", () => Client.APIRoom?.Playlist.Count == 2);
|
AddAssert("playlist has 2 items", () => Client.APIRoom?.Playlist.Count == 2);
|
||||||
AddAssert("last playlist item is different", () => Client.APIRoom?.Playlist[1].Beatmap.Value.OnlineID == OtherBeatmap.OnlineID);
|
|
||||||
|
|
||||||
addItem(() => InitialBeatmap);
|
addItem(() => InitialBeatmap);
|
||||||
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
||||||
AddAssert("last playlist item is different", () => Client.APIRoom?.Playlist[2].Beatmap.Value.OnlineID == InitialBeatmap.OnlineID);
|
|
||||||
|
|
||||||
AddAssert("first item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("first item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -43,7 +41,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddAssert("playlist has only one item", () => Client.APIRoom?.Playlist.Count == 1);
|
AddAssert("playlist has only one item", () => Client.APIRoom?.Playlist.Count == 1);
|
||||||
AddAssert("playlist item is expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
AddAssert("playlist item is expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||||
AddAssert("last item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("last item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -55,12 +53,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
RunGameplay();
|
RunGameplay();
|
||||||
|
|
||||||
AddAssert("first item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
AddAssert("first item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||||
AddAssert("next item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[1].ID);
|
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[1].ID);
|
||||||
|
|
||||||
RunGameplay();
|
RunGameplay();
|
||||||
|
|
||||||
AddAssert("second item expired", () => Client.APIRoom?.Playlist[1].Expired == true);
|
AddAssert("second item expired", () => Client.APIRoom?.Playlist[1].Expired == true);
|
||||||
AddAssert("next item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[2].ID);
|
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[2].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -74,15 +72,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("change queue mode", () => Client.ChangeSettings(queueMode: QueueMode.HostOnly));
|
AddStep("change queue mode", () => Client.ChangeSettings(queueMode: QueueMode.HostOnly));
|
||||||
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
||||||
AddAssert("playlist item is the other beatmap", () => Client.CurrentMatchPlayingItem.Value?.BeatmapID == OtherBeatmap.OnlineID);
|
AddAssert("item 2 is not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
||||||
AddAssert("playlist item is not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
AddAssert("current item is the other beatmap", () => Client.Room?.Settings.PlaylistItemId == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCorrectItemSelectedAfterNewItemAdded()
|
public void TestCorrectItemSelectedAfterNewItemAdded()
|
||||||
{
|
{
|
||||||
addItem(() => OtherBeatmap);
|
addItem(() => OtherBeatmap);
|
||||||
AddAssert("selected beatmap is initial beatmap", () => Beatmap.Value.BeatmapInfo.OnlineID == InitialBeatmap.OnlineID);
|
AddUntilStep("selected beatmap is initial beatmap", () => Beatmap.Value.BeatmapInfo.OnlineID == InitialBeatmap.OnlineID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItem(Func<BeatmapInfo> beatmap)
|
private void addItem(Func<BeatmapInfo> beatmap)
|
||||||
|
@ -9,6 +9,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
@ -20,7 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFirstItemSelectedByDefault()
|
public void TestFirstItemSelectedByDefault()
|
||||||
{
|
{
|
||||||
AddAssert("first item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("first item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -28,7 +29,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
selectNewItem(() => InitialBeatmap);
|
selectNewItem(() => InitialBeatmap);
|
||||||
|
|
||||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("playlist item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -36,7 +37,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
selectNewItem(() => OtherBeatmap);
|
selectNewItem(() => OtherBeatmap);
|
||||||
|
|
||||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
|
AddAssert("playlist item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -47,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("playlist contains two items", () => Client.APIRoom?.Playlist.Count == 2);
|
AddAssert("playlist contains two items", () => Client.APIRoom?.Playlist.Count == 2);
|
||||||
AddAssert("first playlist item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
AddAssert("first playlist item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
||||||
AddAssert("second playlist item not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
AddAssert("second playlist item not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
||||||
AddAssert("second playlist item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[1].ID);
|
AddAssert("second playlist item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[1].ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -85,6 +86,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private void selectNewItem(Func<BeatmapInfo> beatmap)
|
private void selectNewItem(Func<BeatmapInfo> beatmap)
|
||||||
{
|
{
|
||||||
|
AddUntilStep("wait for playlist panels to load", () =>
|
||||||
|
{
|
||||||
|
var queueList = this.ChildrenOfType<MultiplayerQueueList>().Single();
|
||||||
|
return queueList.ChildrenOfType<DrawableRoomPlaylistItem>().Count() == queueList.Items.Count;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("click edit button", () =>
|
AddStep("click edit button", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistEditButton>().First());
|
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistEditButton>().First());
|
||||||
@ -97,7 +104,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
|
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
|
||||||
|
|
||||||
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
||||||
AddUntilStep("selected item is new beatmap", () => Client.CurrentMatchPlayingItem.Value?.Beatmap.Value?.OnlineID == otherBeatmap.OnlineID);
|
AddUntilStep("selected item is new beatmap", () => (CurrentSubScreen as MultiplayerMatchSubScreen)?.SelectedItem.Value?.BeatmapID == otherBeatmap.OnlineID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItem(Func<BeatmapInfo> beatmap)
|
private void addItem(Func<BeatmapInfo> beatmap)
|
||||||
|
@ -391,9 +391,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set user ready", () => client.ChangeState(MultiplayerUserState.Ready));
|
pressReadyButton();
|
||||||
AddStep("delete beatmap", () => beatmaps.Delete(importedSet));
|
|
||||||
|
|
||||||
|
AddStep("delete beatmap", () => beatmaps.Delete(importedSet));
|
||||||
AddUntilStep("user state is idle", () => client.LocalUser?.State == MultiplayerUserState.Idle);
|
AddUntilStep("user state is idle", () => client.LocalUser?.State == MultiplayerUserState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,10 +413,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pressReadyButton();
|
||||||
|
|
||||||
AddStep("Enter song select", () =>
|
AddStep("Enter song select", () =>
|
||||||
{
|
{
|
||||||
var currentSubScreen = ((Screens.OnlinePlay.Multiplayer.Multiplayer)multiplayerScreenStack.CurrentScreen).CurrentSubScreen;
|
var currentSubScreen = ((Screens.OnlinePlay.Multiplayer.Multiplayer)multiplayerScreenStack.CurrentScreen).CurrentSubScreen;
|
||||||
((MultiplayerMatchSubScreen)currentSubScreen).OpenSongSelection(client.CurrentMatchPlayingItem.Value);
|
((MultiplayerMatchSubScreen)currentSubScreen).OpenSongSelection(client.Room?.Settings.PlaylistItemId);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for song select", () => this.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault()?.BeatmapSetsLoaded == true);
|
AddUntilStep("wait for song select", () => this.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault()?.BeatmapSetsLoaded == true);
|
||||||
@ -592,19 +594,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for ready button to be enabled", () => readyButton.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
pressReadyButton();
|
||||||
|
pressReadyButton();
|
||||||
AddStep("click ready button", () =>
|
|
||||||
{
|
|
||||||
InputManager.MoveMouseTo(readyButton);
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for player to be ready", () => client.Room?.Users[0].State == MultiplayerUserState.Ready);
|
|
||||||
AddUntilStep("wait for ready button to be enabled", () => readyButton.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
|
||||||
|
|
||||||
AddStep("click start button", () => InputManager.Click(MouseButton.Left));
|
|
||||||
|
|
||||||
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player);
|
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player);
|
||||||
|
|
||||||
// Gameplay runs in real-time, so we need to incrementally check if gameplay has finished in order to not time out.
|
// Gameplay runs in real-time, so we need to incrementally check if gameplay has finished in order to not time out.
|
||||||
@ -665,7 +656,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private MultiplayerReadyButton readyButton => this.ChildrenOfType<MultiplayerReadyButton>().Single();
|
private ReadyButton readyButton => this.ChildrenOfType<ReadyButton>().Single();
|
||||||
|
|
||||||
|
private void pressReadyButton()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for ready button to be enabled", () => readyButton.Enabled.Value);
|
||||||
|
|
||||||
|
MultiplayerUserState lastState = MultiplayerUserState.Idle;
|
||||||
|
|
||||||
|
AddStep("click ready button", () =>
|
||||||
|
{
|
||||||
|
lastState = client.LocalUser?.State ?? MultiplayerUserState.Idle;
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(readyButton);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for state change", () => client.LocalUser?.State != lastState);
|
||||||
|
}
|
||||||
|
|
||||||
private void createRoom(Func<Room> room)
|
private void createRoom(Func<Room> room)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
|
|
||||||
@ -27,7 +28,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("initialise gameplay", () =>
|
AddStep("initialise gameplay", () =>
|
||||||
{
|
{
|
||||||
Stack.Push(player = new MultiplayerPlayer(Client.APIRoom, Client.CurrentMatchPlayingItem.Value, Client.Room?.Users.ToArray()));
|
Stack.Push(player = new MultiplayerPlayer(Client.APIRoom, new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
|
||||||
|
Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset }
|
||||||
|
}, Client.Room?.Users.ToArray()));
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen() && player.IsLoaded);
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen() && player.IsLoaded);
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -27,11 +28,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMultiplayerQueueList : MultiplayerTestScene
|
public class TestSceneMultiplayerQueueList : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private MultiplayerQueueList playlist;
|
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private readonly TestUserLookupCache userLookupCache = new TestUserLookupCache();
|
private readonly TestUserLookupCache userLookupCache = new TestUserLookupCache();
|
||||||
|
|
||||||
|
private MultiplayerQueueList playlist;
|
||||||
private BeatmapManager beatmaps;
|
private BeatmapManager beatmaps;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
private BeatmapSetInfo importedSet;
|
private BeatmapSetInfo importedSet;
|
||||||
@ -50,12 +52,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("create playlist", () =>
|
AddStep("create playlist", () =>
|
||||||
{
|
{
|
||||||
|
selectedItem.Value = null;
|
||||||
|
|
||||||
Child = playlist = new MultiplayerQueueList
|
Child = playlist = new MultiplayerQueueList
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = new Vector2(500, 300),
|
Size = new Vector2(500, 300),
|
||||||
SelectedItem = { BindTarget = Client.CurrentMatchPlayingItem },
|
SelectedItem = { BindTarget = selectedItem },
|
||||||
Items = { BindTarget = Client.APIRoom!.Playlist }
|
Items = { BindTarget = Client.APIRoom!.Playlist }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -107,22 +111,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }));
|
||||||
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
|
||||||
|
|
||||||
assertDeleteButtonVisibility(0, false);
|
|
||||||
|
|
||||||
addPlaylistItem(() => API.LocalUser.Value.OnlineID);
|
addPlaylistItem(() => API.LocalUser.Value.OnlineID);
|
||||||
|
|
||||||
|
AddStep("select item 0", () => selectedItem.Value = playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().ElementAt(0).Model);
|
||||||
assertDeleteButtonVisibility(0, false);
|
assertDeleteButtonVisibility(0, false);
|
||||||
assertDeleteButtonVisibility(1, true);
|
assertDeleteButtonVisibility(1, true);
|
||||||
|
|
||||||
// Run through gameplay.
|
AddStep("select item 1", () => selectedItem.Value = playlist.ChildrenOfType<RearrangeableListItem<PlaylistItem>>().ElementAt(1).Model);
|
||||||
AddStep("set state to ready", () => Client.ChangeUserState(API.LocalUser.Value.Id, MultiplayerUserState.Ready));
|
assertDeleteButtonVisibility(0, true);
|
||||||
AddUntilStep("local state is ready", () => Client.LocalUser?.State == MultiplayerUserState.Ready);
|
|
||||||
AddStep("start match", () => Client.StartMatch());
|
|
||||||
AddUntilStep("match started", () => Client.LocalUser?.State == MultiplayerUserState.WaitingForLoad);
|
|
||||||
AddStep("set state to loaded", () => Client.ChangeUserState(API.LocalUser.Value.Id, MultiplayerUserState.Loaded));
|
|
||||||
AddUntilStep("local state is playing", () => Client.LocalUser?.State == MultiplayerUserState.Playing);
|
|
||||||
AddStep("set state to finished play", () => Client.ChangeUserState(API.LocalUser.Value.Id, MultiplayerUserState.FinishedPlay));
|
|
||||||
AddUntilStep("local state is results", () => Client.LocalUser?.State == MultiplayerUserState.Results);
|
|
||||||
|
|
||||||
assertDeleteButtonVisibility(1, false);
|
assertDeleteButtonVisibility(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,42 +109,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]);
|
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestBeatmapUpdatedOnReImport()
|
|
||||||
{
|
|
||||||
BeatmapSetInfo importedSet = null;
|
|
||||||
|
|
||||||
AddStep("import altered beatmap", () =>
|
|
||||||
{
|
|
||||||
IBeatmap beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
|
||||||
|
|
||||||
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
|
||||||
|
|
||||||
// intentionally increment online IDs to clash with import below.
|
|
||||||
beatmap.BeatmapInfo.OnlineID++;
|
|
||||||
beatmap.BeatmapInfo.BeatmapSet.OnlineID++;
|
|
||||||
|
|
||||||
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
|
||||||
});
|
|
||||||
|
|
||||||
setupAndCreateRoom(room =>
|
|
||||||
{
|
|
||||||
room.Name.Value = "my awesome room";
|
|
||||||
room.Host.Value = API.LocalUser.Value;
|
|
||||||
room.Playlist.Add(new PlaylistItem
|
|
||||||
{
|
|
||||||
Beatmap = { Value = importedSet.Beatmaps[0] },
|
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
AddAssert("match has altered beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize == 1);
|
|
||||||
|
|
||||||
importBeatmap();
|
|
||||||
|
|
||||||
AddAssert("match has original beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize != 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupAndCreateRoom(Action<Room> room)
|
private void setupAndCreateRoom(Action<Room> room)
|
||||||
{
|
{
|
||||||
AddStep("setup room", () => room(SelectedRoom.Value));
|
AddStep("setup room", () => room(SelectedRoom.Value));
|
||||||
|
@ -95,8 +95,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
protected readonly BindableList<int> PlayingUserIds = new BindableList<int>();
|
protected readonly BindableList<int> PlayingUserIds = new BindableList<int>();
|
||||||
|
|
||||||
public readonly Bindable<PlaylistItem?> CurrentMatchPlayingItem = new Bindable<PlaylistItem?>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
|
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -162,9 +160,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, password ?? room.Password.Value).ConfigureAwait(false);
|
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, password ?? room.Password.Value).ConfigureAwait(false);
|
||||||
Debug.Assert(joinedRoom != null);
|
Debug.Assert(joinedRoom != null);
|
||||||
|
|
||||||
// Populate playlist items.
|
|
||||||
var playlistItems = await Task.WhenAll(joinedRoom.Playlist.Select(item => createPlaylistItem(item, item.ID == joinedRoom.Settings.PlaylistItemId))).ConfigureAwait(false);
|
|
||||||
|
|
||||||
// Populate users.
|
// Populate users.
|
||||||
Debug.Assert(joinedRoom.Users != null);
|
Debug.Assert(joinedRoom.Users != null);
|
||||||
await Task.WhenAll(joinedRoom.Users.Select(PopulateUser)).ConfigureAwait(false);
|
await Task.WhenAll(joinedRoom.Users.Select(PopulateUser)).ConfigureAwait(false);
|
||||||
@ -176,7 +171,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
APIRoom = room;
|
APIRoom = room;
|
||||||
|
|
||||||
APIRoom.Playlist.Clear();
|
APIRoom.Playlist.Clear();
|
||||||
APIRoom.Playlist.AddRange(playlistItems);
|
APIRoom.Playlist.AddRange(joinedRoom.Playlist.Select(createPlaylistItem));
|
||||||
|
|
||||||
Debug.Assert(LocalUser != null);
|
Debug.Assert(LocalUser != null);
|
||||||
addUserToAPIRoom(LocalUser);
|
addUserToAPIRoom(LocalUser);
|
||||||
@ -219,7 +214,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
APIRoom = null;
|
APIRoom = null;
|
||||||
Room = null;
|
Room = null;
|
||||||
CurrentMatchPlayingItem.Value = null;
|
|
||||||
PlayingUserIds.Clear();
|
PlayingUserIds.Clear();
|
||||||
|
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
@ -477,28 +471,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Debug.Assert(APIRoom != null);
|
Debug.Assert(APIRoom != null);
|
||||||
Debug.Assert(Room != null);
|
Debug.Assert(Room != null);
|
||||||
|
|
||||||
Scheduler.Add(() =>
|
Scheduler.Add(() => updateLocalRoomSettings(newSettings));
|
||||||
{
|
|
||||||
// ensure the new selected item is populated immediately.
|
|
||||||
var playlistItem = APIRoom.Playlist.Single(p => p.ID == newSettings.PlaylistItemId);
|
|
||||||
|
|
||||||
if (playlistItem != null)
|
|
||||||
{
|
|
||||||
GetAPIBeatmap(playlistItem.BeatmapID).ContinueWith(b =>
|
|
||||||
{
|
|
||||||
// Should be called outside of the `Scheduler` logic (and specifically accessing `Exception`) to suppress an exception from firing outwards.
|
|
||||||
bool success = b.Exception == null;
|
|
||||||
|
|
||||||
Scheduler.Add(() =>
|
|
||||||
{
|
|
||||||
if (success)
|
|
||||||
playlistItem.Beatmap.Value = b.Result;
|
|
||||||
|
|
||||||
updateLocalRoomSettings(newSettings);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
@ -653,12 +626,10 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PlaylistItemAdded(MultiplayerPlaylistItem item)
|
public Task PlaylistItemAdded(MultiplayerPlaylistItem item)
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var playlistItem = await createPlaylistItem(item, true).ConfigureAwait(false);
|
|
||||||
|
|
||||||
Scheduler.Add(() =>
|
Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
@ -668,11 +639,13 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Debug.Assert(APIRoom != null);
|
Debug.Assert(APIRoom != null);
|
||||||
|
|
||||||
Room.Playlist.Add(item);
|
Room.Playlist.Add(item);
|
||||||
APIRoom.Playlist.Add(playlistItem);
|
APIRoom.Playlist.Add(createPlaylistItem(item));
|
||||||
|
|
||||||
ItemAdded?.Invoke(item);
|
ItemAdded?.Invoke(item);
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task PlaylistItemRemoved(long playlistItemId)
|
public Task PlaylistItemRemoved(long playlistItemId)
|
||||||
@ -697,12 +670,10 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PlaylistItemChanged(MultiplayerPlaylistItem item)
|
public Task PlaylistItemChanged(MultiplayerPlaylistItem item)
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
var playlistItem = await createPlaylistItem(item, true).ConfigureAwait(false);
|
|
||||||
|
|
||||||
Scheduler.Add(() =>
|
Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
@ -715,15 +686,13 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
int existingIndex = APIRoom.Playlist.IndexOf(APIRoom.Playlist.Single(existing => existing.ID == item.ID));
|
int existingIndex = APIRoom.Playlist.IndexOf(APIRoom.Playlist.Single(existing => existing.ID == item.ID));
|
||||||
APIRoom.Playlist.RemoveAt(existingIndex);
|
APIRoom.Playlist.RemoveAt(existingIndex);
|
||||||
APIRoom.Playlist.Insert(existingIndex, playlistItem);
|
APIRoom.Playlist.Insert(existingIndex, createPlaylistItem(item));
|
||||||
|
|
||||||
// If the currently-selected item was the one that got replaced, update the selected item to the new one.
|
|
||||||
if (CurrentMatchPlayingItem.Value?.ID == playlistItem.ID)
|
|
||||||
CurrentMatchPlayingItem.Value = playlistItem;
|
|
||||||
|
|
||||||
ItemChanged?.Invoke(item);
|
ItemChanged?.Invoke(item);
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -752,12 +721,11 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
APIRoom.Password.Value = Room.Settings.Password;
|
APIRoom.Password.Value = Room.Settings.Password;
|
||||||
APIRoom.Type.Value = Room.Settings.MatchType;
|
APIRoom.Type.Value = Room.Settings.MatchType;
|
||||||
APIRoom.QueueMode.Value = Room.Settings.QueueMode;
|
APIRoom.QueueMode.Value = Room.Settings.QueueMode;
|
||||||
RoomUpdated?.Invoke();
|
|
||||||
|
|
||||||
CurrentMatchPlayingItem.Value = APIRoom.Playlist.SingleOrDefault(p => p.ID == settings.PlaylistItemId);
|
RoomUpdated?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<PlaylistItem> createPlaylistItem(MultiplayerPlaylistItem item, bool populateBeatmapImmediately)
|
private PlaylistItem createPlaylistItem(MultiplayerPlaylistItem item)
|
||||||
{
|
{
|
||||||
var ruleset = Rulesets.GetRuleset(item.RulesetID);
|
var ruleset = Rulesets.GetRuleset(item.RulesetID);
|
||||||
|
|
||||||
@ -779,9 +747,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
playlistItem.RequiredMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
|
playlistItem.RequiredMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
|
||||||
playlistItem.AllowedMods.AddRange(item.AllowedMods.Select(m => m.ToMod(rulesetInstance)));
|
playlistItem.AllowedMods.AddRange(item.AllowedMods.Select(m => m.ToMod(rulesetInstance)));
|
||||||
|
|
||||||
if (populateBeatmapImmediately)
|
|
||||||
playlistItem.Beatmap.Value = await GetAPIBeatmap(item.BeatmapID).ConfigureAwait(false);
|
|
||||||
|
|
||||||
return playlistItem;
|
return playlistItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +756,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// <param name="beatmapId">The beatmap ID.</param>
|
/// <param name="beatmapId">The beatmap ID.</param>
|
||||||
/// <param name="cancellationToken">A token to cancel the request.</param>
|
/// <param name="cancellationToken">A token to cancel the request.</param>
|
||||||
/// <returns>The <see cref="APIBeatmap"/> retrieval task.</returns>
|
/// <returns>The <see cref="APIBeatmap"/> retrieval task.</returns>
|
||||||
protected abstract Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default);
|
public abstract Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For the provided user ID, update whether the user is included in <see cref="CurrentMatchPlayingUserIds"/>.
|
/// For the provided user ID, update whether the user is included in <see cref="CurrentMatchPlayingUserIds"/>.
|
||||||
|
@ -178,7 +178,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return connection.InvokeAsync(nameof(IMultiplayerServer.RemovePlaylistItem), playlistItemId);
|
return connection.InvokeAsync(nameof(IMultiplayerServer.RemovePlaylistItem), playlistItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
public override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return beatmapLookupCache.GetBeatmapAsync(beatmapId, cancellationToken);
|
return beatmapLookupCache.GetBeatmapAsync(beatmapId, cancellationToken);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -24,6 +25,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays.BeatmapSet;
|
using osu.Game.Overlays.BeatmapSet;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -90,6 +92,10 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private UserLookupCache userLookupCache { get; set; }
|
private UserLookupCache userLookupCache { get; set; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private MultiplayerClient multiplayerClient { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapLookupCache beatmapLookupCache { get; set; }
|
private BeatmapLookupCache beatmapLookupCache { get; set; }
|
||||||
|
|
||||||
@ -157,7 +163,15 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
|
|
||||||
if (Item.Beatmap.Value == null)
|
if (Item.Beatmap.Value == null)
|
||||||
{
|
{
|
||||||
var foundBeatmap = await beatmapLookupCache.GetBeatmapAsync(Item.BeatmapID).ConfigureAwait(false);
|
IBeatmapInfo foundBeatmap;
|
||||||
|
|
||||||
|
if (multiplayerClient != null)
|
||||||
|
// This call can eventually go away (and use the else case below).
|
||||||
|
// Currently required only due to the method being overridden to provide special behaviour in tests.
|
||||||
|
foundBeatmap = await multiplayerClient.GetAPIBeatmap(Item.BeatmapID).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
foundBeatmap = await beatmapLookupCache.GetBeatmapAsync(Item.BeatmapID).ConfigureAwait(false);
|
||||||
|
|
||||||
Schedule(() => Item.Beatmap.Value = foundBeatmap);
|
Schedule(() => Item.Beatmap.Value = foundBeatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
public abstract class RoomSubScreen : OnlinePlaySubScreen, IPreviewTrackOwner
|
public abstract class RoomSubScreen : OnlinePlaySubScreen, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
[Cached(typeof(IBindable<PlaylistItem>))]
|
[Cached(typeof(IBindable<PlaylistItem>))]
|
||||||
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||||
|
|
||||||
public override bool? AllowTrackAdjustments => true;
|
public override bool? AllowTrackAdjustments => true;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
protected OnlinePlayScreen ParentScreen { get; private set; }
|
protected OnlinePlayScreen ParentScreen { get; private set; }
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private OnlinePlayBeatmapAvailabilityTracker beatmapAvailabilityTracker { get; set; }
|
private readonly OnlinePlayBeatmapAvailabilityTracker beatmapAvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
|
||||||
|
|
||||||
protected IBindable<BeatmapAvailability> BeatmapAvailability => beatmapAvailabilityTracker.Availability;
|
protected IBindable<BeatmapAvailability> BeatmapAvailability => beatmapAvailabilityTracker.Availability;
|
||||||
|
|
||||||
@ -90,11 +90,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
|
|
||||||
Padding = new MarginPadding { Top = Header.HEIGHT };
|
Padding = new MarginPadding { Top = Header.HEIGHT };
|
||||||
|
|
||||||
beatmapAvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker
|
|
||||||
{
|
|
||||||
SelectedItem = { BindTarget = SelectedItem }
|
|
||||||
};
|
|
||||||
|
|
||||||
RoomId.BindTo(room.RoomID);
|
RoomId.BindTo(room.RoomID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,10 +242,10 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
SelectedItem.BindValueChanged(_ => Scheduler.AddOnce(selectedItemChanged));
|
SelectedItem.BindValueChanged(_ => Scheduler.AddOnce(selectedItemChanged));
|
||||||
|
|
||||||
beatmapManager.ItemUpdated += beatmapUpdated;
|
|
||||||
|
|
||||||
UserMods.BindValueChanged(_ => Scheduler.AddOnce(UpdateMods));
|
UserMods.BindValueChanged(_ => Scheduler.AddOnce(UpdateMods));
|
||||||
|
|
||||||
|
beatmapAvailabilityTracker.SelectedItem.BindTo(SelectedItem);
|
||||||
|
beatmapAvailabilityTracker.Availability.BindValueChanged(_ => updateWorkingBeatmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
@ -374,8 +369,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapUpdated(BeatmapSetInfo set) => Schedule(updateWorkingBeatmap);
|
|
||||||
|
|
||||||
private void updateWorkingBeatmap()
|
private void updateWorkingBeatmap()
|
||||||
{
|
{
|
||||||
var beatmap = SelectedItem.Value?.Beatmap.Value;
|
var beatmap = SelectedItem.Value?.Beatmap.Value;
|
||||||
@ -443,14 +436,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
/// <param name="room">The room to change the settings of.</param>
|
/// <param name="room">The room to change the settings of.</param>
|
||||||
protected abstract RoomSettingsOverlay CreateRoomSettingsOverlay(Room room);
|
protected abstract RoomSettingsOverlay CreateRoomSettingsOverlay(Room room);
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (beatmapManager != null)
|
|
||||||
beatmapManager.ItemUpdated -= beatmapUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UserModSelectButton : PurpleTriangleButton
|
public class UserModSelectButton : PurpleTriangleButton
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
sampleUnready = audio.Samples.Get(@"Multiplayer/player-unready");
|
sampleUnready = audio.Samples.Get(@"Multiplayer/player-unready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
SelectedItem.BindValueChanged(_ => updateState());
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnRoomUpdated()
|
protected override void OnRoomUpdated()
|
||||||
{
|
{
|
||||||
base.OnRoomUpdated();
|
base.OnRoomUpdated();
|
||||||
@ -104,7 +111,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
|
|
||||||
bool enableButton =
|
bool enableButton =
|
||||||
Room?.State == MultiplayerRoomState.Open
|
Room?.State == MultiplayerRoomState.Open
|
||||||
&& Client.CurrentMatchPlayingItem.Value?.Expired == false
|
&& SelectedItem.Value?.ID == Room.Settings.PlaylistItemId
|
||||||
|
&& !Room.Playlist.Single(i => i.ID == Room.Settings.PlaylistItemId).Expired
|
||||||
&& !operationInProgress.Value;
|
&& !operationInProgress.Value;
|
||||||
|
|
||||||
// When the local user is the host and spectating the match, the "start match" state should be enabled if any users are ready.
|
// When the local user is the host and spectating the match, the "start match" state should be enabled if any users are ready.
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private MultiplayerClient client { get; set; }
|
private MultiplayerClient client { get; set; }
|
||||||
|
|
||||||
private readonly PlaylistItem itemToEdit;
|
private readonly long? itemToEdit;
|
||||||
|
|
||||||
private LoadingLayer loadingLayer;
|
private LoadingLayer loadingLayer;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
/// <param name="itemToEdit">The item to be edited. May be null, in which case a new item will be added to the playlist.</param>
|
/// <param name="itemToEdit">The item to be edited. May be null, in which case a new item will be added to the playlist.</param>
|
||||||
/// <param name="beatmap">An optional initial beatmap selection to perform.</param>
|
/// <param name="beatmap">An optional initial beatmap selection to perform.</param>
|
||||||
/// <param name="ruleset">An optional initial ruleset selection to perform.</param>
|
/// <param name="ruleset">An optional initial ruleset selection to perform.</param>
|
||||||
public MultiplayerMatchSongSelect(Room room, PlaylistItem itemToEdit = null, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
|
public MultiplayerMatchSongSelect(Room room, long? itemToEdit = null, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null)
|
||||||
: base(room)
|
: base(room)
|
||||||
{
|
{
|
||||||
this.itemToEdit = itemToEdit;
|
this.itemToEdit = itemToEdit;
|
||||||
@ -67,7 +67,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
var multiplayerItem = new MultiplayerPlaylistItem
|
var multiplayerItem = new MultiplayerPlaylistItem
|
||||||
{
|
{
|
||||||
ID = itemToEdit?.ID ?? 0,
|
ID = itemToEdit ?? 0,
|
||||||
BeatmapID = item.BeatmapID,
|
BeatmapID = item.BeatmapID,
|
||||||
BeatmapChecksum = item.Beatmap.Value.MD5Hash,
|
BeatmapChecksum = item.Beatmap.Value.MD5Hash,
|
||||||
RulesetID = item.RulesetID,
|
RulesetID = item.RulesetID,
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -67,8 +68,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
SelectedItem.BindTo(client.CurrentMatchPlayingItem);
|
|
||||||
|
|
||||||
BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
|
BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
|
||||||
UserMods.BindValueChanged(onUserModsChanged);
|
UserMods.BindValueChanged(onUserModsChanged);
|
||||||
|
|
||||||
@ -147,7 +146,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
new MultiplayerPlaylist
|
new MultiplayerPlaylist
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RequestEdit = OpenSongSelection
|
RequestEdit = item => OpenSongSelection(item.ID)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new[]
|
new[]
|
||||||
@ -224,7 +223,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
/// Opens the song selection screen to add or edit an item.
|
/// Opens the song selection screen to add or edit an item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemToEdit">An optional playlist item to edit. If null, a new item will be added instead.</param>
|
/// <param name="itemToEdit">An optional playlist item to edit. If null, a new item will be added instead.</param>
|
||||||
internal void OpenSongSelection([CanBeNull] PlaylistItem itemToEdit = null)
|
internal void OpenSongSelection(long? itemToEdit = null)
|
||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
return;
|
return;
|
||||||
@ -327,9 +326,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (client.LocalUser?.State == MultiplayerUserState.Ready)
|
if (client.LocalUser?.State == MultiplayerUserState.Ready)
|
||||||
client.ChangeState(MultiplayerUserState.Idle);
|
client.ChangeState(MultiplayerUserState.Idle);
|
||||||
}
|
}
|
||||||
else
|
else if (client.LocalUser?.State == MultiplayerUserState.Spectating
|
||||||
|
&& (client.Room?.State == MultiplayerRoomState.WaitingForLoad || client.Room?.State == MultiplayerRoomState.Playing))
|
||||||
{
|
{
|
||||||
if (client.LocalUser?.State == MultiplayerUserState.Spectating && (client.Room?.State == MultiplayerRoomState.WaitingForLoad || client.Room?.State == MultiplayerRoomState.Playing))
|
|
||||||
onLoadRequested();
|
onLoadRequested();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,11 +388,50 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCurrentItem();
|
||||||
|
|
||||||
addItemButton.Alpha = client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly ? 1 : 0;
|
addItemButton.Alpha = client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly ? 1 : 0;
|
||||||
|
|
||||||
Scheduler.AddOnce(UpdateMods);
|
Scheduler.AddOnce(UpdateMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCurrentItem()
|
||||||
|
{
|
||||||
|
Debug.Assert(client.Room != null);
|
||||||
|
|
||||||
|
var expectedSelectedItem = Room.Playlist.SingleOrDefault(i => i.ID == client.Room.Settings.PlaylistItemId);
|
||||||
|
|
||||||
|
if (expectedSelectedItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// There's no reason to renew the selected item if its content hasn't changed.
|
||||||
|
if (SelectedItem.Value?.Equals(expectedSelectedItem) == true && expectedSelectedItem.Beatmap.Value != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Clear the selected item while the lookup is performed, so components like the ready button can enter their disabled states.
|
||||||
|
SelectedItem.Value = null;
|
||||||
|
|
||||||
|
if (expectedSelectedItem.Beatmap.Value == null)
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
var beatmap = await client.GetAPIBeatmap(expectedSelectedItem.BeatmapID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
expectedSelectedItem.Beatmap.Value = beatmap;
|
||||||
|
|
||||||
|
if (Room.Playlist.SingleOrDefault(i => i.ID == client.Room?.Settings.PlaylistItemId)?.Equals(expectedSelectedItem) == true)
|
||||||
|
applyCurrentItem();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
applyCurrentItem();
|
||||||
|
|
||||||
|
void applyCurrentItem() => SelectedItem.Value = expectedSelectedItem;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleRoomLost() => Schedule(() =>
|
private void handleRoomLost() => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (this.IsCurrentScreen())
|
if (this.IsCurrentScreen())
|
||||||
@ -446,6 +484,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (client.Room == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!client.IsHost)
|
if (!client.IsHost)
|
||||||
{
|
{
|
||||||
// todo: should handle this when the request queue is implemented.
|
// todo: should handle this when the request queue is implemented.
|
||||||
@ -454,7 +495,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Push(new MultiplayerMatchSongSelect(Room, SelectedItem.Value, beatmap, ruleset));
|
this.Push(new MultiplayerMatchSongSelect(Room, client.Room.Settings.PlaylistItemId, beatmap, ruleset));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -376,7 +376,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public override Task RemovePlaylistItem(long playlistItemId) => RemoveUserPlaylistItem(api.LocalUser.Value.OnlineID, playlistItemId);
|
public override Task RemovePlaylistItem(long playlistItemId) => RemoveUserPlaylistItem(api.LocalUser.Value.OnlineID, playlistItemId);
|
||||||
|
|
||||||
protected override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
public override Task<APIBeatmap> GetAPIBeatmap(int beatmapId, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
IBeatmapSetInfo? set = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)
|
IBeatmapSetInfo? set = roomManager.ServerSideRooms.SelectMany(r => r.Playlist)
|
||||||
.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
|
.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
|
||||||
|
Loading…
Reference in New Issue
Block a user