/// <summary> /// Create a shape instance /// </summary> /// <returns></returns> public override ShapeBase CreateShapeInstance() { // create a shape FmodSoundShape Sound = new FmodSoundShape("Fmod - Sound"); Sound.Position = EditorManager.Scene.CurrentShapeSpawnPosition; return(Sound); }
/// <summary> /// This function must be overridden, since we have to reset the hotspots /// </summary> /// <returns></returns> public override ShapeBase Clone() { FmodSoundShape copy = (FmodSoundShape)base.Clone(); System.Diagnostics.Debug.Assert(!copy.Selected); // turned off in ShapeBase copy._hotSpotVolume = null; copy._hotSpotFadeMin = null; copy._hotSpotFadeMax = null; copy._hotSpotPlaySound = null; copy._hotSpotOuterCone = null; copy._hotSpotInnerCone = null; return(copy); }
void MigrateSoundShapeProperties(ShapeObject3D oldShape, FmodSoundShape newShape) { MigrateBaseProperties(oldShape, newShape); // Sound specific newShape.Filename = (string)oldShape.GetType().GetProperty("Filename").GetValue(oldShape, null); newShape.Is3D = (bool)oldShape.GetType().GetProperty("Is3D").GetValue(oldShape, null); newShape.Streaming = (bool)oldShape.GetType().GetProperty("Streaming").GetValue(oldShape, null); newShape.Looped = (bool)oldShape.GetType().GetProperty("Looped").GetValue(oldShape, null); { PropertyInfo propInfo = oldShape.GetType().GetProperty("StartPaused"); if (propInfo != null) { newShape.StartPaused = (bool)propInfo.GetValue(oldShape, null); } } { PropertyInfo propInfo = oldShape.GetType().GetProperty("DisposeWhenFinished"); if (propInfo != null) { newShape.DisposeWhenFinished = (bool)propInfo.GetValue(oldShape, null); } } newShape.Volume = (float)oldShape.GetType().GetProperty("Volume").GetValue(oldShape, null); newShape.MinDistance = (float)oldShape.GetType().GetProperty("MinDistance").GetValue(oldShape, null); newShape.MaxDistance = (float)oldShape.GetType().GetProperty("MaxDistance").GetValue(oldShape, null); newShape.Pan = (float)oldShape.GetType().GetProperty("Pan").GetValue(oldShape, null); newShape.Priority = (int)oldShape.GetType().GetProperty("Priority").GetValue(oldShape, null); newShape.Directional = (bool)oldShape.GetType().GetProperty("Directional").GetValue(oldShape, null); newShape.ConeInside = (float)oldShape.GetType().GetProperty("ConeInside").GetValue(oldShape, null); newShape.ConeOutside = (float)oldShape.GetType().GetProperty("ConeOutside").GetValue(oldShape, null); { PropertyInfo propInfo = oldShape.GetType().GetProperty("BackgroundMusic"); if (propInfo != null) { newShape.BackgroundMusic = (bool)propInfo.GetValue(oldShape, null); } } }
public MigrateSoundLinksAction(ShapeObject3D oldShape, FmodSoundShape newShape) { _oldShape = oldShape; _newShape = newShape; }
/// <summary> /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin /// </summary> void MigrateToFmodShapes() { // If old Sound plugin is not loaded, don't do anything IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin"); if (soundPlugin == null || !soundPlugin.Initialized) return; // collect all sound specific shapes ShapeCollection soundShapes = new ShapeCollection(); foreach (Layer layer in EditorManager.Scene.Layers) if (layer.Modifiable && layer.Loaded) AddSoundShapesRecursive(soundShapes, layer.Root); if (soundShapes.Count == 0) return; // prompt a dialog DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res != DialogResult.Yes) return; ShapeCollection newShapes = new ShapeCollection(); int iConvertedCount = 0; if (soundShapes.Count > 0) { GroupAction actions = new GroupAction("Migrate Sound shapes"); foreach (ShapeObject3D oldShape in soundShapes) { ShapeObject3D newShape = null; if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape") { newShape = new FmodSoundShape(oldShape.ShapeName); MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape); actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false)); actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape)); actions.Add(new MigrateChildrenAction(oldShape, newShape)); actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape)); newShapes.Add(newShape); } else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape") { newShape = new FmodCollisionMeshShape(oldShape.ShapeName); MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape); actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false)); actions.Add(new MigrateChildrenAction(oldShape, newShape)); actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape)); newShapes.Add(newShape); } if (newShape == null) continue; iConvertedCount++; } // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion actions.Do(); } // ensure, that all migrated childs have valid engine instances foreach (ShapeBase shape in newShapes) foreach (ShapeBase child in shape.ChildCollection) child.ReCreateEngineInstance(true); EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information); }
void MigrateSoundShapeProperties(ShapeObject3D oldShape, FmodSoundShape newShape) { MigrateBaseProperties(oldShape, newShape); // Sound specific newShape.Filename = (string)oldShape.GetType().GetProperty("Filename").GetValue(oldShape, null); newShape.Is3D = (bool)oldShape.GetType().GetProperty("Is3D").GetValue(oldShape, null); newShape.Streaming = (bool)oldShape.GetType().GetProperty("Streaming").GetValue(oldShape, null); newShape.Looped = (bool)oldShape.GetType().GetProperty("Looped").GetValue(oldShape, null); { PropertyInfo propInfo = oldShape.GetType().GetProperty("StartPaused"); if (propInfo != null) newShape.StartPaused = (bool)propInfo.GetValue(oldShape, null); } { PropertyInfo propInfo = oldShape.GetType().GetProperty("DisposeWhenFinished"); if (propInfo != null) newShape.DisposeWhenFinished = (bool)propInfo.GetValue(oldShape, null); } newShape.Volume = (float)oldShape.GetType().GetProperty("Volume").GetValue(oldShape, null); newShape.MinDistance = (float)oldShape.GetType().GetProperty("MinDistance").GetValue(oldShape, null); newShape.MaxDistance = (float)oldShape.GetType().GetProperty("MaxDistance").GetValue(oldShape, null); newShape.Pan = (float)oldShape.GetType().GetProperty("Pan").GetValue(oldShape, null); newShape.Priority = (int)oldShape.GetType().GetProperty("Priority").GetValue(oldShape, null); newShape.Directional = (bool)oldShape.GetType().GetProperty("Directional").GetValue(oldShape, null); newShape.ConeInside = (float)oldShape.GetType().GetProperty("ConeInside").GetValue(oldShape, null); newShape.ConeOutside = (float)oldShape.GetType().GetProperty("ConeOutside").GetValue(oldShape, null); { PropertyInfo propInfo = oldShape.GetType().GetProperty("BackgroundMusic"); if (propInfo != null) newShape.BackgroundMusic = (bool)propInfo.GetValue(oldShape, null); } }
/// <summary> /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin /// </summary> void MigrateToFmodShapes() { // If old Sound plugin is not loaded, don't do anything IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin"); if (soundPlugin == null || !soundPlugin.Initialized) { return; } // collect all sound specific shapes ShapeCollection soundShapes = new ShapeCollection(); foreach (Layer layer in EditorManager.Scene.Layers) { if (layer.Modifiable && layer.Loaded) { AddSoundShapesRecursive(soundShapes, layer.Root); } } if (soundShapes.Count == 0) { return; } // prompt a dialog DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res != DialogResult.Yes) { return; } ShapeCollection newShapes = new ShapeCollection(); int iConvertedCount = 0; if (soundShapes.Count > 0) { GroupAction actions = new GroupAction("Migrate Sound shapes"); foreach (ShapeObject3D oldShape in soundShapes) { ShapeObject3D newShape = null; if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape") { newShape = new FmodSoundShape(oldShape.ShapeName); MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape); actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false)); actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape)); actions.Add(new MigrateChildrenAction(oldShape, newShape)); actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape)); newShapes.Add(newShape); } else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape") { newShape = new FmodCollisionMeshShape(oldShape.ShapeName); MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape); actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false)); actions.Add(new MigrateChildrenAction(oldShape, newShape)); actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape)); newShapes.Add(newShape); } if (newShape == null) { continue; } iConvertedCount++; } // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion actions.Do(); } // ensure, that all migrated childs have valid engine instances foreach (ShapeBase shape in newShapes) { foreach (ShapeBase child in shape.ChildCollection) { child.ReCreateEngineInstance(true); } } EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// Create a shape instance /// </summary> /// <returns></returns> public override ShapeBase CreateShapeInstance() { // create a shape FmodSoundShape Sound = new FmodSoundShape("Fmod - Sound"); Sound.Position = EditorManager.Scene.CurrentShapeSpawnPosition; return Sound; }