Exemple #1
0
        private void UninstallMod(object sender, RoutedEventArgs args)
        {
            if (!ReadmeCheckbox.IsChecked ?? false)
            {
                MessageBox.Show(this, "Please confirm that you read and understood the text.", "Confirmation required", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            if (!HalflifeDirectoryFinder.CheckModDirectory())
            {
                UninstallButton.Visibility = Visibility.Collapsed;
                return;
            }

            var result = MessageBox.Show(this, "Are you sure you want to uninstall Half-Life: VR? All files, including savegames and your settings, will be removed.", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    Directory.Delete(HalflifeDirectoryFinder.VRDirectory, true);

                    MessageBox.Show(this, "Successfully uninstalled Half-Life: VR.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception e)
                {
                    MessageBox.Show(this, "Error while trying to uninstall Half-Life: VR: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            UninstallButton.Visibility = HalflifeDirectoryFinder.CheckModDirectory() ? Visibility.Visible : Visibility.Collapsed;
        }
Exemple #2
0
 public MainWindow()
 {
     InitializeComponent();
     HalflifeDirectoryFinder.InitializeFromSteam();
     HalfLifeDirectoryInput.Text         = HalflifeDirectoryFinder.HLDirectory;
     HalfLifeDirectoryInput.TextChanged += (object sender, TextChangedEventArgs e) =>
     {
         HalflifeDirectoryFinder.HLDirectory = HalfLifeDirectoryInput.Text;
         UninstallButton.Visibility          = HalflifeDirectoryFinder.CheckModDirectory() ? Visibility.Visible : Visibility.Collapsed;
     };
     using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("HLVRInstaller.README.txt"), Encoding.UTF8))
     {
         ReadmeContent.Inlines.Add(new Run(reader.ReadToEnd()));
     }
     UninstallButton.Visibility = HalflifeDirectoryFinder.CheckModDirectory() ? Visibility.Visible : Visibility.Collapsed;
 }
Exemple #3
0
        private async void InstallMod(object sender, RoutedEventArgs args)
        {
            if (!ReadmeCheckbox.IsChecked ?? false)
            {
                MessageBox.Show(this, "Please confirm that you read and understood the text.", "Confirmation required", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            if (!HalflifeDirectoryFinder.CheckHLDirectory())
            {
                var result = MessageBox.Show(this, "\"" + HalflifeDirectoryFinder.HLDirectory + "\" doesn't seem to be a valid Half-Life installation. Install anyways?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            if (HalflifeDirectoryFinder.CheckModDirectory())
            {
                var result = MessageBox.Show(this, "Half-Life: VR is already installed. Install anyways? (All files will be overwritten.)", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            try
            {
                PreInstall.Visibility    = Visibility.Collapsed;
                DuringInstall.Visibility = Visibility.Visible;

                InstallError = "";
                doCancel     = false;

                await Task.Run(() =>
                {
                    Install();
                });

                if (doCancel)
                {
                    doCancel = false;
                    return;
                }

                if (!string.IsNullOrEmpty(InstallError))
                {
                    MessageBox.Show(this, InstallError, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (HalflifeDirectoryFinder.CheckModDirectory())
                {
                    var result = MessageBox.Show(this, "Installation succeeded! Installer will quit. Do you want to launch Half-Life: VR now?", "Yay", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    if (result == MessageBoxResult.Yes)
                    {
                        Process.Start(new ProcessStartInfo
                        {
                            WorkingDirectory = HalflifeDirectoryFinder.VRDirectory,
                            FileName         = HalflifeDirectoryFinder.VRConfigExecutable,
                            UseShellExecute  = false
                        });
                    }
                    Application.Current?.Shutdown();
                }
                else
                {
                    MessageBox.Show(this, "Installation failed. Not really sure why :/", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            finally
            {
                PreInstall.Visibility      = Visibility.Visible;
                DuringInstall.Visibility   = Visibility.Collapsed;
                UninstallButton.Visibility = HalflifeDirectoryFinder.CheckModDirectory() ? Visibility.Visible : Visibility.Collapsed;
            }
        }