Replace OnAlreadyDownloading with returning a bool from Download.

This commit is contained in:
DrabWeb 2018-06-06 03:18:42 -03:00
parent df4c855aa2
commit 188272e15d
3 changed files with 24 additions and 26 deletions

View File

@ -18,8 +18,6 @@ namespace osu.Game.Beatmaps.Drawables
public readonly BindableBool Downloaded = new BindableBool(); public readonly BindableBool Downloaded = new BindableBool();
public event Action OnAlreadyDownloading;
public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false) public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false)
{ {
this.set = set; this.set = set;
@ -50,18 +48,16 @@ namespace osu.Game.Beatmaps.Drawables
} }
} }
public void Download() public bool Download()
{ {
if (Downloaded.Value) if (Downloaded.Value)
return; return false;
if (beatmaps.GetExistingDownload(set) != null) if (beatmaps.GetExistingDownload(set) != null)
{ return false;
OnAlreadyDownloading?.Invoke();
return;
}
beatmaps.Download(set, noVideo); beatmaps.Download(set, noVideo);
return true;
} }
private void setAdded(BeatmapSetInfo s) private void setAdded(BeatmapSetInfo s)

View File

@ -64,7 +64,16 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
}, },
}); });
Action = downloader.Download; Action = () =>
{
if (!downloader.Download())
{
Content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
.MoveToX(0, 50, Easing.InSine);
}
};
downloader.Downloaded.ValueChanged += d => downloader.Downloaded.ValueChanged += d =>
{ {
@ -73,14 +82,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
else else
this.FadeIn(200); this.FadeIn(200);
}; };
downloader.OnAlreadyDownloading += () =>
{
Content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
.MoveToX(0, 50, Easing.InSine);
};
} }
} }
} }

View File

@ -30,7 +30,16 @@ namespace osu.Game.Overlays.Direct
}, },
}; };
Action = downloader.Download; Action = () =>
{
if (!downloader.Download())
{
Content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
.MoveToX(0, 50, Easing.InSine);
}
};
downloader.Downloaded.ValueChanged += d => downloader.Downloaded.ValueChanged += d =>
{ {
@ -39,14 +48,6 @@ namespace osu.Game.Overlays.Direct
else else
this.FadeIn(200); this.FadeIn(200);
}; };
downloader.OnAlreadyDownloading += () =>
{
Content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
.MoveToX(0, 50, Easing.InSine);
};
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)