Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed User Ruleset from Leaderboard #31720

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions osu.Game/Online/Leaderboards/LeaderboardScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public partial class LeaderboardScore : OsuClickableContainer, IHasContextMenu,
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;

// using nullable enable here because canBeNull is not respected for OsuGame
#nullable enable

[Resolved]
private OsuGame? game { get; set; }
Comment on lines +90 to +94
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not how this should be done. Old classes where NRT is still not on are a bit of an edge case.

diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs
index 2f8e7bb7b9..438a0e2268 100644
--- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs
+++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs
@@ -6,6 +6,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using JetBrains.Annotations;
 using osu.Framework.Allocation;
 using osu.Framework.Extensions.Color4Extensions;
 using osu.Framework.Graphics;
@@ -87,11 +88,9 @@ public partial class LeaderboardScore : OsuClickableContainer, IHasContextMenu,
         [Resolved]
         private ScoreManager scoreManager { get; set; } = null!;
 
-        // using nullable enable here because canBeNull is not respected for OsuGame
-#nullable enable
-
-        [Resolved]
-        private OsuGame? game { get; set; }
+        [Resolved(CanBeNull = true)]
+        [CanBeNull]
+        private OsuGame game { get; set; }
 
         public LeaderboardScore(ScoreInfo score, int? rank, bool isOnlineScope = true, bool highlightFriend = true)
         {


public LeaderboardScore(ScoreInfo score, int? rank, bool isOnlineScope = true, bool highlightFriend = true)
{
Score = score;
Expand All @@ -103,6 +109,7 @@ public LeaderboardScore(ScoreInfo score, int? rank, bool isOnlineScope = true, b
private void load(IAPIProvider api, OsuColour colour)
{
var user = Score.User;
var ruleset = Score.Ruleset;
bool isUserFriend = api.Friends.Any(friend => friend.TargetID == user.OnlineID);

statisticsLabels = GetStatistics(Score).Select(s => new ScoreComponentLabel(s)).ToList();
Expand Down Expand Up @@ -264,6 +271,7 @@ private void load(IAPIProvider api, OsuColour colour)
},
};

innerAvatar.Action = () => game?.ShowUser(user, ruleset);
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
}

Expand Down
4 changes: 3 additions & 1 deletion osu.Game/OsuGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
using osu.Game.Overlays.OSD;
using osu.Game.Overlays.SkinEditor;
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens;
Expand Down Expand Up @@ -551,7 +552,8 @@ public void ShowChannel(string channel) => waitForReady(() => channelManager, _
/// Show a user's profile as an overlay.
/// </summary>
/// <param name="user">The user to display.</param>
public void ShowUser(IUser user) => waitForReady(() => userProfile, _ => userProfile.ShowUser(user));
/// <param name="ruleset">The user's ruleset to display on profile.</param>
public void ShowUser(IUser user, IRulesetInfo ruleset = null) => waitForReady(() => userProfile, _ => userProfile.ShowUser(user, ruleset));

/// <summary>
/// Show a beatmap's set as an overlay, displaying the given beatmap.
Expand Down
4 changes: 4 additions & 0 deletions osu.Game/Screens/SelectV2/Leaderboards/LeaderboardScoreV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public partial class LeaderboardScoreV2 : OsuClickableContainer, IHasContextMenu
[Resolved]
private IAPIProvider api { get; set; } = null!;

[Resolved]
private OsuGame? game { get; set; }

private Container content = null!;
private Box background = null!;
private Box foreground = null!;
Expand Down Expand Up @@ -185,6 +188,7 @@ private void load()
}
};

innerAvatar.Action = () => game?.ShowUser(user, score.Ruleset);
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
}

Expand Down