private void ApplyRom(string gameName, string gameID, Game game)
        {
            if (_db_rename_rom_using_title)
            {
                MyNesDB.UpdateEntry(gameID, game.Title);
                Trace.WriteLine(string.Format("->Rom renamed from {0} to {1}", gameName, game.Title), "Detect And Download From TheGamesDB.net");
            }

            // Overview
            if (_db_add_overview_as_tab)
                AddOverviewConentToGame("Overview", _db_overview_folder, game.Overview, gameID);

            #region Banners
            if (_db_add_banners_as_tab)
            {
                if (game.Images.Banners != null)
                {
                    if (game.Images.Banners.Count > 0)
                    {
                        // Download the tabs for it !
                        List<string> links = new List<string>();
                        for (int i = 0; i < game.Images.Banners.Count; i++)
                        {
                            links.Add(GamesDB.BaseImgURL + game.Images.Banners[i].Path);
                            if (_db_banners_ic_limitdownload)
                                break;// one link added so far.
                        }
                        AddTabConentFilesToRom("Banners", _db_banners_folder, links, gameID, _db_banners_is_cover ? "COVERS" : "SNAPS");
                    }
                }
            }
            #endregion
            #region Screenshots
            if (_db_add_screenshots_as_tab)
            {
                if (game.Images.Screenshots != null)
                {
                    if (game.Images.Screenshots.Count > 0)
                    {
                        // Download the tabs for it !
                        List<string> links = new List<string>();
                        for (int i = 0; i < game.Images.Screenshots.Count; i++)
                        {
                            links.Add(GamesDB.BaseImgURL + game.Images.Screenshots[i].Path);
                            if (_db_screenshots_ic_limitdownload)
                                break;// one link added so far.
                        }
                        // Download for it !
                        AddTabConentFilesToRom("Screenshots", _db_screenshots_folder, links, gameID, _db_screenshots_is_cover ? "COVERS" : "SNAPS");
                    }
                }
            }
            #endregion
            #region Fanart
            if (_db_add_fanart_as_tab)
            {
                if (game.Images.Fanart != null)
                {
                    if (game.Images.Fanart.Count > 0)
                    {
                        // Download the tabs for it !
                        List<string> links = new List<string>();
                        for (int i = 0; i < game.Images.Fanart.Count; i++)
                        {
                            links.Add(GamesDB.BaseImgURL + game.Images.Fanart[i].Path);
                            if (_db_fanart_ic_limitdownload)
                                break;// one link added so far.
                        }
                        // Download the tabs for it !
                        AddTabConentFilesToRom("Fanart", _db_fanart_folder, links, gameID, _db_fanart_is_cover ? "COVERS" : "SNAPS");
                    }
                }
            }
            #endregion
            #region Boxart back
            if (_db_add_boxart_back_as_tab)
            {
                if (game.Images.BoxartBack != null)
                {
                    // Download the tabs for it !
                    List<string> links = new List<string>();
                    links.Add(GamesDB.BaseImgURL + game.Images.BoxartBack.Path);

                    // Download the tabs for it !
                    AddTabConentFilesToRom("Boxart Back", _db_boxart_back_folder, links, gameID, _db_boxart_back_is_cover ? "COVERS" : "SNAPS");
                }
            }
            #endregion
            #region Boxart Front
            if (_db_add_boxart_front_as_tab)
            {
                if (game.Images.BoxartFront != null)
                {
                    // Download the tabs for it !
                    List<string> links = new List<string>();
                    links.Add(GamesDB.BaseImgURL + game.Images.BoxartFront.Path);

                    // Download the tabs for it !
                    AddTabConentFilesToRom("Boxart Front", _db_boxart_front_folder, links, gameID, _db_boxart_front_is_cover ? "COVERS" : "SNAPS");
                }
            }
            #endregion
        }
Пример #2
0
        /// <summary>
        /// Gets the data for a specific game.
        /// </summary>
        /// <param name="ID">The game ID to return data for</param>
        /// <returns>A Game-object containing all the data about the game, or null if no game was found</returns>
        public static Game GetGame(int ID) {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"http://thegamesdb.net/api/GetGame.php?id=" + ID);

            XmlNode root = doc.DocumentElement;
            IEnumerator ienum = root.GetEnumerator();

            XmlNode platformNode = root.FirstChild.NextSibling;
            Game game = new Game();

            IEnumerator ienumGame = platformNode.GetEnumerator();
            XmlNode attributeNode;
            while (ienumGame.MoveNext()) {
                attributeNode = (XmlNode)ienumGame.Current;

                // Iterate through all platform attributes
                switch (attributeNode.Name) {
                    case "id":
                        int.TryParse(attributeNode.InnerText, out game.ID);
                        break;
                    case "Overview":
                        game.Overview = attributeNode.InnerText;
                        break;
                    case "GameTitle":
                        game.Title = attributeNode.InnerText;
                        break;
                    case "Platform":
                        game.Platform = attributeNode.InnerText;
                        break;
                    case "ReleaseDate":
                        game.ReleaseDate = attributeNode.InnerText;
                        break;
                    case "overview":
                        game.Overview = attributeNode.InnerText;
                        break;
                    case "ESRB":
                        game.ESRB = attributeNode.InnerText;
                        break;
                    case "Players":
                        game.Players = attributeNode.InnerText;
                        break;
                    case "Publisher":
                        game.Publisher = attributeNode.InnerText;
                        break;
                    case "Developer":
                        game.Developer = attributeNode.InnerText;
                        break;
                    case "Rating":
                        //double.TryParse(attributeNode.InnerText, out game.Rating);
                        game.Rating = attributeNode.InnerText;
                        break;
                    case "AlternateTitles":
                        IEnumerator ienumAlternateTitles = attributeNode.GetEnumerator();
                        while (ienumAlternateTitles.MoveNext()) {
                            game.AlternateTitles.Add(((XmlNode) ienumAlternateTitles.Current).InnerText);
                        }
                        break;
                    case "Genres":
                        IEnumerator ienumGenres = attributeNode.GetEnumerator();
                        while (ienumGenres.MoveNext()) {
                            game.Genres.Add(((XmlNode) ienumGenres.Current).InnerText);
                        }
                        break;
                    case "Images":
                        game.Images.FromXmlNode(attributeNode);
                        break;
                }
            }

            return game;
        }