1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-22 07:49:51 +08:00

Merge pull request #32360 from peppy/add-team-beatmap-leaderboards

Add team beatmap leaderboards
This commit is contained in:
Bartłomiej Dach
2025-03-13 10:04:53 +01:00
committed by GitHub
Unverified
14 changed files with 106 additions and 8 deletions
@@ -201,6 +201,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("ensure no scores displayed", () => leaderboard.SetScores(null));
AddStep(@"Network failure", () => leaderboard.SetErrorState(LeaderboardState.NetworkFailure));
AddStep(@"No team", () => leaderboard.SetErrorState(LeaderboardState.NoTeam));
AddStep(@"No supporter", () => leaderboard.SetErrorState(LeaderboardState.NotSupporter));
AddStep(@"Not logged in", () => leaderboard.SetErrorState(LeaderboardState.NotLoggedIn));
AddStep(@"Ruleset unavailable", () => leaderboard.SetErrorState(LeaderboardState.RulesetUnavailable));
+16
View File
@@ -9,6 +9,7 @@ using osu.Game.IO;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users;
namespace osu.Game.Extensions
@@ -164,5 +165,20 @@ namespace osu.Game.Extensions
/// that function does not have per-platform considerations (and is only made to work on windows).
/// </remarks>
public static string GetValidFilename(this string filename) => invalid_filename_chars.Replace(filename, "_");
public static bool RequiresSupporter(this BeatmapLeaderboardScope scope, bool filterMods)
{
switch (scope)
{
case BeatmapLeaderboardScope.Local:
return false;
case BeatmapLeaderboardScope.Country:
case BeatmapLeaderboardScope.Friend:
return true;
}
return filterMods;
}
}
}
@@ -44,6 +44,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard => new TranslatableString(getKey(@"please_invest_in_an_osu_supporter_tag_to_view_this_leaderboard"), @"Please invest in an osu!supporter tag to view this leaderboard!");
/// <summary>
/// "You are not on a team. Maybe you should join one!"
/// </summary>
public static LocalisableString NoTeam => new TranslatableString(getKey(@"no_team"), @"You are not on a team. Maybe you should join one!");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
@@ -356,6 +356,9 @@ namespace osu.Game.Online.Leaderboards
case LeaderboardState.NotSupporter:
return new MessagePlaceholder(LeaderboardStrings.PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard);
case LeaderboardState.NoTeam:
return new MessagePlaceholder(LeaderboardStrings.NoTeam);
case LeaderboardState.Retrieving:
return null;
@@ -14,5 +14,6 @@ namespace osu.Game.Online.Leaderboards
NoScores,
NotLoggedIn,
NotSupporter,
NoTeam
}
}
@@ -22,6 +22,7 @@ namespace osu.Game.Overlays.BeatmapSet
AddItem(BeatmapLeaderboardScope.Global);
AddItem(BeatmapLeaderboardScope.Country);
AddItem(BeatmapLeaderboardScope.Friend);
AddItem(BeatmapLeaderboardScope.Team);
}
[BackgroundDependencyLoader]
@@ -41,6 +41,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
case BeatmapLeaderboardScope.Country:
text.Text = BeatmapsetsStrings.ShowScoreboardNoScoresCountry;
break;
case BeatmapLeaderboardScope.Team:
text.Text = BeatmapsetsStrings.ShowScoreboardNoScoresTeam;
break;
}
}
}
@@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Localisation;
using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public partial class NoTeamPlaceholder : Container
{
public NoTeamPlaceholder()
{
AutoSizeAxes = Axes.Both;
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = LeaderboardStrings.NoTeam,
},
}
};
}
}
}
@@ -3,11 +3,10 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Resources.Localisation.Web;
using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@@ -30,7 +29,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = BeatmapsetsStrings.ShowScoreboardSupporterOnly,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
},
text = new LinkFlowContainer(t => t.Font = t.Font.With(size: 11))
{
@@ -12,6 +12,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
@@ -40,6 +41,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly LeaderboardModSelector modSelector;
private readonly NoScoresPlaceholder noScoresPlaceholder;
private readonly NotSupporterPlaceholder notSupporterPlaceholder;
private readonly NoTeamPlaceholder noTeamPlaceholder;
[Resolved]
private IAPIProvider api { get; set; }
@@ -154,10 +156,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
AlwaysPresent = true,
Margin = new MarginPadding { Vertical = 10 }
},
noTeamPlaceholder = new NoTeamPlaceholder
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Vertical = 10 },
Alpha = 0,
},
notSupporterPlaceholder = new NotSupporterPlaceholder
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Vertical = 10 },
Alpha = 0,
},
new FillFlowContainer
@@ -247,13 +257,21 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
return;
}
if ((scope.Value != BeatmapLeaderboardScope.Global || modSelector.SelectedMods.Count > 0) && !userIsSupporter)
if ((scope.Value == BeatmapLeaderboardScope.Team) && user.Value.Team == null)
{
Scores = null;
noTeamPlaceholder.Show();
return;
}
if (scope.Value.RequiresSupporter(modSelector.SelectedMods.Count > 0) && !userIsSupporter)
{
Scores = null;
notSupporterPlaceholder.Show();
return;
}
noTeamPlaceholder.Hide();
notSupporterPlaceholder.Hide();
Show();
@@ -138,12 +138,18 @@ namespace osu.Game.Screens.Select.Leaderboards
return null;
}
if (!api.LocalUser.Value.IsSupporter && (Scope != BeatmapLeaderboardScope.Global || filterMods))
if (Scope.RequiresSupporter(filterMods) && !api.LocalUser.Value.IsSupporter)
{
SetErrorState(LeaderboardState.NotSupporter);
return null;
}
if (Scope == BeatmapLeaderboardScope.Team && api.LocalUser.Value.Team == null)
{
SetErrorState(LeaderboardState.NoTeam);
return null;
}
IReadOnlyList<Mod>? requestMods = null;
if (filterMods && !mods.Value.Any())
@@ -20,5 +20,8 @@ namespace osu.Game.Screens.Select.Leaderboards
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowScoreboardFriend))]
Friend,
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowScoreboardTeam))]
Team,
}
}
@@ -83,6 +83,7 @@ namespace osu.Game.Screens.Select
new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Global),
new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Country),
new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Friend),
new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Team),
}).ToArray();
private BeatmapDetailAreaTabItem getTabItemFromTabType(TabType type)
@@ -104,6 +105,9 @@ namespace osu.Game.Screens.Select
case TabType.Friends:
return new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Friend);
case TabType.Team:
return new BeatmapDetailAreaLeaderboardTabItem<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Team);
default:
throw new ArgumentOutOfRangeException(nameof(type));
}
@@ -131,6 +135,9 @@ namespace osu.Game.Screens.Select
case BeatmapLeaderboardScope.Friend:
return TabType.Friends;
case BeatmapLeaderboardScope.Team:
return TabType.Team;
default:
throw new ArgumentOutOfRangeException(nameof(item));
}
@@ -146,7 +153,8 @@ namespace osu.Game.Screens.Select
Local,
Country,
Global,
Friends
Friends,
Team
}
}
}
+1 -1
View File
@@ -36,7 +36,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="20.1.0" />
<PackageReference Include="ppy.osu.Framework" Version="2025.313.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.307.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.313.0" />
<PackageReference Include="Sentry" Version="5.1.1" />
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
<PackageReference Include="SharpCompress" Version="0.39.0" />