private void extractME3DLCPackagesToolStripMenuItem_Click(object sender, EventArgs e) { enableGameDataMenu(false); GameData gameData = new GameData(MeType.ME3_TYPE, _configIni); if (!Directory.Exists(GameData.GamePath)) { MessageBox.Show("Game path is wrong!"); enableGameDataMenu(true); return; } if (!Directory.Exists(GameData.DLCData)) { MessageBox.Show("No DLCs need to be extracted."); enableGameDataMenu(true); return; } Misc.startTimer(); ME3DLC.unpackAllDLC(this, null); var time = Misc.stopTimer(); updateStatusLabel("DLCs extracted. Process total time: " + Misc.getTimerFormat(time)); updateStatusLabel2(""); enableGameDataMenu(true); }
private void buttonUnpackDLC_Click(object sender, EventArgs e) { buttonsEnable(false); ME3DLC.unpackAllDLC(null, this); updateStatusPackDLC(""); buttonsEnable(true); }
static public void unpackAllDLC(bool ipc) { if (!Directory.Exists(GameData.DLCData)) { return; } List <string> sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList(); int totalSfars = sfarFiles.Count; for (int i = 0; i < sfarFiles.Count; i++) { if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc"))) { sfarFiles.RemoveAt(i--); } } if (sfarFiles.Count() == 0) { return; } if (ipc) { Console.WriteLine("[IPC]STAGE_WEIGHT STAGE_UNPACKDLC " + string.Format("{0:0.000000}", ((float)sfarFiles.Count / totalSfars))); Console.Out.Flush(); } int totalNumFiles = 0; int currentProgress = 0; for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); totalNumFiles += getNumberOfFiles(sfarFiles[i]); } for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); string outPath = Path.Combine(GameData.DLCData, DLCname); ME3DLC dlc = new ME3DLC(); if (ipc) { Console.WriteLine("[IPC]PROCESSING_FILE " + sfarFiles[i]); Console.Out.Flush(); } dlc.extract(sfarFiles[i], outPath, ipc, ref currentProgress, totalNumFiles); } }
private void PackME3DLC(string inPath, string DLCname) { GameData gameData = new GameData(MeType.ME3_TYPE, _configIni); if (!Directory.Exists(GameData.GamePath)) { MessageBox.Show("Game path is wrong!"); return; } string outPath = Path.Combine(Path.Combine(GameData.GamePath, "BIOGame", "DLCTemp"), DLCname, "CookedPCConsole", "Default.sfar"); ME3DLC dlc = new ME3DLC(this); dlc.fullRePack(inPath, outPath, DLCname, this, null); }
static public void unpackAllDLC(MainWindow mainWindow, Installer installer) { if (!Directory.Exists(GameData.DLCData)) { if (mainWindow != null) { MessageBox.Show("No DLCs need to be extracted."); } return; } List <string> sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList(); for (int i = 0; i < sfarFiles.Count; i++) { if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc"))) { sfarFiles.RemoveAt(i--); } } if (sfarFiles.Count() == 0) { if (mainWindow != null) { MessageBox.Show("No DLCs need to be extracted."); } return; } long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath); long diskUsage = 0; for (int i = 0; i < sfarFiles.Count; i++) { diskUsage += new FileInfo(sfarFiles[i]).Length; } diskUsage = (long)(diskUsage * 2.5); if (diskUsage > diskFreeSpace) { if (mainWindow != null) { MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free."); } return; } string tmpDlcDir = Path.Combine(GameData.GamePath, "BIOGame", "DLCTemp"); if (Directory.Exists(tmpDlcDir)) { Directory.Delete(tmpDlcDir, true); } Directory.CreateDirectory(tmpDlcDir); string originInstallFiles = Path.Combine(GameData.DLCData, "__metadata"); if (Directory.Exists(originInstallFiles)) { Directory.Move(originInstallFiles, tmpDlcDir + "\\__metadata"); } for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); string outPath = Path.Combine(tmpDlcDir, DLCname); Directory.CreateDirectory(outPath); ME3DLC dlc = new ME3DLC(mainWindow); if (mainWindow != null) { mainWindow.updateStatusLabel("SFAR extracting - DLC " + (i + 1) + " of " + sfarFiles.Count); } if (installer != null) { installer.updateStatusPrepare("Extracting DLC ... " + (i + 1) + " of " + sfarFiles.Count); } dlc.extract(sfarFiles[i], outPath); } sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList(); for (int i = 0; i < sfarFiles.Count; i++) { if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc"))) { string source = Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i])); Directory.Move(source, tmpDlcDir + "\\" + Path.GetFileName(source)); } } Directory.Delete(GameData.DLCData, true); Directory.Move(tmpDlcDir, GameData.DLCData); }
private void buttonSTART_Click(object sender, EventArgs e) { buttonsEnable(false); buttonPreInstallCheck.Enabled = false; buttonSTART.Enabled = false; labelFinalStatus.Text = "Process in progress..."; errors = ""; log = ""; Misc.startTimer(); log += "Prepare game data started..." + Environment.NewLine; updateStatusPrepare("In progress..."); if (GameData.gameType == MeType.ME1_TYPE) { Misc.VerifyME1Exe(gameData, false); } if (GameData.gameType == MeType.ME3_TYPE) { ME3DLC.unpackAllDLC(null, this); gameData.getPackages(true, true); } if (GameData.gameType != MeType.ME1_TYPE) { gameData.getTfcTextures(); } checkBoxPrepare.Checked = true; updateStatusPrepare(""); log += "Prepare game data finished" + Environment.NewLine + Environment.NewLine; if (Directory.Exists(GameData.DLCData)) { List <string> dirs = Directory.EnumerateDirectories(GameData.DLCData).ToList(); log += "Detected folowing folders in DLC path:" + Environment.NewLine; for (int dl = 0; dl < dirs.Count; dl++) { log += Path.GetFileName(dirs[dl]) + Environment.NewLine; } } else { log += "Not detected folders in DLC path" + Environment.NewLine; } log += Environment.NewLine; log += "Scan textures started..." + Environment.NewLine; updateStatusScan("In progress..."); if (checkBoxOptionFaster.Checked) { errors += treeScan.PrepareListOfTextures(null, cachePackageMgr, null, this, ref log, true); } else { errors += treeScan.PrepareListOfTextures(null, null, null, this, ref log, true); } textures = treeScan.treeScan; checkBoxScan.Checked = true; updateStatusScan(""); log += "Scan textures finished" + Environment.NewLine + Environment.NewLine; if (checkBoxOptionFaster.Checked) { if (GameData.gameType == MeType.ME1_TYPE) { log += "Remove mipmaps started..." + Environment.NewLine; updateStatusMipMaps("In progress..."); errors += mipMaps.removeMipMapsME1(1, textures, cachePackageMgr, null, this, checkBoxPreEnableRepack.Checked); errors += mipMaps.removeMipMapsME1(2, textures, cachePackageMgr, null, this, checkBoxPreEnableRepack.Checked); checkBoxMipMaps.Checked = true; updateStatusMipMaps(""); log += "Remove mipmaps finished" + Environment.NewLine + Environment.NewLine; } else { log += "Remove mipmaps started..." + Environment.NewLine; updateStatusMipMaps("In progress..."); errors += mipMaps.removeMipMapsME2ME3(textures, cachePackageMgr, null, this, checkBoxPreEnableRepack.Checked); checkBoxMipMaps.Checked = true; updateStatusMipMaps(""); log += "Remove mipmaps finished" + Environment.NewLine + Environment.NewLine; } } log += "Process textures started..." + Environment.NewLine; updateStatusTextures("In progress..."); applyModules(); checkBoxTextures.Checked = true; updateStatusTextures(""); log += "Process textures finished" + Environment.NewLine + Environment.NewLine; updateStatusStore("Progress..."); cachePackageMgr.CloseAllWithSave(checkBoxPreEnableRepack.Checked); checkBoxStore.Checked = true; updateStatusStore(""); if (!checkBoxOptionFaster.Checked) { if (GameData.gameType == MeType.ME1_TYPE) { log += "Remove mipmaps started..." + Environment.NewLine; updateStatusMipMaps("In progress..."); errors += mipMaps.removeMipMapsME1(1, textures, null, null, this, checkBoxPreEnableRepack.Checked); errors += mipMaps.removeMipMapsME1(2, textures, null, null, this, checkBoxPreEnableRepack.Checked); checkBoxMipMaps.Checked = true; updateStatusMipMaps(""); log += "Remove mipmaps finished" + Environment.NewLine + Environment.NewLine; } else { log += "Remove mipmaps started..." + Environment.NewLine; updateStatusMipMaps("In progress..."); errors += mipMaps.removeMipMapsME2ME3(textures, null, null, this, checkBoxPreEnableRepack.Checked); checkBoxMipMaps.Checked = true; updateStatusMipMaps(""); log += "Remove mipmaps finished" + Environment.NewLine + Environment.NewLine; } } log += "Updating LODs and other settings started..." + Environment.NewLine; updateStatusLOD("In progress..."); string path = gameData.EngineConfigIniPath; bool exist = File.Exists(path); if (!exist) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } ConfIni engineConf = new ConfIni(path); LODSettings.updateLOD((MeType)gameId, engineConf); LODSettings.updateGFXSettings((MeType)gameId, engineConf); checkBoxLOD.Checked = true; updateStatusLOD(""); log += "Updating LODs and other settings finished" + Environment.NewLine + Environment.NewLine; if (checkBoxPreEnableRepack.Checked) { log += "Repack started..." + Environment.NewLine; for (int i = 0; i < GameData.packageFiles.Count; i++) { updateStatusRepackZlib("Repacking PCC files... " + ((i + 1) * 100 / GameData.packageFiles.Count) + " %"); Package package = new Package(GameData.packageFiles[i], true, true); if (package.compressed && package.compressionType != Package.CompressionType.Zlib) { package.Dispose(); package = new Package(GameData.packageFiles[i]); package.SaveToFile(true); } } checkBoxRepackZlib.Checked = true; updateStatusRepackZlib(""); log += "Repack finished" + Environment.NewLine + Environment.NewLine; } if (checkBoxPreEnablePack.Checked) { if (Directory.Exists(GameData.DLCData)) { TOCBinFile.UpdateAllTOCBinFiles(); log += "Repack started..." + Environment.NewLine; updateStatusPackDLC("In progress..."); 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--); } } string tmpDlcDir = Path.Combine(GameData.GamePath, "BIOGame", "DLCTemp"); for (int i = 0; i < DLCs.Count; i++) { string DLCname = Path.GetFileName(DLCs[i]); string outPath = Path.Combine(tmpDlcDir, DLCname, "CookedPCConsole", "Default.sfar"); ME3DLC dlc = new ME3DLC(null); dlc.fullRePack(DLCs[i], outPath, DLCname, null, this); } Directory.Delete(GameData.DLCData, true); Directory.Move(tmpDlcDir, GameData.DLCData); updateStatusPackDLC(""); log += "Repack started finished" + Environment.NewLine + Environment.NewLine; } checkBoxPackDLC.Checked = true; } var time = Misc.stopTimer(); labelFinalStatus.Text = "Process finished. Process total time: " + Misc.getTimerFormat(time); buttonExit.Enabled = true; buttonNormal.Enabled = true; log += "==========================================" + Environment.NewLine; log += "LOD settings:" + Environment.NewLine; LODSettings.readLOD((MeType)gameId, engineConf, ref log); log += "==========================================" + Environment.NewLine; string filename = "install-log.txt"; if (File.Exists(filename)) { File.Delete(filename); } using (FileStream fs = new FileStream(filename, FileMode.CreateNew)) { fs.WriteStringASCII(log); } filename = "errors-install.txt"; if (File.Exists(filename)) { File.Delete(filename); } if (errors != "") { using (FileStream fs = new FileStream(filename, FileMode.CreateNew)) { fs.WriteStringASCII(errors); } MessageBox.Show("WARNING: Some errors have occured!"); Process.Start(filename); } }
static public void unpackAllDLC(MainWindow mainWindow, Installer installer, bool ipc) { if (!Directory.Exists(GameData.DLCData)) { if (mainWindow != null) { MessageBox.Show("No DLCs need to be extracted."); } return; } List <string> sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList(); int totalSfars = sfarFiles.Count; for (int i = 0; i < sfarFiles.Count; i++) { if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc"))) { sfarFiles.RemoveAt(i--); } } if (sfarFiles.Count() == 0) { if (mainWindow != null) { MessageBox.Show("No DLCs need to be extracted."); } return; } if (ipc) { Console.WriteLine("[IPC]STAGE_WEIGHT STAGE_UNPACKDLC " + string.Format("{0:0.000000}", ((float)sfarFiles.Count / totalSfars))); Console.Out.Flush(); } int totalNumFiles = 0; int currentProgress = 0; for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); totalNumFiles += getNumberOfFiles(sfarFiles[i]); } if (mainWindow != null) { long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath); long diskUsage = 0; for (int i = 0; i < sfarFiles.Count; i++) { diskUsage += new FileInfo(sfarFiles[i]).Length; } diskUsage = (long)(diskUsage * 2.5); if (diskUsage > diskFreeSpace) { if (mainWindow != null) { MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free."); } } } for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); string outPath = Path.Combine(GameData.DLCData, DLCname); ME3DLC dlc = new ME3DLC(mainWindow, installer); if (mainWindow != null) { mainWindow.updateStatusLabel("SFAR extracting - DLC " + (i + 1) + " of " + sfarFiles.Count); } if (ipc) { Console.WriteLine("[IPC]PROCESSING_FILE " + sfarFiles[i]); Console.Out.Flush(); } dlc.extract(sfarFiles[i], outPath, ipc, ref currentProgress, totalNumFiles); } }