Exemplo n.º 1
0
        private void UpdateStatic()
        {
            // unpack static.psarc
            const int numSteps = 5; // max number of times ReportProgress will be called
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 0;

            progress += step;
            ProcessStarted(progress, "Unpacking static file ... ");

            var srcPath  = Path.Combine(rsDir, "static.psarc");
            var destPath = Path.Combine(rsDir, "static.psarc.org");

            // backup the original static.psarc and never overwrite it
            if (!File.Exists(destPath))
            {
                File.Copy(srcPath, destPath, false);
            }

            var tmpModDir = Path.Combine(tmpWorkDir, "cis_static");

            if (Directory.Exists(tmpModDir))
            {
                DirectoryExtension.SafeDelete(tmpModDir, true);
            }
            Directory.CreateDirectory(tmpModDir);

            destPath = tmpModDir;
            // Packer.Unpack(srcPath, destPath); // not working here
            ExternalApps.UnpackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            // convert user png images to dds images
            progress += step * 3;
            ProcessStarted(progress, "Convertng user PNG images ...");

            // CRITICAL PATH AND ARGS
            var rootDir = string.Format("static_{0}", DLCInlayCreator.GlobalTitlePlatform);

            srcPath  = imageArray[6, 3];
            destPath = Path.Combine(tmpModDir, rootDir, "gfxassets\\views", Path.GetFileName(imageArray[6, 2]));
            ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[6, 1]), ImageHandler.Size2IntY(imageArray[6, 1]));

            // repack static.psarc
            progress += step;
            ProcessStarted(progress, "Repacking static file ...");
            srcPath  = Path.Combine(tmpModDir, rootDir);
            destPath = Path.Combine(rsDir, "static.psarc");
            // Packer.Pack(srcPath, destPath);  // not working
            ExternalApps.RepackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            ProcessCompleted(null, null);
        }