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
|
|
|
|
|
2018-05-26 04:51:05 +08:00
|
|
|
|
using System.Linq;
|
2019-02-28 17:44:40 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2021-10-29 16:58:46 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
2020-02-22 08:24:50 +08:00
|
|
|
|
using osu.Game.Overlays.Comments;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
using osuTK.Graphics;
|
2019-07-09 22:56:08 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2021-01-21 12:30:47 +08:00
|
|
|
|
public class BeatmapSetOverlay : OnlineOverlay<BeatmapSetHeader>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public const float X_PADDING = 40;
|
2020-02-05 03:17:27 +08:00
|
|
|
|
public const float Y_PADDING = 25;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public const float RIGHT_WIDTH = 275;
|
2020-09-03 14:46:56 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
private readonly Bindable<APIBeatmapSet> beatmapSet = new Bindable<APIBeatmapSet>();
|
2018-04-18 12:08:53 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public BeatmapSetOverlay()
|
2021-01-18 15:48:12 +08:00
|
|
|
|
: base(OverlayColourScheme.Blue)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-28 18:58:21 +08:00
|
|
|
|
Info info;
|
2020-02-22 08:40:59 +08:00
|
|
|
|
CommentsSection comments;
|
2019-07-11 00:40:29 +08:00
|
|
|
|
|
2021-01-18 15:48:12 +08:00
|
|
|
|
Child = new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-01-18 15:48:12 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 20),
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-01-21 12:30:47 +08:00
|
|
|
|
info = new Info(),
|
2021-01-18 15:48:12 +08:00
|
|
|
|
new ScoresContainer
|
|
|
|
|
{
|
2021-01-21 12:30:47 +08:00
|
|
|
|
Beatmap = { BindTarget = Header.HeaderContent.Picker.Beatmap }
|
2021-01-18 15:48:12 +08:00
|
|
|
|
},
|
|
|
|
|
comments = new CommentsSection()
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-06-12 22:37:34 +08:00
|
|
|
|
Header.BeatmapSet.BindTo(beatmapSet);
|
2019-02-28 17:44:40 +08:00
|
|
|
|
info.BeatmapSet.BindTo(beatmapSet);
|
2020-02-22 08:24:50 +08:00
|
|
|
|
comments.BeatmapSet.BindTo(beatmapSet);
|
2019-02-28 17:44:40 +08:00
|
|
|
|
|
2021-01-20 09:56:46 +08:00
|
|
|
|
Header.HeaderContent.Picker.Beatmap.ValueChanged += b =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-02 23:55:29 +08:00
|
|
|
|
info.BeatmapInfo = b.NewValue;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
ScrollFlow.ScrollToStart();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-21 12:30:47 +08:00
|
|
|
|
protected override BeatmapSetHeader CreateHeader() => new BeatmapSetHeader();
|
2021-01-18 15:48:12 +08:00
|
|
|
|
|
2021-02-09 17:32:44 +08:00
|
|
|
|
protected override Color4 BackgroundColour => ColourProvider.Background6;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 14:19:23 +08:00
|
|
|
|
protected override void PopOutComplete()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-14 14:19:23 +08:00
|
|
|
|
base.PopOutComplete();
|
|
|
|
|
beatmapSet.Value = null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 14:58:45 +08:00
|
|
|
|
public void FetchAndShowBeatmap(int beatmapId)
|
2018-04-18 12:08:53 +08:00
|
|
|
|
{
|
2019-02-28 17:44:40 +08:00
|
|
|
|
beatmapSet.Value = null;
|
2019-07-09 22:38:17 +08:00
|
|
|
|
|
2018-04-18 12:08:53 +08:00
|
|
|
|
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
|
|
|
|
|
req.Success += res =>
|
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
beatmapSet.Value = res;
|
|
|
|
|
Header.HeaderContent.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineID == beatmapId);
|
2018-04-18 12:08:53 +08:00
|
|
|
|
};
|
2019-05-14 14:07:18 +08:00
|
|
|
|
API.Queue(req);
|
2019-07-09 22:38:17 +08:00
|
|
|
|
|
2018-04-18 12:08:53 +08:00
|
|
|
|
Show();
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 14:58:45 +08:00
|
|
|
|
public void FetchAndShowBeatmapSet(int beatmapSetId)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-28 17:44:40 +08:00
|
|
|
|
beatmapSet.Value = null;
|
2019-07-09 22:38:17 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var req = new GetBeatmapSetRequest(beatmapSetId);
|
2021-10-29 16:58:46 +08:00
|
|
|
|
req.Success += res => beatmapSet.Value = res;
|
2019-05-14 14:07:18 +08:00
|
|
|
|
API.Queue(req);
|
2019-07-09 22:38:17 +08:00
|
|
|
|
|
2018-04-18 12:08:53 +08:00
|
|
|
|
Show();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 11:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Show an already fully-populated beatmap set.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="set">The set to show.</param>
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public void ShowBeatmapSet(APIBeatmapSet set)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
beatmapSet.Value = set;
|
|
|
|
|
Show();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2020-02-22 08:24:50 +08:00
|
|
|
|
|
2020-02-22 08:40:59 +08:00
|
|
|
|
private class CommentsSection : BeatmapSetLayoutSection
|
2020-02-22 08:24:50 +08:00
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
2020-02-22 08:24:50 +08:00
|
|
|
|
|
2020-02-22 08:40:59 +08:00
|
|
|
|
public CommentsSection()
|
2020-02-22 08:24:50 +08:00
|
|
|
|
{
|
2020-02-22 08:40:59 +08:00
|
|
|
|
CommentsContainer comments;
|
|
|
|
|
|
|
|
|
|
Add(comments = new CommentsContainer());
|
|
|
|
|
|
2020-02-22 08:24:50 +08:00
|
|
|
|
BeatmapSet.BindValueChanged(beatmapSet =>
|
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
if (beatmapSet.NewValue?.OnlineID > 0)
|
2020-02-22 08:24:50 +08:00
|
|
|
|
{
|
2020-02-23 21:46:42 +08:00
|
|
|
|
Show();
|
2021-10-29 16:58:46 +08:00
|
|
|
|
comments.ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineID);
|
2020-02-22 08:24:50 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-02-23 21:46:42 +08:00
|
|
|
|
Hide();
|
2020-02-22 08:24:50 +08:00
|
|
|
|
}
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|