Пример #1
0
        static osuElements()
        {
            StoryboardFileRepository = Storyboard.FileReader();
            SkinFileRepository       = SkinFileReader.SkinReader();
            BeatmapFileRepository    = BeatmapFileReader.BeatmapReader();
            ReplayFileRepository     = Replay.FileReader();
            CollectionDbRepository   = CollectionDb.FileReader();
            OsuDbRepository          = OsuDb.FileReader();
            ScoresDbRepository       = ScoresDb.FileReader();

            ApiReplayRepository  = new ApiReplayRepository();
            ApiBeatmapRepository = new ApiBeatmapRepository();
            ApiReplayRepository  = new ApiReplayRepository();
            ApiUserRepository    = new ApiUserRepository();

            using (var osureg = Registry.ClassesRoot.OpenSubKey("osu\\DefaultIcon")) {
                if (osureg == null)
                {
                    return;
                }
                var osukey  = osureg.GetValue(null).ToString();
                var osupath = osukey.Remove(0, 1);
                OsuDirectory = osupath.Remove(osupath.Length - 11);
            }
        }
Пример #2
0
        public async Task <IActionResult> ItemPage(int id)
        {
            List <Item> items = db.Items.Where(x => x.IdCollection == id).ToList();

            CollectionDb collectionDb = await db.CollectionDbs.FirstOrDefaultAsync(x => x.Id == id);

            if (items.Count == 0)
            {
                Item item = new Item
                {
                    IdCollection = collectionDb.Id,
                    Collection   = collectionDb,
                    Id           = 0
                };

                items.Add(item);
            }
            else
            {
                items[0].Collection = collectionDb;
            }

            ViewBag.OwnerName = await db.Users.FirstOrDefaultAsync(x => x.Id == collectionDb.IdUser);

            return(View(items));
        }
Пример #3
0
        private static object RunGenColByGradeAndReturnExitCode(GenColByGradeOptions opts)
        {
            string osuDbPath = Path.Combine(opts.OsuPath, "osu!.db");

            if (!File.Exists(osuDbPath))
            {
                throw new FileNotFoundException("Missing osu!.db in selected folder.");
            }
            CollectionDb existingCollection = null;

            if (opts.MergeWithExisting)
            {
                string existingPath = Path.Combine(opts.OsuPath, "collection.db");
                if (!File.Exists(existingPath))
                {
                    Console.WriteLine("Missing collection.db in selected folder. Skipping merge operation");
                }
                else
                {
                    existingCollection = new CollectionDb(existingPath);
                }
            }

            OsuDb        osuDb    = new OsuDb(osuDbPath);
            Mode         gameMode = (Mode)Enum.Parse(typeof(Mode), opts.Mode, true);
            CollectionDb colDb    = CollectionTools.GenerateCollectionDbByGrade(osuDb, gameMode, opts.Prefix, existingCollection);

            colDb.WriteToFile(opts.OutputFile);
            return(0);
        }
Пример #4
0
        private void LoadCollections()
        {
            if (loading)
                return;
            loading = true;
            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                collections.Clear();
                collections.Add(new Collection("loading...", new TimeSpan()));
            }
            );


            //string path = @"D:\Program Files\osu";

            CollectionDb collectionsdb = CollectionDb.Read(Path.Combine(osuPath, "collection.db"));
            ScoresDb scores = ScoresDb.Read(Path.Combine(osuPath, "scores.db"));
            OsuDb maps = OsuDb.Read(Path.Combine(osuPath, "osu!.db"));

            System.Windows.Application.Current.Dispatcher.Invoke(() => collections.Clear());
            foreach (var coll in collectionsdb.Collections)
            {
                ObservableCollection<Map> loadedMaps = new ObservableCollection<Map>();
                int totalPlayTime = 0;

                foreach (string hash in coll.BeatmapHashes)
                {
                    int playCount;
                    if (scores.Beatmaps.ContainsKey(hash))
                        playCount = scores.Beatmaps[hash].Count;
                    else
                        playCount = 0;

                    var map = maps.Beatmaps.Where((a) => a.BeatmapChecksum == hash).FirstOrDefault();
                    if (map == null)
                        continue;
                    int length = map.DrainTimeSeconds;

                    double stars = -1;
                    if (map.DiffStarRatingStandard.Count > 0)
                        stars = map.DiffStarRatingStandard[osu.Shared.Mods.None];
                    else if (map.DiffStarRatingCtB.Count > 0)
                        stars = map.DiffStarRatingCtB[osu.Shared.Mods.None];
                    else if (map.DiffStarRatingMania.Count > 0)
                        stars = map.DiffStarRatingMania[osu.Shared.Mods.None];
                    else if (map.DiffStarRatingTaiko.Count > 0)
                        stars = map.DiffStarRatingTaiko[osu.Shared.Mods.None];

                    var loadedMap = new Map(map.Title + ' ' + '[' + map.Version + ']', stars, TimeSpan.FromSeconds(length * playCount));
                    loadedMaps.Add(loadedMap);
                    totalPlayTime += length * playCount;
                }

                Collection loaded = new Collection(coll.Name, TimeSpan.FromSeconds(totalPlayTime));
                loaded.Maps = loadedMaps;
                System.Windows.Application.Current.Dispatcher.Invoke(() => collections.Add(loaded));
            }
            loading = false;
        }
