Example #1
0
        public static GameLocationInfo GetGameLocation(FFXIIIGamePart gamePart)
        {
            try
            {
                using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                using (RegistryKey registryKey = localMachine.OpenSubKey(GetSteamRegistyPath(gamePart)))
                {
                    if (registryKey == null)
                        throw Exceptions.CreateException("Запись в реестре не обнаружена.");

                    GameLocationInfo result = new GameLocationInfo((string)registryKey.GetValue(GameLocationSteamRegistryProvider.SteamGamePathTag));
                    result.Validate();

                    return result;
                }
            }
            catch
            {
                return Application.Current.Dispatcher.Invoke(() =>
                {
                    using (CommonOpenFileDialog dlg = new CommonOpenFileDialog(String.Format("Укажите каталог Final Fantasy XIII-{0}...", (int)gamePart)))
                    {
                        dlg.IsFolderPicker = true;
                        if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
                            throw new OperationCanceledException();

                        GameLocationInfo result = new GameLocationInfo(dlg.FileName);
                        result.Validate();

                        return result;
                    }
                });
            }
        }
Example #2
0
 private static string GetSteamRegistyPath(FFXIIIGamePart gamePart)
 {
     switch (gamePart)
     {
         case FFXIIIGamePart.Part1:
             return GameLocationSteamRegistryProvider.SteamRegistyPart1Path;
         case FFXIIIGamePart.Part2:
             return GameLocationSteamRegistryProvider.SteamRegistyPart2Path;
         default:
             throw new NotImplementedException();
     }
 }
 private void OnPart3ButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         Result = FFXIIIGamePart.Part3;
         DialogResult = true;
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(this, ex);
         Environment.Exit(1);
     }
 }
Example #4
0
 private void OnPart3ButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         Result       = FFXIIIGamePart.Part3;
         DialogResult = true;
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(this, ex);
         Environment.Exit(1);
     }
 }
Example #5
0
        private static string GetSteamRegistyPath(FFXIIIGamePart gamePart)
        {
            switch (gamePart)
            {
            case FFXIIIGamePart.Part1:
                return(GameLocationSteamRegistryProvider.SteamRegistyPart1Path);

            case FFXIIIGamePart.Part2:
                return(GameLocationSteamRegistryProvider.SteamRegistyPart2Path);

            default:
                throw new NotImplementedException();
            }
        }
        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 #7
0
        public static GameLocationInfo GetGameLocation(FFXIIIGamePart gamePart)
        {
            try
            {
                using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                    using (RegistryKey registryKey = localMachine.OpenSubKey(GetSteamRegistyPath(gamePart)))
                    {
                        if (registryKey == null)
                        {
                            throw Exceptions.CreateException("Запись в реестре не обнаружена.");
                        }

                        GameLocationInfo result = new GameLocationInfo((string)registryKey.GetValue(GameLocationSteamRegistryProvider.SteamGamePathTag));
                        result.Validate();

                        return(result);
                    }
            }
            catch
            {
                return(Application.Current.Dispatcher.Invoke(() =>
                {
                    using (CommonOpenFileDialog dlg = new CommonOpenFileDialog($"Укажите каталог Final Fantasy XIII-{(int)gamePart}..."))
                    {
                        dlg.IsFolderPicker = true;
                        if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
                        {
                            throw new OperationCanceledException();
                        }

                        GameLocationInfo result = new GameLocationInfo(dlg.FileName);
                        result.Validate();

                        return result;
                    }
                }));
            }
        }
Example #8
0
 public static void SetGamePart(FFXIIIGamePart result)
 {
     GamePart = result;
 }
Example #9
0
 public static void SetGamePart(FFXIIIGamePart result)
 {
     GamePart = result;
 }