Example #1
0
 public void Load()
 {
     lock (FileLock)
     {
         XmlElement config = XmlHelper.LoadDocument(ConfigurationFilePath);
         GameLocation    = GameLocationInfo.FromXml(config["GameLocation"]);
         WorkingLocation = WorkingLocationInfo.FromXml(config["WorkingLocation"]);
         FileCommanderSelectedNodePath = config.FindString("FileCommanderSelectedNodePath");
         LocalizatorEnvironment        = LocalizatorEnvironmentInfo.FromXml(config["LocalizatorEnvironment"]);
     }
 }
        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));
        }