Esempio n. 1
0
        public void patch(Server server)
        {
            serverToDownload = server;

            if (ApplicationStatus.oldServer != null && shouldMoveAway)
            {
                PatchMover.moveAway((Server)ApplicationStatus.oldServer);
            }
            else if (!shouldMoveAway)
            {
                shouldMoveAway = true;
            }

            using (WebClient webClient = new WebClient())
            {
                string patchFileURL = URLFormatter.format($"{server.website}/{server.downloadDirectory}/patchfile.dat");

                if (server.downloadDirectory == string.Empty || server.patchesDirectory == string.Empty ||
                    !ResourceHelper.resourceExists(patchFileURL))
                {
                    form.downloadStatusLabel.Text = "Status: Server does not support the launcher's patcher";
                    form.playButton.Text          = "Play";
                    form.playButton.Enabled       = true;
                    ApplicationStatus.downloading = false;
                    return;
                }

                ApplicationStatus.downloading = true;

                webClient.DownloadProgressChanged += downloadPatchProgressChanged;
                webClient.DownloadFileAsync(new System.Uri(patchFileURL), "patchfile.dat");
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.downloadPatchFileCompleted);
            }
        }
Esempio n. 2
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ApplicationStatus.downloading)
            {
                DialogResult result = MessageBox.Show("Application is currently downloading files - interrupting file download will destroy patch files and could dislocate patch files.\nDo you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result != DialogResult.Yes)
                {
                    return;
                }
            }

            if (!(serverContainer.getServers().Count > 0))
            {
                return;
            }

            ServerWriter.write(serverContainer.getServers(), "local_servers.dat");

            if (ApplicationStatus.activeServer != null)
            {
                PatchMover.moveAway((Server)ApplicationStatus.activeServer);
            }
        }
Esempio n. 3
0
        public void downloadPatchFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            form.downloadStatusLabel.Text = "Status: Download complete";
            form.progressBar.Value        = 0;

            PatchMover.moveActive(serverToDownload);

            List <Patch> patches = patchFilesToPatch(PatchReader.readPatches("patchfile.dat"));

            if (patches.Count > 0)
            {
                downloadPatches(patches);
            }

            form.playButton.Enabled       = true;
            form.playButton.Text          = "Play";
            ApplicationStatus.downloading = false;

            WebClient client = (WebClient)sender;

            client.CancelAsync();
            client.Dispose();
        }