2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-08 21:32:07 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-10-13 10:58:25 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-09-08 21:32:07 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-09-13 00:00:20 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-09-25 15:35:40 +00:00
|
|
|
|
using osu.Framework.Input;
|
2017-09-08 21:32:07 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-10-13 10:58:25 +00:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2017-09-25 09:26:27 +00:00
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
2017-10-13 10:58:25 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
2017-11-11 00:46:06 +00:00
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
2017-09-08 21:32:07 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-09-25 09:26:27 +00:00
|
|
|
|
public class BeatmapSetOverlay : WaveOverlayContainer
|
2017-09-08 21:32:07 +00:00
|
|
|
|
{
|
|
|
|
|
public const float X_PADDING = 40;
|
|
|
|
|
public const float RIGHT_WIDTH = 275;
|
|
|
|
|
|
2017-09-13 15:37:18 +00:00
|
|
|
|
private readonly Header header;
|
|
|
|
|
private readonly Info info;
|
2017-11-12 04:05:50 +00:00
|
|
|
|
private readonly ScoresContainer scores;
|
2017-09-08 21:32:07 +00:00
|
|
|
|
|
2017-10-13 10:58:25 +00:00
|
|
|
|
private APIAccess api;
|
|
|
|
|
private RulesetStore rulesets;
|
2017-11-12 04:05:50 +00:00
|
|
|
|
private GetScoresRequest getScoresRequest;
|
2017-10-13 10:58:25 +00:00
|
|
|
|
|
2017-11-15 10:01:30 +00:00
|
|
|
|
private readonly ScrollContainer scroll;
|
|
|
|
|
|
2017-09-27 03:22:47 +00:00
|
|
|
|
// receive input outside our bounds so we can trigger a close event on ourselves.
|
|
|
|
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
|
|
|
|
|
2017-09-25 09:26:27 +00:00
|
|
|
|
public BeatmapSetOverlay()
|
2017-09-08 21:32:07 +00:00
|
|
|
|
{
|
|
|
|
|
FirstWaveColour = OsuColour.Gray(0.4f);
|
|
|
|
|
SecondWaveColour = OsuColour.Gray(0.3f);
|
|
|
|
|
ThirdWaveColour = OsuColour.Gray(0.2f);
|
|
|
|
|
FourthWaveColour = OsuColour.Gray(0.1f);
|
|
|
|
|
|
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Width = 0.85f;
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 3,
|
|
|
|
|
Offset = new Vector2(0f, 1f),
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-13 00:00:20 +00:00
|
|
|
|
Children = new Drawable[]
|
2017-09-08 21:32:07 +00:00
|
|
|
|
{
|
2017-09-13 00:00:20 +00:00
|
|
|
|
new Box
|
2017-09-08 21:32:07 +00:00
|
|
|
|
{
|
2017-09-13 00:00:20 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.2f)
|
|
|
|
|
},
|
2017-11-15 10:01:30 +00:00
|
|
|
|
scroll = new ScrollContainer
|
2017-09-13 00:00:20 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollbarVisible = false,
|
2017-09-13 15:37:18 +00:00
|
|
|
|
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
2017-09-13 00:00:20 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-09-13 15:37:18 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-09-13 21:25:23 +00:00
|
|
|
|
header = new Header(),
|
2017-09-13 15:37:18 +00:00
|
|
|
|
info = new Info(),
|
2017-11-11 00:46:06 +00:00
|
|
|
|
scores = new ScoresContainer(),
|
2017-09-13 15:37:18 +00:00
|
|
|
|
},
|
2017-09-13 00:00:20 +00:00
|
|
|
|
},
|
2017-09-08 21:32:07 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2017-09-13 15:37:18 +00:00
|
|
|
|
|
2017-11-12 04:05:50 +00:00
|
|
|
|
header.Picker.Beatmap.ValueChanged += b =>
|
|
|
|
|
{
|
|
|
|
|
info.Beatmap = b;
|
|
|
|
|
updateScores(b);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateScores(BeatmapInfo beatmap)
|
|
|
|
|
{
|
|
|
|
|
getScoresRequest?.Cancel();
|
|
|
|
|
|
|
|
|
|
if (!beatmap.OnlineBeatmapID.HasValue)
|
|
|
|
|
{
|
|
|
|
|
scores.CleanAllScores();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 15:49:10 +00:00
|
|
|
|
scores.IsLoading = true;
|
2017-11-12 04:05:50 +00:00
|
|
|
|
|
2017-12-11 09:35:12 +00:00
|
|
|
|
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
2017-11-13 15:49:10 +00:00
|
|
|
|
getScoresRequest.Success += r =>
|
|
|
|
|
{
|
|
|
|
|
scores.Scores = r.Scores;
|
|
|
|
|
scores.IsLoading = false;
|
|
|
|
|
};
|
2017-11-12 04:05:50 +00:00
|
|
|
|
api.Queue(getScoresRequest);
|
2017-09-08 21:32:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 10:58:25 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(APIAccess api, RulesetStore rulesets)
|
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
this.rulesets = rulesets;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 21:32:07 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
FadeEdgeEffectTo(0.25f, APPEAR_DURATION, Easing.In);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2017-10-14 02:58:06 +00:00
|
|
|
|
header.Details.StopPreview();
|
2017-09-08 21:32:07 +00:00
|
|
|
|
FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 15:35:40 +00:00
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
State = Visibility.Hidden;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 10:58:25 +00:00
|
|
|
|
public void ShowBeatmapSet(int beatmapSetId)
|
|
|
|
|
{
|
|
|
|
|
// todo: display the overlay while we are loading here. we need to support setting BeatmapSet to null for this to work.
|
|
|
|
|
var req = new GetBeatmapSetRequest(beatmapSetId);
|
|
|
|
|
req.Success += res => ShowBeatmapSet(res.ToBeatmapSet(rulesets));
|
|
|
|
|
api.Queue(req);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 21:32:07 +00:00
|
|
|
|
public void ShowBeatmapSet(BeatmapSetInfo set)
|
|
|
|
|
{
|
2017-09-13 21:25:23 +00:00
|
|
|
|
header.BeatmapSet = info.BeatmapSet = set;
|
2017-09-08 21:32:07 +00:00
|
|
|
|
Show();
|
2017-11-15 10:01:30 +00:00
|
|
|
|
scroll.ScrollTo(0);
|
2017-09-08 21:32:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|