mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Moved LinkFlowContainer out of ProfileHeader to make it available for other uses too (e.g. chat) and renamed it to LinkTextFlowContainer bc it can contain both links and text, not only one
This commit is contained in:
44
osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs
Normal file
44
osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class OsuLinkTextFlowContainer : OsuLinkTextFlowContainer<OsuLinkSpriteText>
|
||||
{
|
||||
public OsuLinkTextFlowContainer(Action<SpriteText> defaultCreationParameters = null)
|
||||
: base(defaultCreationParameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuLinkTextFlowContainer<T> : OsuTextFlowContainer
|
||||
where T : OsuLinkSpriteText, new()
|
||||
{
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public OsuLinkTextFlowContainer(Action<SpriteText> defaultCreationParameters = null) : base(defaultCreationParameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SpriteText CreateSpriteText() => new T();
|
||||
|
||||
public void AddLink(string text, string url, Action<SpriteText> creationParameters = null)
|
||||
{
|
||||
AddText(text, link =>
|
||||
{
|
||||
((T)link).Url = url;
|
||||
creationParameters?.Invoke(link);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user