1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 07:23:14 +08:00

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 event Action OnAlreadyDownloading;
public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false)
{
this.set = set;
@ -50,18 +48,16 @@ namespace osu.Game.Beatmaps.Drawables
}
}
public void Download()
public bool Download()
{
if (Downloaded.Value)
return;
return false;
if (beatmaps.GetExistingDownload(set) != null)
{
OnAlreadyDownloading?.Invoke();
return;
}
return false;
beatmaps.Download(set, noVideo);
return true;
}
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 =>
{
@ -73,14 +82,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
else
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 =>
{
@ -39,14 +48,6 @@ namespace osu.Game.Overlays.Direct
else
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)