public BeatmapCard(APIBeatmapSet beatmapSet) : base(HoverSampleSet.Submit) { this.beatmapSet = beatmapSet; favouriteState = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount)); downloadTracker = new BeatmapDownloadTracker(beatmapSet); }
protected BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true) : base(HoverSampleSet.Button) { Expanded = new BindableBool { Disabled = !allowExpansion }; BeatmapSet = beatmapSet; FavouriteState = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount)); DownloadTracker = new BeatmapDownloadTracker(beatmapSet); }
public BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true) : base(HoverSampleSet.Submit) { Expanded = new BindableBool { Disabled = !allowExpansion }; this.beatmapSet = beatmapSet; favouriteState = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount)); downloadTracker = new BeatmapDownloadTracker(beatmapSet); }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => Scheduler.AddOnce(updateAvailability), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); // handles changes to hash that didn't occur from the import process (ie. a user editing the beatmap in the editor, somehow). realmSubscription?.Dispose(); realmSubscription = realm.RegisterForNotifications(r => filteredBeatmaps(), (items, changes, ___) => { if (changes == null) { return; } Scheduler.AddOnce(updateAvailability); }); }, true); }
private void load(OverlayColourProvider colourProvider) { coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f)); BeatmapSet.BindValueChanged(setInfo => { Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; cover.OnlineInfo = setInfo.NewValue; downloadTracker?.RemoveAndDisposeImmediately(); if (setInfo.NewValue == null) { onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint); fadeContent.Hide(); loading.Show(); downloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } else { downloadTracker = new BeatmapDownloadTracker(setInfo.NewValue); downloadTracker.State.BindValueChanged(_ => updateDownloadButtons()); AddInternal(downloadTracker); fadeContent.FadeIn(500, Easing.OutQuint); loading.Hide(); title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; featuredArtist.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0; onlineStatusPill.FadeIn(500, Easing.OutQuint); downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); updateDownloadButtons(); } }, true); }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => updateAvailability(), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); }, true); // These events are needed for a fringe case where a modified/altered beatmap is imported with matching OnlineIDs. // During the import process this will cause the existing beatmap set to be silently deleted and replaced with the new one. // This is not exposed to us via `BeatmapDownloadTracker` so we have to take it into our own hands (as we care about the hash matching). beatmapManager.ItemUpdated += itemUpdated; beatmapManager.ItemRemoved += itemRemoved; }
private void load() { foreach (string filename in downloadableFilenames) { var match = Regex.Match(filename, @"([0-9]*) (.*) - (.*)\.osz"); var beatmapSet = new APIBeatmapSet { OnlineID = int.Parse(match.Groups[1].Value), Artist = match.Groups[2].Value, Title = match.Groups[3].Value, }; var beatmapDownloadTracker = new BeatmapDownloadTracker(beatmapSet); downloadTrackers.Add(beatmapDownloadTracker); AddInternal(beatmapDownloadTracker); beatmapDownloader.Download(beatmapSet); } }
private void load() { foreach (string filename in downloadableFilenames) { var match = Regex.Match(filename, @"([0-9]*) (.*) - (.*)\.osz"); var beatmapSet = new APIBeatmapSet { OnlineID = int.Parse(match.Groups[1].Value), Artist = match.Groups[2].Value, Title = match.Groups[3].Value, }; var beatmapDownloadTracker = new BeatmapDownloadTracker(beatmapSet); downloadTrackers.Add(beatmapDownloadTracker); AddInternal(beatmapDownloadTracker); // Note that this is downloading the beatmaps even if they are already downloaded. // We could rely more on `BeatmapDownloadTracker`'s exposed state to avoid this. beatmapDownloader.Download(beatmapSet); } }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => updateAvailability(), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); }, true); }
private void beginTracking() { Debug.Assert(selectedBeatmap.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(selectedBeatmap.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => Scheduler.AddOnce(updateAvailability), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); // handles changes to hash that didn't occur from the import process (ie. a user editing the beatmap in the editor, somehow). realmSubscription?.Dispose(); realmSubscription = realm.RegisterForNotifications(r => filteredBeatmaps(), (items, changes, ___) => { if (changes == null) { return; } Scheduler.AddOnce(updateAvailability); }); }