mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Split UnderscoredLinkContainer in different classes
This commit is contained in:
parent
52fad723a2
commit
6efa61b992
@ -30,8 +30,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
private const int corner_radius = 10;
|
||||
private readonly SpriteIcon icon;
|
||||
private readonly OsuSpriteText playCountText;
|
||||
private readonly UnderscoredLinkContainer mapper;
|
||||
private readonly UnderscoredLinkContainer beatmapName;
|
||||
private readonly UnderscoredUserLink mapper;
|
||||
|
||||
public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount)
|
||||
{
|
||||
@ -76,7 +75,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
Padding = new MarginPadding { Left = 15, Right = 20 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
beatmapName = new UnderscoredLinkContainer
|
||||
new UnderscoredBeatmapLink(beatmap)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
@ -111,7 +110,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
Text = "mapped by ",
|
||||
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular),
|
||||
},
|
||||
mapper = new UnderscoredLinkContainer
|
||||
mapper = new UnderscoredUserLink(beatmap.Metadata.Author.Id)
|
||||
{
|
||||
Text = new OsuSpriteText[]
|
||||
{
|
||||
@ -157,22 +156,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colors, UserProfileOverlay userProfileOverlay, BeatmapSetOverlay beatmapSetOverlay)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colors)
|
||||
{
|
||||
idleBackgroundColour = background.Colour = colors.GreySeafoam;
|
||||
hoveredBackgroundColour = colors.GreySeafoamLight;
|
||||
mapperText.Colour = mapper.Colour = colors.GreySeafoamLighter;
|
||||
icon.Colour = playCountText.Colour = colors.Yellow;
|
||||
|
||||
mapper.ClickAction = () => userProfileOverlay.ShowUser(beatmap.Metadata.Author.Id);
|
||||
beatmapName.ClickAction = () =>
|
||||
{
|
||||
if (beatmap.OnlineBeatmapID != null)
|
||||
beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value);
|
||||
else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null)
|
||||
beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value);
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
|
30
osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs
Normal file
30
osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class UnderscoredBeatmapLink : UnderscoredLinkContainer
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
|
||||
public UnderscoredBeatmapLink(BeatmapInfo beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapSetOverlay beatmapSetOverlay)
|
||||
{
|
||||
ClickAction = () =>
|
||||
{
|
||||
if (beatmap.OnlineBeatmapID != null)
|
||||
beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value);
|
||||
else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null)
|
||||
beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -11,13 +11,14 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class UnderscoredLinkContainer : Container
|
||||
public abstract class UnderscoredLinkContainer : Container
|
||||
{
|
||||
private const int duration = 200;
|
||||
public Action ClickAction;
|
||||
private readonly Container underscore;
|
||||
private readonly FillFlowContainer<OsuSpriteText> textContent;
|
||||
|
||||
protected Action ClickAction;
|
||||
|
||||
public IReadOnlyList<OsuSpriteText> Text
|
||||
{
|
||||
get => textContent.Children;
|
||||
@ -28,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
}
|
||||
}
|
||||
|
||||
public UnderscoredLinkContainer()
|
||||
protected UnderscoredLinkContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Child = new Container
|
||||
|
23
osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs
Normal file
23
osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class UnderscoredUserLink : UnderscoredLinkContainer
|
||||
{
|
||||
private readonly long userId;
|
||||
|
||||
public UnderscoredUserLink(long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(UserProfileOverlay userProfileOverlay)
|
||||
{
|
||||
ClickAction = () => userProfileOverlay?.ShowUser(userId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user