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