Skip to content

Commit

Permalink
Merge pull request #29404 from frenzibyte/fix-user-profile-ux
Browse files Browse the repository at this point in the history
Fix user profile overlay colour resetting when selecting another ruleset
  • Loading branch information
smoogipoo authored Aug 13, 2024
2 parents 5060154 + 7acc177 commit 3753f65
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 16 additions & 2 deletions osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Rulesets.Taiko;
using osu.Game.Users;

namespace osu.Game.Tests.Visual.Online
Expand Down Expand Up @@ -192,13 +193,26 @@ public void TestCustomColourSchemeWithReload()
int hue2 = 0;

AddSliderStep("hue 2", 0, 360, 50, h => hue2 = h);
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 2 }));
AddWaitStep("wait some", 3);

AddStep("complete request", () => pendingRequest.TriggerSuccess(new APIUser
{
Username = $"Colorful #{hue2}",
Id = 1,
Id = 2,
CountryCode = CountryCode.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
ProfileHue = hue2,
PlayMode = "osu",
}));

AddStep("show user different ruleset", () => profile.ShowUser(new APIUser { Id = 2 }, new TaikoRuleset().RulesetInfo));
AddWaitStep("wait some", 3);

AddStep("complete request", () => pendingRequest.TriggerSuccess(new APIUser
{
Username = $"Colorful #{hue2}",
Id = 2,
CountryCode = CountryCode.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
ProfileHue = hue2,
Expand Down
7 changes: 5 additions & 2 deletions osu.Game/Overlays/UserProfileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ private void fetchAndSetContent()
{
Debug.Assert(user != null);

if (user.OnlineID == Header.User.Value?.User.Id && ruleset?.MatchesOnlineID(Header.User.Value?.Ruleset) == true)
bool sameUser = user.OnlineID == Header.User.Value?.User.Id;
if (sameUser && ruleset?.MatchesOnlineID(Header.User.Value?.Ruleset) == true)
return;

if (sectionsContainer != null)
Expand All @@ -118,7 +119,9 @@ private void fetchAndSetContent()
}
: Array.Empty<ProfileSection>();

changeOverlayColours(OverlayColourScheme.Pink.GetHue());
if (!sameUser)
changeOverlayColours(OverlayColourScheme.Pink.GetHue());

recreateBaseContent();

if (API.State.Value != APIState.Offline)
Expand Down

0 comments on commit 3753f65

Please sign in to comment.