private void CreateThenEditNewPlaylist() { UltraStarPlaylist newPlaylist = playlistManager.CreateNewPlaylist("New Playlist"); songSelectSceneControl.PlaylistChooserControl.Selection.Value = newPlaylist; ShowEditCurrentPlaylistDialog(); }
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(); }); }
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); }
public string GetPlaylistName(UltraStarPlaylist playlist) { if (playlist == null) { return(""); } string filePath = playlistToFilePathMap[playlist]; string fileName = Path.GetFileNameWithoutExtension(filePath); return(fileName); }
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); }
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); }
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); }
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; } } }
public PlaylistChangeEvent(UltraStarPlaylist playlist, SongMeta songMeta) { Playlist = playlist; SongMeta = songMeta; }
public void AddSongToPlaylist(UltraStarPlaylist playlist, SongMeta songMeta) { playlist.AddLineEntry(new UltraStartPlaylistSongEntry(songMeta.Artist, songMeta.Title)); playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta)); SavePlaylist(playlist); }
public void RemoveSongFromPlaylist(UltraStarPlaylist playlist, SongMeta songMeta) { playlist.RemoveSongEntry(songMeta.Artist, songMeta.Title); playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta)); SavePlaylist(playlist); }
static void Init() { playlistToFilePathMap.Clear(); playlists.Clear(); favoritesPlaylist = new UltraStarPlaylist(); }