public void SetLang(TOCeditor toc) { toc.Text = GlobalLang[CurrentLanguage].Entries[85]; //85 toc.fileToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[86]; toc.openToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[87]; toc.saveToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[88]; toc.searchToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[89]; toc.searchAgainToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[90]; //90 toc.editFilesizeToolStripMenuItem.Text = GlobalLang[CurrentLanguage].Entries[91]; }
public void DecompressPCC(string path) { if (!File.Exists(path)) { return; } PCCObjects.Misc.PCCDecompress(path); string filen = Path.GetFileName(path); FileStream fs2 = new FileStream(path, FileMode.Open, FileAccess.Read); uint fsize = (uint)fs2.Length; fs2.Close(); TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(filen, fsize)) { MessageBox.Show("Didn't found Entry"); } tc.Close(); }
public static void DLCTocFix(String path) { if (String.Compare(Path.GetFileName(path), "PCConsoleTOC.bin", true) != 0) { throw new FileFormatException("Incorrect file passed!"); } else if (!File.Exists(path)) { throw new FileNotFoundException("PCConsoleTOC.bin file not found!"); } TOCeditor tc = new TOCeditor(); FileInfo[] files = new DirectoryInfo(Path.GetDirectoryName(path)).GetFiles(); for (int i = 0; i < files.Length; i++) { if (String.Compare(".bin", files[i].Extension, true) == 0) { continue; } tc.UpdateFile("\\" + Path.GetFileName(files[i].FullName), (uint)files[i].Length, path); } }
public static void DLCTocFix(String path) { if (String.Compare(Path.GetFileName(path), "PCConsoleTOC.bin", true) != 0) throw new FileFormatException("Incorrect file passed!"); else if (!File.Exists(path)) throw new FileNotFoundException("PCConsoleTOC.bin file not found!"); TOCeditor tc = new TOCeditor(); FileInfo[] files = new DirectoryInfo(Path.GetDirectoryName(path)).GetFiles(); for (int i = 0; i < files.Length; i++) { if (String.Compare(".bin", files[i].Extension, true) == 0) continue; tc.UpdateFile("\\" + Path.GetFileName(files[i].FullName), (uint)files[i].Length, path); } }
public void CreateDefaultLang() { Language l = new Language(); Form1 f1 = new Form1(); Form2 f2 = new Form2(); DLCExplorer dlc = new DLCExplorer(); TOCeditor toc = new TOCeditor(); Conditionals con = new Conditionals(); Language_Selector lng = new Language_Selector(); AFCExtract afc = new AFCExtract(); BIKExtract bik = new BIKExtract(); PropertyManager prop = new PropertyManager(); XBoxConverter xbox = new XBoxConverter(); Language_Editor lne = new Language_Editor(); string[] t = new string[0]; MainWindow tlk = new MainWindow(); l.name = "Default"; l.Entries = new List <string>(); #region Form1 l.Entries.Add(f1.userToolsToolStripMenuItem.Text); //0 l.Entries.Add(f1.dLCEditorToolStripMenuItem.Text); l.Entries.Add(f1.tLKEditorToolStripMenuItem.Text); l.Entries.Add(f1.tOCbinEditorToolStripMenuItem.Text); //5 l.Entries.Add(f1.decompressorToolStripMenuItem.Text); l.Entries.Add(f1.conditionalsToolStripMenuItem.Text); l.Entries.Add(f1.lanugageSelectorToolStripMenuItem.Text); //l.Entries.Add("Extractor"); // KFreon: Not sure what all this is for exactly, so just filling in bits l.Entries.Add(f1.aFCToWAVToolStripMenuItem.Text); //10 l.Entries.Add(f1.moviestfcToBIKToolStripMenuItem.Text); l.Entries.Add(f1.propertyManagerToolStripMenuItem.Text); //l.Entries.Add(f1.xBoxConverterToolStripMenuItem.Text); l.Entries.Add(f1.optionsToolStripMenuItem.Text); l.Entries.Add(f1.selectToolLanguageToolStripMenuItem.Text); //15 #endregion #region Form2 l.Entries.Add(f2.Text); l.Entries.Add(f2.fileOpenToolStripMenuItem.Text); #endregion #region DLC Explorer l.Entries.Add(dlc.Text); //60 l.Entries.Add(dlc.groupBoxSfar.Text); l.Entries.Add(dlc.labelNumOfFiles.Text); l.Entries.Add(dlc.labelTotalUncSize.Text); l.Entries.Add(dlc.labelTotalUncBytes.Text); l.Entries.Add(dlc.labelTotalComprSize.Text); //65 l.Entries.Add(dlc.labelTotalComprBytes.Text); l.Entries.Add(dlc.labelComprRatio.Text); l.Entries.Add(dlc.labelFirstEntryOffset.Text); l.Entries.Add(dlc.labelFirstBlockOffset.Text); l.Entries.Add(dlc.labelFirstDataOffset.Text); //70 l.Entries.Add(dlc.groupBoxFile.Text); l.Entries.Add(dlc.labelFullName.Text); l.Entries.Add(dlc.labelHash.Text); l.Entries.Add(dlc.labelFileSize.Text); l.Entries.Add(dlc.labelUncSizeBytes.Text); //75 l.Entries.Add(dlc.labelComprSize.Text); l.Entries.Add(dlc.labelComprSizeBytes.Text); l.Entries.Add(dlc.labelEntry.Text); l.Entries.Add(dlc.labelBlockIndex.Text); l.Entries.Add(dlc.labelDataOffset.Text); //80 l.Entries.Add(dlc.toolStripOpenFile.Text); l.Entries.Add(dlc.toolStripSaveFile.Text); l.Entries.Add(dlc.toolStripInfo.Text); l.Entries.Add(dlc.toolStripAbout.Text); #endregion #region TOC Editor l.Entries.Add(toc.Text); //85 l.Entries.Add(toc.fileToolStripMenuItem.Text); l.Entries.Add(toc.openToolStripMenuItem.Text); l.Entries.Add(toc.saveToolStripMenuItem.Text); l.Entries.Add(toc.searchToolStripMenuItem.Text); l.Entries.Add(toc.searchAgainToolStripMenuItem.Text); //90 l.Entries.Add(toc.editFilesizeToolStripMenuItem.Text); #endregion #region Conditionals l.Entries.Add(con.Text); l.Entries.Add(con.fileToolStripMenuItem.Text); l.Entries.Add(con.openToolStripMenuItem.Text); l.Entries.Add(con.saveToolStripMenuItem.Text); //95 l.Entries.Add(con.mapToSVGToolStripMenuItem.Text); l.Entries.Add(con.editToolStripMenuItem.Text); #endregion #region Language Select l.Entries.Add(lng.Text); l.Entries.Add(lng.radioButton1.Text); l.Entries.Add(lng.radioButton2.Text); //100 l.Entries.Add(lng.radioButton3.Text); l.Entries.Add(lng.radioButton4.Text); l.Entries.Add(lng.radioButton5.Text); l.Entries.Add(lng.radioButton6.Text); l.Entries.Add(lng.button1.Text); //105 l.Entries.Add(lng.button2.Text); #endregion #region AFC l.Entries.Add(afc.Text); l.Entries.Add(afc.fileToolStripMenuItem.Text); l.Entries.Add(afc.openToolStripMenuItem.Text); l.Entries.Add(afc.extractToolStripMenuItem.Text); //110 l.Entries.Add(afc.selectedToolStripMenuItem.Text); l.Entries.Add(afc.allToolStripMenuItem.Text); #endregion #region BIK l.Entries.Add(bik.Text); l.Entries.Add(bik.fileToolStripMenuItem.Text); l.Entries.Add(bik.openToolStripMenuItem.Text); //115 l.Entries.Add(bik.extractToolStripMenuItem.Text); l.Entries.Add(bik.selectedToolStripMenuItem.Text); l.Entries.Add(bik.allToolStripMenuItem.Text); #endregion #region PropertyMan l.Entries.Add(prop.Text); l.Entries.Add(prop.fileToolStripMenuItem.Text); //120 l.Entries.Add(prop.newToolStripMenuItem.Text); l.Entries.Add(prop.loadDefinitonsToolStripMenuItem.Text); l.Entries.Add(prop.saveDefinitionsToolStripMenuItem.Text); l.Entries.Add(prop.loadDefaultToolStripMenuItem.Text); l.Entries.Add(prop.saveAsDefaultToolStripMenuItem.Text); //125 l.Entries.Add(prop.importFromFileToolStripMenuItem.Text); l.Entries.Add(prop.actionToolStripMenuItem.Text); l.Entries.Add(prop.addClassToolStripMenuItem.Text); l.Entries.Add(prop.addPropertyToolStripMenuItem.Text); l.Entries.Add(prop.deleteClassToolStripMenuItem.Text); //130 l.Entries.Add(prop.deletePropertyToolStripMenuItem.Text); #endregion #region xboxconverter l.Entries.Add(xbox.Text); l.Entries.Add(xbox.fileToolStripMenuItem.Text); l.Entries.Add(xbox.xXXPCCToolStripMenuItem.Text); l.Entries.Add(xbox.pCCXXXToolStripMenuItem.Text); //135 #endregion #region Language Editor l.Entries.Add(lne.Text); l.Entries.Add(lne.fileToolStripMenuItem.Text); l.Entries.Add(lne.saveToolStripMenuItem.Text); l.Entries.Add(lne.editToolStripMenuItem.Text); l.Entries.Add(lne.copyLanguagToolStripMenuItem.Text); //140 l.Entries.Add(lne.deleteLanguageToolStripMenuItem.Text); l.Entries.Add(lne.renameLanguageToolStripMenuItem.Text); l.Entries.Add(lne.editEntryToolStripMenuItem.Text); l.Entries.Add(lne.setLanguageAsDefaultToolStripMenuItem.Text); #endregion GlobalLang.Add(l); }
public void ImportFromFile(int tfc) { OpenFileDialog Dialog = new OpenFileDialog(); if (T2D.PixelFormat == "PF_DXT1\0" || T2D.PixelFormat == "PF_DXT5\0") Dialog.Filter = "DDS Files (*.dds)|*.dds"; if (T2D.PixelFormat == "PF_G8\0" || T2D.PixelFormat == "PF_V8U8\0" || T2D.PixelFormat == "PF_A8R8G8B8\0") Dialog.Filter = "TGA Files (*.tga)|*.tga"; int format = -1; if (T2D.PixelFormat == "PF_DXT1\0") format = 0; if (T2D.PixelFormat == "PF_DXT5\0") format = 1; if (T2D.PixelFormat == "PF_V8U8\0") format = 2; if (T2D.PixelFormat == "PF_A8R8G8B8\0") format = 3; if (T2D.PixelFormat == "PF_G8\0") format = 4; if (!TextureTFCs[tfc].InCache) { if (Dialog.ShowDialog() == DialogResult.OK) { if (format == 0 || format == 1) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY && t.ImageFormat == format && t.memsize == TextureTFCs[tfc].size) { for (int i = 0; i < t.memsize; i++) memory[TextureTFCs[tfc].offset + i] = t.memory[i]; MessageBox.Show("Done."); } } if (format > 1 && format < 5) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) if (t.ImageBits != 32) { MessageBox.Show("Please use 32 bit Targa image!"); } else { switch (format) { case 2: for (int i = 0; i < t.memsize / 4; i++) { memory[TextureTFCs[tfc].offset + i * 2] = t.memory[i * 4]; memory[TextureTFCs[tfc].offset + i * 2 + 1] = t.memory[i * 4 + 2]; } break; case 3: for (int i = 0; i < t.memsize; i++) memory[TextureTFCs[tfc].offset + i] = t.memory[i]; break; case 4: for (int i = 0; i < t.memsize / 4; i++) memory[TextureTFCs[tfc].offset + i] = t.memory[i * 4]; break; } MessageBox.Show("Done."); } } } } else if (Dialog.ShowDialog() == DialogResult.OK) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if ((format == 0 || format == 1) && t.ImageFormat == format) if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) { TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) buff = ZBlock.Compress(t.memory); else buff = t.memory; byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 16 + i] = buff2[i]; TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) MessageBox.Show("Didn't found Entry"); tc.Close(); } } else { System.Windows.Forms.DialogResult m = MessageBox.Show("The size doesn't match, import anyway?", "ME3 Explorer", MessageBoxButtons.YesNo); if (m == DialogResult.Yes) { TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) buff = ZBlock.Compress(t.memory); else buff = t.memory; byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 16 + i] = buff2[i]; if (tfc == 0) { buff2 = BitConverter.GetBytes(t.ImageSizeX); for (int i = 0; i < 4; i++) memory[T2D.offSizeX + i] = buff2[i]; buff2 = BitConverter.GetBytes(t.ImageSizeY); for (int i = 0; i < 4; i++) memory[T2D.offSizeY + i] = buff2[i]; } else { buff2 = BitConverter.GetBytes(t.ImageSizeX * 2); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + i] = buff2[i]; buff2 = BitConverter.GetBytes(t.ImageSizeY * 2); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 4 + i] = buff2[i]; TFCf.AppendToTFC(buff); } TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) MessageBox.Show("Didn't found Entry"); tc.Close(); } } } if (format > 1 && format < 5) { if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) if (t.ImageBits != 32) { MessageBox.Show("Please use 32 bit Targa image!"); } else { byte[] buf = new byte[0]; switch (format) { case 2: buf = new byte[t.memsize / 2]; for (int i = 0; i < t.memsize / 4; i++) { buf[i * 2] = t.memory[i * 4]; buf[i * 2 + 1] = t.memory[i * 4 + 2]; } break; case 3: buf = t.memory; break; case 4: buf = new byte[t.memsize / 4]; for (int i = 0; i < t.memsize / 4; i++) buf[i] = t.memory[i * 4]; break; } TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) buff = ZBlock.Compress(t.memory); else buff = t.memory; byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) memory[TextureTFCs[tfc].HeaderOffset + 12 + i] = buff2[i]; TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) MessageBox.Show("Didn't found Entry"); tc.Close(); } MessageBox.Show("Done."); } } } }
public void CloneEntry(int entry) { byte[] buffdata; DialogResult r = MessageBox.Show("Clone with new data?","", MessageBoxButtons.YesNo); if (r == DialogResult.No) { buffdata = EntryToBuff(entry); } else { OpenFileDialog d = new OpenFileDialog(); d.Filter = "bin files (*.bin)|*.bin|all files|*.*"; if (d.ShowDialog() == DialogResult.OK) { FileStream f = new FileStream(d.FileName, FileMode.Open, FileAccess.Read); int size = (int)f.Length; buffdata = new byte[size]; int count; int sum = 0; while ((count = f.Read(buffdata, sum, size - sum)) > 0) sum += count; } else return; } int sizebefore = memsize; MemoryStream m = new MemoryStream(); m.Write(memory, 0, (int)Header.offinfo + 8); byte[] buff = BitConverter.GetBytes(Header.ExportCount + 1); m.Write(buff, 0, 4); buff = BitConverter.GetBytes(sizebefore); m.Write(buff, 0, 4); m.Write(memory, (int)Header.offinfo + 16,sizebefore - ((int)Header.offinfo + 16)); for (int i = 0; i < Export.Length; i++) { uint len = Export[i].end - Export[i].start; m.Write(memory, (int)Export[i].start, (int)len); } int pos =(int)m.Length; uint len2 = Export[entry].end - Export[entry].start; m.Write(memory, (int)Export[entry].start, 32); buff = BitConverter.GetBytes(buffdata.Length); m.Write(buff, 0, 4); buff = BitConverter.GetBytes(pos + (int)len2); m.Write(buff, 0, 4); m.Write(memory, (int)Export[entry].start + 40, (int)len2- 40); m.Write(buffdata, 0, buffdata.Length); Header.ExportCount++; Header.ExportOffset = (uint)sizebefore; exports ex = new exports(); ex.Class = Export[entry].Class; ex.DataOffset = (uint)pos + len2; ex.DataSize = (uint)buffdata.Length; ex.end = (uint)pos + len2; ex.Link = Export[entry].Link; ex.Name = Export[entry].Name; ex.off = Export[entry].off; ex.start = (uint)pos; exports[] t = new exports[Header.ExportCount]; for (int i = 0; i < Header.ExportCount - 1; i++) t[i] = Export[i]; t[Header.ExportCount - 1] = ex; Export = t; memory = m.ToArray(); TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(loadedFilename, (uint)memsize)) MessageBox.Show("Didn't found Entry"); }
public void CreateDefaultLang() { Language l = new Language(); Form1 f1 = new Form1(); Form2 f2 = new Form2(); DLCExplorer dlc = new DLCExplorer(); TOCeditor toc = new TOCeditor(); Conditionals con = new Conditionals(); Language_Selector lng = new Language_Selector(); AFCExtract afc = new AFCExtract(); BIKExtract bik = new BIKExtract(); PropertyManager prop = new PropertyManager(); XBoxConverter xbox = new XBoxConverter(); Language_Editor lne = new Language_Editor(); string[] t = new string[0]; MainWindow tlk = new MainWindow(); l.name = "Default"; l.Entries = new List<string>(); #region Form1 l.Entries.Add(f1.userToolsToolStripMenuItem.Text); //0 l.Entries.Add(f1.dLCEditorToolStripMenuItem.Text); l.Entries.Add(f1.tLKEditorToolStripMenuItem.Text); l.Entries.Add(f1.tOCbinEditorToolStripMenuItem.Text); //5 l.Entries.Add(f1.decompressorToolStripMenuItem.Text); l.Entries.Add(f1.conditionalsToolStripMenuItem.Text); l.Entries.Add(f1.lanugageSelectorToolStripMenuItem.Text); //l.Entries.Add("Extractor"); // KFreon: Not sure what all this is for exactly, so just filling in bits l.Entries.Add(f1.aFCToWAVToolStripMenuItem.Text); //10 l.Entries.Add(f1.moviestfcToBIKToolStripMenuItem.Text); l.Entries.Add(f1.propertyManagerToolStripMenuItem.Text); //l.Entries.Add(f1.xBoxConverterToolStripMenuItem.Text); l.Entries.Add(f1.optionsToolStripMenuItem.Text); l.Entries.Add(f1.selectToolLanguageToolStripMenuItem.Text); //15 #endregion #region Form2 l.Entries.Add(f2.Text); l.Entries.Add(f2.fileOpenToolStripMenuItem.Text); #endregion #region DLC Explorer l.Entries.Add(dlc.Text); //60 l.Entries.Add(dlc.groupBoxSfar.Text); l.Entries.Add(dlc.labelNumOfFiles.Text); l.Entries.Add(dlc.labelTotalUncSize.Text); l.Entries.Add(dlc.labelTotalUncBytes.Text); l.Entries.Add(dlc.labelTotalComprSize.Text); //65 l.Entries.Add(dlc.labelTotalComprBytes.Text); l.Entries.Add(dlc.labelComprRatio.Text); l.Entries.Add(dlc.labelFirstEntryOffset.Text); l.Entries.Add(dlc.labelFirstBlockOffset.Text); l.Entries.Add(dlc.labelFirstDataOffset.Text); //70 l.Entries.Add(dlc.groupBoxFile.Text); l.Entries.Add(dlc.labelFullName.Text); l.Entries.Add(dlc.labelHash.Text); l.Entries.Add(dlc.labelFileSize.Text); l.Entries.Add(dlc.labelUncSizeBytes.Text); //75 l.Entries.Add(dlc.labelComprSize.Text); l.Entries.Add(dlc.labelComprSizeBytes.Text); l.Entries.Add(dlc.labelEntry.Text); l.Entries.Add(dlc.labelBlockIndex.Text); l.Entries.Add(dlc.labelDataOffset.Text); //80 l.Entries.Add(dlc.toolStripOpenFile.Text); l.Entries.Add(dlc.toolStripSaveFile.Text); l.Entries.Add(dlc.toolStripInfo.Text); l.Entries.Add(dlc.toolStripAbout.Text); #endregion #region TOC Editor l.Entries.Add(toc.Text); //85 l.Entries.Add(toc.fileToolStripMenuItem.Text); l.Entries.Add(toc.openToolStripMenuItem.Text); l.Entries.Add(toc.saveToolStripMenuItem.Text); l.Entries.Add(toc.searchToolStripMenuItem.Text); l.Entries.Add(toc.searchAgainToolStripMenuItem.Text); //90 l.Entries.Add(toc.editFilesizeToolStripMenuItem.Text); #endregion #region Conditionals l.Entries.Add(con.Text); l.Entries.Add(con.fileToolStripMenuItem.Text); l.Entries.Add(con.openToolStripMenuItem.Text); l.Entries.Add(con.saveToolStripMenuItem.Text); //95 l.Entries.Add(con.mapToSVGToolStripMenuItem.Text); l.Entries.Add(con.editToolStripMenuItem.Text); #endregion #region Language Select l.Entries.Add(lng.Text); l.Entries.Add(lng.radioButton1.Text); l.Entries.Add(lng.radioButton2.Text); //100 l.Entries.Add(lng.radioButton3.Text); l.Entries.Add(lng.radioButton4.Text); l.Entries.Add(lng.radioButton5.Text); l.Entries.Add(lng.radioButton6.Text); l.Entries.Add(lng.button1.Text); //105 l.Entries.Add(lng.button2.Text); #endregion #region AFC l.Entries.Add(afc.Text); l.Entries.Add(afc.fileToolStripMenuItem.Text); l.Entries.Add(afc.openToolStripMenuItem.Text); l.Entries.Add(afc.extractToolStripMenuItem.Text); //110 l.Entries.Add(afc.selectedToolStripMenuItem.Text); l.Entries.Add(afc.allToolStripMenuItem.Text); #endregion #region BIK l.Entries.Add(bik.Text); l.Entries.Add(bik.fileToolStripMenuItem.Text); l.Entries.Add(bik.openToolStripMenuItem.Text); //115 l.Entries.Add(bik.extractToolStripMenuItem.Text); l.Entries.Add(bik.selectedToolStripMenuItem.Text); l.Entries.Add(bik.allToolStripMenuItem.Text); #endregion #region PropertyMan l.Entries.Add(prop.Text); l.Entries.Add(prop.fileToolStripMenuItem.Text); //120 l.Entries.Add(prop.newToolStripMenuItem.Text); l.Entries.Add(prop.loadDefinitonsToolStripMenuItem.Text); l.Entries.Add(prop.saveDefinitionsToolStripMenuItem.Text); l.Entries.Add(prop.loadDefaultToolStripMenuItem.Text); l.Entries.Add(prop.saveAsDefaultToolStripMenuItem.Text); //125 l.Entries.Add(prop.importFromFileToolStripMenuItem.Text); l.Entries.Add(prop.actionToolStripMenuItem.Text); l.Entries.Add(prop.addClassToolStripMenuItem.Text); l.Entries.Add(prop.addPropertyToolStripMenuItem.Text); l.Entries.Add(prop.deleteClassToolStripMenuItem.Text); //130 l.Entries.Add(prop.deletePropertyToolStripMenuItem.Text); #endregion #region xboxconverter l.Entries.Add(xbox.Text); l.Entries.Add(xbox.fileToolStripMenuItem.Text); l.Entries.Add(xbox.xXXPCCToolStripMenuItem.Text); l.Entries.Add(xbox.pCCXXXToolStripMenuItem.Text); //135 #endregion #region Language Editor l.Entries.Add(lne.Text); l.Entries.Add(lne.fileToolStripMenuItem.Text); l.Entries.Add(lne.saveToolStripMenuItem.Text); l.Entries.Add(lne.editToolStripMenuItem.Text); l.Entries.Add(lne.copyLanguagToolStripMenuItem.Text); //140 l.Entries.Add(lne.deleteLanguageToolStripMenuItem.Text); l.Entries.Add(lne.renameLanguageToolStripMenuItem.Text); l.Entries.Add(lne.editEntryToolStripMenuItem.Text); l.Entries.Add(lne.setLanguageAsDefaultToolStripMenuItem.Text); #endregion GlobalLang.Add(l); }
private void ImportWav(string pathafc, string pathwav, int off, string pathBIO, bool updateTOC = true) { if (!File.Exists(pathafc) || !File.Exists(pathwav)) { return; } FileStream fs = new FileStream(pathafc, FileMode.Open, FileAccess.Read); byte[] Header = new byte[94]; fs.Seek(DataOffset, SeekOrigin.Begin); for (int i = 0; i < 94; i++) { Header[i] = (byte)fs.ReadByte(); } fs.Close(); fs = new FileStream(pathwav, FileMode.Open, FileAccess.Read); byte[] newfile = new byte[fs.Length]; for (int i = 0; i < fs.Length; i++) { newfile[i] = (byte)fs.ReadByte(); } fs.Close(); newfile = ModifyHeader(newfile, Header); fs = new FileStream(pathafc, FileMode.Append, FileAccess.Write, FileShare.Write); int newoff = (int)fs.Length; int newsize = newfile.Length; for (int i = 0; i < newsize; i++) { fs.WriteByte(newfile[i]); } uint newafcsize = (uint)fs.Length; fs.Close(); byte[] buff = BitConverter.GetBytes(newsize); for (int i = 0; i < 4; i++) { memory[ValueOffset + i - 4] = buff[i]; } for (int i = 0; i < 4; i++) { memory[ValueOffset + i] = buff[i]; } buff = BitConverter.GetBytes(newoff); for (int i = 0; i < 4; i++) { memory[ValueOffset + i + 4] = buff[i]; } DataSize = newsize; DataOffset = newoff; TOCeditor tc = new TOCeditor(); string s = Path.GetFileName(pathafc); if (updateTOC) { if (!tc.UpdateFile("\\" + s, newafcsize, pathBIO + "PCConsoleTOC.bin")) { MessageBox.Show("Didn't found Entry!"); } } }
private void ImportWav(string pathafc, string pathwav, int off, string pathBIO, bool updateTOC = true) { if (!File.Exists(pathafc) || !File.Exists(pathwav)) return; FileStream fs = new FileStream(pathafc, FileMode.Open, FileAccess.Read); byte[] Header = new byte[94]; fs.Seek(DataOffset, SeekOrigin.Begin); for (int i = 0; i < 94; i++) Header[i] = (byte)fs.ReadByte(); fs.Close(); fs = new FileStream(pathwav, FileMode.Open, FileAccess.Read); byte[] newfile = new byte[fs.Length]; for (int i = 0; i < fs.Length; i++) newfile[i] = (byte)fs.ReadByte(); fs.Close(); newfile = ModifyHeader(newfile, Header); fs = new FileStream(pathafc, FileMode.Append, FileAccess.Write, FileShare.Write); int newoff = (int)fs.Length; int newsize = newfile.Length; for (int i = 0; i < newsize; i++) fs.WriteByte(newfile[i]); uint newafcsize = (uint)fs.Length; fs.Close(); byte[] buff = BitConverter.GetBytes(newsize); for (int i = 0; i < 4; i++) memory[ValueOffset + i - 4] = buff[i]; for (int i = 0; i < 4; i++) memory[ValueOffset + i] = buff[i]; buff = BitConverter.GetBytes(newoff); for (int i = 0; i < 4; i++) memory[ValueOffset + i + 4] = buff[i]; DataSize = newsize; DataOffset = newoff; TOCeditor tc = new TOCeditor(); string s = Path.GetFileName(pathafc); if (updateTOC) if (!tc.UpdateFile("\\" + s, newafcsize, pathBIO + "PCConsoleTOC.bin")) MessageBox.Show("Didn't found Entry!"); }
public void ImportFromFile(int tfc) { OpenFileDialog Dialog = new OpenFileDialog(); if (T2D.PixelFormat == "PF_DXT1\0" || T2D.PixelFormat == "PF_DXT5\0") { Dialog.Filter = "DDS Files (*.dds)|*.dds"; } if (T2D.PixelFormat == "PF_G8\0" || T2D.PixelFormat == "PF_V8U8\0" || T2D.PixelFormat == "PF_A8R8G8B8\0") { Dialog.Filter = "TGA Files (*.tga)|*.tga"; } int format = -1; if (T2D.PixelFormat == "PF_DXT1\0") { format = 0; } if (T2D.PixelFormat == "PF_DXT5\0") { format = 1; } if (T2D.PixelFormat == "PF_V8U8\0") { format = 2; } if (T2D.PixelFormat == "PF_A8R8G8B8\0") { format = 3; } if (T2D.PixelFormat == "PF_G8\0") { format = 4; } if (!TextureTFCs[tfc].InCache) { if (Dialog.ShowDialog() == DialogResult.OK) { if (format == 0 || format == 1) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY && t.ImageFormat == format && t.memsize == TextureTFCs[tfc].size) { for (int i = 0; i < t.memsize; i++) { memory[TextureTFCs[tfc].offset + i] = t.memory[i]; } MessageBox.Show("Done."); } } if (format > 1 && format < 5) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) { if (t.ImageBits != 32) { MessageBox.Show("Please use 32 bit Targa image!"); } else { switch (format) { case 2: for (int i = 0; i < t.memsize / 4; i++) { memory[TextureTFCs[tfc].offset + i * 2] = t.memory[i * 4]; memory[TextureTFCs[tfc].offset + i * 2 + 1] = t.memory[i * 4 + 2]; } break; case 3: for (int i = 0; i < t.memsize; i++) { memory[TextureTFCs[tfc].offset + i] = t.memory[i]; } break; case 4: for (int i = 0; i < t.memsize / 4; i++) { memory[TextureTFCs[tfc].offset + i] = t.memory[i * 4]; } break; } MessageBox.Show("Done."); } } } } } else if (Dialog.ShowDialog() == DialogResult.OK) { ImageFile t = new ImageFile(); t.ImportFromFile(Dialog.FileName); if ((format == 0 || format == 1) && t.ImageFormat == format) { if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) { TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) { buff = ZBlock.Compress(t.memory); } else { buff = t.memory; } byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; } buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 16 + i] = buff2[i]; } TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) { MessageBox.Show("Didn't found Entry"); } tc.Close(); } } else { System.Windows.Forms.DialogResult m = MessageBox.Show("The size doesn't match, import anyway?", "ME3 Explorer", MessageBoxButtons.YesNo); if (m == DialogResult.Yes) { TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) { buff = ZBlock.Compress(t.memory); } else { buff = t.memory; } byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; } buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 16 + i] = buff2[i]; } if (tfc == 0) { buff2 = BitConverter.GetBytes(t.ImageSizeX); for (int i = 0; i < 4; i++) { memory[T2D.offSizeX + i] = buff2[i]; } buff2 = BitConverter.GetBytes(t.ImageSizeY); for (int i = 0; i < 4; i++) { memory[T2D.offSizeY + i] = buff2[i]; } } else { buff2 = BitConverter.GetBytes(t.ImageSizeX * 2); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + i] = buff2[i]; } buff2 = BitConverter.GetBytes(t.ImageSizeY * 2); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 4 + i] = buff2[i]; } TFCf.AppendToTFC(buff); } TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) { MessageBox.Show("Didn't found Entry"); } tc.Close(); } } } } if (format > 1 && format < 5) { if (t.ImageSizeX == TextureTFCs[tfc].sizeX && t.ImageSizeY == TextureTFCs[tfc].sizeY) { if (t.ImageBits != 32) { MessageBox.Show("Please use 32 bit Targa image!"); } else { byte[] buf = new byte[0]; switch (format) { case 2: buf = new byte[t.memsize / 2]; for (int i = 0; i < t.memsize / 4; i++) { buf[i * 2] = t.memory[i * 4]; buf[i * 2 + 1] = t.memory[i * 4 + 2]; } break; case 3: buf = t.memory; break; case 4: buf = new byte[t.memsize / 4]; for (int i = 0; i < t.memsize / 4; i++) { buf[i] = t.memory[i * 4]; } break; } TFCFile TFCf = new TFCFile(T2D.Tsource); byte[] buff; if (TFCf.isTFCCompressed()) { buff = ZBlock.Compress(t.memory); } else { buff = t.memory; } byte[] buff2 = BitConverter.GetBytes(TFCf.getFileSize()); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 20 + i] = buff2[i]; } buff2 = BitConverter.GetBytes(buff.Length); for (int i = 0; i < 4; i++) { memory[TextureTFCs[tfc].HeaderOffset + 12 + i] = buff2[i]; } TFCf.AppendToTFC(buff); int size = TFCf.getFileSize(); if (size != -1) { TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(T2D.Tsource + ".tfc", (uint)size)) { MessageBox.Show("Didn't found Entry"); } tc.Close(); } MessageBox.Show("Done."); } } } } }
public void CloneEntry(int entry) { byte[] buffdata; DialogResult r = MessageBox.Show("Clone with new data?", "", MessageBoxButtons.YesNo); if (r == DialogResult.No) { buffdata = EntryToBuff(entry); } else { OpenFileDialog d = new OpenFileDialog(); d.Filter = "bin files (*.bin)|*.bin|all files|*.*"; if (d.ShowDialog() == DialogResult.OK) { FileStream f = new FileStream(d.FileName, FileMode.Open, FileAccess.Read); int size = (int)f.Length; buffdata = new byte[size]; int count; int sum = 0; while ((count = f.Read(buffdata, sum, size - sum)) > 0) { sum += count; } } else { return; } } int sizebefore = memsize; MemoryStream m = new MemoryStream(); m.Write(memory, 0, (int)Header.offinfo + 8); byte[] buff = BitConverter.GetBytes(Header.ExportCount + 1); m.Write(buff, 0, 4); buff = BitConverter.GetBytes(sizebefore); m.Write(buff, 0, 4); m.Write(memory, (int)Header.offinfo + 16, sizebefore - ((int)Header.offinfo + 16)); for (int i = 0; i < Export.Length; i++) { uint len = Export[i].end - Export[i].start; m.Write(memory, (int)Export[i].start, (int)len); } int pos = (int)m.Length; uint len2 = Export[entry].end - Export[entry].start; m.Write(memory, (int)Export[entry].start, 32); buff = BitConverter.GetBytes(buffdata.Length); m.Write(buff, 0, 4); buff = BitConverter.GetBytes(pos + (int)len2); m.Write(buff, 0, 4); m.Write(memory, (int)Export[entry].start + 40, (int)len2 - 40); m.Write(buffdata, 0, buffdata.Length); Header.ExportCount++; Header.ExportOffset = (uint)sizebefore; exports ex = new exports(); ex.Class = Export[entry].Class; ex.DataOffset = (uint)pos + len2; ex.DataSize = (uint)buffdata.Length; ex.end = (uint)pos + len2; ex.Link = Export[entry].Link; ex.Name = Export[entry].Name; ex.off = Export[entry].off; ex.start = (uint)pos; exports[] t = new exports[Header.ExportCount]; for (int i = 0; i < Header.ExportCount - 1; i++) { t[i] = Export[i]; } t[Header.ExportCount - 1] = ex; Export = t; memory = m.ToArray(); TOCeditor tc = new TOCeditor(); if (!tc.UpdateFile(loadedFilename, (uint)memsize)) { MessageBox.Show("Didn't found Entry"); } }