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" );
        }
        public void Run()
        {
            reader = new ZipReader();
            reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic;
            reader.ProcessZipEntry = ProcessZipEntry_Classic;
            string texDir = Path.Combine( Program.AppDirectory, "texpacks" );
            string path = Path.Combine( texDir, "default.zip" );

            using( Stream srcClassic = new MemoryStream( jarClassic ),
                  srcModern = new MemoryStream( jar162 ),
                  dst = new FileStream( path, 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" );
                using( Bitmap guiBitmap = new Bitmap( new MemoryStream( pngGuiPatch ) ) ) {
                    writer.WriteNewImage( guiBitmap, "gui.png" );
                }
                animBitmap.Dispose();
                writer.WriteCentralDirectoryRecords();
            }
        }
 void Extract( Stream stream, Game game )
 {
     this.game = game;
     game.Animations.Dispose();
     ZipReader reader = new ZipReader();
     reader.ShouldProcessZipEntry = ShouldProcessZipEntry;
     reader.ProcessZipEntry = ProcessZipEntry;
     reader.Extract( stream );
 }
        void CheckDefaultZip( string path )
        {
            ZipReader reader = new ZipReader();
            reader.ShouldProcessZipEntry = ShouldProcessZipEntry;
            reader.ProcessZipEntry = ProcessZipEntry;

            using( Stream src = new FileStream( path, FileMode.Open, FileAccess.Read ) )
                reader.Extract( src );
        }
Beispiel #5
0
		void Extract( Stream stream, Game game ) {
			this.game = game;
			game.Animations.Dispose();
			ZipReader reader = new ZipReader();
			
			reader.ShouldProcessZipEntry = (f) => true;
			reader.ProcessZipEntry = ProcessZipEntry;
			reader.Extract( stream );
		}
        void Extract( Stream stream, Game game )
        {
            this.game = game;
            game.Events.RaiseTexturePackChanged();
            ZipReader reader = new ZipReader();

            reader.ShouldProcessZipEntry = (f) => true;
            reader.ProcessZipEntry = ProcessZipEntry;
            reader.Extract( stream );
        }
        void Extract(Stream stream, Game game)
        {
            this.game = game;
            game.Events.RaiseTexturePackChanged();
            ZipReader reader = new ZipReader();

            reader.ShouldProcessZipEntry = (f) => true;
            reader.ProcessZipEntry       = ProcessZipEntry;
            reader.Extract(stream);
        }
Beispiel #8
0
        static void MakeUpdatesFolder( byte[] zipData )
        {
            using( MemoryStream stream = new MemoryStream( zipData ) ) {
                ZipReader reader = new ZipReader();
                Directory.CreateDirectory( "CS_Update" );

                reader.ShouldProcessZipEntry = (f) => true;
                reader.ProcessZipEntry = ProcessZipEntry;
                reader.Extract( stream );
            }
        }
        internal void TryLoadTexturePack()
        {
            if( !File.Exists( "default.zip" ) ) return;

            using( Stream fs = new FileStream( "default.zip", FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
                ZipReader reader = new ZipReader();

                reader.ShouldProcessZipEntry = (f) => f == "terrain.png";
                reader.ProcessZipEntry = ProcessZipEntry;
                reader.Extract( fs );
            }
        }
        static void MakeUpdatesFolder( byte[] zipData )
        {
            using( MemoryStream stream = new MemoryStream( zipData ) ) {
                ZipReader reader = new ZipReader();
                string path = Path.Combine( Program.AppDirectory, "CS_Update" );
                Directory.CreateDirectory( path );

                reader.ShouldProcessZipEntry = (f) => true;
                reader.ProcessZipEntry = ProcessZipEntry;
                reader.Extract( stream );
            }
        }
        public void Run()
        {
            reader = new ZipReader();
            reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic;
            reader.ProcessZipEntry = ProcessZipEntry_Classic;

            using( Stream srcClassic = new MemoryStream( jarClassic ),
                  srcModern = new MemoryStream( jar162 ),
                  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();
            }
        }
        internal void TryLoadTexturePack()
        {
            Options.Load();
            string texPack = Options.Get( OptionsKey.DefaultTexturePack ) ?? "default.zip";

            if( !File.Exists( texPack ) )
                texPack = "default.zip";
            if( !File.Exists( texPack ) )
                return;

            using( Stream fs = new FileStream( texPack, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
                ZipReader reader = new ZipReader();

                reader.ShouldProcessZipEntry = (f) => f == "terrain.png";
                reader.ProcessZipEntry = ProcessZipEntry;
                reader.Extract( fs );
            }
        }
        void CheckClassicGuiPng( string path )
        {
            ZipReader reader = new ZipReader();
            reader.ShouldProcessZipEntry = ShouldProcessZipEntry;
            reader.ProcessZipEntry = ProcessZipEntry;

            using( Stream src = new FileStream( path, FileMode.Open, FileAccess.Read ) )
                reader.Extract( src );
            if( !classicGuiPngExists )
                defaultZipExists = false;
        }
 void ExtractTexturePack( string texPack )
 {
     using( Stream fs = new FileStream( texPack, FileMode.Open, FileAccess.Read, FileShare.Read ) ) {
         ZipReader reader = new ZipReader();
         reader.ShouldProcessZipEntry = (f) => f == "default.png" || f == "terrain.png";
         reader.ProcessZipEntry = ProcessZipEntry;
         reader.Extract( fs );
     }
 }