#region ================== Namespaces using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Text; using System.IO; using CodeImp.DoomBuilder.Editing; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Windows; using CodeImp.DoomBuilder.Config; #endregion namespace CodeImp.DoomBuilder.Plugins { /// /// This is the key link between the Doom Builder core and the plugin. /// Every plugin must expose a single class that inherits this class. /// public class Plug : IDisposable { #region ================== Constants #endregion #region ================== Variables // Internals private Plugin plugin; // Disposing private bool isdisposed = false; #endregion #region ================== Properties // Internals internal Plugin Plugin { get { return plugin; } set { plugin = value; } } /// /// Indicates if the plugin has been disposed. /// public bool IsDisposed { get { return isdisposed; } } /// /// Override this to return a more descriptive name for your plugin. /// Default is the library filename without extension. /// public virtual string Name { get { return plugin.Name; } } #endregion #region ================== Constructor / Disposer /// /// This is the key link between the Doom Builder core and the plugin. /// Every plugin must expose a single class that inherits this class. /// /// NOTE: Some methods cannot be used in this constructor, because the plugin /// is not yet fully initialized. Instead, use the Initialize method to do /// your initializations. /// /// public Plug() { // Initialize // We have no destructor GC.SuppressFinalize(this); } /// /// This is called by the Doom Builder core when the plugin is being disposed. /// public virtual void Dispose() { // Not already disposed? if(!isdisposed) { // Clean up plugin = null; // Done isdisposed = true; } } #endregion #region ================== Methods /// /// This finds the embedded resource with the specified name in the plugin and creates /// a Stream from it. Returns null when the embedded resource cannot be found. /// /// Name of the resource in the plugin. /// Returns a Stream of the embedded resource, /// or null when the resource cannot be found. public Stream GetResourceStream(string resourcename) { return plugin.GetResourceStream(resourcename); } #endregion #region ================== Events /// /// This iscalled when the ceiling surface buffer is updated for a sector. The plugin can /// modify the vertices to change how the surface is presented to the user. /// public virtual void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices) { } /// /// This iscalled when the floor surface buffer is updated for a sector. The plugin can /// modify the vertices to change how the surface is presented to the user. /// public virtual void OnSectorFloorSurfaceUpdate(Sector s, ref FlatVertex[] vertices) { } /// /// Occurs before a map is opened. /// public virtual void OnMapOpenBegin() { } /// /// Occurs after a map is opened. /// public virtual void OnMapOpenEnd() { } /// /// Occurs before a new map is created. /// public virtual void OnMapNewBegin() { } /// /// Occurs after a new map is created. /// public virtual void OnMapNewEnd() { } /// /// Occurs before the MapSet is changed. This means that the active MapSet will be disposed and changed to a new one. /// public virtual void OnMapSetChangeBegin() { } /// /// Occurs after the MapSet is changed. /// public virtual void OnMapSetChangeEnd() { } /// /// This is called after the constructor to allow a plugin to initialize. /// public virtual void OnInitialize() { } /// /// This is called when the user chose to reload the resources. /// public virtual void OnReloadResources() { } /// /// This is called by the Doom Builder core when the editing mode changes. /// Return false to abort the mode change. /// /// The previous editing mode /// The new editing mode public virtual bool OnModeChange(EditMode oldmode, EditMode newmode) { return true; } /// /// Called by the Doom Builder core when the user changes the program configuration (F5). /// public virtual void OnProgramReconfigure() { } /// /// Called by the Doom Builder core when the user changes the map settings (F2). /// public virtual void OnMapReconfigure() { } /// /// Called by the Doom Builder core when the user wants to copy selected geometry. /// Return false to abort the copy operation. /// The result parameter is false when the operation was already aborted by another plugin. /// public virtual bool OnCopyBegin(bool result) { return true; } /// /// Called by the Doom Builder core when the user has copied geometry. /// public virtual void OnCopyEnd() { } /// /// Called by the Doom Builder core when the user wants to paste geometry into the map. /// Return false to abort the paste operation. /// The result parameter is false when the operation was already aborted by another plugin. /// public virtual bool OnPasteBegin(PasteOptions options, bool result) { return true; } /// /// Called by the Doom Builder core when the user pastes geometry into the map. The new geometry is created and marked before this method is called. /// public virtual void OnPasteEnd(PasteOptions options) { } /// /// Called by the Doom Builder core when the user wants to undo the previous action. /// Return false to abort the operation. /// The result parameter is false when the operation was already aborted by another plugin. /// public virtual bool OnUndoBegin(bool result) { return true; } /// /// Called by the Doom Builder core when the user has undone the previous action. /// public virtual void OnUndoEnd() { } /// /// Called by the Doom Builder core when the user wants to redo the previously undone action. /// Return false to abort the operation. /// The result parameter is false when the operation was already aborted by another plugin. /// public virtual bool OnRedoBegin(bool result) { return true; } /// /// Called by the Doom Builder core when the user has redone the action. /// public virtual void OnRedoEnd() { } /// /// Called when the user opens the Preferences dialog. /// public virtual void OnShowPreferences(PreferencesController controller) { } /// /// Called when the user closes the Preferences dialog by either accepting the changes or cancelling. /// public virtual void OnClosePreferences(PreferencesController controller) { } #endregion } }