1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 04:07:24 +08:00
osu-lazer/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2018-12-14 13:20:03 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
2018-12-14 13:20:03 +08:00
using osu.Framework.Graphics;
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
{
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[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";
}
[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
}
}