Split content recreation methods

This commit is contained in:
Salman Ahmed 2024-07-18 00:26:37 +03:00
parent d61a72b8fb
commit 5317086171
1 changed files with 18 additions and 15 deletions

View File

@ -118,7 +118,8 @@ private void fetchAndSetContent()
}
: Array.Empty<ProfileSection>();
setupBaseContent(OverlayColourScheme.Pink.GetHue(), forceContentRecreation: true);
changeOverlayColours(OverlayColourScheme.Pink.GetHue());
recreateBaseContent();
if (API.State.Value != APIState.Offline)
{
@ -136,8 +137,9 @@ private void userLoadComplete(APIUser loadedUser, IRulesetInfo? userRuleset)
// reuse header and content if same colour scheme, otherwise recreate both.
int profileHue = loadedUser.ProfileHue ?? OverlayColourScheme.Pink.GetHue();
if (profileHue != ColourProvider.Hue)
setupBaseContent(profileHue, forceContentRecreation: false);
if (changeOverlayColours(profileHue))
recreateBaseContent();
var actualRuleset = rulesets.GetRuleset(userRuleset?.ShortName ?? loadedUser.PlayMode).AsNonNull();
@ -163,19 +165,8 @@ private void userLoadComplete(APIUser loadedUser, IRulesetInfo? userRuleset)
loadingLayer.Hide();
}
private void setupBaseContent(int hue, bool forceContentRecreation)
private void recreateBaseContent()
{
int previousHue = ColourProvider.Hue;
ColourProvider.ChangeColourScheme(hue);
if (hue != previousHue)
{
RecreateHeader();
UpdateColours();
}
else if (!forceContentRecreation)
return;
Child = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
@ -224,6 +215,18 @@ private void setupBaseContent(int hue, bool forceContentRecreation)
};
}
private bool changeOverlayColours(int hue)
{
if (hue == ColourProvider.Hue)
return false;
ColourProvider.ChangeColourScheme(hue);
RecreateHeader();
UpdateColours();
return true;
}
private partial class ProfileSectionTabControl : OsuTabControl<ProfileSection>
{
public ProfileSectionTabControl()