/// <summary> /// Tries to get the current beatmapsetID by trying all available methods /// </summary> /// <returns>The beatmapSetID</returns> private int getBeatmapSetID() { //first we check the current beatmap if (BeatmapManager.Current.BeatmapSetId > 0) { return(BeatmapManager.Current.BeatmapSetId); } //secondly we check the osz2 file if (packagePreviousUpload != null) { return(System.Convert.ToInt32(packagePreviousUpload.GetMetadata(MapMetaType.BeatmapSetID))); } //thirdly we check other beatmaps foreach (Beatmap b in beatmaps) { if (b.BeatmapSetId > 0) { return(b.BeatmapSetId); } } return(-1); }
private void SetDifficulty(Difficulty newDifficulty, bool force = false) { bool isNewDifficulty = Player.Difficulty != newDifficulty || force; velocity = 0; if (Player.Beatmap == null) { return; } MapPackage package = Player.Beatmap.Package; if (package == null) { return; } if (isNewDifficulty) { if (!force) { AudioEngine.PlaySample(OsuSamples.ButtonTap); } string versions = package.GetMetadata(MapMetaType.Version); if (versions != null && !versions.Contains(newDifficulty.ToString())) { /*if (Player.Difficulty == Difficulty.Easy) * //came from easy -> expert; drop back on normal! * Player.Difficulty = Difficulty.Normal; * else*/ { isNewDifficulty = false; pendingModeChange = false; } } else { Player.Difficulty = newDifficulty; } } updateModeSelectionArrows(isNewDifficulty); }
/// <summary> /// Process and load a single osz2 package. /// </summary> private static bool ProcessPackage(string filename, BeatmapTreeLevel treeLevel) { MapPackage package = Osz2Factory.TryOpen(filename); if (package == null) { NotificationManager.ShowMessage("Error reading " + Path.GetFileName(filename), Color.Red, 4000); return(false); } int mapsLoaded = 0; foreach (string file in package.MapFiles) { Beatmap b = new Beatmap { Filename = file }; if (InitialLoadComplete) { int index = Beatmaps.BinarySearch(b); if (index >= 0) { Beatmap found = Beatmaps[index]; if (found.InOszContainer) { found.DatabaseNotFound = false; found.BeatmapPresent = true; found.ContainingFolderAbsolute = filename; found.InOszContainer = true; treeLevel.Beatmaps.Add(found); mapsLoaded++; continue; } } } b.BeatmapSetId = Convert.ToInt32(package.GetMetadata(MapMetaType.BeatmapSetID)); b.BeatmapId = package.GetIDByMap(file); b.ContainingFolderAbsolute = filename; b.InOszContainer = true; b.AudioPresent = true; b.BeatmapPresent = true; b.ProcessHeaders(); if (!b.HeadersLoaded) { //failed? continue; } b.NewFile = true; NewFilesList.Add(b); if (!b.AudioPresent && !b.BeatmapPresent) { continue; } Add(b); lastAddedMap = b; treeLevel.Beatmaps.Add(b); mapsLoaded++; } Osz2Factory.CloseMapPackage(package); //package.Unlock(); return(mapsLoaded > 0); }