1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

ModIcon improvements

This commit is contained in:
Andrei Zavatski 2019-08-07 08:46:27 +03:00
parent 6b1132c5ca
commit 1d42f0959a
2 changed files with 7 additions and 18 deletions

View File

@ -96,7 +96,7 @@ namespace osu.Game.Overlays.Mods
}
}
foregroundIcon.Highlighted = Selected;
foregroundIcon.Highlighted.Value = Selected;
SelectionChanged?.Invoke(SelectedMod);
return true;

View File

@ -11,11 +11,14 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osuTK;
using osu.Framework.Bindables;
namespace osu.Game.Rulesets.UI
{
public class ModIcon : Container, IHasTooltip
{
public readonly BindableBool Highlighted = new BindableBool();
private readonly SpriteIcon modIcon;
private readonly SpriteIcon background;
@ -97,26 +100,12 @@ namespace osu.Game.Rulesets.UI
highlightedColour = colours.PinkLight;
break;
}
applyStyle();
}
private bool highlighted;
public bool Highlighted
protected override void LoadComplete()
{
get => highlighted;
set
{
highlighted = value;
applyStyle();
}
}
private void applyStyle()
{
background.Colour = highlighted ? highlightedColour : backgroundColour;
base.LoadComplete();
Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true);
}
}
}