mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add the ability to override Highlighted action to the ModIcon
This commit is contained in:
@ -92,11 +92,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
{
|
{
|
||||||
Scale = new Vector2(mod_scale);
|
Scale = new Vector2(mod_scale);
|
||||||
Add(new HoverClickSounds());
|
Add(new HoverClickSounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
Selected.BindValueChanged(selected =>
|
Selected.BindValueChanged(selected =>
|
||||||
{
|
{
|
||||||
updateState();
|
updateState();
|
||||||
OnSelectionChanged?.Invoke(mod, selected.NewValue);
|
OnSelectionChanged?.Invoke(Mod, selected.NewValue);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +125,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
private void updateState()
|
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; }
|
public virtual string TooltipText { get; }
|
||||||
|
|
||||||
|
protected Mod Mod { get; private set; }
|
||||||
|
|
||||||
public ModIcon(Mod mod)
|
public ModIcon(Mod mod)
|
||||||
{
|
{
|
||||||
if (mod == null) throw new ArgumentNullException(nameof(mod));
|
Mod = mod ?? throw new ArgumentNullException(nameof(mod));
|
||||||
|
|
||||||
type = mod.Type;
|
type = mod.Type;
|
||||||
|
|
||||||
@ -106,12 +108,19 @@ namespace osu.Game.Rulesets.UI
|
|||||||
modIcon.Colour = colours.Yellow;
|
modIcon.Colour = colours.Yellow;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background.Colour = backgroundColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user