mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:02:55 +08:00
create local link flow container
This commit is contained in:
parent
40db228e91
commit
66ba24e865
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -12,6 +14,7 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -25,9 +28,6 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
private readonly FillFlowContainer textContainer;
|
private readonly FillFlowContainer textContainer;
|
||||||
private readonly Container imageContainer;
|
private readonly Container imageContainer;
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
|
|
||||||
|
|
||||||
public ChangelogSupporterPromo()
|
public ChangelogSupporterPromo()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -93,7 +93,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour, TextureStore textures)
|
private void load(OsuColour colour, TextureStore textures)
|
||||||
{
|
{
|
||||||
LinkFlowContainer supportLinkText;
|
SupporterPromoLinkFlowContainer supportLinkText;
|
||||||
textContainer.Children = new Drawable[]
|
textContainer.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Light),
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Light),
|
||||||
Margin = new MarginPadding { Bottom = 20 },
|
Margin = new MarginPadding { Bottom = 20 },
|
||||||
},
|
},
|
||||||
supportLinkText = new LinkFlowContainer(t =>
|
supportLinkText = new SupporterPromoLinkFlowContainer(t =>
|
||||||
{
|
{
|
||||||
t.Font = t.Font.With(size: 14);
|
t.Font = t.Font.With(size: 14);
|
||||||
t.Colour = colour.PinkLighter;
|
t.Colour = colour.PinkLighter;
|
||||||
@ -125,7 +125,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 and 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[]
|
||||||
@ -149,5 +149,39 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SupporterPromoLinkFlowContainer : LinkFlowContainer
|
||||||
|
{
|
||||||
|
public SupporterPromoLinkFlowContainer(Action<SpriteText> defaultCreationParameters)
|
||||||
|
: base(defaultCreationParameters)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public new void AddLink(string text, string url, Action<SpriteText> creationParameters) =>
|
||||||
|
AddInternal(new SupporterPromoLinkCompiler(AddText(text, creationParameters)) { Url = url });
|
||||||
|
|
||||||
|
private class SupporterPromoLinkCompiler : DrawableLinkCompiler
|
||||||
|
{
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
|
public string Url;
|
||||||
|
|
||||||
|
public SupporterPromoLinkCompiler(IEnumerable<Drawable> parts)
|
||||||
|
: base(parts)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colour)
|
||||||
|
{
|
||||||
|
TooltipText = Url;
|
||||||
|
Action = () => game?.HandleLink(Url);
|
||||||
|
IdleColour = colour.PinkDark;
|
||||||
|
HoverColour = Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user