Merge pull request #5629 from EVAST9919/mod-icon-improvements

Change Highlighted property in ModIcon to a Bindable
This commit is contained in:
Dan Balasescu 2019-08-07 19:57:08 +09:00 committed by GitHub
commit 07983877db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}
}
}