private void Verify_Click(object sender, RoutedEventArgs e)
        {
            string torrentUrl;
            if (!GameUpdater.HttpGet("http://www.zombies.nu/dayzerotorrent.txt", out torrentUrl))
            {
                InfoPopup popup = new InfoPopup();
                popup.Headline.Content = "An Error occured.";
                popup.Message.Content = "Could not contact Zombies.nu.\nPlease try again.";
                popup.Owner = popup.Owner = MainWindow.GetWindow(this.Parent);
                popup.Title = "Error";
                popup.Show();
                return;
            }
            else
            {
                TorrentState state = TorrentUpdater.CurrentState();
                if (state == TorrentState.Stopped)
                {
                    TorrentUpdater verifier = new TorrentUpdater(torrentUrl); // Sets up launcher to start checking files.
                    verifier.StartTorrents(1);
                }
                FileVerifierPopup popup = new FileVerifierPopup();
                popup.Owner = MainWindow.GetWindow(this.Parent);
                popup.Headline.Content = "Please Wait";
                popup.Title = "Please Wait";

                popup.Show();
            }
        }
Esempio n. 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var cplusplusinstalled = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\10.0\\VC\\VCRedist\\x64\\");
            if (cplusplusinstalled == null)
                cplusplusinstalled = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\10.0\\VC\\VCRedist\\x86\\");
            if ((cplusplusinstalled == null) || (cplusplusinstalled != null && (int)cplusplusinstalled.GetValue("Installed") != 1)) // If not installed or not existing
            {
                InfoPopup infoPopup = new InfoPopup();
                infoPopup.Message.Content = "You need C++ 2010 installed to play DayZero. Download here:";
                infoPopup.Headline.Content = "C++ 2010 Redistributable not installed.";
                infoPopup.SetLink("http://www.microsoft.com/en-us/download/details.aspx?id=8328");
                infoPopup.SetWidth(500);
                infoPopup.Show();
            }
            AppDomain.CurrentDomain.UnhandledException += UncaughtThreadException;
            DispatcherUnhandledException += UncaughtUiThreadException;

            ApplyUpdateIfNeccessary();

            LocalMachineInfo.Current.Update();

            base.OnStartup(e);
        }
Esempio n. 3
0
        public void DownloadAndInstall(int revision, HashWebClient.RemoteFileInfo archiveInfo, bool steamBeta,
			string steamBuild, UpdatesView view)
        {
            if (steamBeta)
            {
                const int appId = 33930;
                string gameName = "Arma 2: Operation Arrowhead Beta";
                DirectoryInfo armaPath = null;

                try
                {
                    armaPath = new DirectoryInfo(CalculatedGameSettings.Current.Arma2OAPath);
                }
                catch (ArgumentException aex)
                {
                    bool overridenPath = string.IsNullOrWhiteSpace(UserSettings.Current.GameOptions.Arma2OADirectoryOverride);

                    Execute.OnUiThreadSync(() =>
                    {
                        var popup = new InfoPopup("Invalid path", MainWindow.GetWindow(view));
                        popup.Headline.Content = "Game could not be found";
                        popup.SetMessage(overridenPath
                            ? "Invalid game override path, please enter a new game path or remove it"
                            : "Game could not located via the registry, please enter an override path");

                        popup.Show();
                    }, null, DispatcherPriority.Input);

                    return;
                }

                for (armaPath = armaPath.Parent; armaPath != null; armaPath = armaPath.Parent)
                {
                    if (armaPath.Name.Equals("steamapps", StringComparison.OrdinalIgnoreCase))
                    {
                        string manifestName = "appmanifest_" + appId.ToString() + ".acf";
                        string fullManifestPath = Path.Combine(armaPath.FullName, manifestName);
                        if (File.Exists(fullManifestPath))
                        {
                            // Kill Steam so we can edit the game configuration.
                            Process[] processes = Process.GetProcessesByName("Steam");

                            foreach (Process process in processes)
                            {
                                // #YOLO
                                try
                                {
                                    process.Kill();
                                    process.WaitForExit();
                                }
                                catch
                                {
                                    MessageBox.Show("Unable to shut down steam to start patching.",
                                        "Patch error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                    return;
                                }
                            }

                            var acfKeys = new KeyValue();
                            var reader = new StreamReader(fullManifestPath);
                            var acfReader = new KVTextReader(acfKeys, reader.BaseStream);
                            reader.Close();
                            KeyValue currentBuild = acfKeys.Children.FirstOrDefault(k => k.Name == "buildid");
                            if (!String.IsNullOrEmpty(currentBuild.Value))
                            {
                                if (Equals(currentBuild.Value, steamBuild))
                                {
                                    Execute.OnUiThreadSync(() =>
                                    {
                                        var popup = new InfoPopup("User intervention required", MainWindow.GetWindow(view));
                                        popup.Headline.Content = "Game update using Steam";
                                        popup.SetMessage(gameName + " might be corrupted.\n" +
                                                         "Please validate your client files manually.\n" +
                                                         "Or by clicking on the following link:");
                                        popup.SetLink("steam://validate/" + appId.ToString() + "/", "Update " + gameName);
                                        popup.Closed += (sender, args) => view.CheckForUpdates();
                                        popup.Show();
                                    }, null, DispatcherPriority.Input);
                                }
                                else
                                {
                                    KeyValue gameState = acfKeys.Children.FirstOrDefault(k => k.Name == "StateFlags");
                                    if (!String.IsNullOrEmpty(gameState.Value))
                                    {
                                        currentBuild.Value = steamBuild;
                                        gameState.Value = "2";
                                        acfKeys.SaveToFile(fullManifestPath, false);

                                        Thread.Sleep(1000);

                                        Execute.OnUiThreadSync(() =>
                                        {
                                            var popup = new InfoPopup("User intervention required", MainWindow.GetWindow(view));
                                            popup.Headline.Content = "Game update using Steam";
                                            popup.SetMessage(gameName + " branch switched to BETA.\n" +
                                                             "Please restart Steam to download update.");
                                            popup.Closed += (sender, args) => view.CheckForUpdates();
                                            popup.Show();
                                        }, null, DispatcherPriority.Input);
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("Patching failed, '" + gameName + "' is not located inside a SteamLibrary folder.",
                                    "Patch error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                return;
                            }

                            return;
                        }
                        else
                        {
                            Execute.OnUiThreadSync(() =>
                            {
                                var popup = new InfoPopup("User intervention required", MainWindow.GetWindow(view));
                                popup.Headline.Content = "Game update using Steam";
                                popup.SetMessage(gameName + " is not installed.\n" +
                                                 "Please install it from the Library tab.\n" +
                                                 "Or by clicking on the following link:");
                                popup.SetLink("steam://install/" + appId.ToString() + "/", "Install " + gameName);
                                popup.Closed += (sender, args) => view.CheckForUpdates();
                                popup.Show();
                            }, null, DispatcherPriority.Input);

                            return;
                        }
                    }
                }
                if (armaPath == null)
                {
                    MessageBox.Show("Patching failed, '" + gameName + "' is not located inside a SteamLibrary folder.",
                        "Patch error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }
            }
            else
            {
                DownloadAndInstall(revision, archiveInfo);
            }
        }