mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Move leaderboard implementation to Player
itself
This commit is contained in:
parent
368faa0084
commit
d251c0b2ac
@ -41,15 +41,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
private readonly TaskCompletionSource<bool> resultsReady = new TaskCompletionSource<bool>();
|
private readonly TaskCompletionSource<bool> resultsReady = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
private MultiplayerGameplayLeaderboard leaderboard;
|
|
||||||
|
|
||||||
private readonly MultiplayerRoomUser[] users;
|
private readonly MultiplayerRoomUser[] users;
|
||||||
|
|
||||||
private readonly Bindable<bool> leaderboardExpanded = new BindableBool();
|
|
||||||
|
|
||||||
private LoadingLayer loadingDisplay;
|
private LoadingLayer loadingDisplay;
|
||||||
private FillFlowContainer leaderboardFlow;
|
private FillFlowContainer leaderboardFlow;
|
||||||
|
|
||||||
|
private MultiplayerGameplayLeaderboard multiplayerLeaderboard;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a multiplayer player.
|
/// Construct a multiplayer player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -81,38 +79,33 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
Spacing = new Vector2(5)
|
Spacing = new Vector2(5)
|
||||||
});
|
});
|
||||||
|
|
||||||
HUDOverlay.HoldingForHUD.BindValueChanged(_ => updateLeaderboardExpandedState());
|
|
||||||
LocalUserPlaying.BindValueChanged(_ => updateLeaderboardExpandedState(), true);
|
|
||||||
|
|
||||||
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
|
|
||||||
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(users), l =>
|
|
||||||
{
|
|
||||||
if (!LoadedBeatmapSuccessfully)
|
|
||||||
return;
|
|
||||||
|
|
||||||
leaderboard.Expanded.BindTo(leaderboardExpanded);
|
|
||||||
|
|
||||||
leaderboardFlow.Insert(0, l);
|
|
||||||
|
|
||||||
if (leaderboard.TeamScores.Count >= 2)
|
|
||||||
{
|
|
||||||
LoadComponentAsync(new GameplayMatchScoreDisplay
|
|
||||||
{
|
|
||||||
Team1Score = { BindTarget = leaderboard.TeamScores.First().Value },
|
|
||||||
Team2Score = { BindTarget = leaderboard.TeamScores.Last().Value },
|
|
||||||
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
|
||||||
}, scoreDisplay => leaderboardFlow.Insert(1, scoreDisplay));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LoadComponentAsync(new GameplayChatDisplay(Room)
|
LoadComponentAsync(new GameplayChatDisplay(Room)
|
||||||
{
|
{
|
||||||
Expanded = { BindTarget = leaderboardExpanded },
|
Expanded = { BindTarget = LeaderboardExpandedState },
|
||||||
}, chat => leaderboardFlow.Insert(2, chat));
|
}, chat => leaderboardFlow.Insert(2, chat));
|
||||||
|
|
||||||
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override GameplayLeaderboard CreateGameplayLeaderboard() => multiplayerLeaderboard = new MultiplayerGameplayLeaderboard(users);
|
||||||
|
|
||||||
|
protected override void AddLeaderboardToHUD(GameplayLeaderboard leaderboard)
|
||||||
|
{
|
||||||
|
Debug.Assert(leaderboard == multiplayerLeaderboard);
|
||||||
|
|
||||||
|
leaderboardFlow.Insert(0, leaderboard);
|
||||||
|
|
||||||
|
if (multiplayerLeaderboard.TeamScores.Count >= 2)
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new GameplayMatchScoreDisplay
|
||||||
|
{
|
||||||
|
Team1Score = { BindTarget = multiplayerLeaderboard.TeamScores.First().Value },
|
||||||
|
Team2Score = { BindTarget = multiplayerLeaderboard.TeamScores.Last().Value },
|
||||||
|
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
||||||
|
}, scoreDisplay => leaderboardFlow.Insert(1, scoreDisplay));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadAsyncComplete()
|
protected override void LoadAsyncComplete()
|
||||||
{
|
{
|
||||||
base.LoadAsyncComplete();
|
base.LoadAsyncComplete();
|
||||||
@ -167,9 +160,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLeaderboardExpandedState() =>
|
|
||||||
leaderboardExpanded.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;
|
|
||||||
|
|
||||||
private void failAndBail(string message = null)
|
private void failAndBail(string message = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(message))
|
if (!string.IsNullOrEmpty(message))
|
||||||
@ -232,8 +222,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
Debug.Assert(Room.RoomID.Value != null);
|
Debug.Assert(Room.RoomID.Value != null);
|
||||||
|
|
||||||
return leaderboard.TeamScores.Count == 2
|
return multiplayerLeaderboard.TeamScores.Count == 2
|
||||||
? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, leaderboard.TeamScores)
|
? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, multiplayerLeaderboard.TeamScores)
|
||||||
: new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem);
|
: new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Scoring.Legacy;
|
using osu.Game.Scoring.Legacy;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -375,6 +376,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (Configuration.AutomaticallySkipIntro)
|
if (Configuration.AutomaticallySkipIntro)
|
||||||
skipIntroOverlay.SkipWhenReady();
|
skipIntroOverlay.SkipWhenReady();
|
||||||
|
|
||||||
|
loadLeaderboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
|
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
|
||||||
@ -820,6 +823,39 @@ namespace osu.Game.Screens.Play
|
|||||||
return mouseWheelDisabled.Value && !e.AltPressed;
|
return mouseWheelDisabled.Value && !e.AltPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Gameplay leaderboard
|
||||||
|
|
||||||
|
protected readonly Bindable<bool> LeaderboardExpandedState = new BindableBool();
|
||||||
|
|
||||||
|
private void loadLeaderboard()
|
||||||
|
{
|
||||||
|
HUDOverlay.HoldingForHUD.BindValueChanged(_ => updateLeaderboardExpandedState());
|
||||||
|
LocalUserPlaying.BindValueChanged(_ => updateLeaderboardExpandedState(), true);
|
||||||
|
|
||||||
|
LoadComponentAsync(CreateGameplayLeaderboard(), leaderboard =>
|
||||||
|
{
|
||||||
|
if (!LoadedBeatmapSuccessfully)
|
||||||
|
return;
|
||||||
|
|
||||||
|
leaderboard.Expanded.BindTo(LeaderboardExpandedState);
|
||||||
|
AddLeaderboardToHUD(leaderboard);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Margin = new MarginPadding { Bottom = 75, Left = 20 },
|
||||||
|
};
|
||||||
|
|
||||||
|
protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.Add(leaderboard);
|
||||||
|
|
||||||
|
private void updateLeaderboardExpandedState() =>
|
||||||
|
LeaderboardExpandedState.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Fail Logic
|
#region Fail Logic
|
||||||
|
|
||||||
protected FailOverlay FailOverlay { get; private set; }
|
protected FailOverlay FailOverlay { get; private set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user