private async Task Patch(DirectoryInfo translationDir)
        {
            Position = 0;

            if (CancelEvent.IsSet())
                return;

            FFXIIIGamePart gamePart = FFXIIIGamePart.Part1; // TODO
            InteractionService.SetGamePart(gamePart);

            String configurationFilePath = Path.Combine(translationDir.FullName, PatcherService.ConfigurationFileName);
            XmlElement config = XmlHelper.LoadDocument(configurationFilePath);
            LocalizatorEnvironmentInfo info = LocalizatorEnvironmentInfo.FromXml(config["LocalizatorEnvironment"]);
            info.Validate();

            LocalizatorEnvironmentInfo currentInfo = InteractionService.LocalizatorEnvironment.Provide();
            currentInfo.UpdateUrls(info);

            InteractionService.LocalizatorEnvironment.SetValue(currentInfo);
            InteractionService.WorkingLocation.SetValue(new WorkingLocationInfo(translationDir.FullName));

            if (currentInfo.IsIncompatible(typeof(App).Assembly.GetName().Version))
            {
                if (MessageBox.Show(this.GetParentElement<Window>(), "Ваша версия программы установки несовместима с текущим перевод. Обновить?", "Ошибка!", MessageBoxButton.YesNo, MessageBoxImage.Error) != MessageBoxResult.Yes)
                    return;

                string path = await DownloadLatestPatcher();
                DirectoryInfo updatePath = ExtractZipToTempFolder(path);
                string destination = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\');

                string patcherPath = Path.Combine(updatePath.FullName, "Pulse.Patcher.exe");
                ProcessStartInfo procInfo = new ProcessStartInfo(patcherPath, $"/u \"{destination}\"")
                {
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    WorkingDirectory = updatePath.FullName
                };
                
                Process.Start(procInfo);
                Environment.Exit(0);
            }

            if (CancelEvent.IsSet())
                return;

            GameLocationInfo gameLocation = PatcherService.GetGameLocation(gamePart);
            await Task.Run(() => Patch(translationDir, gameLocation));
        }
Example #2
0
        protected override async Task DoAction()
        {
            Label = PlayingLabel;
            try
            {
                Maximum = 2;

                GameLocationInfo gameLocation = PatcherService.GetGameLocation(FFXIIIGamePart.Part1);
                gameLocation.Validate();
                Position = 1;

                if (CancelEvent.WaitOne(0))
                {
                    return;
                }

                if (MusicPlayer != null && MusicPlayer.PlaybackState == NAudio.Wave.PlaybackState.Playing)
                {
                    MusicPlayer.Pause();
                }

                String args = GameSettings.GetGameProcessArguments();

                await Task.Factory.StartNew(() => Process.Start(gameLocation.ExecutablePath, args));

                Position = 2;

                if (InteractionService.LocalizatorEnvironment.Provide().ExitAfterRunGame)
                {
                    Application.Current.MainWindow.Close();
                }
            }
            finally
            {
                Label = PlayLabel;
            }
        }