1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Update direct download button state on beatmap import and removal

This commit is contained in:
Roman Kapustin 2019-02-12 21:20:49 +03:00
parent e174fa2d3e
commit 11234d3c60
2 changed files with 20 additions and 9 deletions

View File

@ -76,6 +76,9 @@ namespace osu.Game.Overlays.Direct
{
this.colours = colours;
beatmaps.ItemAdded += (set, existing, silent) => updateState(BeatmapSet.Value);
beatmaps.ItemRemoved += set => updateState(BeatmapSet.Value);
button.Action = () =>
{
switch (State.Value)
@ -94,6 +97,12 @@ namespace osu.Game.Overlays.Direct
};
}
private void updateState(BeatmapSetInfo set)
{
if (set.OnlineBeatmapSetID == BeatmapSet.Value.OnlineBeatmapSetID)
UpdateState(BeatmapSet.Value);
}
private void updateState(DownloadState state)
{
switch (state)

View File

@ -34,15 +34,7 @@ namespace osu.Game.Overlays.Direct
{
this.beatmaps = beatmaps;
BeatmapSet.BindValueChanged(set =>
{
if (set == null)
attachDownload(null);
else if (beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID).Any())
State.Value = DownloadState.LocallyAvailable;
else
attachDownload(beatmaps.GetExistingDownload(set));
}, true);
BeatmapSet.BindValueChanged(UpdateState, true);
beatmaps.BeatmapDownloadBegan += download =>
{
@ -53,6 +45,16 @@ namespace osu.Game.Overlays.Direct
beatmaps.ItemAdded += setAdded;
}
protected void UpdateState(BeatmapSetInfo set)
{
if (set == null)
attachDownload(null);
else if (this.beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Any())
State.Value = DownloadState.LocallyAvailable;
else
attachDownload(this.beatmaps.GetExistingDownload(set));
}
#region Disposal
protected override void Dispose(bool isDisposing)