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;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
2018-05-26 04:51:05 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class BeatmapSetOverlay : WaveOverlayContainer
|
|
|
|
|
{
|
2018-04-18 12:08:53 +08:00
|
|
|
|
private const int fade_duration = 300;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public const float X_PADDING = 40;
|
|
|
|
|
public const float RIGHT_WIDTH = 275;
|
|
|
|
|
|
|
|
|
|
private readonly Header header;
|
|
|
|
|
private readonly Info info;
|
|
|
|
|
|
|
|
|
|
private APIAccess api;
|
|
|
|
|
private RulesetStore rulesets;
|
|
|
|
|
|
|
|
|
|
private readonly ScrollContainer scroll;
|
|
|
|
|
|
2018-04-18 12:08:53 +08:00
|
|
|
|
private BeatmapSetInfo beatmapSet;
|
|
|
|
|
|
|
|
|
|
public BeatmapSetInfo BeatmapSet
|
|
|
|
|
{
|
|
|
|
|
get => beatmapSet;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-01-18 13:28:06 +08:00
|
|
|
|
header.BeatmapSet.Value = info.BeatmapSet = beatmapSet = value;
|
2018-04-18 12:08:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
// receive input outside our bounds so we can trigger a close event on ourselves.
|
2018-09-26 13:01:15 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public BeatmapSetOverlay()
|
|
|
|
|
{
|
2018-04-18 14:58:45 +08:00
|
|
|
|
ScoresContainer scores;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
Waves.FirstWaveColour = OsuColour.Gray(0.4f);
|
|
|
|
|
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
|
|
|
|
|
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
|
|
|
|
|
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.2f)
|
|
|
|
|
},
|
|
|
|
|
scroll = new ScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollbarVisible = false,
|
|
|
|
|
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
header = new Header(),
|
|
|
|
|
info = new Info(),
|
|
|
|
|
scores = new ScoresContainer(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-22 16:51:39 +08:00
|
|
|
|
header.Picker.Beatmap.ValueChanged += b =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-22 16:51:39 +08:00
|
|
|
|
info.Beatmap = b.NewValue;
|
|
|
|
|
scores.Beatmap = b.NewValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-06-21 15:19:07 +08:00
|
|
|
|
private void load(APIAccess api, RulesetStore rulesets)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
this.rulesets = rulesets;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
2018-04-15 15:44:40 +08:00
|
|
|
|
FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2018-04-20 11:47:23 +08:00
|
|
|
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
State = Visibility.Hidden;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 14:58:45 +08:00
|
|
|
|
public void FetchAndShowBeatmap(int beatmapId)
|
2018-04-18 12:08:53 +08:00
|
|
|
|
{
|
|
|
|
|
BeatmapSet = null;
|
|
|
|
|
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
|
|
|
|
|
req.Success += res =>
|
|
|
|
|
{
|
2018-11-25 17:19:09 +08:00
|
|
|
|
BeatmapSet = res.ToBeatmapSet(rulesets);
|
2019-01-18 13:28:06 +08:00
|
|
|
|
header.Picker.Beatmap.Value = header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
|
2018-04-18 12:08:53 +08:00
|
|
|
|
};
|
|
|
|
|
api.Queue(req);
|
|
|
|
|
Show();
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 14:58:45 +08:00
|
|
|
|
public void FetchAndShowBeatmapSet(int beatmapSetId)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-18 12:08:53 +08:00
|
|
|
|
BeatmapSet = null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var req = new GetBeatmapSetRequest(beatmapSetId);
|
2018-11-25 17:19:09 +08:00
|
|
|
|
req.Success += res => BeatmapSet = res.ToBeatmapSet(rulesets);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
api.Queue(req);
|
2018-04-18 12:08:53 +08:00
|
|
|
|
Show();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowBeatmapSet(BeatmapSetInfo set)
|
|
|
|
|
{
|
2018-04-18 12:08:53 +08:00
|
|
|
|
BeatmapSet = set;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Show();
|
|
|
|
|
scroll.ScrollTo(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|