Пример #5
0
        public SongSelector(BeatmapDb beatmapDb, CollectionDb collectionDb, DirectoryInfo songsFolder)
        {
            BeatmapDb    = beatmapDb;
            CollectionDb = collectionDb;
            SongsFolder  = songsFolder;

            CollectionMode = false;
        }
Пример #6
0
        public void ReadCollectionDbEmpty()
        {
            using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UnitTestProject.Data.Collection.20200811_empty.db");
            var db = CollectionDb.Read(stream);

            db.OsuVersion.Should().Be(20200811);
            db.Collections.Should().BeEmpty();
        }
Пример #7
0
        public async Task <IActionResult> Item(int id)
        {
            Item item = await db.Items.FirstOrDefaultAsync(x => x.Id == id);

            CollectionDb collection = await db.CollectionDbs.FirstOrDefaultAsync(x => x.Id == item.IdCollection);

            item.Collection = collection;
            return(View(item));
        }
Пример #8
0
        public void CollectionTest()
        {
            var collectionDb = new CollectionDb();
            var logger       = new BasicLogger();

            collectionDb.ReadFile(logger);
            var scores  = collectionDb.Collections.Sum(c => c.Count);
            var deleted = collectionDb.RemoveEmpty();

            collectionDb.WriteFile();
        }
Пример #9
0
        public void ReadCollectionDb()
        {
            CollectionDb db = CollectionDb.Read(SharedCode.GetRelativeFile("collection.db"));

            Debug.WriteLine("Version: " + db.OsuVersion);
            Debug.WriteLine("Amount of collections: " + db.Collections.Count);
            foreach (var c in db.Collections)
            {
                Debug.WriteLine($" - Collection {c.Name} has {c.BeatmapHashes.Count} item" + (c.BeatmapHashes.Count == 1 ? "" : "s"));
            }
        }
Пример #10
0
        public void ReadCollectionDb()
        {
            CollectionDb db = CollectionDb.Read(OsuPath + "collection.db");

            Debug.WriteLine("Version: " + db.OsuVersion);
            Debug.WriteLine("Amount of collections: " + db.AmountOfCollections);
            foreach (var c in db.Collections)
            {
                Debug.WriteLine($" - Collection {c.Name} with {c.Md5Hashes.Count} item" + (c.Md5Hashes.Count == 1 ? "" : "s"));
            }
        }
