mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Use BindTarget
from card rather than caching & resolving download tracker
This commit is contained in:
@ -16,8 +16,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
public class DownloadButton : BeatmapCardIconButton
|
||||
{
|
||||
public IBindable<DownloadState> State => state;
|
||||
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
|
||||
|
||||
private readonly APIBeatmapSet beatmapSet;
|
||||
private readonly Bindable<DownloadState> downloadState = new Bindable<DownloadState>();
|
||||
|
||||
private Bindable<bool> preferNoVideo = null!;
|
||||
|
||||
@ -32,23 +34,22 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, BeatmapDownloadTracker downloadTracker)
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
preferNoVideo = config.GetBindable<bool>(OsuSetting.PreferNoVideo);
|
||||
((IBindable<DownloadState>)downloadState).BindTo(downloadTracker.State);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
preferNoVideo.BindValueChanged(_ => updateState());
|
||||
downloadState.BindValueChanged(_ => updateState(), true);
|
||||
state.BindValueChanged(_ => updateState(), true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
this.FadeTo(downloadState.Value != DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||
this.FadeTo(state.Value != DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||
|
||||
if (beatmapSet.Availability.DownloadDisabled)
|
||||
{
|
||||
|
@ -14,8 +14,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
public class GoToBeatmapButton : BeatmapCardIconButton
|
||||
{
|
||||
public IBindable<DownloadState> State => state;
|
||||
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
|
||||
|
||||
private readonly APIBeatmapSet beatmapSet;
|
||||
private readonly Bindable<DownloadState> downloadState = new Bindable<DownloadState>();
|
||||
|
||||
public GoToBeatmapButton(APIBeatmapSet beatmapSet)
|
||||
{
|
||||
@ -26,24 +28,22 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame? game, BeatmapDownloadTracker downloadTracker)
|
||||
private void load(OsuGame? game)
|
||||
{
|
||||
Action = () => game?.PresentBeatmap(beatmapSet);
|
||||
|
||||
((IBindable<DownloadState>)downloadState).BindTo(downloadTracker.State);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
downloadState.BindValueChanged(_ => updateState(), true);
|
||||
state.BindValueChanged(_ => updateState(), true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
this.FadeTo(downloadState.Value == DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||
this.FadeTo(state.Value == DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user