2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Users;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-02-12 12:04:46 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
|
|
|
|
{
|
|
|
|
|
public class AuthorInfo : Container
|
|
|
|
|
{
|
|
|
|
|
private const float height = 50;
|
|
|
|
|
|
|
|
|
|
private readonly UpdateableAvatar avatar;
|
|
|
|
|
private readonly FillFlowContainer fields;
|
|
|
|
|
|
|
|
|
|
private BeatmapSetInfo beatmapSet;
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public BeatmapSetInfo BeatmapSet
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => beatmapSet;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
beatmapSet = value;
|
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
private void updateDisplay()
|
|
|
|
|
{
|
|
|
|
|
avatar.User = BeatmapSet?.Metadata.Author;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
fields.Clear();
|
|
|
|
|
if (BeatmapSet == null)
|
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
var online = BeatmapSet.OnlineInfo;
|
|
|
|
|
|
|
|
|
|
fields.Children = new Drawable[]
|
|
|
|
|
{
|
2019-02-20 15:52:36 +08:00
|
|
|
|
new Field("mapped by", BeatmapSet.Metadata.Author.Username, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)),
|
2019-02-12 12:04:46 +08:00
|
|
|
|
new Field("submitted on", online.Submitted.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-18 15:04:02 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (online.Ranked.HasValue)
|
|
|
|
|
{
|
2019-02-12 12:04:46 +08:00
|
|
|
|
fields.Add(new Field("ranked on", online.Ranked.Value.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold)));
|
2018-04-18 15:04:02 +08:00
|
|
|
|
}
|
|
|
|
|
else if (online.LastUpdated.HasValue)
|
|
|
|
|
{
|
2019-02-12 12:04:46 +08:00
|
|
|
|
fields.Add(new Field("last updated on", online.LastUpdated.Value.ToString(@"MMMM d, yyyy"), OsuFont.GetFont(weight: FontWeight.Bold)));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AuthorInfo()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = height;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-12-20 19:08:22 +08:00
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = 3,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = avatar = new UpdateableAvatar
|
|
|
|
|
{
|
2018-04-18 15:04:02 +08:00
|
|
|
|
ShowGuestOnNull = false,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Size = new Vector2(height),
|
|
|
|
|
},
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 3,
|
|
|
|
|
Offset = new Vector2(0f, 1f),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
fields = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Left = height + 5 },
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 19:08:22 +08:00
|
|
|
|
private void load()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-18 15:04:02 +08:00
|
|
|
|
updateDisplay();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class Field : FillFlowContainer
|
|
|
|
|
{
|
2019-02-12 12:04:46 +08:00
|
|
|
|
public Field(string first, string second, FontUsage secondFont)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Horizontal;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = $"{first} ",
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 13)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = second,
|
2019-02-20 18:32:30 +08:00
|
|
|
|
Font = secondFont.With(size: 13)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ClickableArea : OsuClickableContainer, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
public string TooltipText => @"View Profile";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|