private void AnnotatedBeatmapLevelCollectionsViewController_didSelectAnnotatedBeatmapLevelCollectionEvent(IAnnotatedBeatmapLevelCollection annotatedBeatmapLevelCollection) { if (annotatedBeatmapLevelCollection is BeatSaberPlaylistsLib.Types.IPlaylist selectedPlaylist) { Events.RaisePlaylistSelected(selectedPlaylist, parentManager); this.selectedPlaylist = selectedPlaylist; parentManager = PlaylistLibUtils.playlistManager.GetManagerForPlaylist(selectedPlaylist); } else { this.selectedPlaylist = null; parentManager = null; } foreach (ILevelCollectionUpdater levelCollectionUpdater in levelCollectionUpdaters) { levelCollectionUpdater.LevelCollectionUpdated(annotatedBeatmapLevelCollection, parentManager); } }
private void CreateKeyboardEnter(string folderName) { folderName = folderName.Replace("/", "").Replace("\\", "").Replace(".", ""); if (!string.IsNullOrEmpty(folderName)) { BeatSaberPlaylistsLib.PlaylistManager childManager = currentParentManager.CreateChildManager(folderName); if (currentManagers.Contains(childManager)) { popupModalsController.ShowOkModal(levelSelectionNavigationController.transform, "\"" + folderName + "\" already exists! Please use a different name.", null); } else { CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(folderName, icon: PlaylistLibUtils.DrawFolderIcon(folderName)); customListTableData.data.Add(customCellInfo); customListTableData.tableView.ReloadData(); customListTableData.tableView.ClearSelection(); currentManagers.Add(childManager); } } }
internal void ShowPlaylistsForManager(BeatSaberPlaylistsLib.PlaylistManager parentManager) { customListTableData.data.Clear(); this.parentManager = parentManager; childManagers = parentManager.GetChildManagers().ToArray(); var childPlaylists = parentManager.GetAllPlaylists(false).Where(playlist => !playlist.ReadOnly); this.childPlaylists = childPlaylists.ToList(); foreach (BeatSaberPlaylistsLib.PlaylistManager playlistManager in childManagers) { customListTableData.data.Add(new CustomCellInfo(Path.GetFileName(playlistManager.PlaylistPath), "Folder", folderIcon)); } foreach (BeatSaberPlaylistsLib.Types.IPlaylist playlist in childPlaylists) { if (playlist is IDeferredSpriteLoad deferredSpriteLoadPlaylist && !deferredSpriteLoadPlaylist.SpriteWasLoaded) { deferredSpriteLoadPlaylist.SpriteLoaded -= DeferredSpriteLoadPlaylist_SpriteLoaded; deferredSpriteLoadPlaylist.SpriteLoaded += DeferredSpriteLoadPlaylist_SpriteLoaded; _ = playlist.coverImage; }
public void LevelCollectionUpdated(IAnnotatedBeatmapLevelCollection annotatedBeatmapLevelCollection, BeatSaberPlaylistsLib.PlaylistManager parentManager) { if (this.selectedPlaylist != null) { this.selectedPlaylist.SpriteLoaded -= SelectedPlaylist_SpriteLoaded; } if (annotatedBeatmapLevelCollection is Playlist selectedPlaylist) { this.selectedPlaylist = selectedPlaylist; selectedPlaylist.SpriteLoaded += SelectedPlaylist_SpriteLoaded; } else { this.selectedPlaylist = null; } }
internal static void RaisePlaylistSelected(BeatSaberPlaylistsLib.Types.IPlaylist playlist, BeatSaberPlaylistsLib.PlaylistManager parentManager) => playlistSelected?.Invoke(playlist, parentManager);
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))); }