mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Add url clicking support to profile badges
This commit is contained in:
parent
0296e85ceb
commit
e11d44d14f
@ -52,8 +52,15 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
||||||
Description = "Outstanding help by being a voluntary test subject.",
|
Description = "Outstanding help by being a voluntary test subject.",
|
||||||
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
||||||
}
|
Url = "https://osu.ppy.sh/wiki/en/People/Community_Contributors",
|
||||||
|
},
|
||||||
|
new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
||||||
|
Description = "Badge without a url.",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Title = "osu!volunteer",
|
Title = "osu!volunteer",
|
||||||
Colour = "ff0000",
|
Colour = "ff0000",
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header.Components
|
namespace osu.Game.Overlays.Profile.Header.Components
|
||||||
{
|
{
|
||||||
[LongRunningLoad]
|
[LongRunningLoad]
|
||||||
public class DrawableBadge : CompositeDrawable, IHasTooltip
|
public class DrawableBadge : OsuClickableContainer
|
||||||
{
|
{
|
||||||
public static readonly Vector2 DRAWABLE_BADGE_SIZE = new Vector2(86, 40);
|
public static readonly Vector2 DRAWABLE_BADGE_SIZE = new Vector2(86, 40);
|
||||||
|
|
||||||
@ -29,22 +27,25 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LargeTextureStore textures)
|
private void load(LargeTextureStore textures, ILinkHandler? linkHandler)
|
||||||
{
|
{
|
||||||
InternalChild = new Sprite
|
Child = new Sprite
|
||||||
{
|
{
|
||||||
FillMode = FillMode.Fit,
|
FillMode = FillMode.Fit,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Texture = textures.Get(badge.ImageUrl),
|
Texture = textures.Get(badge.ImageUrl),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(badge.Url))
|
||||||
|
Action = () => linkHandler?.HandleLink(badge.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
InternalChild.FadeInFromZero(200);
|
this.FadeInFromZero(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalisableString TooltipText => badge.Description;
|
public override LocalisableString TooltipText => badge.Description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,8 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
[JsonProperty("image_url")]
|
[JsonProperty("image_url")]
|
||||||
public string ImageUrl;
|
public string ImageUrl;
|
||||||
|
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user