private void ActionAbstractShaderOpenRes(AbstractShader shader) { if (shader == null) { return; } FileImportProvider.OpenSourceFile(shader, shader is FragmentShader ? ".frag" : ".vert", shader.SaveSource); }
private void ActionAudioDataOpenRes(AudioData audio) { if (audio == null) { return; } FileImportProvider.OpenSourceFile(audio, ".ogg", audio.SaveOggVorbisData); }
private void ActionPixmapOpenRes(Pixmap pixmap) { if (pixmap == null) { return; } FileImportProvider.OpenSourceFile(pixmap, ".png", pixmap.SavePixelData); }
public override void Perform(Resource obj) { var lua = obj as LuaScript; if (lua != null) { FileImportProvider.OpenSourceFile(lua, LuaScript.RawFileExt, lua.SaveSource); } }
public override void Perform(Resource obj) { Pixmap pixmap = obj as Pixmap; AbstractShader shader = obj as AbstractShader; if (pixmap != null) { FileImportProvider.OpenSourceFile(pixmap, ".png", pixmap.SavePixelData); } else if (shader != null) { FileImportProvider.OpenSourceFile(shader, shader is FragmentShader ? ".frag" : shader is VertexShader ? ".vert" : ".geom", shader.SaveSource); } }
public override void Perform(Resource obj) { Pixmap pixmap = obj as Pixmap; AudioData audioData = obj as AudioData; AbstractShader shader = obj as AbstractShader; if (pixmap != null) { FileImportProvider.OpenSourceFile(pixmap, PixmapFileImporter.SourceFileExtPrimary, pixmap.SavePixelData); } else if (audioData != null) { FileImportProvider.OpenSourceFile(audioData, AudioDataFileImporter.SourceFileExtPrimary, audioData.SaveOggVorbisData); } else if (shader != null) { FileImportProvider.OpenSourceFile(shader, shader is FragmentShader ? ShaderFileImporter.SourceFileExtFragment : ShaderFileImporter.SourceFileExtVertex, shader.SaveSource); } }
public override void Perform(Resource obj) { Pixmap pixmap = obj as Pixmap; AudioData audioData = obj as AudioData; AbstractShader shader = obj as AbstractShader; if (pixmap != null) { FileImportProvider.OpenSourceFile(pixmap, ".png", pixmap.SavePixelData); } else if (audioData != null) { FileImportProvider.OpenSourceFile(audioData, ".ogg", audioData.SaveOggVorbisData); } else if (shader != null) { FileImportProvider.OpenSourceFile(shader, shader is FragmentShader ? ".frag" : ".vert", shader.SaveSource); } }
private static void mainForm_Activated(object sender, EventArgs e) { // Perform scheduled source file reimports if (reimportSchedule.Count > 0) { // Hacky: Wait a little for the files to be accessable again (Might be used by another process) System.Threading.Thread.Sleep(50); foreach (string file in reimportSchedule) { if (!File.Exists(file)) { continue; } FileImportProvider.ReimportFile(file); } reimportSchedule.Clear(); } }
private static void ProcessSourceDirEvents() { // Process events while (sourceDirEventBuffer.Count > 0) { FileSystemEventArgs e = FetchFileSystemEvent(sourceDirEventBuffer, sourceDirWatcher.Path); if (e == null) { continue; } if (e.ChangeType == WatcherChangeTypes.Changed) { if (File.Exists(e.FullPath) && PathHelper.IsPathLocatedIn(e.FullPath, EditorHelper.SourceMediaDirectory)) { reimportSchedule.Add(e.FullPath); } if (SrcFileModified != null) { SrcFileModified(null, e); } } else if (e.ChangeType == WatcherChangeTypes.Created) { } else if (e.ChangeType == WatcherChangeTypes.Deleted) { if (SrcFileDeleted != null) { SrcFileDeleted(null, e); } } else if (e.ChangeType == WatcherChangeTypes.Renamed) { RenamedEventArgs rename = e as RenamedEventArgs; FileImportProvider.NotifyFileRenamed(rename.OldFullPath, rename.FullPath); if (SrcFileRenamed != null) { SrcFileRenamed(null, e); } } } }
public override void Perform(Resource obj) { Pixmap pixmap = obj as Pixmap; AudioData audioData = obj as AudioData; AbstractShader shader = obj as AbstractShader; if (pixmap != null) { FileImportProvider.OpenSourceFile( pixmap, PixmapFileImporter.SourceFileExtPrimary, path => SavePixmapData(pixmap, path)); } else if (audioData != null) { FileImportProvider.OpenSourceFile( audioData, AudioDataFileImporter.SourceFileExtPrimary, path => SaveAudioData(audioData, path)); } else if (shader != null) { string fileExt; if (shader is FragmentShader) { fileExt = ShaderFileImporter.SourceFileExtFragment; } else { fileExt = ShaderFileImporter.SourceFileExtVertex; } FileImportProvider.OpenSourceFile( shader, fileExt, path => SaveShaderData(shader, path)); } }
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); }); } }