From 4a11f2ec2ac4114cc3c89a843ff45d1700a3adef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Aug 2018 18:16:36 +0900 Subject: [PATCH] Improve UX when adjusting visual settings at loading screen --- osu.Game/Screens/Play/PlayerLoader.cs | 32 +++++++++++++++++-- .../PlayerSettings/PlayerSettingsGroup.cs | 22 ++++++++++++- .../Play/ScreenWithBeatmapBackground.cs | 17 ++++++++-- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 97a728ffb7..e9aa012cd7 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -1,11 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.States; using osu.Framework.Localisation; using osu.Framework.Screens; using osu.Framework.Threading; @@ -20,6 +22,8 @@ namespace osu.Game.Screens.Play { public class PlayerLoader : ScreenWithBeatmapBackground { + private static readonly Vector2 background_blur = new Vector2(15); + private Player player; private BeatmapMetadataDisplay info; @@ -60,7 +64,7 @@ private void load() Margin = new MarginPadding(25), Children = new PlayerSettingsGroup[] { - new VisualSettings(), + visualSettings = new VisualSettings(), new InputSettings() } }); @@ -122,9 +126,33 @@ protected override void LogoArriving(OsuLogo logo, bool resuming) } private ScheduledDelegate pushDebounce; + private VisualSettings visualSettings; private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; + protected override bool OnHover(InputState state) + { + // restore our screen defaults + InitializeBackgroundElements(); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (GetContainingInputManager().HoveredDrawables.Contains(visualSettings)) + { + // show user setting preview + UpdateBackgroundElements(); + } + base.OnHoverLost(state); + } + + protected override void InitializeBackgroundElements() + { + Background?.FadeTo(1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + Background?.BlurTo(background_blur, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + private void pushWhenLoaded() { if (!IsCurrentScreen) return; @@ -215,7 +243,7 @@ public MetadataLine(string left, string right) Anchor = Anchor.TopCentre, Origin = Anchor.TopRight, Margin = new MarginPadding { Right = 5 }, - Colour = OsuColour.Gray(0.5f), + Colour = OsuColour.Gray(0.8f), Text = left, }, new OsuSpriteText diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index c4767f404d..64c49099f2 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -128,6 +128,27 @@ protected PlayerSettingsGroup() }; } + private const float fade_duration = 800; + private const float inactive_alpha = 0.5f; + + protected override void LoadComplete() + { + base.LoadComplete(); + this.Delay(600).FadeTo(inactive_alpha, fade_duration, Easing.OutQuint); + } + + protected override bool OnHover(InputState state) + { + this.FadeIn(fade_duration, Easing.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + this.FadeTo(inactive_alpha, fade_duration, Easing.OutQuint); + base.OnHoverLost(state); + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -140,7 +161,6 @@ private void load(OsuColour colours) protected override Container Content => content; - protected override bool OnHover(InputState state) => true; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; } } diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 7f18305b1c..26d3218fbf 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -15,6 +15,8 @@ public abstract class ScreenWithBeatmapBackground : OsuScreen { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); + protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background; + public override bool AllowBeatmapRulesetChange => false; protected const float BACKGROUND_FADE_DURATION = 800; @@ -43,21 +45,30 @@ protected override void OnEntering(Screen last) DimLevel.ValueChanged += _ => UpdateBackgroundElements(); BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); - UpdateBackgroundElements(); + InitializeBackgroundElements(); } protected override void OnResuming(Screen last) { base.OnResuming(last); - UpdateBackgroundElements(); + InitializeBackgroundElements(); } + /// + /// Called once on entering screen. By Default, performs a full call. + /// + protected virtual void InitializeBackgroundElements() => UpdateBackgroundElements(); + + /// + /// Called wen background elements require updates, usually due to a user changing a setting. + /// + /// protected virtual void UpdateBackgroundElements() { if (!IsCurrentScreen) return; Background?.FadeTo(BackgroundOpacity, BACKGROUND_FADE_DURATION, Easing.OutQuint); - (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); + Background?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); } } }