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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-02-10 05:27:37 +08:00
|
|
|
|
using System;
|
2021-06-17 15:05:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-09-13 10:41:10 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-06-18 02:55:07 +08:00
|
|
|
|
using osu.Game.Users.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
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;
|
2021-04-19 22:54:29 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2021-10-29 16:58:46 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-25 17:26:27 +08:00
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
2017-09-13 10:41:10 +08:00
|
|
|
|
{
|
|
|
|
|
public partial class AuthorInfo : Container
|
|
|
|
|
{
|
|
|
|
|
private const float height = 50;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 15:05:50 +08:00
|
|
|
|
private UpdateableAvatar avatar;
|
|
|
|
|
private FillFlowContainer fields;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
private APIBeatmapSet beatmapSet;
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public APIBeatmapSet BeatmapSet
|
2017-09-14 05:25:23 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => beatmapSet;
|
2017-09-14 05:25:23 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2017-09-14 05:25:23 +08:00
|
|
|
|
beatmapSet = value;
|
2021-06-17 15:05:50 +08:00
|
|
|
|
Scheduler.AddOnce(updateDisplay);
|
2017-09-14 05:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 15:05:50 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-09-13 10:41:10 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = height;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-13 10:41:10 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-12-20 19:08:22 +08:00
|
|
|
|
new Container
|
2017-09-13 10:41:10 +08:00
|
|
|
|
{
|
2017-09-30 10:41:32 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-02-17 04:43:33 +08:00
|
|
|
|
CornerRadius = 4,
|
2017-09-13 10:41:10 +08:00
|
|
|
|
Masking = true,
|
2023-11-15 08:15:22 +08:00
|
|
|
|
Child = avatar = new UpdateableAvatar(showUserPanelOnHover: true, showGuestOnNull: false)
|
2017-09-30 10:41:32 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(height),
|
|
|
|
|
},
|
2017-09-13 10:41:10 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Radius = 4,
|
2017-09-13 10:41:10 +08:00
|
|
|
|
Offset = new Vector2(0f, 1f),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
fields = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Left = height + 5 },
|
|
|
|
|
},
|
|
|
|
|
};
|
2021-06-17 15:05:50 +08:00
|
|
|
|
|
|
|
|
|
Scheduler.AddOnce(updateDisplay);
|
2017-09-13 10:41:10 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 15:05:50 +08:00
|
|
|
|
private void updateDisplay()
|
2017-09-30 10:41:32 +08:00
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
avatar.User = BeatmapSet?.Author;
|
2021-06-17 15:05:50 +08:00
|
|
|
|
|
|
|
|
|
fields.Clear();
|
|
|
|
|
if (BeatmapSet == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
fields.Children = new Drawable[]
|
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
new Field("mapped by", BeatmapSet.Author, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)),
|
|
|
|
|
new Field("submitted", BeatmapSet.Submitted, OsuFont.GetFont(weight: FontWeight.Bold))
|
2021-06-17 15:05:50 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
if (BeatmapSet.Ranked.HasValue)
|
2021-06-17 15:05:50 +08:00
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
fields.Add(new Field(BeatmapSet.Status.ToString().ToLowerInvariant(), BeatmapSet.Ranked.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
2021-06-17 15:05:50 +08:00
|
|
|
|
}
|
2021-10-29 16:58:46 +08:00
|
|
|
|
else if (BeatmapSet.LastUpdated.HasValue)
|
2021-06-17 15:05:50 +08:00
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
fields.Add(new Field("last updated", BeatmapSet.LastUpdated.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
2021-06-17 15:05:50 +08:00
|
|
|
|
}
|
2017-09-30 10:41:32 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-13 10:41:10 +08:00
|
|
|
|
private partial class Field : FillFlowContainer
|
|
|
|
|
{
|
2019-02-12 12:04:46 +08:00
|
|
|
|
public Field(string first, string second, FontUsage secondFont)
|
2017-09-13 10:41:10 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Horizontal;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-13 10:41:10 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = $"{first} ",
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 11)
|
2017-09-13 10:41:10 +08:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = second,
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Font = secondFont.With(size: 11)
|
2017-09-13 10:41:10 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-02-10 05:27:37 +08:00
|
|
|
|
|
|
|
|
|
public Field(string first, DateTimeOffset second, FontUsage secondFont)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Horizontal;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = $"{first} ",
|
|
|
|
|
Font = OsuFont.GetFont(size: 13)
|
|
|
|
|
},
|
|
|
|
|
new DrawableDate(second)
|
|
|
|
|
{
|
|
|
|
|
Font = secondFont.With(size: 13)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-04-19 22:54:29 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
public Field(string first, APIUser second, FontUsage secondFont)
|
2021-04-19 22:54:29 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Horizontal;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new LinkFlowContainer(s =>
|
|
|
|
|
{
|
|
|
|
|
s.Font = OsuFont.GetFont(size: 11);
|
|
|
|
|
}).With(d =>
|
|
|
|
|
{
|
|
|
|
|
d.AutoSizeAxes = Axes.Both;
|
|
|
|
|
d.AddText($"{first} ");
|
|
|
|
|
d.AddUserLink(second, s => s.Font = secondFont.With(size: 11));
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-09-13 10:41:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|