1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 05:42:56 +08:00

Fix idle/hover colour handling weirdness in OsuHoverContainer

This commit is contained in:
Dean Herbert 2025-01-16 18:54:51 +09:00
parent 582c5180b9
commit cde8e7b82e
No known key found for this signature in database
3 changed files with 17 additions and 25 deletions

View File

@ -15,9 +15,11 @@ namespace osu.Game.Graphics.Containers
{
protected const float FADE_DURATION = 500;
protected Color4 HoverColour;
public Color4? HoverColour { get; set; }
private Color4 fallbackHoverColour;
protected Color4 IdleColour = Color4.White;
public Color4? IdleColour { get; set; }
private Color4 fallbackIdleColour;
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
@ -67,18 +69,18 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (HoverColour == default)
HoverColour = colours.Yellow;
fallbackHoverColour = colours.Yellow;
fallbackIdleColour = Color4.White;
}
protected override void LoadComplete()
{
base.LoadComplete();
EffectTargets.ForEach(d => d.FadeColour(IdleColour));
EffectTargets.ForEach(d => d.FadeColour(IdleColour ?? fallbackIdleColour));
}
private void fadeIn() => EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
private void fadeIn() => EffectTargets.ForEach(d => d.FadeColour(HoverColour ?? fallbackHoverColour, FADE_DURATION, Easing.OutQuint));
private void fadeOut() => EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));
private void fadeOut() => EffectTargets.ForEach(d => d.FadeColour(IdleColour ?? fallbackIdleColour, FADE_DURATION, Easing.OutQuint));
}
}

View File

@ -14,7 +14,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Online.Chat
{
@ -28,18 +27,6 @@ namespace osu.Game.Online.Chat
/// </summary>
public readonly SlimReadOnlyListWrapper<Drawable> Parts;
public new Color4 IdleColour
{
get => base.IdleColour;
set => base.IdleColour = value;
}
public new Color4 HoverColour
{
get => base.HoverColour;
set => base.HoverColour = value;
}
[Resolved]
private OverlayColourProvider? overlayColourProvider { get; set; }
@ -69,8 +56,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (IdleColour == default)
IdleColour = overlayColourProvider?.Light2 ?? colours.Blue;
IdleColour ??= overlayColourProvider?.Light2 ?? colours.Blue;
}
protected override IEnumerable<Drawable> EffectTargets => Parts;

View File

@ -1,6 +1,7 @@
// 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 System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -200,16 +201,19 @@ namespace osu.Game.Overlays.Profile.Header.Components
case FriendStatus.NotMutual:
IdleColour = colour.Green.Opacity(0.7f);
HoverColour = IdleColour.Lighten(0.1f);
HoverColour = IdleColour.Value.Lighten(0.1f);
break;
case FriendStatus.Mutual:
IdleColour = colour.Pink.Opacity(0.7f);
HoverColour = IdleColour.Lighten(0.1f);
HoverColour = IdleColour.Value.Lighten(0.1f);
break;
default:
throw new ArgumentOutOfRangeException();
}
EffectTargets.ForEach(d => d.FadeColour(IsHovered ? HoverColour : IdleColour, FADE_DURATION, Easing.OutQuint));
EffectTargets.ForEach(d => d.FadeColour(IsHovered ? HoverColour.Value : IdleColour.Value, FADE_DURATION, Easing.OutQuint));
}
private enum FriendStatus