private void formatUpdateAll_Click(object sender, EventArgs e) { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog(this, EditorRes.GeneralRes.TaskFormatUpdateAll_Caption, EditorRes.GeneralRes.TaskFormatUpdateAll_Desc, this.async_ChangeDataFormat, null); taskDialog.ShowDialog(); }
private void formatXml_Click(object sender, EventArgs e) { if (Duality.Serialization.Formatter.DefaultMethod == Duality.Serialization.FormattingMethod.Xml) { return; } Duality.Serialization.Formatter.DefaultMethod = Duality.Serialization.FormattingMethod.Xml; this.UpdateToolbar(); ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog(this, EditorRes.GeneralRes.TaskChangeDataFormat_Caption, string.Format(EditorRes.GeneralRes.TaskChangeDataFormat_Desc, Duality.Serialization.Formatter.DefaultMethod.ToString()), this.async_ChangeDataFormat, null); taskDialog.ShowDialog(); }
private void batchActionRenameType_Click(object sender, EventArgs e) { FolderBrowserDialog folderDialog = new FolderBrowserDialog(); folderDialog.ShowNewFolderButton = false; folderDialog.SelectedPath = Path.GetFullPath(DualityApp.DataDirectory); folderDialog.Description = "Select a folder to process.."; if (folderDialog.ShowDialog(this) == DialogResult.OK) { RenameTypeDialog dialog = new RenameTypeDialog(this.GetAvailTypes()); if (dialog.ShowDialog(this) == DialogResult.OK) { int replaced = 0; ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( PluginRes.ResourceHackerRes.TaskBatchRenameType_Caption, string.Format(PluginRes.ResourceHackerRes.TaskBatchRenameType_Desc, dialog.SearchFor, dialog.ReplaceWith), this.async_PerformBatchAction, new BatchActionTaskData(folderDialog.SelectedPath, n => replaced += n.ReplaceTypeStrings(dialog.SearchFor, dialog.ReplaceWith))); taskDialog.MainThreadRequired = false; taskDialog.ShowDialog(); MessageBox.Show( string.Format(PluginRes.ResourceHackerRes.MessageBox_RenameType_Text, replaced, dialog.SearchFor, dialog.ReplaceWith), PluginRes.ResourceHackerRes.MessageBox_RenameType_Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private static void ProcessDataDirEvents() { List<ResourceRenamedEventArgs> renameEventBuffer = null; // Process events while (dataDirEventBuffer.Count > 0) { FileSystemEventArgs e = FetchFileSystemEvent(dataDirEventBuffer, dataDirWatcher.Path); if (e == null) continue; if (e.ChangeType == WatcherChangeTypes.Changed) { ResourceEventArgs args = new ResourceEventArgs(e.FullPath); bool justSaved = editorJustSavedRes.Contains(Path.GetFullPath(e.FullPath)); // Ignore stuff saved by the editor itself if (!justSaved && (Resource.IsResourceFile(e.FullPath) || args.IsDirectory)) { // Unregister outdated resources, if modified outside the editor if (!args.IsDirectory && ContentProvider.IsContentAvailable(args.Path)) { bool isCurrentScene = args.Content.Is<Scene>() && Scene.Current == args.Content.Res; if (isCurrentScene || DualityEditorApp.IsResourceUnsaved(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_ConfirmReloadResource_Text, e.FullPath), EditorRes.GeneralRes.Msg_ConfirmReloadResource_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { string curScenePath = Scene.CurrentPath; ContentProvider.RemoveContent(args.Path); if (isCurrentScene) Scene.Current = ContentProvider.RequestContent<Scene>(curScenePath).Res; } } else ContentProvider.RemoveContent(args.Path); } if (ResourceModified != null) ResourceModified(null, args); } } else if (e.ChangeType == WatcherChangeTypes.Created) { if (File.Exists(e.FullPath)) { // Register newly detected ressource file if (Resource.IsResourceFile(e.FullPath)) { if (ResourceCreated != null) ResourceCreated(null, new ResourceEventArgs(e.FullPath)); } // Import non-ressource file else { bool abort = false; if (FileImportProvider.IsImportFileExisting(e.FullPath)) { DialogResult result = MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_ImportConfirmOverwrite_Text, e.FullPath), EditorRes.GeneralRes.Msg_ImportConfirmOverwrite_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); abort = result == DialogResult.No; } if (!abort) { bool importedSuccessfully = FileImportProvider.ImportFile(e.FullPath); if (!importedSuccessfully) { MessageBox.Show( String.Format(EditorRes.GeneralRes.Msg_CantImport_Text, e.FullPath), EditorRes.GeneralRes.Msg_CantImport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } abort = !importedSuccessfully; } } } else if (Directory.Exists(e.FullPath)) { // Register newly detected ressource directory if (ResourceCreated != null) ResourceCreated(null, new ResourceEventArgs(e.FullPath)); } } else if (e.ChangeType == WatcherChangeTypes.Deleted) { // Is it a Resource file or just something else? ResourceEventArgs args = new ResourceEventArgs(e.FullPath); if (Resource.IsResourceFile(e.FullPath) || args.IsDirectory) { // Unregister no-more existing resources if (args.IsDirectory) ContentProvider.RemoveContentTree(args.Path); else ContentProvider.RemoveContent(args.Path); if (ResourceDeleted != null) ResourceDeleted(null, args); } } else if (e.ChangeType == WatcherChangeTypes.Renamed) { // Is it a Resource file or just something else? RenamedEventArgs re = e as RenamedEventArgs; ResourceRenamedEventArgs args = new ResourceRenamedEventArgs(re.FullPath, re.OldFullPath); if (Resource.IsResourceFile(e.FullPath) || args.IsDirectory) { // Rename content registerations if (args.IsDirectory) ContentProvider.RenameContentTree(args.OldPath, args.Path); else ContentProvider.RenameContent(args.OldPath, args.Path); // Query skipped paths bool isSkippedPath = false; if (BeginGlobalRename != null) { BeginGlobalRenameEventArgs beginGlobalRenameArgs = new BeginGlobalRenameEventArgs(args.Path, args.OldPath); BeginGlobalRename(null, beginGlobalRenameArgs); isSkippedPath = beginGlobalRenameArgs.Cancel; } if (!isSkippedPath) { // Buffer rename event to perform the global rename for all at once. if (renameEventBuffer == null) renameEventBuffer = new List<ResourceRenamedEventArgs>(); renameEventBuffer.Add(args); } if (ResourceRenamed != null) ResourceRenamed(null, args); } } } // If required, perform a global rename operation in all existing content if (renameEventBuffer != null) { // Don't do it now - schedule it for the main form event loop so we don't block here. DualityEditorApp.MainForm.BeginInvoke((Action)delegate() { ProcessingBigTaskDialog taskDialog = new ProcessingBigTaskDialog( EditorRes.GeneralRes.TaskRenameContentRefs_Caption, EditorRes.GeneralRes.TaskRenameContentRefs_Desc, async_RenameContentRefs, renameEventBuffer); taskDialog.ShowDialog(DualityEditorApp.MainForm); }); } }