added custom hoverclicksounds so links make sounds on hover&click

This commit is contained in:
FreezyLemon 2018-01-11 18:52:50 +01:00
parent 174fdf5037
commit 2c67ff75ed
2 changed files with 19 additions and 1 deletions

View File

@ -16,6 +16,8 @@ public class OsuClickableContainer : ClickableContainer
protected override Container<Drawable> Content => content;
protected virtual HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet);
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal)
{
this.sampleSet = sampleSet;
@ -33,7 +35,7 @@ private void load()
InternalChildren = new Drawable[]
{
content,
new HoverClickSounds(sampleSet)
CreateHoverClickSounds(sampleSet)
};
}
}

View File

@ -9,6 +9,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using OpenTK;
namespace osu.Game.Online.Chat
@ -25,6 +26,8 @@ public class DrawableLinkCompiler : OsuHoverContainer, IHasTooltip
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceiveMouseInputAt(screenSpacePos));
protected override HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
public DrawableLinkCompiler(IEnumerable<SpriteText> parts)
{
Parts = parts.ToList();
@ -39,5 +42,18 @@ private void load(OsuColour colours)
protected override IEnumerable<Drawable> EffectTargets => Parts;
public string TooltipText { get; set; }
private class LinkHoverSounds : HoverClickSounds
{
private readonly List<SpriteText> parts;
public LinkHoverSounds(HoverSampleSet sampleSet, List<SpriteText> parts)
: base(sampleSet)
{
this.parts = parts;
}
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => parts.Any(d => d.ReceiveMouseInputAt(screenSpacePos));
}
}
}