public bool _Load(string file) { File = file; SPlaylist data; try { var xml = new CXmlDeserializer(); data = xml.Deserialize <SPlaylist>(File); } catch (Exception e) { CLog.Error("Cannot load playlist from " + file + ": " + e.Message); return(false); } Name = data.Info.Name; Songs = new List <CPlaylistSong>(); foreach (SPlaylistSong songEntry in data.Songs) { CSong plSong = CSongs.AllSongs.FirstOrDefault(song => song.Artist == songEntry.Artist && song.Title == songEntry.Title); if (plSong == null) { CLog.Error("Can't find song '" + songEntry.Title + "' from '" + songEntry.Artist + "' in playlist file: " + File); } else { var playlistSong = new CPlaylistSong(plSong.ID, songEntry.GameMode); Songs.Add(playlistSong); } } return(true); }
public void AddSong(int SongID, EGameMode gm) { CPlaylistSong song = new CPlaylistSong(); song.SongID = SongID; song.GameMode = gm; Songs.Add(song); }
public void AddSong(int songID) { var song = new CPlaylistSong { SongID = songID, GameMode = CSongs.GetSong(songID).IsGameModeAvailable(EGameMode.TR_GAMEMODE_DUET) ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL }; Songs.Add(song); }
public void InsertSong(int destNr, int songID, EGameMode gm) { if (destNr < 0 || destNr >= Songs.Count) { return; } CPlaylistSong ps = new CPlaylistSong(songID, gm); Songs.Insert(destNr, ps); }
public void SongInsert(int DestNr, int SongID, EGameMode gm) { if (DestNr < 0 || DestNr > Songs.Count - 1) { return; } CPlaylistSong ps = new CPlaylistSong(SongID, gm); Songs.Insert(DestNr, ps); }
public void MoveSong(int sourceNr, int destNr) { if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr >= Songs.Count || destNr >= Songs.Count) { return; } CPlaylistSong song = Songs[sourceNr]; Songs.RemoveAt(sourceNr); Songs.Insert(destNr, song); }
public void SongMove(int SourceNr, int DestNr) { if (SourceNr < 0 || DestNr < 0 || SourceNr == DestNr || SourceNr > Songs.Count - 1 || DestNr > Songs.Count - 1) { return; } CPlaylistSong ps = new CPlaylistSong(Songs[SourceNr]); Songs.RemoveAt(SourceNr); Songs.Insert(DestNr, ps); }
public void AddSong(int SongID) { CPlaylistSong song = new CPlaylistSong(); song.SongID = SongID; if (CSongs.GetSong(SongID).IsDuet) { song.GameMode = EGameMode.TR_GAMEMODE_DUET; } else { song.GameMode = EGameMode.TR_GAMEMODE_NORMAL; } Songs.Add(song); }
private void LoadPlaylist() { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(PlaylistFile); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception e) { loaded = false; if (navigator != null) navigator = null; if (xPathDoc != null) xPathDoc = null; CLog.LogError("Error opening Playlist File " + PlaylistFile + ": " + e.Message); } if (loaded) { string value = String.Empty; if (CHelper.GetValueFromXML("//root/Info/PlaylistName", navigator, ref value, value)) { PlaylistName = value; Songs = new List<CPlaylistSong>(); List<string> songs = CHelper.GetValuesFromXML("Songs", navigator); string artist = String.Empty; string title = String.Empty; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; for (int i = 0; i < songs.Count; i++) { CHelper.GetValueFromXML("//root/Songs/" + songs[i] + "/Artist", navigator, ref artist, String.Empty); CHelper.GetValueFromXML("//root/Songs/" + songs[i] + "/Title", navigator, ref title, String.Empty); CHelper.TryGetEnumValueFromXML<EGameMode>("//root/Songs/" + songs[i] + "/GameMode", navigator, ref gm); CPlaylistSong song = new CPlaylistSong(); song.SongID = -1; CSong[] AllSongs = CSongs.AllSongs; for (int s = 0; s < AllSongs.Length; s++) { if (AllSongs[s].Artist == artist && AllSongs[s].Title == title) { song.SongID = AllSongs[s].ID; break; } } if (song.SongID != -1) { song.GameMode = gm; Songs.Add(song); } else { CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile); } } } else { CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile); } } }
public void AddSong(int songID, EGameMode gm) { var song = new CPlaylistSong(songID, gm); Songs.Add(song); }
public CPlaylistSong(CPlaylistSong ps) { SongID = ps.SongID; GameMode = ps.GameMode; }
public void AddSong(int SongID) { CPlaylistSong song = new CPlaylistSong(); song.SongID = SongID; if (CSongs.GetSong(SongID).IsDuet) song.GameMode = EGameMode.TR_GAMEMODE_DUET; else song.GameMode = EGameMode.TR_GAMEMODE_NORMAL; Songs.Add(song); }
private void LoadPlaylist() { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(PlaylistFile); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception e) { loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } CLog.LogError("Error opening Playlist File " + PlaylistFile + ": " + e.Message); } if (loaded) { string value = String.Empty; if (CHelper.GetValueFromXML("//root/Info/PlaylistName", navigator, ref value, value)) { PlaylistName = value; Songs = new List <CPlaylistSong>(); List <string> songs = CHelper.GetValuesFromXML("Songs", navigator); string artist = String.Empty; string title = String.Empty; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; for (int i = 0; i < songs.Count; i++) { CHelper.GetValueFromXML("//root/Songs/" + songs[i] + "/Artist", navigator, ref artist, String.Empty); CHelper.GetValueFromXML("//root/Songs/" + songs[i] + "/Title", navigator, ref title, String.Empty); CHelper.TryGetEnumValueFromXML <EGameMode>("//root/Songs/" + songs[i] + "/GameMode", navigator, ref gm); CPlaylistSong song = new CPlaylistSong(); song.SongID = -1; CSong[] AllSongs = CSongs.AllSongs; for (int s = 0; s < AllSongs.Length; s++) { if (AllSongs[s].Artist == artist && AllSongs[s].Title == title) { song.SongID = AllSongs[s].ID; break; } } if (song.SongID != -1) { song.GameMode = gm; Songs.Add(song); } else { CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile); } } } else { CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile); } } }
public void SongInsert(int DestNr, int SongID, EGameMode gm) { if (DestNr < 0 || DestNr > Songs.Count - 1) return; CPlaylistSong ps = new CPlaylistSong(SongID, gm); Songs.Insert(DestNr, ps); }
public void SongMove(int SourceNr, int DestNr) { if (SourceNr < 0 || DestNr < 0 || SourceNr == DestNr || SourceNr > Songs.Count - 1 || DestNr > Songs.Count - 1) return; CPlaylistSong ps = new CPlaylistSong(Songs[SourceNr]); Songs.RemoveAt(SourceNr); Songs.Insert(DestNr, ps); }