mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Persist cover visibility to user settings
Follows web precedent, wherein the setting is saved to local storage.
This commit is contained in:
parent
33e91cf512
commit
f2df36e6a5
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile;
|
||||
@ -19,6 +20,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager configManager { get; set; } = null!;
|
||||
|
||||
private ProfileHeader header = null!;
|
||||
|
||||
[SetUpSteps]
|
||||
@ -33,6 +37,22 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestProfileCoverExpanded()
|
||||
{
|
||||
AddStep("Set cover to expanded", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, true));
|
||||
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
||||
AddUntilStep("Cover is expanded", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestProfileCoverCollapsed()
|
||||
{
|
||||
AddStep("Set cover to collapsed", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, false));
|
||||
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
||||
AddUntilStep("Cover is collapsed", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnlineState()
|
||||
{
|
||||
|
@ -58,6 +58,8 @@ namespace osu.Game.Configuration
|
||||
|
||||
SetDefault(OsuSetting.BeatmapListingCardSize, BeatmapCardSize.Normal);
|
||||
|
||||
SetDefault(OsuSetting.ProfileCoverExpanded, true);
|
||||
|
||||
SetDefault(OsuSetting.ToolbarClockDisplayMode, ToolbarClockDisplayMode.Full);
|
||||
|
||||
// Online settings
|
||||
@ -375,5 +377,6 @@ namespace osu.Game.Configuration
|
||||
LastProcessedMetadataId,
|
||||
SafeAreaConsiderations,
|
||||
ComboColourNormalisationAmount,
|
||||
ProfileCoverExpanded,
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class ToggleCoverButton : ProfileHeaderButton
|
||||
{
|
||||
public readonly BindableBool CoverVisible = new BindableBool(true);
|
||||
public readonly BindableBool CoverExpanded = new BindableBool(true);
|
||||
|
||||
public override LocalisableString TooltipText => CoverVisible.Value ? UsersStrings.ShowCoverTo0 : UsersStrings.ShowCoverTo1;
|
||||
public override LocalisableString TooltipText => CoverExpanded.Value ? UsersStrings.ShowCoverTo0 : UsersStrings.ShowCoverTo1;
|
||||
|
||||
private SpriteIcon icon = null!;
|
||||
private Sample? sampleOpen;
|
||||
@ -30,8 +30,8 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
Action = () =>
|
||||
{
|
||||
CoverVisible.Toggle();
|
||||
(CoverVisible.Value ? sampleOpen : sampleClose)?.Play();
|
||||
CoverExpanded.Toggle();
|
||||
(CoverExpanded.Value ? sampleOpen : sampleClose)?.Play();
|
||||
};
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
Size = new Vector2(10.5f, 12)
|
||||
};
|
||||
|
||||
CoverVisible.BindValueChanged(visible => updateState(visible.NewValue), true);
|
||||
CoverExpanded.BindValueChanged(visible => updateState(visible.NewValue), true);
|
||||
}
|
||||
|
||||
private void updateState(bool detailsVisible) => icon.Icon = detailsVisible ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
@ -42,12 +43,16 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
private GroupBadgeFlow groupBadgeFlow = null!;
|
||||
private ToggleCoverButton coverToggle = null!;
|
||||
|
||||
private Bindable<bool> coverExpanded = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
private void load(OverlayColourProvider colourProvider, OsuConfigManager configManager)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
coverExpanded = configManager.GetBindable<bool>(OsuSetting.ProfileCoverExpanded);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
@ -175,7 +180,8 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 10 }
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
CoverExpanded = { BindTarget = coverExpanded }
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -189,7 +195,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
base.LoadComplete();
|
||||
|
||||
User.BindValueChanged(user => updateUser(user.NewValue), true);
|
||||
coverToggle.CoverVisible.BindValueChanged(_ => updateCoverState(), true);
|
||||
coverExpanded.BindValueChanged(_ => updateCoverState(), true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
@ -213,9 +219,9 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
const float transition_duration = 250;
|
||||
|
||||
cover.ResizeHeightTo(coverToggle.CoverVisible.Value ? 250 : 0, transition_duration, Easing.OutQuint);
|
||||
avatar.ResizeTo(new Vector2(coverToggle.CoverVisible.Value ? 120 : content_height), transition_duration, Easing.OutQuint);
|
||||
avatar.TransformTo(nameof(avatar.CornerRadius), coverToggle.CoverVisible.Value ? 40f : 20f, transition_duration, Easing.OutQuint);
|
||||
cover.ResizeHeightTo(coverToggle.CoverExpanded.Value ? 250 : 0, transition_duration, Easing.OutQuint);
|
||||
avatar.ResizeTo(new Vector2(coverToggle.CoverExpanded.Value ? 120 : content_height), transition_duration, Easing.OutQuint);
|
||||
avatar.TransformTo(nameof(avatar.CornerRadius), coverToggle.CoverExpanded.Value ? 40f : 20f, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private partial class ProfileCoverBackground : UserCoverBackground
|
||||
|
Loading…
Reference in New Issue
Block a user