Пример #1
0
        private void toolStripExtractMEMMenuItem(MeType gameType)
        {
            using (OpenFileDialog modFile = new OpenFileDialog())
            {
                modFile.Title       = "Please select Mod file";
                modFile.Filter      = "MEM mod file | *.mem";
                modFile.Multiselect = true;
                if (modFile.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                using (FolderBrowserDialog modDir = new FolderBrowserDialog())
                {
                    modDir.Description = "Please select destination directory for MEM extraction";
                    if (modDir.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    enableGameDataMenu(false);
                    GameData.gameType = gameType;

                    string   errors        = "";
                    string   log           = "";
                    string[] files         = modFile.FileNames;
                    long     diskFreeSpace = Misc.getDiskFreeSpace(modDir.SelectedPath);
                    long     diskUsage     = 0;
                    foreach (string file in files)
                    {
                        diskUsage += new FileInfo(file).Length;
                    }
                    diskUsage = (long)(diskUsage * 2.5);
                    if (diskUsage >= diskFreeSpace)
                    {
                        MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free.");
                    }
                    else
                    {
                        Misc.startTimer();
                        foreach (string file in files)
                        {
                            string outDir = Path.Combine(modDir.SelectedPath, Path.GetFileNameWithoutExtension(file));
                            Directory.CreateDirectory(outDir);
                            updateStatusLabel("MOD: " + file + " - extracting...");
                            updateStatusLabel2("");
                            errors += new MipMaps().extractTextureMod(file, outDir, null, null, ref log);
                        }
                        var time = Misc.stopTimer();
                        updateStatusLabel("MODs extracted. Process total time: " + Misc.getTimerFormat(time));
                        updateStatusLabel2("");
                        if (errors != "")
                        {
                            MessageBox.Show("WARNING: Some errors have occured!");
                        }
                    }
                }
            }
            enableGameDataMenu(true);
        }
Пример #2
0
        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);
        }
