From 3529f34c98b09399448a8aa6f1459e1460275361 Mon Sep 17 00:00:00 2001 From: 5ln Date: Mon, 18 Oct 2021 01:58:38 +0800 Subject: [PATCH] Multi: Hide mods when spectating or Beatmap isn't Locally Available. Signed-off-by: 5ln --- .../TestSceneMultiplayerParticipantsList.cs | 62 +++++++++++++++++++ .../Participants/ParticipantPanel.cs | 6 ++ 2 files changed, 68 insertions(+) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerParticipantsList.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerParticipantsList.cs index c4ebc13245..d1980b03c7 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerParticipantsList.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerParticipantsList.cs @@ -275,6 +275,68 @@ namespace osu.Game.Tests.Visual.Multiplayer var state = i; AddStep($"set state: {state}", () => Client.ChangeUserState(0, state)); } + + AddStep("set state: downloading", () => Client.ChangeUserBeatmapAvailability(0, BeatmapAvailability.Downloading(0))); + + AddStep("set state: locally available", () => Client.ChangeUserBeatmapAvailability(0, BeatmapAvailability.LocallyAvailable())); + } + + [Test] + public void TestModOverlap() + { + AddStep("add dummy mods", () => + { + Client.ChangeUserMods(new Mod[] + { + new OsuModNoFail(), + new OsuModDoubleTime() + }); + }); + + AddStep("add user with mods", () => + { + Client.AddUser(new User + { + Id = 0, + Username = "Baka", + RulesetsStatistics = new Dictionary + { + { + Ruleset.Value.ShortName, + new UserStatistics { GlobalRank = RNG.Next(1, 100000), } + } + }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", + }); + Client.ChangeUserMods(0, new Mod[] + { + new OsuModHardRock(), + new OsuModDoubleTime() + }); + }); + + AddStep("set 0 ready", () => Client.ChangeState(MultiplayerUserState.Ready)); + + AddStep("set 1 spectate", () => Client.ChangeUserState(0, MultiplayerUserState.Spectating)); + + // Have to set back to idle due to status priority. + AddStep("set 0 no map, 1 ready", () => + { + Client.ChangeState(MultiplayerUserState.Idle); + Client.ChangeBeatmapAvailability(BeatmapAvailability.NotDownloaded()); + Client.ChangeUserState(0, MultiplayerUserState.Ready); + }); + + AddStep("set 0 downloading", () => Client.ChangeBeatmapAvailability(BeatmapAvailability.Downloading(0))); + + AddStep("set 0 spectate", () => Client.ChangeUserState(0, MultiplayerUserState.Spectating)); + + AddStep("make both default", () => + { + Client.ChangeBeatmapAvailability(BeatmapAvailability.LocallyAvailable()); + Client.ChangeUserState(0, MultiplayerUserState.Idle); + Client.ChangeState(MultiplayerUserState.Idle); + }); } private void createNewParticipantsList() diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs index 6f8c735b6e..79e305b765 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; @@ -190,6 +191,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability); + if ((User.BeatmapAvailability.State == DownloadState.LocallyAvailable) && (User.State != MultiplayerUserState.Spectating)) + userModsDisplay.FadeIn(fade_time); + else + userModsDisplay.FadeOut(fade_time); + if (Client.IsHost && !User.Equals(Client.LocalUser)) kickButton.FadeIn(fade_time); else