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; }
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(); }
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")); } }
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")); } }
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"); }
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); }
private void readDatabase() { Cdb = CollectionDb.Read(Configs.CollectionDbPath); Odb = OsuDb.Read(Configs.OsuDbPath); }
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"); }