Ejemplo n.º 1
0
        private async Task <bool> CheckGta5Version()
        {
            var currentGameVersion   = _gtaVersionProvider.GetCurrentGtaVersion();
            var supportedGameVersion = await _gtaVersionProvider.GetCurrentlySupportedGtaVersion();

            _logger.Write($"Current GTA version: {currentGameVersion}, supported GTA version: {supportedGameVersion}");

            if (currentGameVersion == null)
            {
                _notificationService.ShowNotification("Failed to get current GTA version.", true);
                return(false);
            }

            if (supportedGameVersion == null)
            {
                _notificationService.ShowNotification("Failed to get supported GTA version.", true);
                return(true);
            }

            if (currentGameVersion >= supportedGameVersion)
            {
                return(true);
            }

            MessageBox.Show($"The supported GTA 5 version is {supportedGameVersion}, but you have {currentGameVersion} installed.\nThere may be issues launching GT-MP.");

            return(true);
        }
        public async Task CheckBackupStatus()
        {
            if (string.IsNullOrWhiteSpace(_gamePath) || !Directory.Exists(_gamePath))
            {
                return;
            }

            var currentGta5Version = _gtaVersionProvider.GetCurrentGtaVersion();

            if (currentGta5Version == null)
            {
                _notificationService.ShowNotification("Failed to check current GTA 5 version.", true);
                return;
            }

            if (!GtaBackupVersionExists(currentGta5Version.Build.ToString(), GetGtaGameType(_gamePath)))
            {
                AskToBackUpGame();
                return;
            }

            var supportedGta5Version = await _gtaVersionProvider.GetCurrentlySupportedGtaVersion();

            if (supportedGta5Version == null)
            {
                _notificationService.ShowNotification("Failed to check currently supported GTA 5 version.", true);
                return;
            }

            int lastGtaBackupVersion = GetBackupVersionsByType(GetGtaGameType(_gamePath)).Min();

            if (lastGtaBackupVersion > supportedGta5Version.Build)
            {
                _notificationService.ShowNotification("GTA 5 can not be downgraded. Last backup game version is not supported.", true);
                _logger.Write("GTA 5 can not be downgraded. Last backup game version is not supported.");
                return;
            }

            if (currentGta5Version > supportedGta5Version && AskToRestoreBackup(supportedGta5Version, currentGta5Version, lastGtaBackupVersion))
            {
                await RestoreBackup(lastGtaBackupVersion, GetGtaGameType(_gamePath));
            }
        }