Esempio n. 1
0
        void ShowGameUpdateWindow(out bool wasUpdated)
        {
            UpdateAvailableWindow theWindow = new UpdateAvailableWindow();

            theWindow.LatestVersionText.Content = VersionCheck.GetLatestGameVersionName();
            theWindow.GameVersionText.Content   = VersionCheck.GetGameVersionName();
            theWindow.WindowTitle.Content       = "Game update available!";
            theWindow.Owner = this;
            theWindow.ShowDialog();

            if (!theWindow.WantsToUpdate)
            {
                wasUpdated = false;
            }
            else
            {
                // Close any other instances of the RenX-Launcher
                if (InstanceHandler.IsAnotherInstanceRunning())
                {
                    InstanceHandler.KillDuplicateInstance();
                }

                var targetDir      = GameInstallation.GetRootPath();
                var applicationDir = Path.Combine(GameInstallation.GetRootPath(), "patch");
                var patchPath      = VersionCheck.GamePatchPath;
                var patchUrls      = VersionCheck.GamePatchUrls;
                var patchVersion   = VersionCheck.GetLatestGameVersionName();

                var progress = new Progress <DirectoryPatcherProgressReport>();
                var cancellationTokenSource = new CancellationTokenSource();

                var  patcher = new RXPatcher();
                Task task    = patcher.ApplyPatchFromWeb(patchUrls.Select(url => url.ServerUri.AbsoluteUri).ToArray(), patchPath, targetDir, applicationDir, progress, cancellationTokenSource.Token, VersionCheck.InstructionsHash);

                var window = new ApplyUpdateWindow(task, patcher, progress, patchVersion, cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Update);
                window.Owner = this;
                window.ShowDialog();

                VersionCheck.UpdateGameVersion();
                wasUpdated = true;
            }
        }
Esempio n. 2
0
        private void ApplyResetOrVerify(ApplyUpdateWindow.UpdateWindowType type)
        {
            var targetDir      = GameInstallation.GetRootPath();
            var applicationDir = System.IO.Path.Combine(GameInstallation.GetRootPath(), "patch");
            var patchPath      = VersionCheck.GamePatchPath;
            var patchUrls      = VersionCheck.GamePatchUrls;
            var patchVersion   = VersionCheck.GetLatestGameVersionName();

            var progress = new Progress <DirectoryPatcherProgressReport>();
            var cancellationTokenSource = new System.Threading.CancellationTokenSource();

            var  patcher = new RXPatcher();
            Task task    = patcher.ApplyPatchFromWeb(patchUrls.Select(url => url.ServerUri.AbsoluteUri).ToArray(), patchPath, targetDir, applicationDir, progress, cancellationTokenSource.Token, VersionCheck.InstructionsHash);

            var window = new ApplyUpdateWindow(task, patcher, progress, patchVersion, cancellationTokenSource, type);

            window.Owner = this;
            window.ShowDialog();

            VersionCheck.UpdateGameVersion();
        }