1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 12:02:54 +08:00

Adjust visuals of incompatible icon and move to own class

This commit is contained in:
Dean Herbert 2021-08-24 13:58:31 +09:00
parent bf0a1167ec
commit afd01d22d6
2 changed files with 72 additions and 9 deletions

View File

@ -0,0 +1,64 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Mods
{
public class IncompatibleIcon : VisibilityContainer, IHasTooltip
{
private Circle circle;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Size = new Vector2(20);
State.Value = Visibility.Hidden;
Alpha = 0;
InternalChildren = new Drawable[]
{
circle = new Circle
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Gray4,
},
new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(0.6f),
Icon = FontAwesome.Solid.Slash,
Colour = Color4.White,
Shadow = true,
}
};
}
protected override void PopIn()
{
this.FadeIn(200, Easing.OutQuint);
circle.FlashColour(Color4.Red, 500, Easing.OutQuint);
this.ScaleTo(1.8f).Then().ScaleTo(1, 500, Easing.OutQuint);
}
protected override void PopOut()
{
this.FadeOut(200, Easing.OutQuint);
this.ScaleTo(0.8f, 200, Easing.In);
}
public LocalisableString TooltipText => "Incompatible with current selected mods";
}
}

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Mods
private ModIcon backgroundIcon;
private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer;
private readonly SpriteIcon incompatibleIcon;
private readonly CompositeDrawable incompatibleIcon;
/// <summary>
/// Fired when the selection changes.
@ -258,7 +258,10 @@ namespace osu.Game.Overlays.Mods
if (selectedMods.Value.Count > 0 && !selectedMods.Value.Contains(m))
isIncompatible = !ModUtils.CheckCompatibleSet(selectedMods.Value.Append(m));
incompatibleIcon.FadeTo(isIncompatible ? 1 : 0, 200, Easing.OutQuint);
if (isIncompatible)
incompatibleIcon.Show();
else
incompatibleIcon.Hide();
}
private void createIcons()
@ -315,15 +318,11 @@ namespace osu.Game.Overlays.Mods
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
},
incompatibleIcon = new SpriteIcon
incompatibleIcon = new IncompatibleIcon
{
Origin = Anchor.BottomRight,
Origin = Anchor.Centre,
Anchor = Anchor.BottomRight,
Icon = FontAwesome.Solid.Ban,
Colour = Color4.Red,
Size = new Vector2(30),
Shadow = true,
Alpha = 0
Position = new Vector2(-13),
}
},
RelativeSizeAxes = Axes.Both,