Exemple #1
0
        private void InstallGamePatch(Launcher.LoginResult loginResult, bool gateStatus)
        {
            var mutex = new Mutex(false, "XivLauncherIsPatching");

            if (mutex.WaitOne(0, false))
            {
                if (Util.CheckIsGameOpen())
                {
                    MessageBox.Show(
                        Loc.Localize("GameIsOpenError", "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                        "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    this.Dispatcher.Invoke(() =>
                    {
                        this.Show();
                        _isLoggingIn = false;
                    });
                }
                else
                {
                    Debug.Assert(loginResult.State == Launcher.LoginState.NeedsPatchGame,
                                 "loginResult.State == Launcher.LoginState.NeedsPatchGame ASSERTION FAILED");

                    var patcher = new PatchManager(Repository.Ffxiv, loginResult.PendingPatches, App.Settings.GamePath, App.Settings.PatchPath, _installer);

                    var progressDialog = new PatchDownloadDialog(patcher);
                    progressDialog.Show();
                    this.Hide();

                    patcher.OnFinish += async(sender, args) =>
                    {
                        progressDialog.Dispatcher.Invoke(() => progressDialog.Close());

                        if (args)
                        {
                            await this.Dispatcher.Invoke(() => StartGameAndAddon(loginResult, gateStatus));

                            _installer.Stop();

                            // Need to wait for installer to exit and release lock on patch files TODO bother winter why is this happening
                            Thread.Sleep(5000);

                            try
                            {
                                DeleteOldPatches();
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex, "Could not delete old patches.");
                            }
                        }
                        else
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                this.Show();
                                _isLoggingIn = false;
                            });
                        }

                        mutex.Close();
                        mutex = null;
                    };

                    patcher.Start();
                }
            }
            else
            {
                MessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
        }
        private void HandleBootCheck(Action whenFinishAction)
        {
            try
            {
                App.Settings.PatchPath ??= new DirectoryInfo(Path.Combine(Paths.RoamingPath, "patches"));

                Game.Patch.PatchList.PatchListEntry[] bootPatches = null;
                try
                {
                    bootPatches = _launcher.CheckBootVersion(App.Settings.GamePath);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Unable to check boot version.");
                    MessageBox.Show(Loc.Localize("CheckBootVersionError", "XIVLauncher was not able to check the boot version for the select game installation. This can happen if a maintenance is currently in progress or if your connection to the version check server is not available. Please report this error if you are able to login with the official launcher, but not XIVLauncher."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);

                    _isLoggingIn = false;

                    Task.Run(SetupHeadlines);
                    Show();
                    Activate();
                    return;
                }

                if (bootPatches != null)
                {
                    var mutex = new Mutex(false, "XivLauncherIsPatching");
                    if (mutex.WaitOne(0, false))
                    {
                        if (Util.CheckIsGameOpen())
                        {
                            MessageBox.Show(
                                Loc.Localize("GameIsOpenError",
                                             "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                                "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                            Environment.Exit(0);
                            return;
                        }

                        var patcher = new PatchManager(bootPatches, App.Settings.GamePath,
                                                       App.Settings.PatchPath, _installer);

                        var progressDialog = new PatchDownloadDialog(patcher);
                        progressDialog.Show();
                        this.Hide();

                        patcher.OnFinish += (sender, args) =>
                        {
                            progressDialog.Dispatcher.Invoke(() =>
                            {
                                progressDialog.Hide();
                                progressDialog.Close();
                            });

                            if (args)
                            {
                                whenFinishAction?.Invoke();
                            }
                            else
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    this.Show();
                                    _isLoggingIn = false;
                                });
                            }

                            // This is a good indicator that we should clear the UID cache
                            UniqueIdCache.Instance.Reset();

                            mutex.Close();
                            mutex = null;
                        };

                        patcher.Start();
                    }
                    else
                    {
                        MessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                        Environment.Exit(0);
                    }
                }
                else
                {
                    whenFinishAction?.Invoke();
                }
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Could not patch boot.", nameof(HandleBootCheck)).ShowDialog();
                Environment.Exit(0);
            }
        }
