private void Select(TableView _, int selectedCellIndex) { if (currentParentManager == null) // If we are at root { if (selectedCellIndex == 0) { IAnnotatedBeatmapLevelCollection[] annotatedBeatmapLevelCollections = Accessors.CustomLevelPackCollectionAccessor(ref beatmapLevelsModel).beatmapLevelPacks.Concat(PlaylistLibUtils.playlistManager.GetAllPlaylists(true)).ToArray(); LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections, 0); folderMode = FolderMode.AllPacks; } else if (selectedCellIndex == 1) { IAnnotatedBeatmapLevelCollection[] annotatedBeatmapLevelCollections = Accessors.CustomLevelPackCollectionAccessor(ref beatmapLevelsModel).beatmapLevelPacks; LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections, 0); folderMode = FolderMode.CustomPacks; } else if (selectedCellIndex == 2) { IAnnotatedBeatmapLevelCollection[] annotatedBeatmapLevelCollections = PlaylistLibUtils.playlistManager.GetAllPlaylists(true); LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections, 0); folderMode = FolderMode.Playlists; } else if (selectedCellIndex == 3) { SetupList(currentParentManager: PlaylistLibUtils.playlistManager); folderMode = FolderMode.Folders; } } else { SetupList(currentParentManager: currentManagers[selectedCellIndex]); } }
private void DeletePlaylist() { parentManager.DeletePlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)selectedPlaylist); int selectedIndex = annotatedBeatmapLevelCollectionsViewController.selectedItemIndex; List <IAnnotatedBeatmapLevelCollection> annotatedBeatmapLevelCollections = Accessors.AnnotatedBeatmapLevelCollectionsAccessor(ref annotatedBeatmapLevelCollectionsViewController).ToList(); annotatedBeatmapLevelCollections.RemoveAt(selectedIndex); selectedIndex--; LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections.ToArray(), selectedIndex < 0 ? 0 : selectedIndex); }
private void LevelFilteringNavigationController_UpdateSecondChildControllerContent_SecondChildControllerUpdatedEvent() { LevelCollectionTableViewUpdatedEvent?.Invoke(downloadingBeatmapLevelCollections, downloadingBeatmapCollectionIdx); UpdateMissingSongs(); LevelFilteringNavigationController_UpdateSecondChildControllerContent.SecondChildControllerUpdatedEvent -= LevelFilteringNavigationController_UpdateSecondChildControllerContent_SecondChildControllerUpdatedEvent; }
private void SetupList(BeatSaberPlaylistsLib.PlaylistManager currentParentManager, bool setBeatmapLevelCollections = true) { customListTableData.tableView.ClearSelection(); customListTableData.data.Clear(); this.currentParentManager = currentParentManager; if (currentParentManager == null) { CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo("Level Packs", icon: levelPacksIcon); customListTableData.data.Add(customCellInfo); customCellInfo = new CustomListTableData.CustomCellInfo("Custom Songs", icon: customPacksIcon); customListTableData.data.Add(customCellInfo); customCellInfo = new CustomListTableData.CustomCellInfo("Playlists", icon: playlistsIcon); customListTableData.data.Add(customCellInfo); customCellInfo = new CustomListTableData.CustomCellInfo("Folders", icon: foldersIcon); customListTableData.data.Add(customCellInfo); backTransform.gameObject.SetActive(false); } else { currentManagers = currentParentManager.GetChildManagers().ToList(); foreach (var childManager in currentManagers) { var folderName = Path.GetFileName(childManager.PlaylistPath); CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(folderName, icon: PlaylistLibUtils.DrawFolderIcon(folderName)); customListTableData.data.Add(customCellInfo); } backTransform.gameObject.SetActive(true); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FolderText))); // If root, can't rename or delete if (currentParentManager.Parent == null) { renameButton.interactable = false; deleteButton.interactable = false; } else { renameButton.interactable = true; deleteButton.interactable = true; } if (setBeatmapLevelCollections) { IAnnotatedBeatmapLevelCollection[] annotatedBeatmapLevelCollections = currentParentManager.GetAllPlaylists(false); LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections, 0); } } customListTableData.tableView.ReloadData(); customListTableData.tableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false); if (currentParentManager == null) { customListTableData.tableView.SelectCellWithIdx(0); // Add hover hint TableCell[] visibleCells = customListTableData.tableView.visibleCells.ToArray(); for (int i = 0; i < visibleCells.Length; i++) { HoverHint hoverHint = visibleCells[i].GetComponent <HoverHint>(); if (hoverHint == null) { hoverHint = visibleCells[i].gameObject.AddComponent <HoverHint>(); hoverHint.SetField("_hoverHintController", hoverHintController); } else { hoverHint.enabled = true; } hoverHint.text = customListTableData.data[i].text; } if (setBeatmapLevelCollections) { Select(customListTableData.tableView, 0); } } else { // Disable hover hint TableCell[] visibleCells = customListTableData.tableView.visibleCells.ToArray(); for (int i = 0; i < visibleCells.Length; i++) { HoverHint hoverHint = visibleCells[i].GetComponent <HoverHint>(); if (hoverHint != null) { hoverHint.enabled = false; } } } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LeftButtonEnabled))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RightButtonEnabled))); }