mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:42:55 +08:00
Merge pull request #27199 from EVAST9919/link-compiler-alloc
Fix `DrawableLinkCompiler` allocations
This commit is contained in:
commit
71afb8881a
@ -4,9 +4,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.ListExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -23,12 +25,21 @@ namespace osu.Game.Online.Chat
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Each word part of a chat link (split for word-wrap support).
|
/// Each word part of a chat link (split for word-wrap support).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<Drawable> Parts;
|
public readonly SlimReadOnlyListWrapper<Drawable> Parts;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider? overlayColourProvider { get; set; }
|
private OverlayColourProvider? overlayColourProvider { get; set; }
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
||||||
|
{
|
||||||
|
foreach (var part in Parts)
|
||||||
|
{
|
||||||
|
if (part.ReceivePositionalInputAt(screenSpacePos))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
|
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
|
||||||
|
|
||||||
@ -39,7 +50,7 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public DrawableLinkCompiler(IEnumerable<Drawable> parts)
|
public DrawableLinkCompiler(IEnumerable<Drawable> parts)
|
||||||
{
|
{
|
||||||
Parts = parts.ToList();
|
Parts = parts.ToList().AsSlimReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -52,15 +63,24 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private partial class LinkHoverSounds : HoverClickSounds
|
private partial class LinkHoverSounds : HoverClickSounds
|
||||||
{
|
{
|
||||||
private readonly List<Drawable> parts;
|
private readonly SlimReadOnlyListWrapper<Drawable> parts;
|
||||||
|
|
||||||
public LinkHoverSounds(HoverSampleSet sampleSet, List<Drawable> parts)
|
public LinkHoverSounds(HoverSampleSet sampleSet, SlimReadOnlyListWrapper<Drawable> parts)
|
||||||
: base(sampleSet)
|
: base(sampleSet)
|
||||||
{
|
{
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
||||||
|
{
|
||||||
|
foreach (var part in parts)
|
||||||
|
{
|
||||||
|
if (part.ReceivePositionalInputAt(screenSpacePos))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user