public void Run( MainForm form ) { using( WebClient client = new GZipWebClient() ) { WebRequest.DefaultWebProxy = null; int i = 0; DownloadData( classicJarUri, client, "classic.jar", form, ref i ); DownloadData( modernJarUri, client, "1.6.2.jar", form, ref i ); DownloadData( terrainPatchUri, client, "terrain-patch.png", form, ref i ); } reader = new ZipReader(); reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic; reader.ProcessZipEntry = ProcessZipEntry_Classic; using( FileStream srcClassic = File.OpenRead( "classic.jar" ), srcModern = File.OpenRead( "1.6.2.jar" ), dst = new FileStream( "default.zip", FileMode.Create, FileAccess.Write ) ) { writer = new ZipWriter( dst ); reader.Extract( srcClassic ); // Grab animations and snow animBitmap = new Bitmap( 1024, 64, PixelFormat.Format32bppArgb ); reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Modern; reader.ProcessZipEntry = ProcessZipEntry_Modern; reader.Extract( srcModern ); writer.WriteNewImage( animBitmap, "animations.png" ); writer.WriteNewString( animationsTxt, "animations.txt" ); animBitmap.Dispose(); writer.WriteCentralDirectoryRecords(); } if( !File.Exists( "terrain-patched.png" ) ) File.Move( "terrain-patch.png", "terrain-patched.png" ); }
private void pictureBox4_Click(object sender, EventArgs e) { SelectedServer = "Challenge"; if ((this.mf == null) || this.mf.IsDisposed) { MainForm mf = new MainForm(); mf.Show(); this.Close(); ConsoleForm.ConsoleFormInstance.richTextBox1AppendText = "Selected Server: " + SelectedServer; } }
static bool DownloadData( string uri, WebClient client, string output, MainForm form, ref int i ) { i++; if( File.Exists( output ) ) return true; form.Text = MainForm.AppName + " - fetching " + output + "(" + i + "/" + resourcesCount + ")"; try { client.DownloadFile( uri, output ); } catch( WebException ex ) { Program.LogException( ex ); MessageBox.Show( "Unable to download or save " + output, "Failed to download or save resource", MessageBoxButtons.OK, MessageBoxIcon.Error ); return false; } return true; }