コード例 #1
0
        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;
                }
コード例 #2
0
 public void Refresh()
 {
     if (folderMode == FolderMode.AllPacks)
     {
         IBeatmapLevelPack[] annotatedBeatmapLevelCollections = Accessors.CustomLevelPackCollectionAccessor(ref beatmapLevelsModel).beatmapLevelPacks.Concat(PlaylistLibUtils.playlistManager.GetAllPlaylists(true)).ToArray();
         int indexToSelect = annotatedBeatmapLevelCollections.IndexOf(annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection);
         if (indexToSelect != -1)
         {
             annotatedBeatmapLevelCollectionsViewController.SetData(annotatedBeatmapLevelCollections, indexToSelect, false);
         }
     }
     else if (folderMode == FolderMode.Playlists)
     {
         BeatSaberPlaylistsLib.Types.IPlaylist[] annotatedBeatmapLevelCollections = PlaylistLibUtils.playlistManager.GetAllPlaylists(true);
         int indexToSelect = annotatedBeatmapLevelCollections.IndexOf(annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection);
         if (indexToSelect != -1)
         {
             annotatedBeatmapLevelCollectionsViewController.SetData(annotatedBeatmapLevelCollections, indexToSelect, false);
         }
     }
     else if (folderMode == FolderMode.Folders)
     {
         BeatSaberPlaylistsLib.Types.IPlaylist[] annotatedBeatmapLevelCollections = currentParentManager.GetAllPlaylists(false);
         int indexToSelect = annotatedBeatmapLevelCollections.IndexOf(annotatedBeatmapLevelCollectionsViewController.selectedAnnotatedBeatmapLevelCollection);
         if (indexToSelect != -1)
         {
             annotatedBeatmapLevelCollectionsViewController.SetData(annotatedBeatmapLevelCollections, indexToSelect, false);
         }
         SetupList(currentParentManager, false);
     }
 }
コード例 #3
0
        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)));
        }