Пример #11
0
        public async Task <IActionResult> DeleteCollection(int idCollection)
        {
            CollectionDb collectionDb = await db.CollectionDbs.FirstOrDefaultAsync(x => x.Id == idCollection);

            User user = await db.Users.FirstOrDefaultAsync(u => u.Id == collectionDb.IdUser);

            db.Remove(collectionDb);
            await db.SaveChangesAsync();

            return(RedirectToAction("UserPage", "Home", new { UserName = user.Email }));
        }
        /// <summary>
        /// Use scoresDb to generate collections based on grade.
        /// </summary>
        /// <param name="scoresDb"></param>
        /// <param name="seperators"></param>
        /// <param name="name"></param>
        /// <param name="collectionDb">Merge collections into existing collectionDb. Overwrites existing collections.</param>
        /// <returns></returns>
        public static CollectionDb GenerateCollectionDbByGrade(OsuDb osuDb, Mode gameMode, string prefix = "", CollectionDb collectionDb = null)
        {
            CollectionDb colDb = new CollectionDb(20190620);

            foreach (Beatmap beatmap in osuDb.GetBeatmaps())
            {
                Grade grade = beatmap.getGrade(gameMode);

                string letter;
                switch (grade)
                {
                case Grade.Unplayed:
                    continue;

                case Grade.XH:
                    letter = "SS+";
                    break;

                case Grade.SH:
                    letter = "S+";
                    break;

                case Grade.X:
                    letter = "SS";
                    break;

                default:
                    letter = grade.ToString();
                    break;
                }

                Collection col = colDb.GetCollectionByName(prefix + letter);
                if (col == null)
                {
                    colDb.AddCollection(new Collection(prefix + letter));
                }

                colDb.GetCollectionByName(prefix + letter).AddBeatmap(beatmap.MD5Beatmap);
            }

            if (collectionDb != null)
            {
                collectionDb.Merge(colDb, AddMode.Overwrite);
                colDb = collectionDb;
            }


            return(colDb);
        }
Пример #13
0
        public void Collections()
        {
            var collectionDb = new CollectionDb();

            collectionDb.ReadFile(); //the pathing is autmatic
            //or set it for a different file
            collectionDb.FullPath = @"X:\Some\Custom\Collection.db";
            var collection = new Collection("cool songs");

            collection.Add(new Beatmap());                                       //adding a beatmap
            collection.Add("1ds3a456sdq3dsq56");                                 //or a hash
            collectionDb.AddColection(collection);
            collectionDb.AddColection("other collection", new List <Beatmap>()); //without constructing a collection object
            collectionDb.RemoveEmpty();                                          //looks for collections without items in them and removes those
            collectionDb.WriteFile();
        }
Пример #14
0
        public void ReadWriteCollectionDb()
        {
            CollectionDb db;

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UnitTestProject.Data.Collection.20210316.db"))
                db = CollectionDb.Read(stream);

            using var ms = new MemoryStream();

            using var sw = new SerializationWriter(ms);
            db.WriteToStream(sw);

            ms.Position = 0;
            var read = CollectionDb.Read(ms);

            db.Should().BeEquivalentTo(read);
        }
Пример #15
0
        public void ReadCollectionDb()
        {
            using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UnitTestProject.Data.Collection.20210316.db");
            var db = CollectionDb.Read(stream);

            db.OsuVersion.Should().Be(20210316);
            db.Collections.Should().HaveCount(2);

            db.Collections[0].Name.Should().Be("Hard maps");
            db.Collections[0].BeatmapHashes.Should().HaveCount(1);
            db.Collections[0].BeatmapHashes[0].Should().Be("06b536749d5a59536983854be90504ee");

            db.Collections[1].Name.Should().Be("My Collection");
            db.Collections[1].BeatmapHashes.Should().HaveCount(2);
            db.Collections[1].BeatmapHashes[0].Should().Be("f281f4cb1a1cf13f4456443a7725bff2");
            db.Collections[1].BeatmapHashes[1].Should().Be("b0670c14ed8f9ac489941890ce9b212e");
        }
