private void exportToolStripMenuItem_Click(object sender, EventArgs e) { if (m_cacheFile == null) { return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Archive Dictonary file (*.tad)|*.tad"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { string tadPath = saveFileDialog.FileName; m_cacheFile.Export(tadPath); m_tadFile = new TADFile(tadPath); FilenameDatabase.MapFilenamesToTAD(m_tadFile); DescriptionDatabase.MapDescriptionToTAD(m_tadFile); if (System.Diagnostics.Debugger.IsAttached) { if (MessageBox.Show("Do you want to unpack the TAC file?", "Unpack TAC", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { tadDataTable1.SetTAD(m_tadFile); } } m_cacheFile = new CacheFile(m_tadFile); m_cacheFile.Unpack(); tadDataTable1.SetCache(m_cacheFile); } }
private void button_Merge_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Filename Database Dump (*.bin)|*.bin"; if (openFileDialog.ShowDialog() == DialogResult.OK) { if (!Helper.IsFileValid(openFileDialog.FileName)) { return; } List <FilenameDatabaseEntry> newEntries; using (FileStream stream = File.Open(openFileDialog.FileName, FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); newEntries = (List <FilenameDatabaseEntry>)formatter.Deserialize(stream); } LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(this); Thread thread = new Thread(delegate() { Merge(newEntries); }); loadingDialog.ShowDialog(thread); } FilenameDatabase.Save(); filenameDatabaseDataTable1.UpdateView(false); }
private void mapFilenamesToTADToolStripMenuItem_Click(object sender, EventArgs e) { if (m_cacheFile == null || m_tadFile == null) { return; } FilenameDatabase filenameDB = new FilenameDatabase(); LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(filenameDB); Thread thread = new Thread(delegate() { filenameDB.MapFilenamesToTADInstance(m_cacheFile); }); loadingDialog.ShowDialog(thread); DescriptionDatabase descDB = new DescriptionDatabase(); loadingDialog = new LoadingDialog(); loadingDialog.SetData(descDB); thread = new Thread(delegate() { descDB.MapDescriptionToTADInstance(m_tadFile); }); loadingDialog.ShowDialog(thread); tadDataTable1.SetCache(m_cacheFile); m_cacheFile.Write(m_cacheFile.Filename); }
private void button_Save_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Filename Database Dump (*.bin)|*.bin"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { FilenameDatabase.Save(saveFileDialog.FileName); } }
private void Merge(List <FilenameDatabaseEntry> entries) { DescriptionChanged(this, new DescriptionChangedArgs("Merging file with database...")); for (int i = 0; i < entries.Count; i++) { ProgressChanged(this, new ProgressChangedArgs(i, entries.Count)); FilenameDatabaseEntry entry = entries[i]; FilenameDatabase.Add(entry); } Finished(this, new FinishedArgs(true)); }
private void button_Load_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Filename Database Dump (*.bin)|*.bin"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FilenameDatabase.Load(openFileDialog.FileName); filenameDatabaseDataTable1.UpdateView(false); } }
public MainWindow() { InitializeComponent(); Text = Version.ApplicationTitle; FilenameDatabase.Load(); WulinshuRaymonfAPI.Read(); DescriptionDatabase.GenerateDatabase(); Helper.CheckUpdates(); }
private void Merge() { DescriptionChanged(this, new DescriptionChangedArgs("Merging with filename database...")); for (int i = 0; i < WulinshuRaymonfAPI.Entries.Count; i++) { ProgressChanged(this, new ProgressChangedArgs(i, WulinshuRaymonfAPI.Entries.Count)); WulinshuRaymonfAPIEntry entry = WulinshuRaymonfAPI.Entries[i]; FilenameDatabase.Add(entry.CreateDatabaseEntry()); } FilenameDatabase.Save(); Finished(this, new FinishedArgs(true)); }
/// <summary> /// Assigns the filenames to each TAD entry. /// </summary> /// <param name="raymonf">True for using raymonf's wulinshu database else the cached database is used which is faster.</param> public void AssignFileNames(bool raymonf = false) { if (raymonf) { foreach (TADEntry entry in Entries) { entry.FileName = Wulinshu.GetFilenameFromHash(entry.FirstHash); } } else { foreach (TADEntry entry in Entries) { entry.FileName = FilenameDatabase.GetFilename(entry.FirstHash, entry.SecondHash); } } }
private void button_Generate_Click(object sender, EventArgs e) { VistaFolderBrowserDialog folderDialog = new VistaFolderBrowserDialog(); if (folderDialog.ShowDialog() == DialogResult.OK) { FilenameCrawler crawler = new FilenameCrawler(); LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(crawler); Thread thread = new Thread(delegate() { crawler.GenerateFilenameDatabase(folderDialog.SelectedPath); }); loadingDialog.ShowDialog(thread); FilenameDatabase.Save(); filenameDatabaseDataTable1.UpdateView(false); } }
public void ConvertLegacy(string filename) { DataCollection dataCollection; using (FileStream reader = new FileStream(filename, FileMode.Open)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); dataCollection = (DataCollection)binaryFormatter.Deserialize(reader); } if (dataCollection == null) { return; } Filename = filename.Replace(".shdcache", ".cache"); TADFile = new TADFile(); TADFile.Filename = filename.Replace(".shdcache", ".tad"); TADFile.Header.FileCount = BitConverter.ToUInt32(dataCollection.Header.FileCount1, 0); TADFile.Header.HeaderChecksum = BitConverter.ToUInt32(dataCollection.Header.HeaderChecksum, 0); TADFile.Header.TacSize = BitConverter.ToUInt32(dataCollection.Header.TacSize, 0); TADFile.Header.UnixTimestamp = new DateTime(1970, 1, 1).AddSeconds(BitConverter.ToInt32(dataCollection.Header.UnixTimestamp, 0)); string fileDir = Path.GetDirectoryName(Filename); string dir = fileDir; if (dataCollection.Files.Count > 0) { dir = Path.GetDirectoryName(dataCollection.Files[0].Meta.FilePath); } Header.RelativeOutputFolder = "\\" + Helper.GetRelativePath(dir, fileDir); Header.RelativeTADPath = "\\" + Helper.GetRelativePath(TADFile.Filename, fileDir); Header.RelativeTACPath = "\\" + Helper.GetRelativePath(TADFile.Filename.Replace(".tad", ".tac"), fileDir); foreach (FileStructure file in dataCollection.Files) { TADFileEntry entry = new TADFileEntry(); entry.FileOffset = BitConverter.ToUInt32(file.FileStart, 0); entry.FileSize = BitConverter.ToUInt32(file.FileSize, 0); entry.RelativePath = Helper.GetRelativePath(file.Meta.FilePath, dir); entry.Index = file.Meta.Index; byte[] firstHash = new byte[4]; Array.Copy(file.Hash1, firstHash, 4); entry.FirstHash = BitConverter.ToUInt32(firstHash, 0); byte[] secondHash = new byte[4]; Array.Copy(file.Hash1, 4, secondHash, 0, 4); entry.SecondHash = BitConverter.ToUInt32(secondHash, 0); byte[] unknown = new byte[4]; Array.Copy(file.Hash2, 0, unknown, 0, 4); entry.Unknown = BitConverter.ToUInt32(unknown, 0); entry.MD5Checksum = file.Meta.MD5Hash; TADFile.FileEntries.Add(entry); } FilenameDatabase filenameDB = new FilenameDatabase(); LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(filenameDB); Thread thread = new Thread(delegate() { filenameDB.MapFilenamesToTADInstance(this); }); loadingDialog.ShowDialog(thread); DescriptionDatabase descDB = new DescriptionDatabase(); loadingDialog = new LoadingDialog(); loadingDialog.SetData(descDB); thread = new Thread(delegate() { descDB.MapDescriptionToTADInstance(TADFile); }); loadingDialog.ShowDialog(thread); Write(Filename); if (File.Exists(filename)) { File.Delete(filename); } }
private void button_Clear_Click(object sender, EventArgs e) { FilenameDatabase.Clear(); filenameDatabaseDataTable1.UpdateView(false); }
/// <summary> /// Unpacks all the files. /// </summary> /// <param name="verbose">True for outputing every filename.</param> /// <param name="raymonf">True for using raymonf's wulinshu database else the cached database is used which is faster.</param> /// <param name="folder">The output folder. When empty it will be extracted in a folder next to the TAD file.</param> public void Unpack(bool verbose = false, bool raymonf = false, string folder = "") { m_abort = false; if (String.IsNullOrEmpty(folder)) { folder = Path.GetDirectoryName(TAD.FilePath) + "\\_" + TAD.FileName + "_"; } if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } if (DescriptionChanged != null) { DescriptionChanged(this, new DescriptionChangedArgs("Unpacking tac...")); } int counter = 0; foreach (TADEntry entry in TAD.Entries) { if (m_abort) { break; } if (ProgressChanged != null) { ProgressChanged(this, new ProgressChangedArgs(counter, TAD.Entries.Count)); } if (raymonf) { entry.FileName = Wulinshu.GetFilenameFromHash(entry.FirstHash); } else { entry.FileName = FilenameDatabase.GetFilename(entry.FirstHash, entry.SecondHash); } if (verbose) { Console.WriteLine("[TAC/TAD] Offset: {1}, Size: {2} -> Filepath: {0}", entry.FileName, entry.FileOffset, entry.FileSize); } m_tacStream.Seek(entry.FileOffset, SeekOrigin.Begin); byte[] fileBuffer = new byte[entry.FileSize]; m_tacStream.Read(fileBuffer, 0, fileBuffer.Length); entry.FilePath = ""; if (String.IsNullOrEmpty(entry.FileName)) { entry.FilePath = String.Format("{0}\\{1}", folder, counter.ToString()); } else { entry.FilePath = entry.FileName.Replace('/', '\\'); entry.FilePath = folder + "\\" + entry.FilePath; string dir = Path.GetDirectoryName(entry.FilePath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } using (FileStream entryStream = File.Create(entry.FilePath)) { entryStream.Write(fileBuffer, 0, fileBuffer.Length); } counter++; } if (ProgressChanged != null) { Finished(this, new FinishedArgs(true)); } }