Exemple #3
0
        private void HandleBootCheck(Action whenFinishAction)
        {
            try
            {
                App.Settings.PatchPath ??= new DirectoryInfo(Path.Combine(Paths.RoamingPath, "patches"));

                var bootPatches = _launcher.CheckBootVersion(App.Settings.GamePath);
                if (bootPatches != null)
                {
                    var mutex = new Mutex(false, "XivLauncherIsPatching");
                    if (mutex.WaitOne(0, false))
                    {
                        if (Util.CheckIsGameOpen())
                        {
                            MessageBox.Show(
                                Loc.Localize("GameIsOpenError",
                                             "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                                "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                            Environment.Exit(0);
                            return;
                        }

                        var patcher = new PatchManager(Repository.Boot, bootPatches, App.Settings.GamePath,
                                                       App.Settings.PatchPath, _installer);

                        var progressDialog = new PatchDownloadDialog(patcher);
                        progressDialog.Show();
                        this.Hide();

                        patcher.OnFinish += (sender, args) =>
                        {
                            if (args)
                            {
                                progressDialog.Dispatcher.Invoke(() => progressDialog.Close());
                                whenFinishAction?.Invoke();
                            }
                            else
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    this.Show();
                                    _isLoggingIn = false;
                                });
                            }

                            mutex.Close();
                            mutex = null;
                        };

                        patcher.Start();
                    }
                    else
                    {
                        MessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                        Environment.Exit(0);
                    }
                }
                else
                {
                    whenFinishAction?.Invoke();
                }
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Could not patch boot.", nameof(HandleBootCheck)).ShowDialog();
                Environment.Exit(0);
            }
        }
        private void InstallGamePatch(Launcher.LoginResult loginResult, bool gateStatus, bool startGame)
        {
            var mutex = new Mutex(false, "XivLauncherIsPatching");

            if (mutex.WaitOne(0, false))
            {
                if (Util.CheckIsGameOpen())
                {
                    CustomMessageBox.Show(
                        Loc.Localize("GameIsOpenError", "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                        "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    this.Dispatcher.Invoke(() =>
                    {
                        this.Show();
                        _isLoggingIn = false;
                    });
                }
                else
                {
                    Debug.Assert(loginResult.State == Launcher.LoginState.NeedsPatchGame,
                                 "loginResult.State == Launcher.LoginState.NeedsPatchGame ASSERTION FAILED");

                    Debug.Assert(loginResult.PendingPatches != null, "loginResult.PendingPatches != null ASSERTION FAILED");

                    var patcher = new PatchManager(loginResult.PendingPatches, App.Settings.GamePath, App.Settings.PatchPath, _installer);

                    var progressDialog = new PatchDownloadDialog(patcher);
                    progressDialog.Show();
                    this.Hide();

                    patcher.OnFinish += async(sender, args) =>
                    {
                        progressDialog.Dispatcher.Invoke(() =>
                        {
                            progressDialog.Hide();
                            progressDialog.Close();
                        });

                        if (args)
                        {
                            if (!startGame)
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    CustomMessageBox.Show(
                                        Loc.Localize("LoginNoStartOk",
                                                     "An update check was executed and any pending updates were installed."), "XIVLauncher",
                                        MessageBoxButton.OK, MessageBoxImage.Information, false);

                                    _isLoggingIn = false;
                                    Show();
                                    Activate();
                                });
                            }
                            else
                            {
                                await this.Dispatcher.Invoke(() => StartGameAndAddon(loginResult, gateStatus));
                            }
                            _installer.Stop();
                        }
                        else
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                this.Show();
                                _isLoggingIn = false;
                            });
                        }

                        mutex.Close();
                        mutex = null;
                    };

                    patcher.Start();
                }
            }
            else
            {
                CustomMessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
        }