예제 #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)
                    );
            }
        }
 private void BeatmapListing_BeatmapsDropped(object sender, Beatmaps args)
 {
     if (CollectionListingModel.SelectedCollections?.Count == 1)
     {
         var collection = CollectionListingModel.SelectedCollections[0];
         CollectionListing_CollectionEditing(sender, CollectionEditArgs.AddBeatmaps(collection.Name, args));
     }
 }
        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);
        }
 private void ViewOnBeatmapsDropped(object sender, Beatmaps args, string collectionName)
 {
     _model.EmitCollectionEditing(CollectionEditArgs.AddBeatmaps(collectionName, args));
 }
예제 #5
0
        internal void Run()
        {
            var osuFileIo = new OsuFileIo(new BeatmapExtension());

            //Automatic Detection of osu! directory location
            string dir = osuFileIo.OsuPathResolver.GetOsuDir(ThisPathIsCorrect, SelectDirectoryDialog);



            string osuPath       = @"E:\osu!\";
            string osuDbFileName = "osu!.db";
            string ExampleCollectionFileLocation = @"E:\osuCollections\SomeCollectionThatExists.db";



            osuFileIo.OsuDatabase.Load(osuPath + osuDbFileName);

            //osu! configuration file is currently only used for getting a songs folder location
            osuFileIo.OsuSettings.Load(osuPath);

            //Data loaded using next 2 functions are going to be automatically correlated
            //with currently avalable beatmap data.
            osuFileIo.CollectionLoader.LoadOsuCollection(ExampleCollectionFileLocation);
            //osuFileIo.CollectionLoader.LoadOsdbCollection("");


            string osuSongsFolderLocation = osuFileIo.OsuSettings.CustomBeatmapDirectoryLocation;

            //Create Collection manager instance
            var collectionManager = new CollectionsManagerWithCounts(osuFileIo.OsuDatabase.LoadedMaps.Beatmaps);

            //or just this:
            //var collectionManager = new CollectionsManager(osuFileIo.OsuDatabase.LoadedMaps.Beatmaps);

            collectionManager.LoadedCollections.CollectionChanged += LoadedCollections_CollectionChanged;

            //Create some dummy collections
            Collection ourCollection = new Collection(osuFileIo.LoadedMaps)
            {
                Name = "Example collection1"
            };
            Collection ourSecondCollection = new Collection(osuFileIo.LoadedMaps)
            {
                Name = "Example collection2"
            };

            //Add these to our manager
            collectionManager.EditCollection(
                CollectionEditArgs.AddCollections(new Collections()
            {
                ourCollection, ourSecondCollection
            })
                );

            //Add some beatmaps to ourSecondCollection
            collectionManager.EditCollection(
                CollectionEditArgs.AddBeatmaps("Example collection2", new Beatmaps()
            {
                new BeatmapExtension()
                {
                    Md5 = "'known' md5"
                },
                new BeatmapExtension()
                {
                    Md5 = "another 'known' md5"
                },
                new BeatmapExtension()
                {
                    Md5 = "md5 that we have no idea about"
                }
            }));

            //Trying to issue any action on collection with unknown name will be just ignored
            collectionManager.EditCollection(
                CollectionEditArgs.AddBeatmaps("Collection that doesn't exist", new Beatmaps()
            {
                new BeatmapExtension()
                {
                    Md5 = "1234567890,yes I know these aren't valid md5s"
                }
            }));

            //Merge our collections into one.
            //Note that while I do not impose a limit on collection name length, osu! does and it will be truncated upon opening collection in osu! client.
            collectionManager.EditCollection(
                CollectionEditArgs.MergeCollections(new Collections()
            {
                ourCollection, ourSecondCollection
            }
                                                    , "Collection created from 2 Example collections")
                );

            //true
            bool isNameTaken = collectionManager.CollectionNameExists("Collection created from 2 Example collections");

            ICollection ourMergedCollection = collectionManager.GetCollectionByName("Collection created from 2 Example collections");

            //These are avaliable only when using CollectionsManagerWithCounts
            var TotalBeatmapCount    = collectionManager.BeatmapsInCollectionsCount;
            var MissingBeatmapsCount = collectionManager.MissingMapSetsCount;

            //Lets save our collections after edits
            //as .osdb
            osuFileIo.CollectionLoader.SaveOsdbCollection(collectionManager.LoadedCollections, ExampleCollectionFileLocation);
            //or .db
            osuFileIo.CollectionLoader.SaveOsuCollection(collectionManager.LoadedCollections, ExampleCollectionFileLocation);
        }