Пример #1
0
        public GameResultItemViewModel(Game game, VpdbRelease release, VpdbVersion version, VpdbTableFile tableFile, ICommand closeCommand)
        {
            Game = game;
            Version = version;
            Release = release;
            TableFile = tableFile;

            SelectResult.Subscribe(_ =>
            {
                GameManager.LinkRelease(Game, release, tableFile.Reference.Id);
                MessageManager.LogReleaseLinked(game, release, tableFile.Reference.Id);

                closeCommand.Execute(null);
            });
        }
Пример #2
0
 /// <summary>
 /// Calculates the total weight of a file based on flavor settings.
 /// </summary>
 /// <param name="tableFile">File to check</param>
 /// <param name="currentFile">The current/previous file of the release or null if new release</param>
 /// <returns>Total weight of the file based on the user's flavor settings</returns>
 private int FlavorWeight(VpdbTableFile tableFile, VpdbTableFile currentFile)
 {
     return _flavorMatchers.Sum(matcher => matcher.Weight(tableFile, currentFile));
 }
Пример #3
0
 /// <summary>
 /// Checks if the flavor of the file is acceptable by the user's flavor settings.
 /// </summary>
 /// <param name="tableFile">File to check</param>
 /// <param name="currentFile">The current/previous file of the release or null if new release</param>
 /// <returns>Returns true if the primary or secondary flavor setting of ALL flavors matches, false otherwise.</returns>
 private bool FlavorMatches(VpdbTableFile tableFile, VpdbTableFile currentFile)
 {
     return _flavorMatchers.TrueForAll(matcher => matcher.Matches(tableFile, currentFile));
 }
Пример #4
0
        /// <summary>
        /// Downloads a release including media and ROMs.
        /// </summary>
        /// <param name="release">Release to download</param>
        /// <param name="tableFile">File of the release to download</param>
        private void DownloadRelease(VpdbRelease release, VpdbTableFile tableFile)
        {
            // also fetch game data for media & co
            _vpdbClient.Api.GetGame(release.Game.Id).Subscribe(game =>  {

                var version = _databaseManager.GetVersion(release.Id, tableFile.Reference.Id);
                _logger.Info($"Downloading {game.DisplayName} - {release.Name} v{version?.Name} ({tableFile.Reference.Id})");

                var gameName = release.Game.DisplayName;
                var pbxPlatform = _platformManager.FindPlatform(tableFile);
                var vpdbPlatform = tableFile.Compatibility[0].Platform;

                // check if backglass image needs to be downloaded
                var backglassImagePath = Path.Combine(pbxPlatform.MediaPath, Job.MediaBackglassImages);
                if (!FileBaseExists(backglassImagePath, gameName)) {
                    _jobManager.AddJob(new Job(release, game.Media["backglass"], FileType.BackglassImage, vpdbPlatform));
                }

                // check if wheel image needs to be downloaded
                var wheelImagePath = Path.Combine(pbxPlatform.MediaPath, Job.MediaWheelImages);
                if (!FileBaseExists(wheelImagePath, gameName)) {
                    _jobManager.AddJob(new Job(release, game.Media["logo"], FileType.WheelImage, vpdbPlatform));
                }

                // queue table shot
                var tableImage = Path.Combine(pbxPlatform.MediaPath, Job.MediaTableImages);
                if (!FileBaseExists(tableImage, gameName)) {
                    _jobManager.AddJob(new Job(release, tableFile.Media["playfield_image"], FileType.TableImage, vpdbPlatform));
                }

                // todo check for ROM to be downloaded
                // todo also queue all remaining non-table files of the release.

                // queue for download
                var job = new Job(release, tableFile, FileType.TableFile, vpdbPlatform);
                _logger.Info("Created new job for {0} - {1} v{2} ({3}): {4}", job.Release.Game.DisplayName, job.Release.Name, job.Version.Name, job.File.Id, job.TableFile.ToString());
                _jobManager.AddJob(job);

                _currentlyDownloading.Remove(release.Id);

            }, exception => _vpdbClient.HandleApiError(exception, "retrieving game details during download"));
        }
Пример #5
0
 public Platform FindPlatform(VpdbTableFile.VpdbPlatform platform)
 {
     string platformName;
     switch (platform) {
         case VpdbTableFile.VpdbPlatform.VP:
             platformName = "Visual Pinball";
             break;
         case VpdbTableFile.VpdbPlatform.FP:
             platformName = "Future Pinball";
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return Platforms.FirstOrDefault(p => platformName.Equals(p.Name));
 }
Пример #6
0
 public Platform FindPlatform(VpdbTableFile tableFile)
 {
     if (tableFile?.Compatibility == null || tableFile.Compatibility.Count == 0) {
         return null;
     }
     return FindPlatform(tableFile.Compatibility[0].Platform);
 }