void updateMEConfig(MeType gameId) { enableGameDataMenu(false); string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Assembly.GetExecutingAssembly().GetName().Name); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string filename = Path.Combine(path, "me" + (int)gameId + "map.bin"); if (!File.Exists(filename)) { MessageBox.Show("Unable to update LOD settings.\nYou must scan your game using Texture Manager first always!"); enableGameDataMenu(true); return; } GameData gameData = new GameData(gameId, _configIni); path = gameData.EngineConfigIniPath; bool exist = File.Exists(path); if (!exist) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } ConfIni engineConf = new ConfIni(path); LODSettings.updateLOD(gameId, engineConf); MessageBox.Show("Game configuration file at " + path + " updated."); enableGameDataMenu(true); }
public MainWindow(bool runAsAdmin) { InitializeComponent(); Text = "Mass Effect Modder v" + Application.ProductVersion; if (runAsAdmin) { Text += " (run as Administrator)"; } _configIni = new ConfIni(); }
public GameData(MeType type, ConfIni configIni, bool force = false, bool installerMode = false) { gameType = type; _configIni = configIni; string key = "ME" + (int)gameType; string path = configIni.Read(key, "GameDataPath"); if (path != null && path != "" && !force) { _path = path.TrimEnd(Path.DirectorySeparatorChar); if (File.Exists(GameExePath)) { return; } else { _path = null; } } string registryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BioWare\Mass Effect"; string entry = "Path"; if (type == MeType.ME2_TYPE) { registryKey += " 2"; } else if (type == MeType.ME3_TYPE) { registryKey += " 3"; entry = "Install Dir"; } path = (string)Registry.GetValue(registryKey, entry, null); if (path != null && !force) { _path = path.TrimEnd(Path.DirectorySeparatorChar); if (File.Exists(GameExePath)) { configIni.Write(key, _path, "GameDataPath"); return; } else { _path = null; } } if (_path != null) { _configIni.Write(key, _path, "GameDataPath"); } }
public MainWindow(bool runAsAdmin) { InitializeComponent(); Text = "Mass Effect Modder v" + Application.ProductVersion; if (runAsAdmin) { Text += " (run as Administrator)"; } _configIni = new ConfIni(); if (runAsAdmin) { MessageBox.Show("The program should be run as standard user to avoid user account issues.\n" + "The program will ask for administrative rights when necessary."); } }
private void updateGfxME(MeType gameId, bool softShadowsMode = false) { enableGameDataMenu(false); GameData gameData = new GameData(gameId, _configIni); string path = gameData.EngineConfigIniPath; bool exist = File.Exists(path); if (!exist) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } ConfIni engineConf = new ConfIni(path); LODSettings.updateGFXSettings(gameId, engineConf, false, false); MessageBox.Show("Game configuration file at " + path + " updated."); enableGameDataMenu(true); }
private void removeLODSettings(MeType gameId) { enableGameDataMenu(false); GameData gameData = new GameData(gameId, _configIni); string path = gameData.EngineConfigIniPath; bool exist = File.Exists(path); if (exist) { ConfIni engineConf = new ConfIni(path); LODSettings.removeLOD(gameId, engineConf); MessageBox.Show("INFO: Game configuration file at " + path + " updated."); } else { MessageBox.Show("INFO: Game configuration file at " + path + " not exist, nothing done."); } enableGameDataMenu(true); }
static public bool ConvertToMEM(int gameId, string inputDir, string memFile) { textures = new List <FoundTexture>(); ConfIni configIni = new ConfIni(); GameData gameData = new GameData((MeType)gameId, configIni); if (GameData.GamePath == null || !Directory.Exists(GameData.GamePath)) { Console.WriteLine("Error: Could not found the game!"); return(false); } string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Assembly.GetExecutingAssembly().GetName().Name); string mapFile = Path.Combine(path, "me" + gameId + "map.bin"); if (!loadTexturesMap(mapFile, textures)) { return(false); } string errors = convertDataModtoMem(inputDir, memFile); string filename = "convert-errors.txt"; if (File.Exists(filename)) { File.Delete(filename); } if (errors != "") { using (FileStream fs = new FileStream(filename, FileMode.CreateNew)) { fs.WriteStringASCII(errors); } Console.WriteLine("Error: Some errors have occured, check log file: " + filename); return(false); } return(true); }
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); } }
public bool Run(bool runAsAdmin) { installerIni = new ConfIni(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "installer.ini")); string gameIdStr = installerIni.Read("GameId", "Main"); if (gameIdStr.ToLowerInvariant() == "me1") { gameId = 1; } else if (gameIdStr.ToLowerInvariant() == "me2") { gameId = 2; } else if (gameIdStr.ToLowerInvariant() == "me3") { gameId = 3; } else { MessageBox.Show("Game ID not recognized in installer.ini, exiting...", "Installer"); return(false); } Text += " ME" + gameId; if (runAsAdmin) { Text += " (run as Administrator)"; } configIni = new ConfIni(); labelStatusPrepare.Text = ""; labelStatusScan.Text = ""; labelStatusTextures.Text = ""; labelStatusStore.Text = ""; labelStatusMipMaps.Text = ""; labelStatusLOD.Text = ""; labelFinalStatus.Text = "Before beginning, press the CHECK button."; if (gameId != 3) { checkBoxPreEnablePack.Visible = false; labelME3DLCPack.Visible = false; checkBoxPackDLC.Visible = false; labelStatusPackDLC.Visible = false; labelMERepackZlib.Visible = false; checkBoxRepackZlib.Visible = false; labelStatusRepackZlib.Visible = false; buttonUnpackDLC.Visible = false; } if (gameId == 3) { checkBoxPreEnableRepack.Visible = false; labelMERepackZlib.Visible = false; labelME3DLCPack.Visible = false; checkBoxRepackZlib.Visible = false; labelStatusRepackZlib.Visible = false; labelME3DLCPack.Visible = false; checkBoxPackDLC.Visible = false; labelStatusPackDLC.Visible = false; } checkBoxOptionVanilla.Checked = false; checkBoxOptionFaster.Checked = false; buttonUnpackDLC.Enabled = false; clearPreCheckStatus(); buttonSTART.Enabled = false; return(true); }
public GameData(MeType type, ConfIni configIni, bool force = false) { gameType = type; _configIni = configIni; string key = "ME" + (int)gameType; string path = configIni.Read(key, "GameDataPath"); if (path != null && path != "" && !force) { _path = path.TrimEnd(Path.DirectorySeparatorChar); if (File.Exists(GameExePath)) { return; } else { _path = null; } } string softwareKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\"; string key64 = @"Wow6432Node\"; string gameKey = @"BioWare\Mass Effect"; string entry = "Path"; if (type == MeType.ME2_TYPE) { gameKey += @" 2"; } else if (type == MeType.ME3_TYPE) { gameKey += @" 3"; entry = "Install Dir"; } path = (string)Registry.GetValue(softwareKey + gameKey, entry, null); if (path == null) { path = (string)Registry.GetValue(softwareKey + key64 + gameKey, entry, null); } if (path != null && !force) { _path = path.TrimEnd(Path.DirectorySeparatorChar); if (File.Exists(GameExePath)) { configIni.Write(key, _path, "GameDataPath"); return; } else { _path = null; } } OpenFileDialog selectExe = new OpenFileDialog(); selectExe.Title = "Please select the Mass Effect " + (int)gameType + " executable file"; if (_path != null) { selectExe.FileName = _path; } switch (gameType) { case MeType.ME1_TYPE: selectExe.Filter = "ME1 exe file|MassEffect.exe"; selectExe.FileName = "MassEffect.exe"; break; case MeType.ME2_TYPE: selectExe.Filter = "ME2 exe file|MassEffect2.exe"; selectExe.FileName = "MassEffect2.exe"; break; case MeType.ME3_TYPE: selectExe.Filter = "ME3 exe file|MassEffect3.exe"; selectExe.FileName = "MassEffect3.exe"; break; } if (selectExe.ShowDialog() == DialogResult.OK) { if (gameType == MeType.ME3_TYPE) { _path = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(selectExe.FileName))); } else { _path = Path.GetDirectoryName(Path.GetDirectoryName(selectExe.FileName)); } } if (_path != null) { _configIni.Write(key, _path, "GameDataPath"); } }