1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapDetailArea.cs

92 lines
3.1 KiB
C#
Raw Normal View History

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.Framework.Graphics.Transforms;
using osu.Game.Beatmaps;
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 12:19:29 +08:00
private const float transition_duration = 500;
2017-03-23 11:29:28 +08:00
private Container content;
protected override Container<Drawable> Content => content;
2017-03-23 12:19:29 +08:00
public readonly Container Details; //todo: replace with a real details view when added
public readonly Leaderboard Leaderboard;
private OsuGame game;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGame game)
{
this.game = game;
}
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-03-23 12:19:29 +08:00
OnFilter = (tab, mods) =>
{
switch (tab)
{
case BeatmapDetailTab.Details:
Details.FadeIn(transition_duration, EasingTypes.OutQuint);
Leaderboard.FadeOut(transition_duration, EasingTypes.OutQuint);
break;
default:
Details.FadeOut(transition_duration, EasingTypes.OutQuint);
Leaderboard.FadeIn(transition_duration, EasingTypes.OutQuint);
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[]
{
Details = new Container
{
RelativeSizeAxes = Axes.Both,
},
Leaderboard = new Leaderboard
{
RelativeSizeAxes = Axes.Both,
}
});
}
private GetScoresRequest getScoresRequest;
public void PresentScores(WorkingBeatmap beatmap)
{
if (game == null) return;
Leaderboard.Scores = null;
getScoresRequest?.Cancel();
if (beatmap?.BeatmapInfo == null) return;
getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo);
getScoresRequest.Success += r => Leaderboard.Scores = r.Scores;
game.API.Queue(getScoresRequest);
2017-03-23 11:22:31 +08:00
}
}
}