Пример #16
0
        private static object RunMergeAndReturnExitCode(MergeOptions opts)
        {
            if (opts.InputFiles.Count == 0)
            {
                Console.WriteLine("No input files, skipping operation.");
            }
            else
            {
                try
                {
                    CollectionDb result = null;
                    foreach (string path in opts.InputFiles)
                    {
                        if (result == null)
                        {
                            result = new CollectionDb(path);
                        }
                        else
                        {
                            result.Merge(new CollectionDb(path), AddMode.Merge);
                        }
                    }
                    result.WriteToFile(opts.OutputFile);
                }
                catch (Exception e)
                {
                    if (e.GetType() == typeof(FileNotFoundException))
                    {
                        Console.WriteLine("One or more inputfiles are not found.");
                    }
                    else if (e.GetType() == typeof(InvalidDataException))
                    {
                        Console.WriteLine("One or more inputfiles contain wrong data.");
                    }
                    else
                    {
                        Console.WriteLine("An error has occurred, make sure all parameters are correct.");
                    }
                    return(1);
                }
            }

            return(0);
        }
        /// <summary>
        /// Use scoresDb to generate collections based on accuracy.
        /// </summary>
        /// <param name="scoresDb"></param>
        /// <param name="seperators"></param>
        /// <param name="name"></param>
        /// <param name="collectionDb">Merge collections into existing collectionDb. Overwrites existing collections.</param>
        /// <returns></returns>
        public static CollectionDb GenerateCollectionDbByAccuracy(ScoresDb scoresDb, List <int> seperators, string name = null, string prefix = "", CollectionDb collectionDb = null)
        {
            List <Score> scores = new List <Score>();

            foreach (BeatmapScores beatmapScores in scoresDb.GetBeatmapScores())
            {
                Score topScore = null;

                if (string.IsNullOrWhiteSpace(name))
                {
                    topScore = beatmapScores.GetHighestScore();
                }
                else
                {
                    topScore = beatmapScores.GetHighestScore(name);
                }

                if (topScore != null)
                {
                    scores.Add(topScore);
                }
            }

            List <Collection> collections = GenerateCollectionsByAccuracy(scores, seperators, prefix);
            CollectionDb      colDb;

            if (collectionDb != null)
            {
                colDb = collectionDb;
            }
            else
            {
                colDb = new CollectionDb(20190620);
            }

            foreach (Collection collection in collections)
            {
                colDb.AddCollection(collection, AddMode.Overwrite);
            }

            return(colDb);
        }
Пример #18
0
        public MainForm()
        {
            InitializeComponent();

            string[] spstring = Application.ExecutablePath.Split(new string[] { "\\osu! mp3 extractor.exe" }, StringSplitOptions.None);
            AppPath = spstring[0];                 //appPath

            Configs = new Configurations(AppPath); //Initialize configurations
            if (!Configs.getConfigurations())
            {
                ConfigurationsForm configForm = new ConfigurationsForm();
                configForm.ShowDialog();
                if (configForm.ShouldClose)
                {
                    Environment.Exit(0);
                }

                while (!Configs.updateConfigurations(configForm.Cfg))
                {
                    configForm.Dispose();

                    configForm = new ConfigurationsForm(configForm.Cfg);
                    configForm.ShowDialog();
                    if (configForm.ShouldClose)
                    {
                        Environment.Exit(0);
                    }
                }
            }

            outputLabelData.Text = Configs.OutPath;
            osuLabelData.Text    = Configs.OsuPath;

            extractor = new Extractor(this.progressBar, this.extractButton, this.optionsButton, this.cancelButton);

            Cdb = new CollectionDb();
            Odb = new OsuDb();

            updateComboBox(false);
        }
Пример #19
0
        public async Task <IActionResult> CreateCollection(CollectionViewModel collectionViewModel)
        {
            List <Field> fields = new List <Field>();

            for (int i = 0; i < 3; i++)
            {
                fields.Add(new Field(collectionViewModel.NameField[i], collectionViewModel.TypeField[i]));
            }

            User ownerCollection = await db.Users.FirstOrDefaultAsync(u => u.Email == collectionViewModel.NameUser);

            CollectionDb collectionDb = new CollectionDb(collectionViewModel.NameCollection, collectionViewModel.Description, collectionViewModel.Theme)
            {
                User            = ownerCollection,
                IdUser          = ownerCollection.Id,
                FormattedFields = fields
            };

            db.CollectionDbs.Add(collectionDb);
            await db.SaveChangesAsync();

            return(RedirectToAction("UserPage", "Home", new { userName = ownerCollection.Email }));
        }
Пример #20
0
 public MainFrame(string path = "")
 {
     Osu_path       = !path.Equals("") ? path : $@"C:\Users\{Environment.UserName}\AppData\Local\osu!\";
     collections_db = CollectionDb.Read(Osu_path + "collection.db");
     osu_db         = OsuDb.Read(Osu_path + "osu!.db");
 }
