Пример #1
0
 /// <summary>
 /// Updates a game from a search result from a scraper
 /// </summary>
 /// <param name="game">Game.</param>
 /// <param name="searchId">Search identifier.</param>
 public static void UpdateGame(Game game, string searchId)
 {
     dynamic result = activeScraper.getInfo (searchId);
     //{"title" : None, "genres" : [], "releaseDate" : None, "description" : None, "rating" : None, "publisher" : None, "developer" : None, "communityRating" : None, "boxArt" : None, "bannerArt" : None}
     foreach (string key in result)
     {
         dynamic value = result [key];
         if (value == null) //Skip null values
             continue;
         switch (key)
         {
             case "title":
                 game.title = value;
                 break;
             case "generes":
                 List<string> genres = new List<string> ();
                 foreach (string genre in value)
                     genres.Add (genre);
                 game.genres = genres;
                 break;
             case "releaseDate":
                 game.releaseDate = DateTime.Parse (value);
                 break;
             case "description":
                 game.description = value;
                 break;
             case "rating":
                 game.rating = value;
                 break;
             case "publisher":
                 game.publisher = value;
                 break;
             case "developer":
                 game.developer = value;
                 break;
             case "communityRating":
                 game.communityRating = value;
                 break;
             case "boxArt":
                 DownloadArtwork (value, game, ArtworkType.BoxArt);
                 break;
             case "bannerArt":
                 DownloadArtwork (value, game, ArtworkType.Banner);
                 break;
         }
     }
 }
Пример #2
0
        private static void DownloadArtwork(string url, Game game, ArtworkType artType)
        {
            WebClient webClient = new WebClient ();

            webClient.DownloadDataCompleted += (sender, e) => {
                string filename = Path.GetRandomFileName() + Path.GetExtension(url);
                string path = Path.Combine(ARTWORK_FOLDER, filename);
                File.WriteAllBytes(path, e.Result);

                if(artType == ArtworkType.Banner)
                    game.bannerArtPath = path;
                else if (artType == ArtworkType.BoxArt)
                    game.boxArtPath= path;
            };

            webClient.DownloadDataAsync (new Uri (url));
        }
Пример #3
0
 public GameDialog(Game game)
 {
     this.Build ();
     this.game = game;
     FillInputs ();
 }
Пример #4
0
 public void SetModels(Game game, Emulator emu)
 {
     gameModel = game;
     emuModel = emu;
     UpdateView ();
 }
Пример #5
0
 /// <summary>
 /// Creates a game based upon the given file.
 /// Information on the game will be sparse to begin with, but after scraping should fill in nicely
 /// </summary>
 /// <param name="file">File.</param>
 protected void CreateGame(FileInfo file)
 {
     Game game = new Game ()
     {
         title = file.Name.Replace(file.Extension, ""), //Pull the extention off the file
         filePath = file.FullName
     };
     games.Add (game);
 }