From 8d640cdc25e50141dfeb49294c6c36060384d259 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 18 Dec 2018 12:56:16 +0900 Subject: [PATCH] Fix leaderboard not being refreshed when finishing gameplay --- osu.Game.Tests/Visual/TestCaseMultiHeader.cs | 2 +- osu.Game/Screens/Multi/Lounge/LoungeScreen.cs | 10 +++++++--- osu.Game/Screens/Multi/Match/MatchScreen.cs | 20 ++++++++----------- osu.Game/Screens/Multi/Multiplayer.cs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index e416000f31..deb098e97d 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual LoungeScreen loungeScreen; Children = new Drawable[] { - loungeScreen = new LoungeScreen + loungeScreen = new LoungeScreen(null) { Padding = new MarginPadding { Top = Header.HEIGHT }, }, diff --git a/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs index 1b49e0c1b3..f7dfd73b85 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeScreen.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.Graphics; using osu.Framework.Graphics.Containers; @@ -20,6 +21,7 @@ namespace osu.Game.Screens.Multi.Lounge private readonly Container content; private readonly SearchContainer search; private readonly RoomsContainer rooms; + private readonly Action pushGameplayScreen; [Cached] private readonly RoomManager manager; @@ -28,8 +30,10 @@ namespace osu.Game.Screens.Multi.Lounge protected override Drawable TransitionContent => content; - public LoungeScreen() + public LoungeScreen(Action pushGameplayScreen) { + this.pushGameplayScreen = pushGameplayScreen; + RoomInspector inspector; Children = new Drawable[] @@ -122,7 +126,7 @@ namespace osu.Game.Screens.Multi.Lounge if (Filter.Tabs.Current.Value == LoungeTab.Create) { Filter.Tabs.Current.Value = LoungeTab.Public; - Push(new MatchScreen(new Room())); + openRoom(new Room()); } search.SearchTerm = Filter.Search.Current.Value ?? string.Empty; @@ -136,7 +140,7 @@ namespace osu.Game.Screens.Multi.Lounge if (!IsCurrentScreen) return; - Push(new MatchScreen(room)); + Push(new MatchScreen(room, s => pushGameplayScreen?.Invoke(s))); } } } diff --git a/osu.Game/Screens/Multi/Match/MatchScreen.cs b/osu.Game/Screens/Multi/Match/MatchScreen.cs index 812f20f377..3f976cb9e2 100644 --- a/osu.Game/Screens/Multi/Match/MatchScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchScreen.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 System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -43,22 +44,21 @@ namespace osu.Game.Screens.Multi.Match private readonly Components.Header header; private readonly Info info; private readonly MatchLeaderboard leaderboard; + private readonly Action pushGameplayScreen; [Cached] private readonly Room room; - [Resolved] - private Multiplayer multiplayer { get; set; } - [Resolved] private BeatmapManager beatmapManager { get; set; } [Resolved] private APIAccess api { get; set; } - public MatchScreen(Room room) + public MatchScreen(Room room, Action pushGameplayScreen) { this.room = room; + this.pushGameplayScreen = pushGameplayScreen; nameBind.BindTo(room.Name); statusBind.BindTo(room.Status); @@ -146,13 +146,6 @@ namespace osu.Game.Screens.Multi.Match playlistBind.BindTo(room.Playlist); } - protected override void OnResuming(Screen last) - { - base.OnResuming(last); - - leaderboard.RefreshScores(); - } - private void addPlaylistItem(PlaylistItem item) { playlistBind.Clear(); @@ -192,7 +185,10 @@ namespace osu.Game.Screens.Multi.Match { default: case GameTypeTimeshift _: - multiplayer.Push(new PlayerLoader(new TimeshiftPlayer(room.RoomID.Value ?? 0, room.Playlist.First().ID))); + var player = new TimeshiftPlayer(room.RoomID.Value ?? 0, room.Playlist.First().ID); + player.Exited += _ => leaderboard.RefreshScores(); + + pushGameplayScreen?.Invoke(new PlayerLoader(player)); break; } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 0169d32c75..73a27a2b0a 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Multi { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = Header.HEIGHT }, - Child = loungeScreen = new LoungeScreen(), + Child = loungeScreen = new LoungeScreen(Push), }, new Header(loungeScreen) });