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; } })); } }
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; } }