2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.Chat
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-12-07 18:39:54 +08:00
|
|
|
|
/// An invisible drawable that brings multiple <see cref="Drawable"/> pieces together to form a consumable clickable link.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public class DrawableLinkCompiler : OsuHoverContainer, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Each word part of a chat link (split for word-wrap support).
|
|
|
|
|
/// </summary>
|
2018-12-07 18:39:54 +08:00
|
|
|
|
public List<Drawable> Parts;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-26 13:01:15 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
protected override HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
|
|
|
|
|
|
2018-12-07 18:39:54 +08:00
|
|
|
|
public DrawableLinkCompiler(IEnumerable<Drawable> parts)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Parts = parts.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
IdleColour = colours.Blue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<Drawable> EffectTargets => Parts;
|
|
|
|
|
|
|
|
|
|
public string TooltipText { get; set; }
|
|
|
|
|
|
|
|
|
|
private class LinkHoverSounds : HoverClickSounds
|
|
|
|
|
{
|
2018-12-07 18:39:54 +08:00
|
|
|
|
private readonly List<Drawable> parts;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-07 18:39:54 +08:00
|
|
|
|
public LinkHoverSounds(HoverSampleSet sampleSet, List<Drawable> parts)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
: base(sampleSet)
|
|
|
|
|
{
|
|
|
|
|
this.parts = parts;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 13:01:15 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|