Procházet zdrojové kódy

Select the correct song after deleting a level

Seth Rubin před 6 roky
rodič
revize
2c190db705
1 změnil soubory, kde provedl 3 přidání a 2 odebrání
  1. 3 2
      SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

+ 3 - 2
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -873,14 +873,15 @@ namespace SongBrowser.UI
                         try
                         {
                             // determine the index we are deleting so we can keep the cursor near the same spot after
+                            // the header counts as an index, so if the index came from the level array we have to add 1.
                             List<IPreviewBeatmapLevel> levels = _levelPackLevelsTableView.GetPrivateField<IBeatmapLevelPack>("_pack").beatmapLevelCollection.beatmapLevels.ToList();
-                            int selectedIndex = levels.FindIndex(x => x.levelID == _levelDetailViewController.selectedDifficultyBeatmap.level.levelID);
+                            int selectedIndex = 1 + levels.FindIndex(x => x.levelID == _levelDetailViewController.selectedDifficultyBeatmap.level.levelID);
 
                             // we are only deleting custom levels, find the song, delete it
                             var song = new Song(SongLoader.CustomLevels.First(x => x.levelID == _levelDetailViewController.selectedDifficultyBeatmap.level.levelID));
                             SongDownloader.Instance.DeleteSong(song);
 
-                            if (selectedIndex > -1)
+                            if (selectedIndex > 0)
                             {
                                 this._model.RemoveSongFromLevelPack(this._model.CurrentLevelPack, _levelDetailViewController.selectedDifficultyBeatmap.level.levelID);
                                 Logger.Log("Removed {0} from custom song list!", song.songName);