2017-03-23 11:22:31 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-03-23 12:19:29 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-03-23 11:22:31 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-23 15:32:35 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
|
using osu.Game.Screens.Select.Leaderboards;
|
2017-03-23 11:22:31 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class BeatmapDetailArea : Container
|
|
|
|
|
{
|
2017-03-23 13:47:27 +08:00
|
|
|
|
private readonly Container content;
|
2017-03-23 11:29:28 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2017-03-30 23:32:18 +08:00
|
|
|
|
public readonly BeatmapDetails Details;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
public readonly Leaderboard Leaderboard;
|
|
|
|
|
|
2017-03-23 15:32:35 +08:00
|
|
|
|
private APIAccess api;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
|
2017-03-23 15:31:08 +08:00
|
|
|
|
private WorkingBeatmap beatmap;
|
|
|
|
|
public WorkingBeatmap Beatmap
|
2017-03-23 12:19:29 +08:00
|
|
|
|
{
|
2017-03-23 15:31:08 +08:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return beatmap;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
beatmap = value;
|
2017-04-08 00:24:36 +08:00
|
|
|
|
Schedule(updateDetails);
|
|
|
|
|
Schedule(updateScores);
|
2017-03-23 15:31:08 +08:00
|
|
|
|
}
|
2017-03-23 12:19:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 11:22:31 +08:00
|
|
|
|
public BeatmapDetailArea()
|
|
|
|
|
{
|
2017-03-23 11:29:28 +08:00
|
|
|
|
AddInternal(new Drawable[]
|
2017-03-23 11:22:31 +08:00
|
|
|
|
{
|
|
|
|
|
new BeatmapDetailAreaTabControl
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-04 23:27:08 +08:00
|
|
|
|
OnFilter = (tab, mods) =>
|
2017-03-23 12:19:29 +08:00
|
|
|
|
{
|
|
|
|
|
switch (tab)
|
|
|
|
|
{
|
|
|
|
|
case BeatmapDetailTab.Details:
|
2017-03-23 15:28:40 +08:00
|
|
|
|
Details.Show();
|
|
|
|
|
Leaderboard.Hide();
|
2017-03-23 12:19:29 +08:00
|
|
|
|
break;
|
2017-04-04 23:27:08 +08:00
|
|
|
|
|
2017-03-23 12:19:29 +08:00
|
|
|
|
default:
|
2017-03-23 15:28:40 +08:00
|
|
|
|
Details.Hide();
|
|
|
|
|
Leaderboard.Show();
|
2017-03-25 06:02:24 +08:00
|
|
|
|
updateScores();
|
2017-03-23 12:19:29 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-23 11:22:31 +08:00
|
|
|
|
},
|
2017-03-23 11:29:28 +08:00
|
|
|
|
content = new Container
|
2017-03-23 11:22:31 +08:00
|
|
|
|
{
|
2017-03-23 11:29:28 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-23 11:22:31 +08:00
|
|
|
|
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
|
|
|
|
|
},
|
2017-03-23 11:29:28 +08:00
|
|
|
|
});
|
2017-03-23 12:19:29 +08:00
|
|
|
|
|
|
|
|
|
Add(new Drawable[]
|
|
|
|
|
{
|
2017-03-30 23:32:18 +08:00
|
|
|
|
Details = new BeatmapDetails
|
2017-03-23 12:19:29 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-26 06:33:03 +08:00
|
|
|
|
Padding = new MarginPadding(5),
|
2017-04-06 21:39:23 +08:00
|
|
|
|
Alpha = 0,
|
2017-03-23 12:19:29 +08:00
|
|
|
|
},
|
|
|
|
|
Leaderboard = new Leaderboard
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 15:31:08 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
updateScores();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
2017-03-23 15:32:35 +08:00
|
|
|
|
private void load(APIAccess api)
|
2017-03-23 15:31:08 +08:00
|
|
|
|
{
|
2017-03-23 15:32:35 +08:00
|
|
|
|
this.api = api;
|
2017-03-23 15:31:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 12:19:29 +08:00
|
|
|
|
private GetScoresRequest getScoresRequest;
|
2017-04-04 23:27:08 +08:00
|
|
|
|
|
2017-03-23 15:31:08 +08:00
|
|
|
|
private void updateScores()
|
2017-03-23 12:19:29 +08:00
|
|
|
|
{
|
2017-03-23 15:32:35 +08:00
|
|
|
|
if (!IsLoaded) return;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
|
|
|
|
|
Leaderboard.Scores = null;
|
|
|
|
|
getScoresRequest?.Cancel();
|
|
|
|
|
|
2017-03-23 15:32:35 +08:00
|
|
|
|
if (api == null || beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) return;
|
2017-03-23 12:19:29 +08:00
|
|
|
|
|
|
|
|
|
getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo);
|
|
|
|
|
getScoresRequest.Success += r => Leaderboard.Scores = r.Scores;
|
2017-03-23 15:32:35 +08:00
|
|
|
|
api.Queue(getScoresRequest);
|
2017-03-23 11:22:31 +08:00
|
|
|
|
}
|
2017-03-25 06:02:24 +08:00
|
|
|
|
|
|
|
|
|
private void updateDetails()
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded) return;
|
|
|
|
|
|
|
|
|
|
if (api == null || beatmap?.BeatmapInfo == null) return;
|
2017-04-04 23:27:08 +08:00
|
|
|
|
|
2017-03-26 06:33:03 +08:00
|
|
|
|
Details.Beatmap = beatmap.Beatmap.BeatmapInfo;
|
2017-03-25 06:02:24 +08:00
|
|
|
|
}
|
2017-03-23 11:22:31 +08:00
|
|
|
|
}
|
2017-04-04 23:27:08 +08:00
|
|
|
|
}
|