From e1445dcb058495d909efab2800f84d51e0f81aaf Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 26 Nov 2021 17:40:45 +0900 Subject: [PATCH] Only show owner in match subscreen --- .../TestSceneDrawableRoomPlaylist.cs | 18 ++++++++++++++---- .../Screens/OnlinePlay/DrawableRoomPlaylist.cs | 6 ++++-- .../OnlinePlay/DrawableRoomPlaylistItem.cs | 16 ++++++++++++---- .../DrawableRoomPlaylistWithResults.cs | 13 ++++++++----- .../Multiplayer/MultiplayerMatchSubScreen.cs | 2 +- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs index b0174104f7..13d98145a1 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs @@ -23,6 +23,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Screens.OnlinePlay; using osu.Game.Tests.Beatmaps; +using osu.Game.Users.Drawables; using osuTK; using osuTK.Input; @@ -308,6 +309,15 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded)); } + [TestCase(false)] + [TestCase(true)] + public void TestWithOwner(bool withOwner) + { + createPlaylist(false, false, withOwner); + + AddAssert("owner visible", () => playlist.ChildrenOfType().All(a => a.IsPresent == withOwner)); + } + private void moveToItem(int index, Vector2? offset = null) => AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType().ElementAt(index), offset)); @@ -331,11 +341,11 @@ namespace osu.Game.Tests.Visual.Multiplayer => AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible", () => (playlist.ChildrenOfType().ElementAt(2 + index * 2).Alpha > 0) == visible); - private void createPlaylist(bool allowEdit, bool allowSelection) + private void createPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false) { AddStep("create playlist", () => { - Child = playlist = new TestPlaylist(allowEdit, allowSelection) + Child = playlist = new TestPlaylist(allowEdit, allowSelection, showItemOwner) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -415,8 +425,8 @@ namespace osu.Game.Tests.Visual.Multiplayer { public new IReadOnlyDictionary> ItemMap => base.ItemMap; - public TestPlaylist(bool allowEdit, bool allowSelection) - : base(allowEdit, allowSelection) + public TestPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false) + : base(allowEdit, allowSelection, showItemOwner: showItemOwner) { } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylist.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylist.cs index f5522cd25d..6deca0482a 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylist.cs @@ -20,11 +20,13 @@ namespace osu.Game.Screens.OnlinePlay private readonly bool allowEdit; private readonly bool allowSelection; + private readonly bool showItemOwner; - public DrawableRoomPlaylist(bool allowEdit, bool allowSelection, bool reverse = false) + public DrawableRoomPlaylist(bool allowEdit, bool allowSelection, bool reverse = false, bool showItemOwner = false) { this.allowEdit = allowEdit; this.allowSelection = allowSelection; + this.showItemOwner = showItemOwner; ((ReversibleFillFlowContainer)ListContainer).Reverse = reverse; } @@ -56,7 +58,7 @@ namespace osu.Game.Screens.OnlinePlay Spacing = new Vector2(0, 2) }; - protected override OsuRearrangeableListItem CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item, allowEdit, allowSelection) + protected override OsuRearrangeableListItem CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item, allowEdit, allowSelection, showItemOwner) { SelectedItem = { BindTarget = SelectedItem }, RequestDeletion = requestDeletion diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index 6c518616e2..6cbdc80d60 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -69,10 +69,11 @@ namespace osu.Game.Screens.OnlinePlay private readonly bool allowEdit; private readonly bool allowSelection; + private readonly bool showItemOwner; protected override bool ShouldBeConsideredForInput(Drawable child) => allowEdit || !allowSelection || SelectedItem.Value == Model; - public DrawableRoomPlaylistItem(PlaylistItem item, bool allowEdit, bool allowSelection) + public DrawableRoomPlaylistItem(PlaylistItem item, bool allowEdit, bool allowSelection, bool showItemOwner) : base(item) { Item = item; @@ -80,6 +81,7 @@ namespace osu.Game.Screens.OnlinePlay // TODO: edit support should be moved out into a derived class this.allowEdit = allowEdit; this.allowSelection = allowSelection; + this.showItemOwner = showItemOwner; beatmap.BindTo(item.Beatmap); valid.BindTo(item.Valid); @@ -142,7 +144,12 @@ namespace osu.Game.Screens.OnlinePlay maskingContainer.BorderColour = colours.Red; } - userLookupCache.GetUserAsync(Item.OwnerID).ContinueWith(u => Schedule(() => ownerAvatar.User = u.Result), TaskContinuationOptions.OnlyOnRanToCompletion); + if (showItemOwner) + { + ownerAvatar.Show(); + userLookupCache.GetUserAsync(Item.OwnerID).ContinueWith(u => Schedule(() => ownerAvatar.User = u.Result), TaskContinuationOptions.OnlyOnRanToCompletion); + } + difficultyIconContainer.Child = new DifficultyIcon(Item.Beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(ICON_HEIGHT) }; panelBackground.Beatmap.Value = Item.Beatmap.Value; @@ -271,7 +278,7 @@ namespace osu.Game.Screens.OnlinePlay Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Direction = FillDirection.Horizontal, - Margin = new MarginPadding { Left = 8 }, + Margin = new MarginPadding { Horizontal = 8 }, AutoSizeAxes = Axes.Both, Spacing = new Vector2(5), ChildrenEnumerable = CreateButtons().Select(button => button.With(b => @@ -285,9 +292,10 @@ namespace osu.Game.Screens.OnlinePlay Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(ICON_HEIGHT), - Margin = new MarginPadding { Left = 8, Right = 8, }, + Margin = new MarginPadding { Right = 8 }, Masking = true, CornerRadius = 4, + Alpha = showItemOwner ? 1 : 0 }, } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistWithResults.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistWithResults.cs index 575f336e58..8b1bb7abc1 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistWithResults.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistWithResults.cs @@ -19,13 +19,16 @@ namespace osu.Game.Screens.OnlinePlay { public Action RequestShowResults; - public DrawableRoomPlaylistWithResults() - : base(false, true) + private readonly bool showItemOwner; + + public DrawableRoomPlaylistWithResults(bool showItemOwner = false) + : base(false, true, showItemOwner: showItemOwner) { + this.showItemOwner = showItemOwner; } protected override OsuRearrangeableListItem CreateOsuDrawable(PlaylistItem item) => - new DrawableRoomPlaylistItemWithResults(item, false, true) + new DrawableRoomPlaylistItemWithResults(item, false, true, showItemOwner) { RequestShowResults = () => RequestShowResults(item), SelectedItem = { BindTarget = SelectedItem }, @@ -35,8 +38,8 @@ namespace osu.Game.Screens.OnlinePlay { public Action RequestShowResults; - public DrawableRoomPlaylistItemWithResults(PlaylistItem item, bool allowEdit, bool allowSelection) - : base(item, allowEdit, allowSelection) + public DrawableRoomPlaylistItemWithResults(PlaylistItem item, bool allowEdit, bool allowSelection, bool showItemOwner) + : base(item, allowEdit, allowSelection, showItemOwner) { } diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs index 1e3cfdbcbb..077e9cef93 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs @@ -153,7 +153,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer null, new Drawable[] { - playlist = new DrawableRoomPlaylist(false, false, true) + playlist = new DrawableRoomPlaylist(false, false, true, true) { RelativeSizeAxes = Axes.Both, },