Пример #1
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);
    }
Пример #2
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);
    }
Пример #3
0
 public void AddSongToPlaylist(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     playlist.AddLineEntry(new UltraStartPlaylistSongEntry(songMeta.Artist, songMeta.Title));
     playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta));
     SavePlaylist(playlist);
 }