Пример #21
0
        public void extract(string mode, Configurations configs, OsuDb odb, CollectionDb cdb)
        {
            Configs   = configs;
            Mode      = mode;
            ValidMode = validChars(mode);
            Odb       = odb;
            Cdb       = cdb;
            Result    = false;

            if (Odb.Beatmaps.Count != 0)
            {
                Log = new List <string>();

                if (!System.IO.File.Exists(Configs.ImgPath))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        Properties.Resources.Defaultsongthumbnail.Save(ms, ImageFormat.Jpeg);
                        ms.Position     = 0;
                        PicDefault.Data = TagLib.ByteVector.FromStream(ms);
                    }
                }
                else
                {
                    PicDefault.Data = TagLib.ByteVector.FromPath(Configs.ImgPath);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(Configs.OutPath, ValidMode));
                    OutputSubFolder = Path.Combine(Configs.OutPath, ValidMode);

                    if (Mode == "Complete library")
                    {
                        PrBarMax = 0;
                        BeatmapEntry oldBeatmap = Odb.Beatmaps[0];
                        foreach (BeatmapEntry beatmap in Odb.Beatmaps)
                        {
                            if (oldBeatmap.BeatmapSetId != beatmap.BeatmapSetId)
                            {
                                PrBarMax++;
                            }
                            oldBeatmap = beatmap;
                        }
                        PrBarMax++;
                    }
                    else
                    {
                        PrBarMax = 0;

                        //Select collection
                        foreach (Collection col in Cdb.Collections)
                        {
                            if (col.Name == Mode)
                            {
                                SelectedCollection = col;
                            }
                        }

                        foreach (string hash in SelectedCollection.BeatmapHashes)
                        {
                            PrBarMax++;
                        }
                    }

                    viewUpdate(true, PrBarMax);
                    BackgroundWorker1.RunWorkerAsync();
                }
                catch (Exception)
                {
                    MessageBox.Show("Unable to create directory:" + Path.Combine(Configs.OutPath, ValidMode) + Environment.NewLine + Environment.NewLine + "Please check if the fonder is read only or protected...", "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Your osu seems to have 0 songs thats weird..." + Environment.NewLine + Environment.NewLine + "Please put some maps in it or try another installation...", "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #22
0
        // generate collections by accuracy
        private static object RunGenColByAccAndReturnExitCode(GenColByAccOptions opts)
        {
            // if online:
            //      check if osu!.db present
            //      check if key and name present

            // if offline:
            //      check if scores.db present


            // if online:
            //      collect list of all maps with scores that are ranked, loved or approved
            //      collect list of all maps in osu!.db where
            //          Grade achieved in standard
            //          Grade achieved in taiko
            //          Grade achieved in CTB
            //          Grade achieved in mania
            //       are not unplayed
            //      use api to get scores
            // can use ranked_score to see if all maps

            // if local: get scores from scores.db
            // if name specified: can use ranked_score to see if all maps

            CollectionDb colDb = null;

            if (opts.Online)
            {
                if (string.IsNullOrWhiteSpace(opts.Key))
                {
                    throw new ArgumentException("Key is empty.");
                }
                if (string.IsNullOrWhiteSpace(opts.Name))
                {
                    throw new ArgumentException("Name is empty.");
                }
                if (!File.Exists(Path.Combine(opts.OsuPath, "osu!.db")))
                {
                    throw new FileNotFoundException("Missing osu!.db in selected folder.");
                }

                throw new NotImplementedException();
            }
            else
            {
                string scoresDbPath = Path.Combine(opts.OsuPath, "scores.db");
                if (!File.Exists(scoresDbPath))
                {
                    throw new FileNotFoundException("Missing scores.db in selected folder.");
                }

                ScoresDb   scoresDb   = new ScoresDb(scoresDbPath);
                List <int> seperators = new List <int>(opts.Seperators);
                colDb = CollectionTools.GenerateCollectionDbByAccuracy(scoresDb, seperators, opts.Name, opts.Prefix);
            }

            if (opts.MergeWithExisting)
            {
                string existingPath = Path.Combine(opts.OsuPath, "collection.db");
                if (!File.Exists(existingPath))
                {
                    Console.WriteLine("Missing collection.db in selected folder. Skipping merge operation");
                }
                else
                {
                    CollectionDb existing = new CollectionDb(existingPath);
                    existing.Merge(colDb, AddMode.Overwrite);
                    colDb = existing;
                }
            }

            colDb.WriteToFile(opts.OutputFile);
            return(0);
        }
Пример #23
0
 private void readDatabase()
 {
     Cdb = CollectionDb.Read(Configs.CollectionDbPath);
     Odb = OsuDb.Read(Configs.OsuDbPath);
 }