1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

Merge pull request #3163 from peppy/improve-visual-settings-preview

Improve UX when adjusting visual settings at loading screen
This commit is contained in:
Dan Balasescu 2018-08-03 19:42:59 +09:00 committed by GitHub
commit 920d988a9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 6 deletions

View File

@ -1,11 +1,13 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.States;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Threading; using osu.Framework.Threading;
@ -20,6 +22,8 @@ namespace osu.Game.Screens.Play
{ {
public class PlayerLoader : ScreenWithBeatmapBackground public class PlayerLoader : ScreenWithBeatmapBackground
{ {
private static readonly Vector2 background_blur = new Vector2(15);
private Player player; private Player player;
private BeatmapMetadataDisplay info; private BeatmapMetadataDisplay info;
@ -60,7 +64,7 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding(25), Margin = new MarginPadding(25),
Children = new PlayerSettingsGroup[] Children = new PlayerSettingsGroup[]
{ {
new VisualSettings(), visualSettings = new VisualSettings(),
new InputSettings() new InputSettings()
} }
}); });
@ -122,9 +126,33 @@ namespace osu.Game.Screens.Play
} }
private ScheduledDelegate pushDebounce; private ScheduledDelegate pushDebounce;
private VisualSettings visualSettings;
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; 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() private void pushWhenLoaded()
{ {
if (!IsCurrentScreen) return; if (!IsCurrentScreen) return;
@ -215,7 +243,7 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
Colour = OsuColour.Gray(0.5f), Colour = OsuColour.Gray(0.8f),
Text = left, Text = left,
}, },
new OsuSpriteText new OsuSpriteText

View File

@ -128,6 +128,27 @@ namespace osu.Game.Screens.Play.PlayerSettings
}; };
} }
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] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -140,7 +161,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
protected override bool OnHover(InputState state) => true;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
} }
} }

View File

@ -15,6 +15,8 @@ namespace osu.Game.Screens.Play
{ {
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
public override bool AllowBeatmapRulesetChange => false; public override bool AllowBeatmapRulesetChange => false;
protected const float BACKGROUND_FADE_DURATION = 800; protected const float BACKGROUND_FADE_DURATION = 800;
@ -43,21 +45,30 @@ namespace osu.Game.Screens.Play
DimLevel.ValueChanged += _ => UpdateBackgroundElements(); DimLevel.ValueChanged += _ => UpdateBackgroundElements();
BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); BlurLevel.ValueChanged += _ => UpdateBackgroundElements();
ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements();
UpdateBackgroundElements(); InitializeBackgroundElements();
} }
protected override void OnResuming(Screen last) protected override void OnResuming(Screen last)
{ {
base.OnResuming(last); base.OnResuming(last);
UpdateBackgroundElements(); InitializeBackgroundElements();
} }
/// <summary>
/// Called once on entering screen. By Default, performs a full <see cref="UpdateBackgroundElements"/> call.
/// </summary>
protected virtual void InitializeBackgroundElements() => UpdateBackgroundElements();
/// <summary>
/// Called wen background elements require updates, usually due to a user changing a setting.
/// </summary>
/// <param name="userChange"></param>
protected virtual void UpdateBackgroundElements() protected virtual void UpdateBackgroundElements()
{ {
if (!IsCurrentScreen) return; if (!IsCurrentScreen) return;
Background?.FadeTo(BackgroundOpacity, BACKGROUND_FADE_DURATION, Easing.OutQuint); 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);
} }
} }
} }