/// <summary> /// Restaure le fichier d'origine depuis la sauvegarde spécifiée /// </summary> /// <param name="fileName">nom du fichier de sauvegarde</param> private bool _RestoreFile(string fileName) { bool isModified = false; string message; if (Regex.IsMatch(fileName, TduFile.BACKUP_FILENAME_PATTERN, RegexOptions.IgnoreCase)) { // Backup -> restauration string originalFileName = File2.ChangeExtensionOfFilename(fileName, null); message = string.Format(_QUESTION_RESTORE, originalFileName, fileName); DialogResult dr = MessageBoxes.ShowQuestion(this, message, MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { // Opération de restauration Tools.RestoreFile(fileName, originalFileName); isModified = true; } } else { // Pour les autres fichiers on interdit la restauration message = string.Format(_ERROR_NOT_A_BACKUP, fileName); MessageBoxes.ShowWarning(this, message); } return(isModified); }
/// <summary> /// Réalise la conversion multiple /// </summary> private void _MultipleConvert() { // Vérifications if (string.IsNullOrEmpty(sourceBNKTextBox.Text) || string.IsNullOrEmpty(targetFolderTextBox.Text)) { return; } Cursor = Cursors.WaitCursor; // Parcours des fichiers et extraction des 2DB BNK bnkFile = TduFile.GetFile(sourceBNKTextBox.Text) as BNK; if (bnkFile == null) { throw new Exception(_ERROR_INVALID_BNK_FILE); } Collection <string> textureFiles = bnkFile.GetPackedFilesPathsByExtension(LibraryConstants.EXTENSION_2DB_FILE); string tempFolder = File2.SetTemporaryFolder(null, LibraryConstants.FOLDER_TEMP, true); foreach (string anotherFilePath in textureFiles) { // 1.Extraction depuis le BNK vers le dossier temporaire bnkFile.ExtractPackedFile(anotherFilePath, tempFolder, true); // 2.Conversion des fichiers 2DB>DDS string fileName = tempFolder + @"\" + bnkFile.GetPackedFileName(anotherFilePath); FileInfo fi = new FileInfo(fileName); string newFileName = targetFolderTextBox.Text + @"\" + File2.ChangeExtensionOfFilename(fi.Name, LibraryConstants.EXTENSION_DDS_FILE); // If file already exists, it is renamed Tools.RenameIfNecessary(newFileName, LibraryConstants.SUFFIX_OLD_FILE); GraphicsConverters._2DBToDDS(fileName, newFileName); } // EVO 32 string message = string.Format(_STATUS_SUCCESS_MULTIPLE, textureFiles.Count); StatusBarLogManager.ShowEvent(this, message); // On efface le champ source sourceBNKTextBox.Text = ""; // Mise à jour de l'emplacement des 2DB _2DBLocationLink.Text = tempFolder; Cursor = Cursors.Default; }
/// <summary> /// Implémentation de l'édition /// </summary> public override void Edit() { if (!string.IsNullOrEmpty(FileName)) { // L'édition d'un fichier 2DB passe par une conversion en DDS string ddsFilename = File2.ChangeExtensionOfFilename(FileName, LibraryConstants.EXTENSION_DDS_FILE); // BUG_49: if DDS file already exists, then open it directly if (!File.Exists(ddsFilename)) { GraphicsConverters._2DBToDDS(FileName, ddsFilename); } // Lancement de l'éditeur par défaut __SystemRun(ddsFilename); } }
/// <summary> /// Returns name of file to be watched during editing /// </summary> /// <param name="fileName">Original file name</param> /// <returns>Name of file to be tracked (by default = original file name)</returns> public static string GetTrackedFileName(string fileName) { // BUG_48: added for accurate tracking support (e.g 2DB files) string resultFileName = null; if (!string.IsNullOrEmpty(fileName)) { // 2DB file processing is particular... if (Regex.IsMatch(fileName, _2DB.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { resultFileName = File2.ChangeExtensionOfFilename(fileName, LibraryConstants.EXTENSION_DDS_FILE); } else { resultFileName = fileName; } } return(resultFileName); }
/// <summary> /// Application des modifs. /// </summary> /// <param name="paramList">Paramètre booléen [0] maintainSize : true pour maintenir la taille, false sinon</param> public override void Apply(params object[] paramList) { if (!string.IsNullOrEmpty(FileName)) { // Si le fichier d'origine est un 2DB, le DDS doit être reconverti string ddsFileName = File2.ChangeExtensionOfFilename(FileName, LibraryConstants.EXTENSION_DDS_FILE); try { // Utilisation d'une copie pour l'en-tête string oldFileName = File2.ChangeExtensionOfFilename(FileName, LibraryConstants.EXTENSION_2DB_OLD_FILE); File.Copy(FileName, oldFileName, true); GraphicsConverters.DDSTo2DB(oldFileName, ddsFileName, FileName, GraphicsConverters.KEEP_ORIGINAL_TEXTURE_NAME, GraphicsConverters.KEEP_ORIGINAL_MIPMAP_COUNT); } catch (Exception ex) { string message = string.Format(_ERROR_APPLY, ddsFileName, FileName); throw new Exception(message, ex); } } }
/// <summary> /// Met à jour le champ cible selon le nom de fichier indiqué. /// (si ce champ est vide) /// </summary> /// <param name="fileName">nom de fichier</param> private void _SetChampCible(string fileName) { newDDSFilePath.Text = File2.ChangeExtensionOfFilename(fileName, LibraryConstants.EXTENSION_DDS_FILE); }