Ejemplo n.º 1
0
        private void PullWholeMapsets(object sender)
        {
            var model = (IBeatmapListingModel)sender;

            if (model.SelectedBeatmaps?.Count > 0)
            {
                var setBeatmaps = new Beatmaps();

                foreach (var selectedBeatmap in model.SelectedBeatmaps)
                {
                    IEnumerable <Beatmap> set;
                    if (selectedBeatmap.MapSetId <= 20)
                    {
                        set = Initalizer.LoadedBeatmaps.Where(b => b.Dir == selectedBeatmap.Dir);
                    }
                    else
                    {
                        set = Initalizer.LoadedBeatmaps.Where(b => b.MapSetId == selectedBeatmap.MapSetId);
                    }
                    setBeatmaps.AddRange(set);
                }
                Initalizer.CollectionEditor.EditCollection(
                    CollectionEditArgs.AddBeatmaps(model.CurrentCollection.Name, setBeatmaps)
                    );
            }
        }
Ejemplo n.º 2
0
        // questionable
        public async Task SyncBeatmapsFromHoLLy(IEnumerable <BeatmapEntry> entries)
        {
            var allBeatmaps = entries.Select(BeatmapConvertExtension.ParseFromHolly).ToList();
            var allIds      = allBeatmaps.Select(k => k.Id).ToList();

            var nonExistAnyMore = await Beatmaps.AsNoTracking().Where(k => !allIds.Contains(k.Id)).ToListAsync();

            if (nonExistAnyMore.Count > 0)
            {
                Beatmaps.RemoveRange(nonExistAnyMore);
            }

            var exists = await Beatmaps.AsNoTracking().Where(k => allIds.Contains(k.Id)).Select(k => k.Id).ToListAsync();

            if (exists.Count > 0)
            {
                var existsHashSet = exists.ToHashSet();
                Beatmaps.UpdateRange(allBeatmaps.Where(k => existsHashSet.Contains(k.Id)));
            }

            var news = allIds.Except(exists).ToHashSet();

            if (news.Count > 0)
            {
                var addRange = allBeatmaps.Where(k => news.Contains(k.Id)).ToHashSet();
                Beatmaps.AddRange(addRange);
            }

            await SaveChangesAsync();
        }
        public void EditCollection(CollectionEditArgs e)
        {
            if (e.Action == CollectionEdit.Rename || e.Action == CollectionEdit.Add)
            {
                bool isRenameform = e.Action == CollectionEdit.Rename;

                var newCollectionName = _collectionAddRenameForm
                                        .GetCollectionName(IsCollectionNameValid, e.OrginalName, isRenameform);

                if (newCollectionName == "")
                {
                    return;
                }
                switch (e.Action)
                {
                case CollectionEdit.Rename:
                    e = CollectionEditArgs.RenameCollection(e.OrginalName, newCollectionName);
                    break;

                case CollectionEdit.Add:
                    e = CollectionEditArgs.AddCollections(new Collections()
                    {
                        new Collection(_mapCacher)
                        {
                            Name = newCollectionName
                        }
                    });
                    break;
                }
            }

            if (e.Action == CollectionEdit.Duplicate)
            {
                var newCollection = new Collection(_mapCacher)
                {
                    Name = GetValidCollectionName(e.OrginalName)
                };

                _collectionEditor.EditCollection(
                    CollectionEditArgs.AddCollections(new Collections()
                {
                    newCollection
                })
                    );

                var beatmaps = new Beatmaps();
                beatmaps.AddRange(e.Collections[0].AllBeatmaps());

                e = CollectionEditArgs.AddBeatmaps(newCollection.Name, beatmaps);
            }

            _collectionEditor.EditCollection(e);
        }
        public void SetCollection(ICollection collection)
        {
            if (collection == null)
            {
                SetBeatmaps(null);
                CurrentCollection = collection;
                return;
            }
            CurrentCollection = collection;
            var maps = new Beatmaps();

            maps.AddRange(collection.AllBeatmaps());
            SetBeatmaps(maps);
        }
Ejemplo n.º 5
0
        private void ReprocessBeatmaps()
        {
            if (_beatmapHashes.Count <= 0)
            {
                return;
            }

            var tempBeatmaps = new Beatmaps();

            tempBeatmaps.AddRange(this.AllBeatmaps());
            UnknownBeatmaps.Clear();
            KnownBeatmaps.Clear();
            DownloadableBeatmaps.Clear();


            foreach (var beatmap in tempBeatmaps)
            {
                ProcessNewlyAddedMap((BeatmapExtension)beatmap);
            }
        }
Ejemplo n.º 6
0
 public async Task AddNewBeatmaps(IEnumerable <Beatmap> beatmaps)
 {
     Beatmaps.AddRange(beatmaps);
     await SaveChangesAsync();
 }