Merge branch 'master' into long-standard

This commit is contained in:
maromalo
2022-11-12 09:52:11 -03:00
committed by GitHub
318 changed files with 3635 additions and 1326 deletions

View File

@ -111,8 +111,6 @@ namespace osu.Game.Graphics.Backgrounds
private void load(LargeTextureStore textures)
{
Sprite.Texture = textures.Get(url) ?? textures.Get(fallback_texture_name);
// ensure we're not loading in without a transition.
this.FadeInFromZero(200, Easing.InOutSine);
}
public override bool Equals(Background other)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -46,15 +44,20 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public bool ContentDisplayed { get; private set; }
protected Bindable<double> UserDimLevel { get; private set; }
protected Bindable<double> UserDimLevel { get; private set; } = null!;
protected Bindable<bool> LightenDuringBreaks { get; private set; }
/// <summary>
/// The amount of dim to be used when <see cref="IgnoreUserSettings"/> is <c>true</c>.
/// </summary>
public Bindable<float> DimWhenUserSettingsIgnored { get; set; } = new Bindable<float>();
protected Bindable<bool> ShowStoryboard { get; private set; }
protected Bindable<bool> LightenDuringBreaks { get; private set; } = null!;
protected Bindable<bool> ShowStoryboard { get; private set; } = null!;
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0;
protected float DimLevel => Math.Max(!IgnoreUserSettings.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
protected float DimLevel => Math.Max(!IgnoreUserSettings.Value ? (float)UserDimLevel.Value - breakLightening : DimWhenUserSettingsIgnored.Value, 0);
protected override Container<Drawable> Content => dimContent;
@ -76,6 +79,7 @@ namespace osu.Game.Graphics.Containers
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
UserDimLevel.ValueChanged += _ => UpdateVisuals();
DimWhenUserSettingsIgnored.ValueChanged += _ => UpdateVisuals();
LightenDuringBreaks.ValueChanged += _ => UpdateVisuals();
IsBreakTime.ValueChanged += _ => UpdateVisuals();
ShowStoryboard.ValueChanged += _ => UpdateVisuals();

View File

@ -70,7 +70,8 @@ namespace osu.Game.Graphics.Cursor
private OsuGame? game { get; set; }
private readonly IBindable<bool> lastInputWasMouse = new BindableBool();
private readonly IBindable<bool> isIdle = new BindableBool();
private readonly IBindable<bool> gameActive = new BindableBool(true);
private readonly IBindable<bool> gameIdle = new BindableBool();
protected override void LoadComplete()
{
@ -81,8 +82,11 @@ namespace osu.Game.Graphics.Cursor
if (game != null)
{
isIdle.BindTo(game.IsIdle);
isIdle.BindValueChanged(_ => updateState());
gameIdle.BindTo(game.IsIdle);
gameIdle.BindValueChanged(_ => updateState());
gameActive.BindTo(game.IsActive);
gameActive.BindValueChanged(_ => updateState());
}
}
@ -90,7 +94,7 @@ namespace osu.Game.Graphics.Cursor
private void updateState()
{
bool combinedVisibility = State.Value == Visibility.Visible && (lastInputWasMouse.Value || !hideCursorOnNonMouseInput) && !isIdle.Value;
bool combinedVisibility = getCursorVisibility();
if (visible == combinedVisibility)
return;
@ -103,6 +107,27 @@ namespace osu.Game.Graphics.Cursor
PopOut();
}
private bool getCursorVisibility()
{
// do not display when explicitly set to hidden state.
if (State.Value == Visibility.Hidden)
return false;
// only hide cursor when game is focused, otherwise it should always be displayed.
if (gameActive.Value)
{
// do not display when last input is not mouse.
if (hideCursorOnNonMouseInput && !lastInputWasMouse.Value)
return false;
// do not display when game is idle.
if (gameIdle.Value)
return false;
}
return true;
}
protected override void Update()
{
base.Update();

View File

@ -0,0 +1,201 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osuTK.Graphics;
namespace osu.Game.Graphics
{
public struct HSPAColour
{
private const float p_r = 0.299f;
private const float p_g = 0.587f;
private const float p_b = 0.114f;
/// <summary>
/// The hue.
/// </summary>
public float H;
/// <summary>
/// The saturation.
/// </summary>
public float S;
/// <summary>
/// The perceived brightness of this colour.
/// </summary>
public float P;
/// <summary>
/// The alpha.
/// </summary>
public float A;
public HSPAColour(float h, float s, float p, float a)
{
H = h;
S = s;
P = p;
A = a;
}
public HSPAColour(Color4 colour)
{
H = 0;
S = 0;
P = MathF.Sqrt(colour.R * colour.R * p_r + colour.G * colour.G * p_g + colour.B + colour.B * p_b);
A = colour.A;
if (colour.R == colour.G && colour.R == colour.B)
return;
if (colour.R >= colour.G && colour.R >= colour.B)
{
if (colour.B >= colour.G)
{
H = 6f / 6f - 1f / 6f * (colour.B - colour.G) / (colour.R - colour.G);
S = 1f - colour.G / colour.R;
}
else
{
H = 0f / 6f + 1f / 6f * (colour.G - colour.B) / (colour.R - colour.B);
S = 1f - colour.B / colour.R;
}
}
else if (colour.G >= colour.R && colour.G >= colour.B)
{
if (colour.R >= colour.B)
{
H = 2f / 6f - 1f / 6f * (colour.R - colour.B) / (colour.G - colour.B);
S = 1f - colour.B / colour.G;
}
else
{
H = 2f / 6f + 1f / 6f * (colour.B - colour.R) / (colour.G - colour.R);
S = 1f - colour.R / colour.G;
}
}
else
{
if (colour.G >= colour.R)
{
H = 4f / 6f - 1f / 6f * (colour.G - colour.R) / (colour.B - colour.R);
S = 1f - colour.R / colour.B;
}
else
{
H = 4f / 6f + 1f / 6f * (colour.R - colour.G) / (colour.B - colour.G);
S = 1f - colour.G / colour.B;
}
}
}
public Color4 ToColor4()
{
float minOverMax = 1f - S;
Color4 result = new Color4 { A = A };
float h = H;
if (minOverMax > 0f)
{
if (h < 1f / 6f)
{
h = 6f * (h - 0f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.B = P / MathF.Sqrt(p_r / minOverMax / minOverMax + p_g * part * part + p_b);
result.R = result.B / minOverMax;
result.G = result.B + h * (result.R - result.B);
}
else if (h < 2f / 6f)
{
h = 6f * (-h + 2f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.B = P / MathF.Sqrt(p_g / minOverMax / minOverMax + p_r * part * part + p_b);
result.G = result.B / minOverMax;
result.R = result.B + h * (result.G - result.B);
}
else if (h < 3f / 6f)
{
h = 6f * (h - 2f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.R = P / MathF.Sqrt(p_g / minOverMax / minOverMax + p_b * part * part + p_r);
result.G = result.R / minOverMax;
result.B = result.R + h * (result.G - result.R);
}
else if (h < 4f / 6f)
{
h = 6f * (-h + 4f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.R = P / MathF.Sqrt(p_b / minOverMax / minOverMax + p_g * part * part + p_r);
result.B = result.R / minOverMax;
result.G = result.R + h * (result.B - result.R);
}
else if (h < 5f / 6f)
{
h = 6f * (h - 4f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.G = P / MathF.Sqrt(p_b / minOverMax / minOverMax + p_r * part * part + p_g);
result.B = result.G / minOverMax;
result.R = result.G + h * (result.B - result.G);
}
else
{
h = 6f * (-h + 6f / 6f);
float part = 1f + h * (1f / minOverMax - 1f);
result.G = P / MathF.Sqrt(p_r / minOverMax / minOverMax + p_b * part * part + p_g);
result.R = result.G / minOverMax;
result.B = result.G + h * (result.R - result.G);
}
}
else
{
if (h < 1f / 6f)
{
h = 6f * (h - 0f / 6f);
result.R = MathF.Sqrt(P * P / (p_r + p_g * h * h));
result.G = result.R * h;
result.B = 0f;
}
else if (h < 2f / 6f)
{
h = 6f * (-h + 2f / 6f);
result.G = MathF.Sqrt(P * P / (p_g + p_r * h * h));
result.R = result.G * h;
result.B = 0f;
}
else if (h < 3f / 6f)
{
h = 6f * (h - 2f / 6f);
result.G = MathF.Sqrt(P * P / (p_g + p_b * h * h));
result.B = result.G * h;
result.R = 0f;
}
else if (h < 4f / 6f)
{
h = 6f * (-h + 4f / 6f);
result.B = MathF.Sqrt(P * P / (p_b + p_g * h * h));
result.G = result.B * h;
result.R = 0f;
}
else if (h < 5f / 6f)
{
h = 6f * (h - 4f / 6f);
result.B = MathF.Sqrt(P * P / (p_b + p_r * h * h));
result.R = result.B * h;
result.G = 0f;
}
else
{
h = 6f * (-h + 6f / 6f);
result.R = MathF.Sqrt(P * P / (p_r + p_b * h * h));
result.B = result.R * h;
result.G = 0f;
}
}
return result;
}
}
}

View File

@ -58,6 +58,14 @@ namespace osu.Game.Graphics.UserInterface
return base.OnClick(e);
}
public override void PlayHoverSample()
{
if (!Enabled.Value)
return;
base.PlayHoverSample();
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{

View File

@ -27,9 +27,6 @@ namespace osu.Game.Graphics.UserInterface
private const float border_width = 3;
private const double animate_in_duration = 200;
private const double animate_out_duration = 500;
private readonly Box fill;
private readonly Container main;
@ -72,7 +69,7 @@ namespace osu.Game.Graphics.UserInterface
Colour = GlowColour.Opacity(0),
Type = EdgeEffectType.Glow,
Radius = 8,
Roundness = 5,
Roundness = 4,
};
}
@ -94,13 +91,18 @@ namespace osu.Game.Graphics.UserInterface
if (value)
{
main.FadeColour(GlowingAccentColour, animate_in_duration, Easing.OutQuint);
main.FadeEdgeEffectTo(0.2f, animate_in_duration, Easing.OutQuint);
main.FadeColour(GlowingAccentColour.Lighten(0.5f), 40, Easing.OutQuint)
.Then()
.FadeColour(GlowingAccentColour, 800, Easing.OutQuint);
main.FadeEdgeEffectTo(Color4.White.Opacity(0.1f), 40, Easing.OutQuint)
.Then()
.FadeEdgeEffectTo(GlowColour.Opacity(0.1f), 800, Easing.OutQuint);
}
else
{
main.FadeEdgeEffectTo(0, animate_out_duration, Easing.OutQuint);
main.FadeColour(AccentColour, animate_out_duration, Easing.OutQuint);
main.FadeEdgeEffectTo(GlowColour.Opacity(0), 800, Easing.OutQuint);
main.FadeColour(AccentColour, 800, Easing.OutQuint);
}
}
}
@ -163,14 +165,20 @@ namespace osu.Game.Graphics.UserInterface
private void onCurrentValueChanged(ValueChangedEvent<bool> filled)
{
fill.FadeTo(filled.NewValue ? 1 : 0, 200, Easing.OutQuint);
const double duration = 200;
fill.FadeTo(filled.NewValue ? 1 : 0, duration, Easing.OutQuint);
if (filled.NewValue)
main.ResizeWidthTo(1, animate_in_duration, Easing.OutElasticHalf);
{
main.ResizeWidthTo(1, duration, Easing.OutElasticHalf);
main.TransformTo(nameof(BorderThickness), 8.5f, duration, Easing.OutElasticHalf);
}
else
main.ResizeWidthTo(0.9f, animate_out_duration, Easing.OutElastic);
main.TransformTo(nameof(BorderThickness), filled.NewValue ? 8.5f : border_width, 200, Easing.OutQuint);
{
main.ResizeWidthTo(0.75f, duration, Easing.OutQuint);
main.TransformTo(nameof(BorderThickness), border_width, duration, Easing.OutQuint);
}
}
}
}

View File

@ -4,7 +4,6 @@
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -95,7 +94,7 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(.1f),
Colour = Color4.White,
Blending = BlendingParameters.Additive,
Depth = float.MinValue
},
@ -126,7 +125,7 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(ClickEvent e)
{
if (Enabled.Value)
Background.FlashColour(BackgroundColour.Lighten(0.4f), 200);
Background.FlashColour(Color4.White, 800, Easing.OutQuint);
return base.OnClick(e);
}
@ -134,7 +133,11 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
if (Enabled.Value)
Hover.FadeIn(200, Easing.OutQuint);
{
Hover.FadeTo(0.2f, 40, Easing.OutQuint)
.Then()
.FadeTo(0.1f, 800, Easing.OutQuint);
}
return base.OnHover(e);
}
@ -143,7 +146,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.OnHoverLost(e);
Hover.FadeOut(300);
Hover.FadeOut(800, Easing.OutQuint);
}
protected override bool OnMouseDown(MouseDownEvent e)

View File

@ -131,8 +131,6 @@ namespace osu.Game.Graphics.UserInterface
},
hoverClickSounds = new HoverClickSounds()
};
Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; };
}
[BackgroundDependencyLoader(true)]
@ -154,7 +152,12 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
CurrentNumber.BindValueChanged(current => TooltipText = getTooltipText(current.NewValue), true);
Current.DisabledChanged += disabled => hoverClickSounds.Enabled.Value = !disabled;
Current.BindDisabledChanged(disabled =>
{
Alpha = disabled ? 0.3f : 1;
hoverClickSounds.Enabled.Value = !disabled;
}, true);
}
protected override bool OnHover(HoverEvent e)
@ -180,7 +183,7 @@ namespace osu.Game.Graphics.UserInterface
private void updateGlow()
{
Nub.Glowing = IsHovered || IsDragged;
Nub.Glowing = !Current.Disabled && (IsHovered || IsDragged);
}
protected override void OnUserChange(T value)