Exemplo n.º 1
0
        private void PackAllME3DLC()
        {
            GameData gameData = new GameData(MeType.ME3_TYPE, _configIni);

            if (!Directory.Exists(GameData.GamePath))
            {
                MessageBox.Show("Game path is wrong!");
                return;
            }
            if (!Directory.Exists(GameData.DLCData))
            {
                MessageBox.Show("No DLCs need to be compressed.");
                return;
            }
            List <string> dlcs = Directory.GetFiles(GameData.DLCData, "Mount.dlc", SearchOption.AllDirectories).ToList();

            if (dlcs.Count() == 0)
            {
                MessageBox.Show("No DLCs need to be compressed.");
                return;
            }

            Misc.startTimer();

            TOCBinFile.UpdateAllTOCBinFiles();

            List <string> DLCs = Directory.GetDirectories(GameData.DLCData).ToList();

            for (int i = 0; i < DLCs.Count; i++)
            {
                List <string> files = Directory.GetFiles(DLCs[i], "Mount.dlc", SearchOption.AllDirectories).ToList();
                if (files.Count == 0)
                {
                    DLCs.RemoveAt(i--);
                }
            }
            long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath);
            long diskUsage     = 0;

            for (int i = 0; i < DLCs.Count; i++)
            {
                diskUsage += Misc.getDirectorySize(DLCs[i]);
            }
            diskUsage = (long)(diskUsage / 1.9);
            if (diskUsage < diskFreeSpace)
            {
                for (int i = 0; i < DLCs.Count; i++)
                {
                    string DLCname = Path.GetFileName(DLCs[i]);
                    updateStatusLabel("DLC compressing - " + (i + 1) + " of " + DLCs.Count);
                    PackME3DLC(DLCs[i], DLCname);
                }

                string tmpDlcDir          = Path.Combine(GameData.GamePath, "BIOGame", "DLCTemp");
                string originInstallFiles = Path.Combine(GameData.DLCData, "__metadata");
                if (Directory.Exists(originInstallFiles))
                {
                    Directory.Move(originInstallFiles, tmpDlcDir + "\\__metadata");
                }
                DLCs = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList();
                for (int i = 0; i < DLCs.Count; i++)
                {
                    if (!File.Exists(Path.Combine(Path.GetDirectoryName(DLCs[i]), "Mount.dlc")))
                    {
                        string source = Path.GetDirectoryName(Path.GetDirectoryName(DLCs[i]));
                        Directory.Move(source, tmpDlcDir + "\\" + Path.GetFileName(source));
                    }
                }

                Directory.Delete(GameData.DLCData, true);
                Directory.Move(tmpDlcDir, GameData.DLCData);
                var time = Misc.stopTimer();
                updateStatusLabel("DLCs repacked. Process total time: " + Misc.getTimerFormat(time));
                updateStatusLabel2("");
            }
            else
            {
                MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free.");
            }
            updateStatusLabel2("");
        }