2021-11-19 05:28:17 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Online;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|
|
|
{
|
2021-11-21 01:36:39 +08:00
|
|
|
public class GoToBeatmapButton : BeatmapCardIconButton
|
2021-11-19 05:28:17 +08:00
|
|
|
{
|
2021-11-21 01:45:24 +08:00
|
|
|
public IBindable<DownloadState> State => state;
|
|
|
|
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
|
|
|
|
|
2021-11-19 05:28:17 +08:00
|
|
|
private readonly APIBeatmapSet beatmapSet;
|
|
|
|
|
2021-11-21 01:36:39 +08:00
|
|
|
public GoToBeatmapButton(APIBeatmapSet beatmapSet)
|
2021-11-19 05:28:17 +08:00
|
|
|
{
|
|
|
|
this.beatmapSet = beatmapSet;
|
|
|
|
|
|
|
|
Icon.Icon = FontAwesome.Solid.AngleDoubleRight;
|
|
|
|
TooltipText = "Go to beatmap";
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2021-11-21 01:45:24 +08:00
|
|
|
private void load(OsuGame? game)
|
2021-11-19 05:28:17 +08:00
|
|
|
{
|
2021-11-19 14:27:38 +08:00
|
|
|
Action = () => game?.PresentBeatmap(beatmapSet);
|
2021-11-19 05:28:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-11-21 01:45:24 +08:00
|
|
|
state.BindValueChanged(_ => updateState(), true);
|
2021-11-19 05:28:17 +08:00
|
|
|
FinishTransforms(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
2021-12-21 15:26:19 +08:00
|
|
|
this.FadeTo(state.Value == DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2021-11-19 05:28:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|