Ejemplo n.º 1
0
        public GameManager(IPinballXManager pinballXManager, IVpdbClient vpdbClient, IVpdbManager vpdbManager, ISettingsManager
                           settingsManager, IDownloadManager downloadManager, IDatabaseManager databaseManager, IVersionManager versionManager,
                           IMessageManager messageManager, IRealtimeManager realtimeManager, IVisualPinballManager visualPinballManager,
                           IThreadManager threadManager, IJobManager jobManager, IFile file, ILogger logger)
        {
            _pinballXManager      = pinballXManager;
            _vpdbClient           = vpdbClient;
            _vpdbManager          = vpdbManager;
            _settingsManager      = settingsManager;
            _downloadManager      = downloadManager;
            _databaseManager      = databaseManager;
            _versionManager       = versionManager;
            _messageManager       = messageManager;
            _realtimeManager      = realtimeManager;
            _visualPinballManager = visualPinballManager;
            _threadManager        = threadManager;
            _file       = file;
            _logger     = logger;
            _jobManager = jobManager;


            // update releases from VPDB on the first run, but delay it a bit so it
            // doesn't do all that shit at the same time!
            _settingsManager.ApiAuthenticated
            .Where(user => user != null)
            .Take(1)
            .Delay(TimeSpan.FromSeconds(2))
            .Subscribe(_ => UpdateReleaseData());

            // subscribe to downloaded releases
            _downloadManager.WhenReleaseDownloaded.Subscribe(OnReleaseDownloaded);

            // link games if new games are added
            //Games.Changed.Subscribe(_ => CheckGameLinks());

            // when game is linked or unlinked, update profile with channel info

            /*IDisposable gameLinked = null;
             * Games.Changed.Subscribe(_ => {
             *      gameLinked?.Dispose();
             *      gameLinked = Games
             *              .Select(g => g.Changed.Where(x => x.PropertyName == "ReleaseId"))
             *              .Merge()
             *              .Subscribe(__ => UpdateChannelConfig());
             * });*/

            // setup pusher messages
            SetupRealtime();
        }
Ejemplo n.º 2
0
        public GameManager(IMenuManager menuManager, IVpdbClient vpdbClient, ISettingsManager 
			settingsManager, IDownloadManager downloadManager, IDatabaseManager databaseManager,
			IVersionManager versionManager, IPlatformManager platformManager, IMessageManager messageManager,
			IRealtimeManager realtimeManager, IVisualPinballManager visualPinballManager, IThreadManager threadManager, ILogger logger)
        {
            _menuManager = menuManager;
            _vpdbClient = vpdbClient;
            _settingsManager = settingsManager;
            _downloadManager = downloadManager;
            _databaseManager = databaseManager;
            _versionManager = versionManager;
            _platformManager = platformManager;
            _messageManager = messageManager;
            _realtimeManager = realtimeManager;
            _visualPinballManager = visualPinballManager;
            _threadManager = threadManager;
            _logger = logger;

            // setup game change listener once all games are fetched.
            _menuManager.Initialized.Subscribe(_ => SetupGameChanges());

            // update releases from VPDB on the first run, but delay it a bit so it
            // doesn't do all that shit at the same time!
            _settingsManager.ApiAuthenticated
                .Where(user => user != null)
                .Take(1)
                .Delay(TimeSpan.FromSeconds(2))
                .Subscribe(_ => UpdateReleaseData());

            // subscribe to downloaded releases
            _downloadManager.WhenReleaseDownloaded.Subscribe(OnReleaseDownloaded);

            // link games if new games are added
            Games.Changed.Subscribe(_ => CheckGameLinks());

            // setup handlers for table file changes
            _menuManager.TableFileChanged.Subscribe(OnTableFileChanged);
            _menuManager.TableFileRemoved.Subscribe(OnTableFileRemoved);

            // when game is linked or unlinked, update profile with channel info
            IDisposable gameLinked = null;
            Games.Changed.Subscribe(_ => {
                gameLinked?.Dispose();
                gameLinked = Games
                    .Select(g => g.Changed.Where(x => x.PropertyName == "ReleaseId"))
                    .Merge()
                    .Subscribe(__ => UpdateChannelConfig());
            });

            // setup pusher messages
            SetupRealtime();
        }