コード例 #1
0
        private void ShowImages(BeatSaberPlaylistsLib.Types.IPlaylist playlist)
        {
            customListTableData.data.Clear();

            // Add clear image
            customListTableData.data.Add(new CustomCellInfo("Clear Icon", "Clear", PlaylistLibUtils.GeneratePlaylistIcon(playlist)));

            // Add default image
            customListTableData.data.Add(new CustomCellInfo("PlaylistManager Icon", "Default", playlistManagerIcon));

            LoadImages();
            foreach (var coverImage in coverImages)
            {
                if (!coverImage.Value.SpriteWasLoaded && !coverImage.Value.Blacklist)
                {
                    coverImage.Value.SpriteLoaded += CoverImage_SpriteLoaded;
                    _ = coverImage.Value.Sprite;
                }
                else if (coverImage.Value.SpriteWasLoaded)
                {
                    customListTableData.data.Add(new CustomCellInfo(Path.GetFileName(coverImage.Key), coverImage.Key, coverImage.Value.Sprite));
                }
            }
            customListTableData.tableView.ReloadData();
            customListTableData.tableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
            _ = ViewControllerMonkeyCleanup();

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(UpButtonEnabled)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownButtonEnabled)));
        }
コード例 #2
0
        private async Task DownloadPlaylistAsync()
        {
            popupModalsController.ShowOkModal(rootTransform, "", CancelButtonPressed, "Cancel");

            UpdateMissingSongs();
            if (MissingSongs == null)
            {
                popupModalsController.OkText       = "Error: The selected playlist cannot be downloaded.";
                popupModalsController.OkButtonText = "Ok";
                return;
            }

            popupModalsController.OkText = string.Format("{0}/{1} songs downloaded", 0, MissingSongs.Count);
            tokenSource.Dispose();
            tokenSource = new CancellationTokenSource();

            preferCustomArchiveURL = true;
            bool shownCustomArchiveWarning = false;

            for (int i = 0; i < MissingSongs.Count; i++)
            {
                if (preferCustomArchiveURL && MissingSongs[i].TryGetCustomData("customArchiveURL", out object outCustomArchiveURL))
                {
                    string customArchiveURL = (string)outCustomArchiveURL;
                    string identifier       = PlaylistLibUtils.GetIdentifierForPlaylistSong(MissingSongs[i]);
                    if (identifier == "")
                    {
                        continue;
                    }

                    if (!shownCustomArchiveWarning)
                    {
                        shownCustomArchiveWarning = true;
                        popupModalsController.ShowYesNoModal(rootTransform, "This playlist uses mirror download links. Would you like to use them?",
                                                             CustomArchivePreferred, noButtonPressedCallback: CustomArchiveNotPreferred, animateParentCanvas: false);
                        await downloadPauseSemaphore.WaitAsync();

                        if (!preferCustomArchiveURL)
                        {
                            i--;
                            continue;
                        }
                    }
                    await DownloaderUtils.instance.BeatmapDownloadByCustomURL(customArchiveURL, identifier, tokenSource.Token);
                }
                else if (!string.IsNullOrEmpty(MissingSongs[i].Hash))
                {
                    await DownloaderUtils.instance.BeatmapDownloadByHash(MissingSongs[i].Hash, tokenSource.Token);
                }
                else if (!string.IsNullOrEmpty(MissingSongs[i].Key))
                {
                    string hash = await DownloaderUtils.instance.BeatmapDownloadByKey(MissingSongs[i].Key.ToLower(), tokenSource.Token);

                    if (!string.IsNullOrEmpty(hash))
                    {
                        MissingSongs[i].Hash = hash;
                    }
                }
                popupModalsController.OkText = string.Format("{0}/{1} songs downloaded", i + 1, MissingSongs.Count);
            }

            popupModalsController.OkText       = "Download Complete!";
            popupModalsController.OkButtonText = "Ok";

            parentManager.StorePlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)selectedPlaylist);

            downloadingBeatmapLevelCollections = Accessors.AnnotatedBeatmapLevelCollectionsAccessor(ref annotatedBeatmapLevelCollectionsViewController).ToArray();
            downloadingBeatmapCollectionIdx    = annotatedBeatmapLevelCollectionsViewController.selectedItemIndex;
            SongCore.Loader.Instance.RefreshSongs(false);
            LevelFilteringNavigationController_UpdateSecondChildControllerContent.SecondChildControllerUpdatedEvent += LevelFilteringNavigationController_UpdateSecondChildControllerContent_SecondChildControllerUpdatedEvent;
        }
コード例 #3
0
 internal void CreatePlaylist(string playlistName)
 {
     PlaylistLibUtils.CreatePlaylist(playlistName, "PlaylistManager");
     ShowPlaylists();
 }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
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)));
        }