From 122fc2de582d496a3f98f70f13f57b587f32cc14 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Jan 2019 19:24:55 +0900 Subject: [PATCH 1/3] Show room leaderboard instead in the lounge --- .../Visual/TestCaseMatchLeaderboard.cs | 3 +- .../Multi/Lounge/Components/RoomInspector.cs | 28 ++++++------------- .../Match/Components/MatchLeaderboard.cs | 15 +++++----- .../Screens/Multi/Match/MatchSubScreen.cs | 5 ++-- .../Ranking/Pages/RoomLeaderboardPage.cs | 2 +- osu.Game/Screens/Multi/RoomBindings.cs | 3 ++ 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMatchLeaderboard.cs b/osu.Game.Tests/Visual/TestCaseMatchLeaderboard.cs index cf475de1f0..821bf84047 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchLeaderboard.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchLeaderboard.cs @@ -17,12 +17,13 @@ namespace osu.Game.Tests.Visual { public TestCaseMatchLeaderboard() { - Add(new MatchLeaderboard(new Room { RoomID = { Value = 3 } }) + Add(new MatchLeaderboard { Origin = Anchor.Centre, Anchor = Anchor.Centre, Size = new Vector2(550f, 450f), Scope = MatchLeaderboardScope.Overall, + Room = new Room { RoomID = { Value = 3 } } }); } diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index 47f5182c39..ef80499884 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -13,10 +13,10 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Components; +using osu.Game.Screens.Multi.Match.Components; using osu.Game.Users; using osuTK; using osuTK.Graphics; @@ -37,11 +37,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components private Box statusStrip; private UpdateableBeatmapBackgroundSprite background; private ParticipantCountDisplay participantCount; - private FillFlowContainer topFlow, participantsFlow; + private FillFlowContainer topFlow; private OsuSpriteText name, status; private BeatmapTypeInfo beatmapTypeInfo; - private ScrollContainer participantsScroll; private ParticipantInfo participantInfo; + private MatchLeaderboard leaderboard; [Resolved] private BeatmapManager beatmaps { get; set; } @@ -147,23 +147,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components }, }, }, - participantsScroll = new OsuScrollContainer + leaderboard = new MatchLeaderboard { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Padding = new MarginPadding { Top = contentPadding.Top, Left = 38, Right = 37 }, - Children = new[] - { - participantsFlow = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - LayoutDuration = transition_duration, - Spacing = new Vector2(5f), - }, - }, - }, + } }; participantInfo.Host.BindTo(bindings.Host); @@ -180,7 +170,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components background.Beatmap.BindTo(bindings.CurrentBeatmap); bindings.Status.BindValueChanged(displayStatus); - bindings.Participants.BindValueChanged(p => participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u))); bindings.Name.BindValueChanged(n => name.Text = n); Room.BindValueChanged(updateRoom, true); @@ -189,10 +178,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components private void updateRoom(Room room) { bindings.Room = room; + leaderboard.Room = room; if (room != null) { - participantsFlow.FadeIn(transition_duration); participantCount.FadeIn(transition_duration); beatmapTypeInfo.FadeIn(transition_duration); name.FadeIn(transition_duration); @@ -200,7 +189,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components } else { - participantsFlow.FadeOut(transition_duration); participantCount.FadeOut(transition_duration); beatmapTypeInfo.FadeOut(transition_duration); name.FadeOut(transition_duration); @@ -214,7 +202,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components { base.UpdateAfterChildren(); - participantsScroll.Height = DrawHeight - topFlow.DrawHeight; + leaderboard.Height = DrawHeight - topFlow.DrawHeight; } private void displayStatus(RoomStatus s) diff --git a/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs b/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs index 864191105f..5ac0453373 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchLeaderboard.cs @@ -16,17 +16,18 @@ namespace osu.Game.Screens.Multi.Match.Components { public Action> ScoresLoaded; - private readonly Room room; - - public MatchLeaderboard(Room room) + public Room Room { - this.room = room; + get => bindings.Room; + set => bindings.Room = value; } + private readonly RoomBindings bindings = new RoomBindings(); + [BackgroundDependencyLoader] private void load() { - room.RoomID.BindValueChanged(id => + bindings.RoomID.BindValueChanged(id => { if (id == null) return; @@ -38,10 +39,10 @@ namespace osu.Game.Screens.Multi.Match.Components protected override APIRequest FetchScores(Action> scoresCallback) { - if (room.RoomID == null) + if (bindings.RoomID.Value == null) return null; - var req = new GetRoomScoresRequest(room.RoomID.Value ?? 0); + var req = new GetRoomScoresRequest(bindings.RoomID.Value ?? 0); req.Success += r => { diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 55a5a2c85e..14cdd90128 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -71,10 +71,11 @@ namespace osu.Game.Screens.Multi.Match { new Drawable[] { - leaderboard = new MatchLeaderboard(room) + leaderboard = new MatchLeaderboard { Padding = new MarginPadding(10), - RelativeSizeAxes = Axes.Both + RelativeSizeAxes = Axes.Both, + Room = room }, new Container { diff --git a/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs b/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs index 54528e5503..44f5f11c93 100644 --- a/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs +++ b/osu.Game/Screens/Multi/Ranking/Pages/RoomLeaderboardPage.cs @@ -103,8 +103,8 @@ namespace osu.Game.Screens.Multi.Ranking.Pages public class ResultsMatchLeaderboard : MatchLeaderboard { public ResultsMatchLeaderboard(Room room) - : base(room) { + Room = room; } protected override bool FadeTop => true; diff --git a/osu.Game/Screens/Multi/RoomBindings.cs b/osu.Game/Screens/Multi/RoomBindings.cs index cdbb6dbea6..30e2918b69 100644 --- a/osu.Game/Screens/Multi/RoomBindings.cs +++ b/osu.Game/Screens/Multi/RoomBindings.cs @@ -39,6 +39,7 @@ namespace osu.Game.Screens.Multi if (room != null) { + RoomID.UnbindFrom(room.RoomID); Name.UnbindFrom(room.Name); Host.UnbindFrom(room.Host); Status.UnbindFrom(room.Status); @@ -56,6 +57,7 @@ namespace osu.Game.Screens.Multi if (room != null) { + RoomID.BindTo(room.RoomID); Name.BindTo(room.Name); Host.BindTo(room.Host); Status.BindTo(room.Status); @@ -82,6 +84,7 @@ namespace osu.Game.Screens.Multi currentRuleset.Value = playlistItem?.Ruleset; } + public readonly Bindable RoomID = new Bindable(); public readonly Bindable Name = new Bindable(); public readonly Bindable Host = new Bindable(); public readonly Bindable Status = new Bindable(); From 2a4c91a6ab7a1d25a15ba61ad4581b48de13ab6e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Jan 2019 19:26:24 +0900 Subject: [PATCH 2/3] Remove unused using --- osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index ef80499884..e8be62e28c 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; From 2dc185f249bfc4766d9fad8703af999406a5331d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Jan 2019 15:15:54 +0900 Subject: [PATCH 3/3] Display avatars rather than full scores --- .../Multi/Lounge/Components/RoomInspector.cs | 351 +++++++++++------- 1 file changed, 215 insertions(+), 136 deletions(-) diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index e8be62e28c..63730ff635 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -13,9 +14,10 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Components; -using osu.Game.Screens.Multi.Match.Components; using osu.Game.Users; using osuTK; using osuTK.Graphics; @@ -36,11 +38,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components private Box statusStrip; private UpdateableBeatmapBackgroundSprite background; private ParticipantCountDisplay participantCount; - private FillFlowContainer topFlow; private OsuSpriteText name, status; private BeatmapTypeInfo beatmapTypeInfo; private ParticipantInfo participantInfo; - private MatchLeaderboard leaderboard; + private MatchParticipants participants; [Resolved] private BeatmapManager beatmaps { get; set; } @@ -57,127 +58,138 @@ namespace osu.Game.Screens.Multi.Lounge.Components RelativeSizeAxes = Axes.Both, Colour = OsuColour.FromHex(@"343138"), }, - topFlow = new FillFlowContainer + new GridContainer { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + RowDimensions = new[] { - new Container - { - RelativeSizeAxes = Axes.X, - Height = 200, - Masking = true, - Children = new Drawable[] - { - background = new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.5f), Color4.Black.Opacity(0)), - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(20), - Children = new Drawable[] - { - participantCount = new ParticipantCountDisplay - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - }, - name = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - TextSize = 30, - }, - }, - }, - }, - }, - statusStrip = new Box - { - RelativeSizeAxes = Axes.X, - Height = 5, - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"28242d"), - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - LayoutDuration = transition_duration, - Padding = contentPadding, - Spacing = new Vector2(0f, 5f), - Children = new Drawable[] - { - status = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - beatmapTypeInfo = new BeatmapTypeInfo(), - }, - }, - }, - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = contentPadding, - Children = new Drawable[] - { - participantInfo = new ParticipantInfo(), - }, - }, + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.Distributed), }, - }, - leaderboard = new MatchLeaderboard - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Padding = new MarginPadding { Top = contentPadding.Top, Left = 38, Right = 37 }, + Content = new[] + { + new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + Height = 200, + Masking = true, + Children = new Drawable[] + { + background = new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.5f), Color4.Black.Opacity(0)), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(20), + Children = new Drawable[] + { + participantCount = new ParticipantCountDisplay + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, + name = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 30, + }, + }, + }, + }, + }, + statusStrip = new Box + { + RelativeSizeAxes = Axes.X, + Height = 5, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"28242d"), + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + LayoutDuration = transition_duration, + Padding = contentPadding, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] + { + status = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + beatmapTypeInfo = new BeatmapTypeInfo(), + }, + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = contentPadding, + Children = new Drawable[] + { + participantInfo = new ParticipantInfo(), + }, + }, + }, + }, + }, + new Drawable[] + { + participants = new MatchParticipants + { + RelativeSizeAxes = Axes.Both, + } + } + } } }; participantInfo.Host.BindTo(bindings.Host); participantInfo.ParticipantCount.BindTo(bindings.ParticipantCount); participantInfo.Participants.BindTo(bindings.Participants); - participantCount.Participants.BindTo(bindings.Participants); participantCount.ParticipantCount.BindTo(bindings.ParticipantCount); participantCount.MaxParticipants.BindTo(bindings.MaxParticipants); - beatmapTypeInfo.Beatmap.BindTo(bindings.CurrentBeatmap); beatmapTypeInfo.Ruleset.BindTo(bindings.CurrentRuleset); beatmapTypeInfo.Type.BindTo(bindings.Type); background.Beatmap.BindTo(bindings.CurrentBeatmap); - bindings.Status.BindValueChanged(displayStatus); bindings.Name.BindValueChanged(n => name.Text = n); - Room.BindValueChanged(updateRoom, true); } private void updateRoom(Room room) { bindings.Room = room; - leaderboard.Room = room; + participants.Room = room; if (room != null) { @@ -197,13 +209,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components } } - protected override void UpdateAfterChildren() - { - base.UpdateAfterChildren(); - - leaderboard.Height = DrawHeight - topFlow.DrawHeight; - } - private void displayStatus(RoomStatus s) { status.Text = s.Message; @@ -213,39 +218,113 @@ namespace osu.Game.Screens.Multi.Lounge.Components status.FadeColour(c, transition_duration); } - private class UserTile : Container, IHasTooltip - { - private readonly User user; - - public string TooltipText => user.Username; - - public UserTile(User user) - { - this.user = user; - Size = new Vector2(70f); - CornerRadius = 5f; - Masking = true; - - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"27252d"), - }, - new UpdateableAvatar - { - RelativeSizeAxes = Axes.Both, - User = user, - }, - }; - } - } - private class RoomStatusNoneSelected : RoomStatus { public override string Message => @"No Room Selected"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8; } + + private class MatchParticipants : CompositeDrawable + { + private Room room; + private readonly FillFlowContainer fill; + + public Room Room + { + get { return room; } + set + { + if (room == value) + return; + + room = value; + updateParticipants(); + } + } + + public MatchParticipants() + { + Padding = new MarginPadding { Horizontal = 10 }; + + InternalChild = new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = fill = new FillFlowContainer + { + Spacing = new Vector2(10), + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Full, + } + }; + } + + [Resolved] + private APIAccess api { get; set; } + + private GetRoomScoresRequest request; + + private void updateParticipants() + { + var roomId = room.RoomID.Value ?? 0; + + request?.Cancel(); + + // nice little progressive fade + int time = 500; + foreach (var c in fill.Children) + { + c.Delay(500 - time).FadeOut(time, Easing.Out); + time = Math.Max(20, time - 20); + c.Expire(); + } + + if (roomId == 0) return; + + request = new GetRoomScoresRequest(roomId); + request.Success += scores => + { + if (roomId != room.RoomID.Value) + return; + + fill.Clear(); + foreach (var s in scores) + fill.Add(new UserTile(s.User)); + + fill.FadeInFromZero(1000, Easing.OutQuint); + }; + + api.Queue(request); + } + + private class UserTile : CompositeDrawable, IHasTooltip + { + private readonly User user; + + public string TooltipText => user.Username; + + public UserTile(User user) + { + this.user = user; + Size = new Vector2(70f); + CornerRadius = 5f; + Masking = true; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"27252d"), + }, + new UpdateableAvatar + { + RelativeSizeAxes = Axes.Both, + User = user, + }, + }; + } + } + } } }