mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:03:08 +08:00
Merge pull request #24730 from cdwcgt/leaderboard-friend-highlight
Highlight friend score in gameplay leaderboards
This commit is contained in:
commit
2c38bed944
@ -6,11 +6,14 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Extensions.PolygonExtensions;
|
using osu.Framework.Extensions.PolygonExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -139,6 +142,31 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
=> AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount);
|
=> AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFriendScore()
|
||||||
|
{
|
||||||
|
APIUser friend = new APIUser { Username = "my friend", Id = 10000 };
|
||||||
|
|
||||||
|
createLeaderboard();
|
||||||
|
addLocalPlayer();
|
||||||
|
|
||||||
|
AddStep("Add friend to API", () =>
|
||||||
|
{
|
||||||
|
var api = (DummyAPIAccess)API;
|
||||||
|
|
||||||
|
api.Friends.Clear();
|
||||||
|
api.Friends.Add(friend);
|
||||||
|
});
|
||||||
|
|
||||||
|
int playerNumber = 1;
|
||||||
|
|
||||||
|
AddRepeatStep("add 3 other players", () => createRandomScore(new APIUser { Username = $"Player {playerNumber++}" }), 3);
|
||||||
|
AddUntilStep("there are no pink color score", () => leaderboard.ChildrenOfType<Box>().All(b => b.Colour != Color4Extensions.FromHex("ff549a")));
|
||||||
|
|
||||||
|
AddRepeatStep("add 3 friend score", () => createRandomScore(friend), 3);
|
||||||
|
AddUntilStep("there are pink color for friend score", () => leaderboard.GetScoreByUsername("my friend").ChildrenOfType<Box>().Any(b => b.Colour == Color4Extensions.FromHex("ff549a")));
|
||||||
|
}
|
||||||
|
|
||||||
private void addLocalPlayer()
|
private void addLocalPlayer()
|
||||||
{
|
{
|
||||||
AddStep("add local player", () =>
|
AddStep("add local player", () =>
|
||||||
@ -179,6 +207,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
return scoreItem != null && scoreItem.ScorePosition == expectedPosition;
|
return scoreItem != null && scoreItem.ScorePosition == expectedPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameplayLeaderboardScore GetScoreByUsername(string username)
|
||||||
|
{
|
||||||
|
return Flow.FirstOrDefault(i => i.User?.Username == username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -11,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Game.Users.Drawables;
|
using osu.Game.Users.Drawables;
|
||||||
@ -107,6 +109,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private IBindable<ScoringMode> scoreDisplayMode = null!;
|
private IBindable<ScoringMode> scoreDisplayMode = null!;
|
||||||
|
|
||||||
|
private bool isFriend;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="GameplayLeaderboardScore"/>.
|
/// Creates a new <see cref="GameplayLeaderboardScore"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -124,7 +128,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, OsuConfigManager osuConfigManager)
|
private void load(OsuColour colours, OsuConfigManager osuConfigManager, IAPIProvider api)
|
||||||
{
|
{
|
||||||
Container avatarContainer;
|
Container avatarContainer;
|
||||||
|
|
||||||
@ -311,6 +315,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
HasQuit.BindValueChanged(_ => updateState());
|
HasQuit.BindValueChanged(_ => updateState());
|
||||||
|
|
||||||
|
isFriend = User != null && api.Friends.Any(u => User.OnlineID == u.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -389,6 +395,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
panelColour = BackgroundColour ?? Color4Extensions.FromHex("ffd966");
|
panelColour = BackgroundColour ?? Color4Extensions.FromHex("ffd966");
|
||||||
textColour = TextColour ?? Color4Extensions.FromHex("2e576b");
|
textColour = TextColour ?? Color4Extensions.FromHex("2e576b");
|
||||||
}
|
}
|
||||||
|
else if (isFriend)
|
||||||
|
{
|
||||||
|
panelColour = BackgroundColour ?? Color4Extensions.FromHex("ff549a");
|
||||||
|
textColour = TextColour ?? Color4.White;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panelColour = BackgroundColour ?? Color4Extensions.FromHex("3399cc");
|
panelColour = BackgroundColour ?? Color4Extensions.FromHex("3399cc");
|
||||||
|
Loading…
Reference in New Issue
Block a user