mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 16:42:55 +08:00
Merge pull request #4242 from UselessToucan/download_button_should_observe_beatmaps_availability
Update direct download button state on beatmapset removal
This commit is contained in:
commit
268be1c5d7
@ -11,6 +11,9 @@ using osu.Game.Online.API.Requests;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A component which tracks a beatmap through potential download/import/deletion.
|
||||||
|
/// </summary>
|
||||||
public abstract class DownloadTrackingComposite : CompositeDrawable
|
public abstract class DownloadTrackingComposite : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||||
@ -51,6 +54,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
};
|
};
|
||||||
|
|
||||||
beatmaps.ItemAdded += setAdded;
|
beatmaps.ItemAdded += setAdded;
|
||||||
|
beatmaps.ItemRemoved += setRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Disposal
|
#region Disposal
|
||||||
@ -105,27 +109,22 @@ namespace osu.Game.Overlays.Direct
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRequestSuccess(string data)
|
private void onRequestSuccess(string _) => Schedule(() => State.Value = DownloadState.Downloaded);
|
||||||
{
|
|
||||||
Schedule(() => State.Value = DownloadState.Downloaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onRequestProgress(float progress)
|
private void onRequestProgress(float progress) => Schedule(() => Progress.Value = progress);
|
||||||
{
|
|
||||||
Schedule(() => Progress.Value = progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onRequestFailure(Exception e)
|
private void onRequestFailure(Exception e) => Schedule(() => attachDownload(null));
|
||||||
{
|
|
||||||
Schedule(() => attachDownload(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo s, bool existing, bool silent)
|
private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => setDownloadStateFromManager(s, DownloadState.LocallyAvailable);
|
||||||
|
|
||||||
|
private void setRemoved(BeatmapSetInfo s) => setDownloadStateFromManager(s, DownloadState.NotDownloaded);
|
||||||
|
|
||||||
|
private void setDownloadStateFromManager(BeatmapSetInfo s, DownloadState state) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (s.OnlineBeatmapSetID != BeatmapSet.Value?.OnlineBeatmapSetID)
|
if (s.OnlineBeatmapSetID != BeatmapSet.Value?.OnlineBeatmapSetID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Schedule(() => State.Value = DownloadState.LocallyAvailable);
|
State.Value = state;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user