Пример #3
0
        private void buttonPreInstallCheck_Click(object sender, EventArgs e)
        {
            clearPreCheckStatus();

            buttonPreInstallCheck.Enabled = false;
            buttonsEnable(false);
            labelFinalStatus.Text  = "Checking...";
            labelPreMods.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreMods.Text      = "Checking...";
            Application.DoEvents();
            memFiles = Directory.GetFiles(".", "*.mem", SearchOption.AllDirectories).Where(item => item.EndsWith(".mem", StringComparison.OrdinalIgnoreCase)).ToList();
            memFiles.Sort();
            if (memFiles.Count == 0)
            {
                labelPreMods.Text             = "No MEM mods found!";
                labelPreMods.ForeColor        = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }
            errors = "";
            log    = "";
            for (int i = 0; i < memFiles.Count; i++)
            {
                using (FileStream fs = new FileStream(memFiles[i], FileMode.Open, FileAccess.Read))
                {
                    uint tag     = fs.ReadUInt32();
                    uint version = fs.ReadUInt32();
                    if (tag != TexExplorer.TextureModTag || version != TexExplorer.TextureModVersion)
                    {
                        if (version != TexExplorer.TextureModVersion)
                        {
                            errors += "File " + memFiles[i] + " was made with an older version of MEM, skipping..." + Environment.NewLine;
                        }
                        else
                        {
                            errors += "File " + memFiles[i] + " is not a valid MEM mod, skipping..." + Environment.NewLine;
                        }
                        continue;
                    }
                    else
                    {
                        uint gameType = 0;
                        fs.JumpTo(fs.ReadInt64());
                        gameType = fs.ReadUInt32();
                        if (gameType != gameId)
                        {
                            errors += "File " + memFiles[i] + " is not a MEM mod valid for this game, skipping..." + Environment.NewLine;
                            continue;
                        }
                    }
                }
            }
            string filename = "errors-precheck.txt";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            if (errors != "")
            {
                labelPreMods.Text             = "There are some errors while detecting MEM mods!";
                labelPreMods.ForeColor        = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);

                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                using (FileStream fs = new FileStream(filename, FileMode.CreateNew))
                {
                    fs.WriteStringASCII(errors);
                }
                Process.Start(filename);
                return;
            }
            labelPreMods.ForeColor  = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreMods.Text       = "";
            checkBoxPreMods.Checked = true;


            labelPreGamePath.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreGamePath.Text      = "Checking...";
            Application.DoEvents();
            gameData          = new GameData((MeType)gameId, configIni);
            labelPrePath.Text = GameData.GamePath;
            if (!Directory.Exists(GameData.GamePath))
            {
                labelPreGamePath.Text         = "Game path is wrong!";
                labelPreGamePath.ForeColor    = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }
            if (!gameData.getPackages(true, true))
            {
                labelPreGamePath.Text         = "Missing game data!";
                labelPreGamePath.ForeColor    = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }
            if (gameId == (int)MeType.ME1_TYPE)
            {
                if (!File.Exists(GameData.GamePath + "\\BioGame\\CookedPC\\Startup_int.upk"))
                {
                    labelPreGamePath.Text         = "ME1 game not found!";
                    labelPreGamePath.ForeColor    = Color.FromKnownColor(KnownColor.Red);
                    labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                    buttonPreInstallCheck.Enabled = true;
                    buttonsEnable(true);
                    return;
                }
            }
            if (gameId == (int)MeType.ME2_TYPE)
            {
                if (!File.Exists(GameData.GamePath + "\\BioGame\\CookedPC\\Textures.tfc"))
                {
                    labelPreGamePath.Text         = "ME2 game not found!";
                    labelPreGamePath.ForeColor    = Color.FromKnownColor(KnownColor.Red);
                    labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                    buttonPreInstallCheck.Enabled = true;
                    buttonsEnable(true);
                    return;
                }
            }
            if (gameId == (int)MeType.ME3_TYPE)
            {
                if (!File.Exists(GameData.GamePath + "\\BIOGame\\PCConsoleTOC.bin"))
                {
                    labelPreGamePath.Text         = "ME3 game not found!";
                    labelPreGamePath.ForeColor    = Color.FromKnownColor(KnownColor.Red);
                    labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                    buttonPreInstallCheck.Enabled = true;
                    buttonsEnable(true);
                    return;
                }
            }
            labelPreGamePath.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreGamePath.Text      = "";
            checkBoxPrePath.Checked    = true;

            labelPreAccess.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreAccess.Text      = "Checking...";
            Application.DoEvents();
            bool writeAccess = false;

            if (Misc.checkWriteAccessDir(GameData.MainData))
            {
                writeAccess = true;
            }
            if (gameId == (int)MeType.ME1_TYPE)
            {
                if (Misc.checkWriteAccessFile(GameData.GamePath + @"\BioGame\CookedPC\Packages\GameObjects\Characters\Humanoids\HumanMale\BIOG_HMM_HED_PROMorph.upk"))
                {
                    writeAccess = true;
                }
                else
                {
                    writeAccess = false;
                }
            }
            if (gameId == (int)MeType.ME2_TYPE)
            {
                if (Misc.checkWriteAccessFile(GameData.GamePath + @"\BioGame\CookedPC\BioD_CitAsL.pcc"))
                {
                    writeAccess = true;
                }
                else
                {
                    writeAccess = false;
                }
            }
            if (gameId == (int)MeType.ME3_TYPE)
            {
                if (Misc.checkWriteAccessFile(GameData.GamePath + @"\BioGame\CookedPCConsole\BioA_CitSam_000LevelTrans.pcc"))
                {
                    writeAccess = true;
                }
                else
                {
                    writeAccess = false;
                }
            }
            if (!writeAccess)
            {
                labelPreAccess.Text           = "Write access denied to game folders!";
                labelPreAccess.ForeColor      = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }
            labelPreAccess.ForeColor  = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreAccess.Text       = "";
            checkBoxPreAccess.Checked = true;


            labelPreSpace.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreSpace.Text      = "Checking...";
            Application.DoEvents();
            long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath);
            long diskUsage     = 0;

            for (int i = 0; i < memFiles.Count; i++)
            {
                diskUsage += new FileInfo(memFiles[i]).Length;
            }
            diskUsage = (long)(diskUsage * 2.5);

            if (gameId == (int)MeType.ME3_TYPE)
            {
                if (Directory.Exists(GameData.DLCData))
                {
                    long          diskUsageDLC = 0;
                    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--);
                        }
                    }
                    for (int i = 0; i < sfarFiles.Count; i++)
                    {
                        diskUsageDLC += new FileInfo(sfarFiles[i]).Length;
                    }
                    diskUsage = (long)(diskUsageDLC * 2.1);
                }
            }

            if (diskUsage > diskFreeSpace)
            {
                labelPreSpace.Text            = "You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free.";
                labelPreSpace.ForeColor       = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary checking failed. Issue detected...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }
            labelPreSpace.ForeColor  = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreSpace.Text       = "";
            checkBoxPreSpace.Checked = true;


            labelPreVanilla.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
            labelPreVanilla.Text      = "Checking...";
            Application.DoEvents();
            if (Misc.detectBrokenMod((MeType)gameId))
            {
                labelPreVanilla.Text          = "Detected broken mod!";
                labelPreVanilla.ForeColor     = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text         = "Preliminary check detected issue...";
                buttonPreInstallCheck.Enabled = true;
                buttonsEnable(true);
                return;
            }

            if (!checkBoxOptionVanilla.Checked)
            {
                errors = Misc.checkGameFiles((MeType)gameId, null, this);
            }
            if (errors != "")
            {
                using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate))
                {
                    fs.SeekEnd();
                    fs.WriteStringASCII("=========================================================" + Environment.NewLine);
                    fs.WriteStringASCII("WARNING: looks like the following file(s) are not vanilla" + Environment.NewLine);
                    fs.WriteStringASCII("=========================================================" + Environment.NewLine + Environment.NewLine);
                    fs.WriteStringASCII(errors);
                }
                Process.Start(filename);
                labelPreVanilla.Text      = "Game files are not vanilla!";
                labelPreVanilla.ForeColor = Color.FromKnownColor(KnownColor.Red);
                labelFinalStatus.Text     = "Preliminary check detected potential issue...";
            }
            else
            {
                labelPreVanilla.ForeColor = Color.FromKnownColor(KnownColor.LimeGreen);
                labelPreVanilla.Text      = "";
                labelFinalStatus.Text     = "Ready to go. Press START button!";
            }
            checkBoxPreVanilla.Checked = true;


            buttonPreInstallCheck.Enabled = true;
            buttonsEnable(true);
            buttonSTART.Enabled = true;
        }
Пример #4
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("");
        }
Пример #5
0
        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);
            }
        }