Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void AddSong(int SongID, EGameMode gm)
        {
            CPlaylistSong song = new CPlaylistSong();

            song.SongID   = SongID;
            song.GameMode = gm;

            Songs.Add(song);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
                }
            }
        }
Beispiel #10
0
        public void AddSong(int songID, EGameMode gm)
        {
            var song = new CPlaylistSong(songID, gm);

            Songs.Add(song);
        }
Beispiel #11
0
 public CPlaylistSong(CPlaylistSong ps)
 {
     SongID   = ps.SongID;
     GameMode = ps.GameMode;
 }
Beispiel #12
0
        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);            
        }
Beispiel #13
0
        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);
                }
            }
        }
Beispiel #14
0
 public CPlaylistSong(CPlaylistSong ps)
 {
     SongID = ps.SongID;
     GameMode = ps.GameMode;
 }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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);
        }
Beispiel #17
0
        public void AddSong(int SongID, EGameMode gm)
        {
            CPlaylistSong song = new CPlaylistSong();
            song.SongID = SongID;
            song.GameMode = gm;

            Songs.Add(song);   
        }