private void CreateThenEditNewPlaylist()
    {
        UltraStarPlaylist newPlaylist = playlistManager.CreateNewPlaylist("New Playlist");

        songSelectSceneControl.PlaylistChooserControl.Selection.Value = newPlaylist;
        ShowEditCurrentPlaylistDialog();
    }
示例#2
0
    public void SavePlaylist(UltraStarPlaylist playlist)
    {
        string[] lines    = playlist.GetLines();
        string   filePath = GetFilePathForPlaylist(playlist);

        File.WriteAllLines(filePath, lines);
    }
    private void Start()
    {
        songSelectSceneControl.PlaylistChooserControl.Selection
        .Subscribe(newValue => currentPlaylist = newValue);

        editPlaylistButton.RegisterCallbackButtonTriggered(() => ShowEditCurrentPlaylistDialog());
        createPlaylistButton.RegisterCallbackButtonTriggered(() => CreateThenEditNewPlaylist());
        submitEditPlaylistButton.RegisterCallbackButtonTriggered(() => SubmitEditPlaylistDialog());
        playlistNameTextField.RegisterValueChangedCallback(evt => OnPlaylistNameTextFieldChanged(evt.newValue));

        deletePlaylistButton.RegisterCallbackButtonTriggered(() =>
        {
            ShowConfirmAndCancelDeleteButtons();
            cancelDeletePlaylistButton.Focus();
        });
        cancelDeletePlaylistButton.RegisterCallbackButtonTriggered(() =>
        {
            ShowDeleteAndSubmitButtons();
            submitEditPlaylistButton.Focus();
        });
        confirmDeletePlaylistButton.RegisterCallbackButtonTriggered(() =>
        {
            string errorMessage = playlistManager.TryRemovePlaylist(currentPlaylist);
            if (!errorMessage.IsNullOrEmpty())
            {
                Debug.LogError(errorMessage);
                uiManager.CreateNotificationVisualElement(errorMessage, "error");
            }
            HideEditPlaylistDialog();
        });
    }
示例#4
0
 private string GetFilePathForPlaylist(UltraStarPlaylist playlist)
 {
     if (playlist == FavoritesPlaylist)
     {
         return(favoritesPlaylistFile);
     }
     return(playlistToFilePathMap[playlist]);
 }
    public List <SongMeta> GetFilteredSongMetas()
    {
        // Ignore prefix for special search syntax
        UltraStarPlaylist playlist      = PlaylistChooserControl.Selection.Value;
        List <SongMeta>   filteredSongs = songSearchControl.GetFilteredSongMetas(songMetas)
                                          .Where(songMeta => playlist == null ||
                                                 playlist.HasSongEntry(songMeta.Artist, songMeta.Title))
                                          .OrderBy(songMeta => GetSongMetaOrderByProperty(songMeta))
                                          .ToList();

        return(filteredSongs);
    }
示例#6
0
    public string GetPlaylistName(UltraStarPlaylist playlist)
    {
        if (playlist == null)
        {
            return("");
        }

        string filePath = playlistToFilePathMap[playlist];
        string fileName = Path.GetFileNameWithoutExtension(filePath);

        return(fileName);
    }
示例#7
0
    public List <SongMeta> GetFilteredSongMetas()
    {
        string            searchText    = IsSearchEnabled() ? GetSearchText() : null;
        UltraStarPlaylist playlist      = playlistSlider.SelectedItem;
        List <SongMeta>   filteredSongs = songMetas
                                          .Where(songMeta => searchText.IsNullOrEmpty() ||
                                                 songMeta.Title.ToLower().Contains(searchText) ||
                                                 songMeta.Artist.ToLower().Contains(searchText))
                                          .Where(songMeta => playlist == null ||
                                                 playlist.HasSongEntry(songMeta.Artist, songMeta.Title))
                                          .ToList();

        return(filteredSongs);
    }
示例#8
0
    public void PlaylistTest()
    {
        UltraStarPlaylist playlist = new UltraStarPlaylist();

        playlist.AddLineEntry(new UltraStartPlaylistLineEntry("# comment"));
        Assert.IsFalse(playlist.HasSongEntry("The artist", "The title"));
        Assert.AreEqual(1, playlist.GetLines().Length);

        playlist.AddLineEntry(new UltraStartPlaylistSongEntry("The artist", "The title"));
        Assert.IsTrue(playlist.HasSongEntry("The artist", "The title"));
        Assert.AreEqual(2, playlist.GetLines().Length);

        playlist.RemoveSongEntry("The artist", "The title");
        Assert.IsFalse(playlist.HasSongEntry("The artist", "The title"));
        Assert.AreEqual(1, playlist.GetLines().Length);
    }
示例#9
0
    public static UltraStarPlaylist ParseFile(string path)
    {
        UltraStarPlaylist playlist = new UltraStarPlaylist();

        string[] lines = File.ReadAllLines(path);
        for (int lineIndex = 0; lineIndex < lines.Length; lineIndex++)
        {
            try
            {
                UltraStartPlaylistLineEntry lineEntry = UltraStarPlaylistLineParser.ParseLine(lines[lineIndex]);
                playlist.AddLineEntry(lineEntry);
            }
            catch (Exception e)
            {
                Debug.LogException(new UltraStarPlaylistParserException($"Error in line {lineIndex + 1} in file '{path}'", e));
            }
        }
        return(playlist);
    }
示例#10
0
    private void ScanPlaylistFolder()
    {
        playlists             = new List <UltraStarPlaylist>();
        playlistToFilePathMap = new Dictionary <UltraStarPlaylist, string>();

        FolderScanner scanner           = new FolderScanner("*" + playlistFileExtension);
        List <string> playlistFilePaths = scanner.GetFiles(playlistFolder);

        foreach (string filePath in playlistFilePaths)
        {
            UltraStarPlaylist playlist = UltraStarPlaylistParser.ParseFile(filePath);
            playlists.Add(playlist);
            playlistToFilePathMap.Add(playlist, filePath);

            // This is the special playlist for the favorite songs.
            if (Path.GetFullPath(favoritesPlaylistFile) == Path.GetFullPath(filePath))
            {
                favoritesPlaylist = playlist;
            }
        }
    }
示例#11
0
 public PlaylistChangeEvent(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     Playlist = playlist;
     SongMeta = songMeta;
 }
示例#12
0
 public void AddSongToPlaylist(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     playlist.AddLineEntry(new UltraStartPlaylistSongEntry(songMeta.Artist, songMeta.Title));
     playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta));
     SavePlaylist(playlist);
 }
示例#13
0
 public void RemoveSongFromPlaylist(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     playlist.RemoveSongEntry(songMeta.Artist, songMeta.Title);
     playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta));
     SavePlaylist(playlist);
 }
示例#14
0
 static void Init()
 {
     playlistToFilePathMap.Clear();
     playlists.Clear();
     favoritesPlaylist = new UltraStarPlaylist();
 }