mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Changed it so ChatLinks handle hover and click sounds themselves
This commit is contained in:
@ -32,7 +32,8 @@ namespace osu.Game.Online.Chat
|
||||
private Color4 hoverColour;
|
||||
private Color4 urlColour;
|
||||
|
||||
private readonly ChatHoverContainer content;
|
||||
private readonly Container content;
|
||||
private readonly HoverClickSounds hoverClickSounds;
|
||||
|
||||
/// <summary>
|
||||
/// Every other sprite in the containing ChatLine that represents the same link.
|
||||
@ -41,6 +42,12 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
protected override Container<Drawable> Content => content ?? base.Content;
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
hoverClickSounds.TriggerOnClick(state);
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override void OnLinkClicked()
|
||||
{
|
||||
var url = Url;
|
||||
@ -167,7 +174,9 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
public ChatLink()
|
||||
{
|
||||
AddInternal(content = new ChatHoverContainer
|
||||
hoverClickSounds = new HoverClickSounds();
|
||||
|
||||
AddInternal(content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
});
|
||||
@ -182,8 +191,12 @@ namespace osu.Game.Online.Chat
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (!SameLinkSprites.Any(sprite => sprite.IsHovered))
|
||||
{
|
||||
hoverClickSounds.TriggerOnHover(state);
|
||||
|
||||
foreach (ChatLink sprite in SameLinkSprites)
|
||||
sprite.TriggerOnHover(state);
|
||||
}
|
||||
|
||||
Content.FadeColour(hoverColour, 500, Easing.OutQuint);
|
||||
|
||||
@ -210,6 +223,9 @@ namespace osu.Game.Online.Chat
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api, BeatmapSetOverlay beatmapSetOverlay, ChatOverlay chat, OsuColour colours)
|
||||
{
|
||||
// Should be ok, inexpensive operation
|
||||
LoadComponentAsync(hoverClickSounds);
|
||||
|
||||
this.api = api;
|
||||
this.beatmapSetOverlay = beatmapSetOverlay;
|
||||
this.chat = chat;
|
||||
@ -219,10 +235,5 @@ namespace osu.Game.Online.Chat
|
||||
if (LinkId != -1)
|
||||
Content.Colour = urlColour;
|
||||
}
|
||||
|
||||
private class ChatHoverContainer : OsuHoverContainer
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user