mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-12-18 08:01:36 +00:00
5cb573d938
Enhanced scripting workflow. Thing and linedef arguments can now have default value in configuration files. Fixed laggy visual camera movement on systems with big uptime. Fixed incorrect alignment of Things with "hangs" flag in GZDoom Visual mode. Fixed Editor crash when nodebuilder fails to build map. A window with error description will be shown instead. Doom light levels were used even in maps in non-doom map format. Tag Explorer plugin: Elements list wasn't updated when map element was deleted. Pugin wasn't disposed properly, which may led to Doom Builder 2 crash on map close. Fixed plugin crash after opening another map. Fixed unresponsive text entry in Filter text box. Fixed plugin crash when Doom Builder can't determmine thing category ("UNKNOWN" category will be used instead).
354 lines
12 KiB
C#
354 lines
12 KiB
C#
#region ================== Namespaces
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using CodeImp.DoomBuilder.Editing;
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
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
|
|
{
|
|
/// <summary>
|
|
/// This is the key link between the Doom Builder core and the plugin.
|
|
/// Every plugin must expose a single class that inherits this class.
|
|
/// </summary>
|
|
public class Plug : IDisposable
|
|
{
|
|
#region ================== Constants
|
|
|
|
#endregion
|
|
|
|
#region ================== Variables
|
|
|
|
// Internals
|
|
private Plugin plugin;
|
|
|
|
// Disposing
|
|
private bool isdisposed = false;
|
|
|
|
//mxd. It's nice to have these avaliable to plugins...
|
|
protected static Point DisplayLocationAbs {
|
|
get {
|
|
if (General.MainWindow == null || General.MainWindow.Display == null)
|
|
return new Point();
|
|
return new Point(General.MainWindow.Location.X + General.MainWindow.ClientRectangle.X + General.MainWindow.Display.Location.X, General.MainWindow.Location.Y + General.MainWindow.ClientRectangle.Y + General.MainWindow.Display.Location.Y);
|
|
}
|
|
}
|
|
|
|
//mxd. It's nice to have these avaliable to plugins...
|
|
protected static Size DisplaySize { get { return (General.MainWindow == null || General.MainWindow.Display == null) ? new Size() : General.MainWindow.Display.Size; } }
|
|
|
|
#endregion
|
|
|
|
#region ================== Properties
|
|
|
|
// Internals
|
|
internal Plugin Plugin { get { return plugin; } set { plugin = value; } }
|
|
|
|
/// <summary>
|
|
/// Indicates if the plugin has been disposed.
|
|
/// </summary>
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
/// <summary>
|
|
/// Override this to return a more descriptive name for your plugin.
|
|
/// Default is the library filename without extension.
|
|
/// </summary>
|
|
public virtual string Name { get { return plugin.Name; } }
|
|
|
|
/// <summary>
|
|
/// Override this to return the minimum revision of the Doom Builder 2 core that is
|
|
/// required to use this plugin. You can find the revision number in the About dialog,
|
|
/// it is the right most part of the version number.
|
|
/// </summary>
|
|
public virtual int MinimumRevision { get { return 0; } }
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
/// <summary>
|
|
/// This is the key link between the Doom Builder core and the plugin.
|
|
/// Every plugin must expose a single class that inherits this class.
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </summary>
|
|
public Plug()
|
|
{
|
|
// Initialize
|
|
|
|
// We have no destructor
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// This is called by the Doom Builder core when the plugin is being disposed.
|
|
/// </summary>
|
|
public virtual void Dispose()
|
|
{
|
|
// Not already disposed?
|
|
if(!isdisposed)
|
|
{
|
|
// Clean up
|
|
plugin = null;
|
|
|
|
// Done
|
|
isdisposed = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Methods
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
/// <param name="resourcename">Name of the resource in the plugin.</param>
|
|
/// <returns>Returns a Stream of the embedded resource,
|
|
/// or null when the resource cannot be found.</returns>
|
|
public Stream GetResourceStream(string resourcename)
|
|
{
|
|
return plugin.GetResourceStream(resourcename);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Events
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices) { }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual void OnSectorFloorSurfaceUpdate(Sector s, ref FlatVertex[] vertices) { }
|
|
|
|
/// <summary>
|
|
/// Occurs before a map is opened.
|
|
/// </summary>
|
|
public virtual void OnMapOpenBegin() { }
|
|
|
|
/// <summary>
|
|
/// Occurs after a map is opened.
|
|
/// </summary>
|
|
public virtual void OnMapOpenEnd() { }
|
|
|
|
/// <summary>
|
|
/// Occurs before a new map is created.
|
|
/// </summary>
|
|
public virtual void OnMapNewBegin() { }
|
|
|
|
/// <summary>
|
|
/// Occurs after a new map is created.
|
|
/// </summary>
|
|
public virtual void OnMapNewEnd() { }
|
|
|
|
/// <summary>
|
|
/// Occurs before the map is closed.
|
|
/// </summary>
|
|
public virtual void OnMapCloseBegin() { }
|
|
|
|
/// <summary>
|
|
/// Occurs after a the map is closed.
|
|
/// </summary>
|
|
public virtual void OnMapCloseEnd() { }
|
|
|
|
/// <summary>
|
|
/// Occurs before a map is saved.
|
|
/// </summary>
|
|
public virtual void OnMapSaveBegin(SavePurpose purpose) { }
|
|
|
|
/// <summary>
|
|
/// Occurs after a map is saved.
|
|
/// </summary>
|
|
public virtual void OnMapSaveEnd(SavePurpose purpose) { }
|
|
|
|
//mxd
|
|
/// <summary>
|
|
/// Occurs before test map is launched. Return false if map launch is not desired.
|
|
/// </summary>
|
|
//public virtual bool OnMapTestBegin() { return true; }
|
|
|
|
//mxd
|
|
/// <summary>
|
|
/// Occurs after game engine is closed.
|
|
/// </summary>
|
|
//public virtual void OnMapTestEnd() { }
|
|
|
|
/// <summary>
|
|
/// Occurs before the MapSet is changed. This means that the active MapSet will be disposed and changed to a new one.
|
|
/// </summary>
|
|
public virtual void OnMapSetChangeBegin() { }
|
|
|
|
/// <summary>
|
|
/// Occurs after the MapSet is changed.
|
|
/// </summary>
|
|
public virtual void OnMapSetChangeEnd() { }
|
|
|
|
/// <summary>
|
|
/// This is called after the constructor to allow a plugin to initialize.
|
|
/// </summary>
|
|
public virtual void OnInitialize() { }
|
|
|
|
/// <summary>
|
|
/// This is called when the user chose to reload the resources.
|
|
/// </summary>
|
|
public virtual void OnReloadResources() { }
|
|
|
|
/// <summary>
|
|
/// This is called by the Doom Builder core when the editing mode changes.
|
|
/// Return false to abort the mode change.
|
|
/// </summary>
|
|
/// <param name="oldmode">The previous editing mode</param>
|
|
/// <param name="newmode">The new editing mode</param>
|
|
public virtual bool OnModeChange(EditMode oldmode, EditMode newmode) { return true; }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when the user changes the program configuration (F5).
|
|
/// </summary>
|
|
public virtual void OnProgramReconfigure() { }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when the user changes the map settings (F2).
|
|
/// </summary>
|
|
public virtual void OnMapReconfigure() { }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual bool OnCopyBegin(bool result) { return true; }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when the user has copied geometry.
|
|
/// </summary>
|
|
public virtual void OnCopyEnd() { }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual bool OnPasteBegin(PasteOptions options, bool result) { return true; }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual void OnPasteEnd(PasteOptions options) { }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual bool OnUndoBegin(bool result) { return true; }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when the user has undone the previous action.
|
|
/// </summary>
|
|
public virtual void OnUndoEnd() { }
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public virtual bool OnRedoBegin(bool result) { return true; }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when the user has redone the action.
|
|
/// </summary>
|
|
public virtual void OnRedoEnd() { }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when a new undo level has been created.
|
|
/// </summary>
|
|
public virtual void OnUndoCreated() { }
|
|
|
|
/// <summary>
|
|
/// Called by the Doom Builder core when an undo level has been withdrawn.
|
|
/// </summary>
|
|
public virtual void OnUndoWithdrawn() { }
|
|
|
|
/// <summary>
|
|
/// Called when the user opens the Preferences dialog.
|
|
/// </summary>
|
|
public virtual void OnShowPreferences(PreferencesController controller) { }
|
|
|
|
/// <summary>
|
|
/// Called when the user closes the Preferences dialog by either accepting the changes or cancelling.
|
|
/// </summary>
|
|
public virtual void OnClosePreferences(PreferencesController controller) { }
|
|
|
|
/// <summary>
|
|
/// Called when an Action begins.
|
|
/// </summary>
|
|
public virtual void OnActionBegin(CodeImp.DoomBuilder.Actions.Action action) { }
|
|
|
|
/// <summary>
|
|
/// Called when an Action ends.
|
|
/// </summary>
|
|
public virtual void OnActionEnd(CodeImp.DoomBuilder.Actions.Action action) { }
|
|
|
|
/// <summary>
|
|
/// Called when an Editing Mode engages
|
|
/// </summary>
|
|
public virtual void OnEditEngage(EditMode oldmode, EditMode newmode) { }
|
|
|
|
/// <summary>
|
|
/// Called when an Editing Mode disengages
|
|
/// </summary>
|
|
public virtual void OnEditDisengage(EditMode oldmode, EditMode newmode) { }
|
|
|
|
/// <summary>
|
|
/// Called when an Editing Mode is cancelled
|
|
/// </summary>
|
|
public virtual void OnEditCancel() { }
|
|
|
|
/// <summary>
|
|
/// Called when an Editing Mode is accepted
|
|
/// </summary>
|
|
public virtual void OnEditAccept() { }
|
|
|
|
// Interface events
|
|
public virtual void OnEditMouseClick(MouseEventArgs e) { }
|
|
public virtual void OnEditMouseDoubleClick(MouseEventArgs e) { }
|
|
public virtual void OnEditMouseDown(MouseEventArgs e) { }
|
|
public virtual void OnEditMouseEnter(EventArgs e) { }
|
|
public virtual void OnEditMouseLeave(EventArgs e) { }
|
|
public virtual void OnEditMouseMove(MouseEventArgs e) { }
|
|
public virtual void OnEditMouseUp(MouseEventArgs e) { }
|
|
public virtual void OnEditKeyDown(KeyEventArgs e) { }
|
|
public virtual void OnEditKeyUp(KeyEventArgs e) { }
|
|
public virtual void OnEditMouseInput(Vector2D delta) { }
|
|
|
|
// Rendering events
|
|
public virtual void OnEditRedrawDisplayBegin() { }
|
|
public virtual void OnEditRedrawDisplayEnd() { }
|
|
public virtual void OnPresentDisplayBegin() { }
|
|
|
|
#endregion
|
|
}
|
|
}
|