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-12-14 13:20:03 +08:00
|
|
|
|
2018-12-14 14:04:04 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Configuration;
|
2018-12-14 13:20:03 +08:00
|
|
|
using osu.Framework.Graphics;
|
2018-12-14 14:04:04 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2018-12-14 13:20:03 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Match.Components
|
|
|
|
{
|
|
|
|
public class ViewBeatmapButton : HeaderButton
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
2018-12-14 14:04:04 +08:00
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private OsuGame osuGame { get; set; }
|
|
|
|
|
2018-12-14 13:20:03 +08:00
|
|
|
public ViewBeatmapButton()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
Size = new Vector2(200, 1);
|
|
|
|
|
|
|
|
Text = "View beatmap";
|
|
|
|
}
|
2018-12-14 14:04:04 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
if (osuGame != null)
|
|
|
|
Beatmap.BindValueChanged(updateAction, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateAction(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
if (beatmap == null)
|
|
|
|
{
|
|
|
|
Enabled.Value = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Action = () => osuGame.ShowBeatmap(beatmap.OnlineBeatmapID ?? 0);
|
|
|
|
Enabled.Value = true;
|
|
|
|
}
|
2018-12-14 13:20:03 +08:00
|
|
|
}
|
|
|
|
}
|