mirror of
https://github.com/ppy/osu
synced 2025-01-04 13:22:08 +00:00
Add the ability to override Highlighted action to the ModIcon
This commit is contained in:
parent
21af390327
commit
62a91e4aaa
@ -92,11 +92,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
Scale = new Vector2(mod_scale);
|
||||
Add(new HoverClickSounds());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Selected.BindValueChanged(selected =>
|
||||
{
|
||||
updateState();
|
||||
OnSelectionChanged?.Invoke(mod, selected.NewValue);
|
||||
OnSelectionChanged?.Invoke(Mod, selected.NewValue);
|
||||
}, true);
|
||||
}
|
||||
|
||||
@ -120,7 +125,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
this.FadeColour(IsHovered || Selected.Value ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
|
||||
Highlighted.Value = (IsHovered || Selected.Value) ? true : false;
|
||||
}
|
||||
|
||||
protected override void OnHighlightedChange(ValueChangedEvent<bool> highlighted)
|
||||
{
|
||||
this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,11 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public virtual string TooltipText { get; }
|
||||
|
||||
protected Mod Mod { get; private set; }
|
||||
|
||||
public ModIcon(Mod mod)
|
||||
{
|
||||
if (mod == null) throw new ArgumentNullException(nameof(mod));
|
||||
Mod = mod ?? throw new ArgumentNullException(nameof(mod));
|
||||
|
||||
type = mod.Type;
|
||||
|
||||
@ -106,12 +108,19 @@ namespace osu.Game.Rulesets.UI
|
||||
modIcon.Colour = colours.Yellow;
|
||||
break;
|
||||
}
|
||||
|
||||
background.Colour = backgroundColour;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true);
|
||||
Highlighted.BindValueChanged(OnHighlightedChange, true);
|
||||
}
|
||||
|
||||
protected virtual void OnHighlightedChange(ValueChangedEvent<bool> highlighted)
|
||||
{
|
||||
background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user