1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:07:25 +08:00

Simplify link style customization code

This commit is contained in:
ekrctb 2021-09-08 15:52:01 +09:00
parent 9637326f0c
commit d417f03a39

View File

@ -126,7 +126,7 @@ namespace osu.Game.Overlays.Changelog
}; };
supportLinkText.AddText("Support further development of osu! and "); supportLinkText.AddText("Support further development of osu! and ");
supportLinkText.AddLink("become an osu!supporter", "https://osu.ppy.sh/home/support", t => t.Font = t.Font.With(weight: FontWeight.Bold)); supportLinkText.AddLink("become an osu!supporter", @"https://osu.ppy.sh/home/support", t => t.Font = t.Font.With(weight: FontWeight.Bold));
supportLinkText.AddText(" today!"); supportLinkText.AddText(" today!");
imageContainer.Children = new Drawable[] imageContainer.Children = new Drawable[]
@ -170,27 +170,18 @@ namespace osu.Game.Overlays.Changelog
{ {
} }
public new void AddLink(string text, string url, Action<SpriteText> creationParameters) => protected override DrawableLinkCompiler CreateLinkCompiler(IEnumerable<SpriteText> parts) => new SupporterPromoLinkCompiler(parts);
AddInternal(new SupporterPromoLinkCompiler(AddText(text, creationParameters)) { Url = url });
private class SupporterPromoLinkCompiler : DrawableLinkCompiler private class SupporterPromoLinkCompiler : DrawableLinkCompiler
{ {
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
public string Url;
public SupporterPromoLinkCompiler(IEnumerable<Drawable> parts) public SupporterPromoLinkCompiler(IEnumerable<Drawable> parts)
: base(parts) : base(parts)
{ {
RelativeSizeAxes = Axes.Both;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colour) private void load(OsuColour colour)
{ {
TooltipText = Url;
Action = () => game?.HandleLink(Url);
IdleColour = colour.PinkDark; IdleColour = colour.PinkDark;
HoverColour = Color4.White; HoverColour = Color4.White;
} }