1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 03:02:54 +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 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 }; protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
@ -67,18 +69,18 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
if (HoverColour == default) fallbackHoverColour = colours.Yellow;
HoverColour = colours.Yellow; fallbackIdleColour = Color4.White;
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.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.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Online.Chat namespace osu.Game.Online.Chat
{ {
@ -28,18 +27,6 @@ namespace osu.Game.Online.Chat
/// </summary> /// </summary>
public readonly SlimReadOnlyListWrapper<Drawable> Parts; 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] [Resolved]
private OverlayColourProvider? overlayColourProvider { get; set; } private OverlayColourProvider? overlayColourProvider { get; set; }
@ -69,8 +56,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
if (IdleColour == default) IdleColour ??= overlayColourProvider?.Light2 ?? colours.Blue;
IdleColour = overlayColourProvider?.Light2 ?? colours.Blue;
} }
protected override IEnumerable<Drawable> EffectTargets => Parts; 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. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -200,16 +201,19 @@ namespace osu.Game.Overlays.Profile.Header.Components
case FriendStatus.NotMutual: case FriendStatus.NotMutual:
IdleColour = colour.Green.Opacity(0.7f); IdleColour = colour.Green.Opacity(0.7f);
HoverColour = IdleColour.Lighten(0.1f); HoverColour = IdleColour.Value.Lighten(0.1f);
break; break;
case FriendStatus.Mutual: case FriendStatus.Mutual:
IdleColour = colour.Pink.Opacity(0.7f); IdleColour = colour.Pink.Opacity(0.7f);
HoverColour = IdleColour.Lighten(0.1f); HoverColour = IdleColour.Value.Lighten(0.1f);
break; 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 private enum FriendStatus