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:
parent
e174fa2d3e
commit
11234d3c60
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user