2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections.Generic ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using System.Drawing ;
2009-04-19 18:07:22 +00:00
using System.IO ;
using System.Reflection ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using System.Runtime.InteropServices ;
using System.Windows.Forms ;
using CodeImp.DoomBuilder.Actions ;
using CodeImp.DoomBuilder.BuilderModes.Interface ;
using CodeImp.DoomBuilder.BuilderModes.IO ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Config ;
2009-07-22 15:16:28 +00:00
using CodeImp.DoomBuilder.Controls ;
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
using CodeImp.DoomBuilder.Data ;
using CodeImp.DoomBuilder.Editing ;
using CodeImp.DoomBuilder.Geometry ;
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Plugins ;
using CodeImp.DoomBuilder.Rendering ;
using CodeImp.DoomBuilder.Types ;
using CodeImp.DoomBuilder.Windows ;
2018-04-14 22:59:58 +00:00
using System.Runtime.CompilerServices ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
public class BuilderPlug : Plug
{
2009-07-23 05:09:53 +00:00
#region = = = = = = = = = = = = = = = = = = API Declarations
[DllImport("user32.dll")]
internal static extern int GetWindowLong ( IntPtr hWnd , int nIndex ) ;
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Constants
2009-07-23 05:09:53 +00:00
internal const int WS_HSCROLL = 0x100000 ;
internal const int WS_VSCROLL = 0x200000 ;
internal const int GWL_STYLE = - 16 ;
2009-04-19 18:07:22 +00:00
#endregion
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
#region = = = = = = = = = = = = = = = = = = Structs ( mxd )
public struct MakeDoorSettings
{
public readonly string DoorTexture ;
public readonly string TrackTexture ;
public readonly string CeilingTexture ;
public readonly bool ResetOffsets ;
2017-04-03 08:20:40 +00:00
public readonly bool ApplyActionSpecials ;
public readonly bool ApplyTag ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
2017-04-03 08:20:40 +00:00
public MakeDoorSettings ( string doortexture , string tracktexture , string ceilingtexture , bool resetoffsets , bool applyactionspecials , bool applytag )
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
{
DoorTexture = doortexture ;
TrackTexture = tracktexture ;
CeilingTexture = ceilingtexture ;
ResetOffsets = resetoffsets ;
2017-04-03 08:20:40 +00:00
ApplyActionSpecials = applyactionspecials ;
ApplyTag = applytag ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
}
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Variables
2009-07-23 05:09:53 +00:00
2009-04-19 18:07:22 +00:00
// Static instance
private static BuilderPlug me ;
// Main objects
private MenusForm menusform ;
private FindReplaceForm findreplaceform ;
private ErrorCheckForm errorcheckform ;
private PreferencesForm preferencesform ;
2009-07-22 15:16:28 +00:00
// Dockers
private UndoRedoPanel undoredopanel ;
private Docker undoredodocker ;
2013-11-21 10:53:11 +00:00
private SectorDrawingOptionsPanel drawingOverridesPanel ; //mxd
private Docker drawingOverridesDocker ; //mxd
2009-07-22 15:16:28 +00:00
2009-04-19 18:07:22 +00:00
// Settings
private int showvisualthings ; // 0 = none, 1 = sprite only, 2 = sprite caged
private bool usegravity ;
private int changeheightbysidedef ; // 0 = nothing, 1 = change ceiling, 2 = change floor
private bool editnewthing ;
private bool editnewsector ;
private bool additiveselect ;
2019-06-20 13:38:41 +00:00
private bool additivepaintselect ;
2009-07-07 11:29:56 +00:00
private bool autoclearselection ;
private bool visualmodeclearselection ;
2009-04-19 18:07:22 +00:00
private string copiedtexture ;
private string copiedflat ;
private Point copiedoffsets ;
2010-08-15 13:45:43 +00:00
private VertexProperties copiedvertexprops ;
2009-04-19 18:07:22 +00:00
private SectorProperties copiedsectorprops ;
private SidedefProperties copiedsidedefprops ;
2010-08-15 13:45:43 +00:00
private LinedefProperties copiedlinedefprops ;
2009-04-19 18:07:22 +00:00
private ThingProperties copiedthingprops ;
private bool viewselectionnumbers ;
2013-09-16 11:44:47 +00:00
private bool viewselectioneffects ; //mxd
2009-05-20 15:03:08 +00:00
private float stitchrange ;
private float highlightrange ;
private float highlightthingsrange ;
private float splitlinedefsrange ;
2017-08-24 13:24:03 +00:00
private float mouseselectionthreshold ;
2009-07-12 11:14:34 +00:00
private bool autodragonpaste ;
2013-03-18 13:52:27 +00:00
private bool autoAlignTextureOffsetsOnCreate ; //mxd
private bool dontMoveGeometryOutsideMapBoundary ; //mxd
2013-12-05 09:24:55 +00:00
private bool autoDrawOnEdit ; //mxd
2013-03-18 13:52:27 +00:00
private bool marqueSelectTouching ; //mxd. Select elements partially/fully inside of marque selection?
private bool syncSelection ; //mxd. Sync selection between Visual and Classic modes.
2013-04-11 09:27:16 +00:00
private bool lockSectorTextureOffsetsWhileDragging ; //mxd
2020-05-03 15:25:07 +00:00
private bool lock3DFloorSectorTextureOffsetsWhileDragging ;
2015-11-03 08:54:56 +00:00
private bool syncthingedit ; //mxd
2016-06-13 23:37:55 +00:00
private bool alphabasedtexturehighlighting ; //mxd
2016-10-03 11:42:12 +00:00
private bool showlightradii ; //mxd
private bool showsoundradii ; //mxd
2020-04-04 16:03:40 +00:00
private int scaletexturesonslopes ; // 0 = base scale of 1, 1 = use current scale as base, 2 = don't scale
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
2019-12-24 07:12:45 +00:00
public override string Name { get { return "Ultimate Doom Builder" ; } } //mxd
2009-04-19 18:07:22 +00:00
public static BuilderPlug Me { get { return me ; } }
2010-08-12 18:42:52 +00:00
2016-01-20 17:54:56 +00:00
//mxd. BuilderModes.dll revision should always match the main module revision
public override bool StrictRevisionMatching { get { return true ; } }
2010-08-12 18:42:52 +00:00
public override int MinimumRevision { get { return Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . Revision ; } }
2009-04-19 18:07:22 +00:00
public MenusForm MenusForm { get { return menusform ; } }
2014-03-05 09:21:28 +00:00
public FindReplaceForm FindReplaceForm { get { return findreplaceform ? ? ( findreplaceform = new FindReplaceForm ( ) ) ; } }
public ErrorCheckForm ErrorCheckForm { get { return errorcheckform ? ? ( errorcheckform = new ErrorCheckForm ( ) ) ; } }
2009-04-19 18:07:22 +00:00
public PreferencesForm PreferencesForm { get { return preferencesform ; } }
// Settings
public int ShowVisualThings { get { return showvisualthings ; } set { showvisualthings = value ; } }
public bool UseGravity { get { return usegravity ; } set { usegravity = value ; } }
public int ChangeHeightBySidedef { get { return changeheightbysidedef ; } }
public bool EditNewThing { get { return editnewthing ; } }
public bool EditNewSector { get { return editnewsector ; } }
public bool AdditiveSelect { get { return additiveselect ; } }
2019-06-20 13:38:41 +00:00
public bool AdditivePaintSelect { get { return additivepaintselect ; } }
2009-07-07 11:29:56 +00:00
public bool AutoClearSelection { get { return autoclearselection ; } }
public bool VisualModeClearSelection { get { return visualmodeclearselection ; } }
2009-04-19 18:07:22 +00:00
public string CopiedTexture { get { return copiedtexture ; } set { copiedtexture = value ; } }
public string CopiedFlat { get { return copiedflat ; } set { copiedflat = value ; } }
public Point CopiedOffsets { get { return copiedoffsets ; } set { copiedoffsets = value ; } }
2010-08-15 13:45:43 +00:00
public VertexProperties CopiedVertexProps { get { return copiedvertexprops ; } set { copiedvertexprops = value ; } }
2009-04-19 18:07:22 +00:00
public SectorProperties CopiedSectorProps { get { return copiedsectorprops ; } set { copiedsectorprops = value ; } }
public SidedefProperties CopiedSidedefProps { get { return copiedsidedefprops ; } set { copiedsidedefprops = value ; } }
2010-08-15 13:45:43 +00:00
public LinedefProperties CopiedLinedefProps { get { return copiedlinedefprops ; } set { copiedlinedefprops = value ; } }
2009-04-19 18:07:22 +00:00
public ThingProperties CopiedThingProps { get { return copiedthingprops ; } set { copiedthingprops = value ; } }
public bool ViewSelectionNumbers { get { return viewselectionnumbers ; } set { viewselectionnumbers = value ; } }
2013-09-16 11:44:47 +00:00
public bool ViewSelectionEffects { get { return viewselectioneffects ; } set { viewselectioneffects = value ; } } //mxd
2013-09-11 09:47:53 +00:00
public float StitchRange { get { return stitchrange ; } internal set { stitchrange = value ; } }
2009-05-20 15:03:08 +00:00
public float HighlightRange { get { return highlightrange ; } }
public float HighlightThingsRange { get { return highlightthingsrange ; } }
public float SplitLinedefsRange { get { return splitlinedefsrange ; } }
2017-08-24 13:24:03 +00:00
public float MouseSelectionThreshold { get { return mouseselectionthreshold ; } }
2009-07-12 11:14:34 +00:00
public bool AutoDragOnPaste { get { return autodragonpaste ; } set { autodragonpaste = value ; } }
2013-12-05 09:24:55 +00:00
public bool AutoDrawOnEdit { get { return autoDrawOnEdit ; } set { autoDrawOnEdit = value ; } } //mxd
2013-03-18 13:52:27 +00:00
public bool AutoAlignTextureOffsetsOnCreate { get { return autoAlignTextureOffsetsOnCreate ; } set { autoAlignTextureOffsetsOnCreate = value ; } } //mxd
public bool DontMoveGeometryOutsideMapBoundary { get { return dontMoveGeometryOutsideMapBoundary ; } set { DontMoveGeometryOutsideMapBoundary = value ; } } //mxd
public bool MarqueSelectTouching { get { return marqueSelectTouching ; } set { marqueSelectTouching = value ; } } //mxd
public bool SyncSelection { get { return syncSelection ; } set { syncSelection = value ; } } //mxd
2013-04-11 09:27:16 +00:00
public bool LockSectorTextureOffsetsWhileDragging { get { return lockSectorTextureOffsetsWhileDragging ; } internal set { lockSectorTextureOffsetsWhileDragging = value ; } } //mxd
2020-05-03 15:25:07 +00:00
public bool Lock3DFloorSectorTextureOffsetsWhileDragging { get { return lock3DFloorSectorTextureOffsetsWhileDragging ; } internal set { lock3DFloorSectorTextureOffsetsWhileDragging = value ; } } //mxd
2015-11-03 08:54:56 +00:00
public bool SyncronizeThingEdit { get { return syncthingedit ; } internal set { syncthingedit = value ; } } //mxd
2016-06-13 23:37:55 +00:00
public bool AlphaBasedTextureHighlighting { get { return alphabasedtexturehighlighting ; } internal set { alphabasedtexturehighlighting = value ; } } //mxd
2016-10-03 11:42:12 +00:00
public bool ShowLightRadii { get { return showlightradii ; } internal set { showlightradii = value ; } } //mxd
public bool ShowSoundRadii { get { return showsoundradii ; } internal set { showsoundradii = value ; } } //mxd
2020-04-04 16:03:40 +00:00
public int ScaleTexturesOnSlopes { get { return scaletexturesonslopes ; } internal set { scaletexturesonslopes = value ; } }
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
//mxd. "Make Door" action persistent settings
internal MakeDoorSettings MakeDoor ;
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Initialize / Dispose
// When plugin is initialized
public override void OnInitialize ( )
{
// Setup
me = this ;
// Settings
showvisualthings = 2 ;
usegravity = false ;
LoadSettings ( ) ;
2015-09-12 21:05:01 +00:00
LoadUISettings ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Load menus form and register it
menusform = new MenusForm ( ) ;
menusform . Register ( ) ;
2013-04-11 09:27:16 +00:00
menusform . TextureOffsetLock . Checked = lockSectorTextureOffsetsWhileDragging ; //mxd
2020-05-03 15:25:07 +00:00
menusform . TextureOffset3DFloorLock . Checked = lock3DFloorSectorTextureOffsetsWhileDragging ;
2015-11-03 08:54:56 +00:00
menusform . SyncronizeThingEditButton . Checked = syncthingedit ; //mxd
menusform . SyncronizeThingEditSectorsItem . Checked = syncthingedit ; //mxd
menusform . SyncronizeThingEditLinedefsItem . Checked = syncthingedit ; //mxd
2016-10-03 11:42:12 +00:00
menusform . ItemLightRadii . Checked = showlightradii ;
menusform . ButtonLightRadii . Checked = showlightradii ;
menusform . ItemSoundRadii . Checked = showsoundradii ;
menusform . ButtonSoundRadii . Checked = showsoundradii ;
2009-07-22 15:16:28 +00:00
// Load Undo\Redo docker
undoredopanel = new UndoRedoPanel ( ) ;
undoredodocker = new Docker ( "undoredo" , "Undo / Redo" , undoredopanel ) ;
General . Interface . AddDocker ( undoredodocker ) ;
2013-03-18 13:52:27 +00:00
2014-09-17 12:46:47 +00:00
//mxd. Create Overrides docker
drawingOverridesPanel = new SectorDrawingOptionsPanel ( ) ;
drawingOverridesDocker = new Docker ( "drawingoverrides" , "Draw Settings" , drawingOverridesPanel ) ;
2013-03-18 13:52:27 +00:00
//mxd
General . Actions . BindMethods ( this ) ;
2009-04-19 18:07:22 +00:00
}
// Disposer
public override void Dispose ( )
{
// Not already disposed?
if ( ! IsDisposed )
{
// Clean up
2009-07-22 15:16:28 +00:00
General . Interface . RemoveDocker ( undoredodocker ) ;
2012-06-28 20:27:48 +00:00
2009-07-22 15:16:28 +00:00
undoredopanel . Dispose ( ) ;
2014-09-17 12:46:47 +00:00
drawingOverridesPanel . Dispose ( ) ; //mxd
2009-04-19 18:07:22 +00:00
menusform . Unregister ( ) ;
menusform . Dispose ( ) ;
menusform = null ;
2015-10-09 21:57:32 +00:00
//mxd. These are created on demand, so they may be nulls.
if ( findreplaceform ! = null )
{
findreplaceform . Dispose ( ) ;
findreplaceform = null ;
}
if ( errorcheckform ! = null )
{
errorcheckform . Dispose ( ) ;
errorcheckform = null ;
}
2009-04-19 18:07:22 +00:00
// Done
me = null ;
base . Dispose ( ) ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
// This loads the plugin settings
private void LoadSettings ( )
{
changeheightbysidedef = General . Settings . ReadPluginSetting ( "changeheightbysidedef" , 0 ) ;
editnewthing = General . Settings . ReadPluginSetting ( "editnewthing" , true ) ;
editnewsector = General . Settings . ReadPluginSetting ( "editnewsector" , false ) ;
additiveselect = General . Settings . ReadPluginSetting ( "additiveselect" , false ) ;
2019-06-20 13:38:41 +00:00
additivepaintselect = General . Settings . ReadPluginSetting ( "additivepaintselect" , additiveselect ) ; // use the same value as additiveselect by default
2009-07-07 20:59:56 +00:00
autoclearselection = General . Settings . ReadPluginSetting ( "autoclearselection" , false ) ;
2009-07-07 11:29:56 +00:00
visualmodeclearselection = General . Settings . ReadPluginSetting ( "visualmodeclearselection" , false ) ;
2013-09-11 08:49:45 +00:00
stitchrange = General . Settings . ReadPluginSetting ( "stitchrange" , 20 ) ;
highlightrange = General . Settings . ReadPluginSetting ( "highlightrange" , 20 ) ;
highlightthingsrange = General . Settings . ReadPluginSetting ( "highlightthingsrange" , 10 ) ;
splitlinedefsrange = General . Settings . ReadPluginSetting ( "splitlinedefsrange" , 10 ) ;
2017-08-24 13:24:03 +00:00
mouseselectionthreshold = General . Settings . ReadPluginSetting ( "mouseselectionthreshold" , 2 ) ;
2009-07-12 11:14:34 +00:00
autodragonpaste = General . Settings . ReadPluginSetting ( "autodragonpaste" , false ) ;
2013-12-05 09:24:55 +00:00
autoDrawOnEdit = General . Settings . ReadPluginSetting ( "autodrawonedit" , true ) ; //mxd
2013-09-11 08:49:45 +00:00
autoAlignTextureOffsetsOnCreate = General . Settings . ReadPluginSetting ( "autoaligntextureoffsetsoncreate" , false ) ; //mxd
2013-03-18 13:52:27 +00:00
dontMoveGeometryOutsideMapBoundary = General . Settings . ReadPluginSetting ( "dontmovegeometryoutsidemapboundary" , false ) ; //mxd
syncSelection = General . Settings . ReadPluginSetting ( "syncselection" , false ) ; //mxd
2020-04-04 16:03:40 +00:00
scaletexturesonslopes = General . Settings . ReadPluginSetting ( "scaletexturesonslopes" , 0 ) ;
2015-09-12 21:05:01 +00:00
}
//mxd. Load settings, which can be changed via UI
private void LoadUISettings ( )
{
2016-06-13 23:37:55 +00:00
lockSectorTextureOffsetsWhileDragging = General . Settings . ReadPluginSetting ( "locktextureoffsets" , false ) ;
2020-05-03 15:25:07 +00:00
lock3DFloorSectorTextureOffsetsWhileDragging = General . Settings . ReadPluginSetting ( "lock3dfloortextureoffsets" , false ) ;
2015-09-12 21:05:01 +00:00
viewselectionnumbers = General . Settings . ReadPluginSetting ( "viewselectionnumbers" , true ) ;
2016-06-13 23:37:55 +00:00
viewselectioneffects = General . Settings . ReadPluginSetting ( "viewselectioneffects" , true ) ;
syncthingedit = General . Settings . ReadPluginSetting ( "syncthingedit" , true ) ;
alphabasedtexturehighlighting = General . Settings . ReadPluginSetting ( "alphabasedtexturehighlighting" , true ) ;
2016-10-03 11:42:12 +00:00
showlightradii = General . Settings . ReadPluginSetting ( "showlightradii" , true ) ;
showsoundradii = General . Settings . ReadPluginSetting ( "showsoundradii" , true ) ;
2009-04-19 18:07:22 +00:00
}
2013-12-05 09:24:55 +00:00
//mxd. Save settings, which can be changed via UI
2015-09-12 21:05:01 +00:00
private void SaveUISettings ( )
2014-12-03 23:15:26 +00:00
{
2013-09-16 11:44:47 +00:00
General . Settings . WritePluginSetting ( "locktextureoffsets" , lockSectorTextureOffsetsWhileDragging ) ;
2020-05-03 15:25:07 +00:00
General . Settings . WritePluginSetting ( "lock3dfloortextureoffsets" , lock3DFloorSectorTextureOffsetsWhileDragging ) ;
2013-09-16 11:44:47 +00:00
General . Settings . WritePluginSetting ( "viewselectionnumbers" , viewselectionnumbers ) ;
General . Settings . WritePluginSetting ( "viewselectioneffects" , viewselectioneffects ) ;
2015-11-03 08:54:56 +00:00
General . Settings . WritePluginSetting ( "syncthingedit" , syncthingedit ) ;
2016-06-13 23:37:55 +00:00
General . Settings . WritePluginSetting ( "alphabasedtexturehighlighting" , alphabasedtexturehighlighting ) ;
2016-10-03 11:42:12 +00:00
General . Settings . WritePluginSetting ( "showlightradii" , showlightradii ) ;
General . Settings . WritePluginSetting ( "showsoundradii" , showsoundradii ) ;
2013-09-16 11:44:47 +00:00
}
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
//mxd. These should be reset when changing maps
private void ResetCopyProperties ( )
{
copiedvertexprops = null ;
copiedthingprops = null ;
copiedlinedefprops = null ;
copiedsidedefprops = null ;
copiedsectorprops = null ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Events
// When floor surface geometry is created for classic modes
public override void OnSectorFloorSurfaceUpdate ( Sector s , ref FlatVertex [ ] vertices )
{
ImageData img = General . Map . Data . GetFlatImage ( s . LongFloorTexture ) ;
if ( ( img ! = null ) & & img . IsImageLoaded )
{
2012-11-27 21:12:20 +00:00
//mxd. Merged from GZDoomEditing plugin
2017-04-03 17:42:30 +00:00
if ( General . Map . UDMF )
2014-12-03 23:15:26 +00:00
{
2012-11-27 21:12:20 +00:00
// Fetch ZDoom fields
2020-05-22 19:39:18 +00:00
Vector2D offset = new Vector2D ( s . Fields . GetValue ( "xpanningfloor" , 0.0 ) ,
s . Fields . GetValue ( "ypanningfloor" , 0.0 ) ) ;
Vector2D scale = new Vector2D ( s . Fields . GetValue ( "xscalefloor" , 1.0 ) ,
s . Fields . GetValue ( "yscalefloor" , 1.0 ) ) ;
double rotate = s . Fields . GetValue ( "rotationfloor" , 0.0 ) ;
2015-04-14 11:33:57 +00:00
int color , light ;
bool absolute ;
//mxd. Apply GLDEFS override?
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
if ( General . Map . Data . GlowingFlats . ContainsKey ( s . LongFloorTexture )
2016-11-09 10:07:21 +00:00
& & General . Map . Data . GlowingFlats [ s . LongFloorTexture ] . Fullbright )
2015-04-14 11:33:57 +00:00
{
color = - 1 ;
2016-11-09 10:07:21 +00:00
light = 255 ;
2015-04-14 11:33:57 +00:00
absolute = true ;
}
else
{
2017-02-13 00:06:29 +00:00
color = PixelColor . Modulate ( PixelColor . FromInt ( s . Fields . GetValue ( "lightcolor" , - 1 ) ) , PixelColor . FromInt ( s . Fields . GetValue ( "color_floor" , - 1 ) ) ) . ToInt ( ) ;
2015-04-14 11:33:57 +00:00
light = s . Fields . GetValue ( "lightfloor" , 0 ) ;
absolute = s . Fields . GetValue ( "lightfloorabsolute" , false ) ;
}
2012-11-27 21:12:20 +00:00
// Setup the vertices with the given settings
SetupSurfaceVertices ( vertices , s , img , offset , scale , rotate , color , light , absolute ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2012-11-27 21:12:20 +00:00
// Make scalars
float sw = 1.0f / img . ScaledWidth ;
float sh = 1.0f / img . ScaledHeight ;
// Make proper texture coordinates
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < vertices . Length ; i + + )
{
2012-11-27 21:12:20 +00:00
vertices [ i ] . u = vertices [ i ] . u * sw ;
vertices [ i ] . v = - vertices [ i ] . v * sh ;
}
2009-04-19 18:07:22 +00:00
}
}
2017-04-03 17:40:51 +00:00
else // [ZZ] proper fallback please.
{
for ( int i = 0 ; i < vertices . Length ; i + + )
{
vertices [ i ] . u = vertices [ i ] . u / 64 ;
vertices [ i ] . v = - vertices [ i ] . v / 64 ;
}
}
2009-04-19 18:07:22 +00:00
}
// When ceiling surface geometry is created for classic modes
public override void OnSectorCeilingSurfaceUpdate ( Sector s , ref FlatVertex [ ] vertices )
{
ImageData img = General . Map . Data . GetFlatImage ( s . LongCeilTexture ) ;
if ( ( img ! = null ) & & img . IsImageLoaded )
{
2012-11-27 21:12:20 +00:00
//mxd. Merged from GZDoomEditing plugin
2014-12-03 23:15:26 +00:00
if ( General . Map . UDMF )
{
2012-11-27 21:12:20 +00:00
// Fetch ZDoom fields
2020-05-22 19:39:18 +00:00
Vector2D offset = new Vector2D ( s . Fields . GetValue ( "xpanningceiling" , 0.0 ) ,
s . Fields . GetValue ( "ypanningceiling" , 0.0 ) ) ;
Vector2D scale = new Vector2D ( s . Fields . GetValue ( "xscaleceiling" , 1.0 ) ,
s . Fields . GetValue ( "yscaleceiling" , 1.0 ) ) ;
double rotate = s . Fields . GetValue ( "rotationceiling" , 0.0 ) ;
2015-04-14 11:33:57 +00:00
int color , light ;
bool absolute ;
//mxd. Apply GLDEFS override?
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
if ( General . Map . Data . GlowingFlats . ContainsKey ( s . LongCeilTexture )
2016-11-09 10:07:21 +00:00
& & General . Map . Data . GlowingFlats [ s . LongCeilTexture ] . Fullbright )
2015-04-14 11:33:57 +00:00
{
color = - 1 ;
2016-11-09 10:07:21 +00:00
light = 255 ;
2015-04-14 11:33:57 +00:00
absolute = true ;
}
else
{
2017-02-13 00:06:29 +00:00
color = PixelColor . Modulate ( PixelColor . FromInt ( s . Fields . GetValue ( "lightcolor" , - 1 ) ) , PixelColor . FromInt ( s . Fields . GetValue ( "color_ceiling" , - 1 ) ) ) . ToInt ( ) ;
light = s . Fields . GetValue ( "lightceiling" , 0 ) ;
2015-04-14 11:33:57 +00:00
absolute = s . Fields . GetValue ( "lightceilingabsolute" , false ) ;
}
2012-11-27 21:12:20 +00:00
// Setup the vertices with the given settings
SetupSurfaceVertices ( vertices , s , img , offset , scale , rotate , color , light , absolute ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2012-11-27 21:12:20 +00:00
// Make scalars
float sw = 1.0f / img . ScaledWidth ;
float sh = 1.0f / img . ScaledHeight ;
// Make proper texture coordinates
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < vertices . Length ; i + + )
{
2012-11-27 21:12:20 +00:00
vertices [ i ] . u = vertices [ i ] . u * sw ;
vertices [ i ] . v = - vertices [ i ] . v * sh ;
}
2009-04-19 18:07:22 +00:00
}
}
2017-04-03 17:40:51 +00:00
else // [ZZ] proper fallback please.
{
for ( int i = 0 ; i < vertices . Length ; i + + )
{
vertices [ i ] . u = vertices [ i ] . u / 64 ;
vertices [ i ] . v = - vertices [ i ] . v / 64 ;
}
}
}
2009-04-19 18:07:22 +00:00
// When the editing mode changes
public override bool OnModeChange ( EditMode oldmode , EditMode newmode )
{
// Show the correct menu for the new mode
menusform . ShowEditingModeMenu ( newmode ) ;
return base . OnModeChange ( oldmode , newmode ) ;
}
// When the Preferences dialog is shown
public override void OnShowPreferences ( PreferencesController controller )
{
base . OnShowPreferences ( controller ) ;
// Load preferences
preferencesform = new PreferencesForm ( ) ;
preferencesform . Setup ( controller ) ;
}
// When the Preferences dialog is closed
public override void OnClosePreferences ( PreferencesController controller )
{
base . OnClosePreferences ( controller ) ;
// Apply settings that could have been changed
LoadSettings ( ) ;
// Unload preferences
preferencesform . Dispose ( ) ;
preferencesform = null ;
}
2009-07-22 15:16:28 +00:00
// New map created
public override void OnMapNewEnd ( )
{
base . OnMapNewEnd ( ) ;
undoredopanel . SetBeginDescription ( "New Map" ) ;
undoredopanel . UpdateList ( ) ;
2012-06-26 08:54:25 +00:00
2013-11-21 10:53:11 +00:00
//mxd
2014-09-17 12:46:47 +00:00
General . Interface . AddDocker ( drawingOverridesDocker ) ;
2013-11-21 10:53:11 +00:00
drawingOverridesPanel . Setup ( ) ;
2017-04-03 08:20:40 +00:00
MakeDoor = new MakeDoorSettings ( General . Map . Config . MakeDoorDoor , General . Map . Config . MakeDoorTrack , General . Map . Config . MakeDoorCeiling , MakeDoor . ResetOffsets , MakeDoor . ApplyActionSpecials , MakeDoor . ApplyTag ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
ResetCopyProperties ( ) ;
2009-07-22 15:16:28 +00:00
}
// Map opened
public override void OnMapOpenEnd ( )
{
base . OnMapOpenEnd ( ) ;
undoredopanel . SetBeginDescription ( "Opened Map" ) ;
undoredopanel . UpdateList ( ) ;
2012-06-26 08:54:25 +00:00
2013-11-21 10:53:11 +00:00
//mxd
2014-09-17 12:46:47 +00:00
General . Interface . AddDocker ( drawingOverridesDocker ) ;
2013-11-21 10:53:11 +00:00
drawingOverridesPanel . Setup ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ;
2017-04-03 08:20:40 +00:00
MakeDoor = new MakeDoorSettings ( General . Map . Config . MakeDoorDoor , General . Map . Config . MakeDoorTrack , General . Map . Config . MakeDoorCeiling , MakeDoor . ResetOffsets , MakeDoor . ApplyActionSpecials , MakeDoor . ApplyTag ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
ResetCopyProperties ( ) ;
2009-07-22 15:16:28 +00:00
}
2015-09-16 12:10:43 +00:00
//mxd
public override void OnMapCloseBegin ( )
{
drawingOverridesPanel . Terminate ( ) ;
General . Interface . RemoveDocker ( drawingOverridesDocker ) ;
}
2018-04-14 22:59:58 +00:00
// Map closed
public override void OnMapCloseEnd ( )
2009-07-22 15:16:28 +00:00
{
base . OnMapCloseEnd ( ) ;
undoredopanel . UpdateList ( ) ;
2016-05-18 23:31:12 +00:00
errorcheckform = null ; //mxd. Error checks may need to be reinitialized
2012-06-26 08:54:25 +00:00
2013-09-16 11:44:47 +00:00
//mxd. Save settings
2015-09-12 21:05:01 +00:00
SaveUISettings ( ) ;
2009-07-22 15:16:28 +00:00
}
2016-05-19 21:44:39 +00:00
//mxd. Error checks may need to be reinitialized
public override void OnMapReconfigure ( )
{
errorcheckform = null ;
}
2009-07-22 15:16:28 +00:00
// Redo performed
public override void OnRedoEnd ( )
{
base . OnRedoEnd ( ) ;
undoredopanel . UpdateList ( ) ;
}
// Undo performed
public override void OnUndoEnd ( )
{
base . OnUndoEnd ( ) ;
undoredopanel . UpdateList ( ) ;
}
// Undo created
public override void OnUndoCreated ( )
{
base . OnUndoCreated ( ) ;
undoredopanel . UpdateList ( ) ;
}
// Undo withdrawn
public override void OnUndoWithdrawn ( )
{
base . OnUndoWithdrawn ( ) ;
undoredopanel . UpdateList ( ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Tools
2012-03-19 21:31:10 +00:00
2012-11-27 21:12:20 +00:00
//mxd. merged from GZDoomEditing plugin
// This applies the given values on the vertices
2014-05-20 09:09:28 +00:00
private static void SetupSurfaceVertices ( FlatVertex [ ] vertices , Sector s , ImageData img , Vector2D offset ,
2020-05-21 12:20:02 +00:00
Vector2D scale , double rotate , int color , int light , bool absolute )
2014-05-20 09:09:28 +00:00
{
2012-11-27 21:12:20 +00:00
// Prepare for math!
rotate = Angle2D . DegToRad ( rotate ) ;
Vector2D texscale = new Vector2D ( 1.0f / img . ScaledWidth , 1.0f / img . ScaledHeight ) ;
if ( ! absolute ) light = s . Brightness + light ;
PixelColor lightcolor = PixelColor . FromInt ( color ) ;
PixelColor brightness = PixelColor . FromInt ( General . Map . Renderer2D . CalculateBrightness ( light ) ) ;
PixelColor finalcolor = PixelColor . Modulate ( lightcolor , brightness ) ;
2017-02-13 00:06:29 +00:00
color = finalcolor . WithAlpha ( 255 ) . ToInt ( ) ;
2012-11-27 21:12:20 +00:00
// Do the math for all vertices
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < vertices . Length ; i + + )
{
2012-11-27 21:12:20 +00:00
Vector2D pos = new Vector2D ( vertices [ i ] . x , vertices [ i ] . y ) ;
pos = pos . GetRotated ( rotate ) ;
pos . y = - pos . y ;
pos = ( pos + offset ) * scale * texscale ;
2020-05-21 12:20:02 +00:00
vertices [ i ] . u = ( float ) pos . x ;
vertices [ i ] . v = ( float ) pos . y ;
2012-11-27 21:12:20 +00:00
vertices [ i ] . c = color ;
}
}
2009-04-19 18:07:22 +00:00
// This finds all class types that inherits from the given type
public Type [ ] FindClasses ( Type t )
{
List < Type > found = new List < Type > ( ) ;
// Get all exported types
2013-09-09 14:03:02 +00:00
Type [ ] types = Assembly . GetExecutingAssembly ( ) . GetTypes ( ) ;
2009-04-19 18:07:22 +00:00
foreach ( Type it in types )
{
// Compare types
if ( t . IsAssignableFrom ( it ) ) found . Add ( it ) ;
}
// Return list
return found . ToArray ( ) ;
}
// This renders the associated sectors/linedefs with the indication color
2015-06-24 21:21:19 +00:00
public static void PlotAssociations ( IRenderer2D renderer , Association asso , List < Line3D > eventlines )
2009-04-19 18:07:22 +00:00
{
// Tag must be above zero
2015-07-28 15:04:21 +00:00
if ( General . GetByIndex ( asso . Tags , 0 ) < 1 ) return ;
2009-04-19 18:07:22 +00:00
// Sectors?
2015-07-28 15:04:21 +00:00
switch ( asso . Type )
2009-04-19 18:07:22 +00:00
{
2015-06-24 21:21:19 +00:00
case UniversalType . SectorTag : {
foreach ( Sector s in General . Map . Map . Sectors )
2014-12-03 23:15:26 +00:00
{
2015-07-28 15:04:21 +00:00
if ( ! asso . Tags . Overlaps ( s . Tags ) ) continue ;
2012-09-17 21:57:08 +00:00
renderer . PlotSector ( s , General . Colors . Indication ) ;
2015-06-24 21:21:19 +00:00
if ( ! General . Settings . GZShowEventLines ) continue ;
Vector2D end = ( s . Labels . Count > 0 ? s . Labels [ 0 ] . position : new Vector2D ( s . BBox . X + s . BBox . Width / 2 , s . BBox . Y + s . BBox . Height / 2 ) ) ;
eventlines . Add ( new Line3D ( asso . Center , end ) ) ; //mxd
2012-09-17 21:57:08 +00:00
}
2015-06-24 21:21:19 +00:00
break ;
2012-09-17 21:57:08 +00:00
}
2015-06-24 21:21:19 +00:00
case UniversalType . LinedefTag : {
foreach ( Linedef l in General . Map . Map . Linedefs )
2014-12-03 23:15:26 +00:00
{
2015-07-28 15:04:21 +00:00
if ( ! asso . Tags . Overlaps ( l . Tags ) ) continue ;
2012-09-17 21:57:08 +00:00
renderer . PlotLinedef ( l , General . Colors . Indication ) ;
2015-06-24 21:21:19 +00:00
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( asso . Center , l . GetCenterPoint ( ) ) ) ; //mxd
2012-09-17 21:57:08 +00:00
}
2015-06-24 21:21:19 +00:00
break ;
2012-09-26 00:04:17 +00:00
}
2009-04-19 18:07:22 +00:00
}
}
// This renders the associated things with the indication color
2015-06-24 21:21:19 +00:00
public static void RenderAssociations ( IRenderer2D renderer , Association asso , List < Line3D > eventlines )
2009-04-19 18:07:22 +00:00
{
// Tag must be above zero
2015-07-28 15:04:21 +00:00
if ( General . GetByIndex ( asso . Tags , 0 ) < 1 ) return ;
2009-04-19 18:07:22 +00:00
// Things?
2015-07-28 15:04:21 +00:00
switch ( asso . Type )
2009-04-19 18:07:22 +00:00
{
2015-07-28 15:04:21 +00:00
case UniversalType . ThingTag :
2015-06-24 21:21:19 +00:00
foreach ( Thing t in General . Map . Map . Things )
2014-12-03 23:15:26 +00:00
{
2015-07-28 15:04:21 +00:00
if ( ! asso . Tags . Contains ( t . Tag ) ) continue ;
2017-02-14 17:33:50 +00:00
//Do not draw the association if the user is hovering over a child link
ThingTypeInfo ti = General . Map . Data . GetThingInfoEx ( t . Type ) ;
if ( ti ! = null & & ti . ThingLink < 0 )
continue ;
2016-04-01 10:49:19 +00:00
renderer . RenderThing ( t , General . Colors . Indication , General . Settings . ActiveThingsAlpha ) ;
2015-06-24 21:21:19 +00:00
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( asso . Center , t . Position ) ) ; //mxd
2012-09-17 21:57:08 +00:00
}
2015-06-24 21:21:19 +00:00
break ;
case UniversalType . SectorTag :
foreach ( Sector s in General . Map . Map . Sectors )
2014-12-03 23:15:26 +00:00
{
2015-07-28 15:04:21 +00:00
if ( ! asso . Tags . Overlaps ( s . Tags ) ) continue ;
2013-12-05 09:24:55 +00:00
int highlightedColor = General . Colors . Highlight . WithAlpha ( 128 ) . ToInt ( ) ;
FlatVertex [ ] verts = new FlatVertex [ s . FlatVertices . Length ] ;
s . FlatVertices . CopyTo ( verts , 0 ) ;
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < verts . Length ; i + + ) verts [ i ] . c = highlightedColor ;
2013-12-05 09:24:55 +00:00
renderer . RenderGeometry ( verts , null , true ) ;
}
2015-06-24 21:21:19 +00:00
break ;
2009-04-19 18:07:22 +00:00
}
}
// This renders the associated sectors/linedefs with the indication color
2015-06-24 21:21:19 +00:00
public static void PlotReverseAssociations ( IRenderer2D renderer , Association asso , List < Line3D > eventlines )
2009-04-19 18:07:22 +00:00
{
// Tag must be above zero
2015-07-28 15:04:21 +00:00
if ( General . GetByIndex ( asso . Tags , 0 ) < 1 ) return ;
2009-04-19 18:07:22 +00:00
// Doom style referencing to sectors?
2015-07-28 15:04:21 +00:00
if ( General . Map . Config . LineTagIndicatesSectors & & ( asso . Type = = UniversalType . SectorTag ) )
2009-04-19 18:07:22 +00:00
{
// Linedefs
foreach ( Linedef l in General . Map . Map . Linedefs )
{
// Any action on this line?
2015-07-28 15:04:21 +00:00
if ( l . Action < = 0 | | ! asso . Tags . Overlaps ( l . Tags ) ) continue ;
2015-06-24 21:21:19 +00:00
renderer . PlotLinedef ( l , General . Colors . Indication ) ;
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( l . GetCenterPoint ( ) , asso . Center ) ) ; //mxd
2012-09-26 00:04:17 +00:00
}
2009-04-19 18:07:22 +00:00
}
2015-06-24 21:21:19 +00:00
// Linedefs
foreach ( Linedef l in General . Map . Map . Linedefs )
2009-04-19 18:07:22 +00:00
{
2015-06-24 21:21:19 +00:00
// Known action on this line?
if ( ( l . Action > 0 ) & & General . Map . Config . LinedefActions . ContainsKey ( l . Action ) )
2009-04-19 18:07:22 +00:00
{
2015-06-24 21:21:19 +00:00
LinedefActionInfo action = General . Map . Config . LinedefActions [ l . Action ] ;
2015-07-28 15:04:21 +00:00
if ( ( ( action . Args [ 0 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( l . Args [ 0 ] ) ) ) | |
( ( action . Args [ 1 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( l . Args [ 1 ] ) ) ) | |
( ( action . Args [ 2 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( l . Args [ 2 ] ) ) ) | |
( ( action . Args [ 3 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( l . Args [ 3 ] ) ) ) | |
( ( action . Args [ 4 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( l . Args [ 4 ] ) ) ) )
2009-04-19 18:07:22 +00:00
{
2015-06-24 21:21:19 +00:00
renderer . PlotLinedef ( l , General . Colors . Indication ) ;
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( l . GetCenterPoint ( ) , asso . Center ) ) ; //mxd
2009-04-19 18:07:22 +00:00
}
}
}
}
// This renders the associated things with the indication color
2015-06-24 21:21:19 +00:00
public static void RenderReverseAssociations ( IRenderer2D renderer , Association asso , List < Line3D > eventlines )
2009-04-19 18:07:22 +00:00
{
// Tag must be above zero
2015-07-28 15:04:21 +00:00
if ( General . GetByIndex ( asso . Tags , 0 ) < 1 ) return ;
2009-04-19 18:07:22 +00:00
// Things
foreach ( Thing t in General . Map . Map . Things )
{
2017-02-14 17:33:50 +00:00
// Get the thing type info
ThingTypeInfo ti = General . Map . Data . GetThingInfoEx ( t . Type ) ;
2009-04-19 18:07:22 +00:00
// Known action on this thing?
if ( ( t . Action > 0 ) & & General . Map . Config . LinedefActions . ContainsKey ( t . Action ) )
{
2017-02-14 17:33:50 +00:00
//Do not draw the association if this is a child link.
// This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
if ( ti ! = null & & asso . DirectLinkType < 0 & & asso . DirectLinkType ! = - t . Type )
continue ;
2009-04-19 18:07:22 +00:00
LinedefActionInfo action = General . Map . Config . LinedefActions [ t . Action ] ;
2015-07-28 15:04:21 +00:00
if ( ( ( action . Args [ 0 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 0 ] ) ) ) | |
( ( action . Args [ 1 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 1 ] ) ) ) | |
( ( action . Args [ 2 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 2 ] ) ) ) | |
( ( action . Args [ 3 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 3 ] ) ) ) | |
( ( action . Args [ 4 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 4 ] ) ) ) )
2014-12-03 23:15:26 +00:00
{
2016-04-01 10:49:19 +00:00
renderer . RenderThing ( t , General . Colors . Indication , General . Settings . ActiveThingsAlpha ) ;
2015-06-24 21:21:19 +00:00
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( t . Position , asso . Center ) ) ; //mxd
2012-09-17 21:57:08 +00:00
}
2017-02-14 17:33:50 +00:00
//If there is a link setup on this thing, and it matches the association, then draw a direct link to any matching tag
if ( ti ! = null & & asso . DirectLinkType = = t . Type & & asso . Tags . Contains ( t . Tag ) )
{
renderer . RenderThing ( t , General . Colors . Indication , General . Settings . ActiveThingsAlpha ) ;
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( t . Position , asso . Center ) ) ;
}
2009-04-19 18:07:22 +00:00
}
2015-09-08 14:54:53 +00:00
//mxd. Thing action on this thing?
else if ( t . Action = = 0 )
{
2017-02-14 17:33:50 +00:00
//Draw the association, unless it is a child link.
// This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
if ( ti ! = null & & asso . DirectLinkType > = 0 & & Math . Abs ( asso . DirectLinkType ) ! = t . Type )
2015-09-08 14:54:53 +00:00
{
if ( ( ( ti . Args [ 0 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 0 ] ) ) ) | |
2017-04-03 08:20:40 +00:00
( ( ti . Args [ 1 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 1 ] ) ) ) | |
( ( ti . Args [ 2 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 2 ] ) ) ) | |
( ( ti . Args [ 3 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 3 ] ) ) ) | |
( ( ti . Args [ 4 ] . Type = = ( int ) asso . Type ) & & ( asso . Tags . Contains ( t . Args [ 4 ] ) ) ) )
2015-09-08 14:54:53 +00:00
{
2016-04-01 10:49:19 +00:00
renderer . RenderThing ( t , General . Colors . Indication , General . Settings . ActiveThingsAlpha ) ;
2015-09-08 14:54:53 +00:00
if ( General . Settings . GZShowEventLines ) eventlines . Add ( new Line3D ( t . Position , asso . Center ) ) ;
}
}
}
2009-04-19 18:07:22 +00:00
}
}
#endregion
2013-03-18 13:52:27 +00:00
2014-10-23 08:18:14 +00:00
#region = = = = = = = = = = = = = = = = = = Actions ( mxd )
2013-03-18 13:52:27 +00:00
[BeginAction("exporttoobj")]
2014-12-03 23:15:26 +00:00
private void ExportToObj ( )
{
2013-12-13 09:31:18 +00:00
// Convert geometry selection to sectors
General . Map . Map . ConvertSelection ( SelectionType . Sectors ) ;
2013-03-18 13:52:27 +00:00
//get sectors
ICollection < Sector > sectors = General . Map . Map . SelectedSectorsCount = = 0 ? General . Map . Map . Sectors : General . Map . Map . GetSelectedSectors ( true ) ;
2014-12-03 23:15:26 +00:00
if ( sectors . Count = = 0 )
{
2013-03-18 13:52:27 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "OBJ export failed. Map has no sectors!" ) ;
return ;
}
//show settings form
WavefrontSettingsForm form = new WavefrontSettingsForm ( General . Map . Map . SelectedSectorsCount = = 0 ? - 1 : sectors . Count ) ;
2014-12-03 23:15:26 +00:00
if ( form . ShowDialog ( ) = = DialogResult . OK )
{
2014-01-30 14:52:08 +00:00
WavefrontExportSettings data = new WavefrontExportSettings ( Path . GetFileNameWithoutExtension ( form . FilePath ) , Path . GetDirectoryName ( form . FilePath ) , form . ObjScale , form . UseGZDoomScale , form . ExportTextures ) ;
2013-03-18 13:52:27 +00:00
WavefrontExporter e = new WavefrontExporter ( ) ;
e . Export ( sectors , data ) ;
}
}
2020-06-17 20:22:00 +00:00
[BeginAction("exporttoimage")]
private void ExportToImage ( )
{
// Convert geometry selection to sectors
General . Map . Map . ConvertSelection ( SelectionType . Sectors ) ;
// Get sectors
ICollection < Sector > sectors = General . Map . Map . SelectedSectorsCount = = 0 ? General . Map . Map . Sectors : General . Map . Map . GetSelectedSectors ( true ) ;
if ( sectors . Count = = 0 )
{
General . Interface . DisplayStatus ( StatusType . Warning , "Image export failed. Map has no sectors!" ) ;
return ;
}
ImageExportSettingsForm form = new ImageExportSettingsForm ( ) ;
if ( form . ShowDialog ( ) = = DialogResult . OK )
{
2020-06-24 20:10:17 +00:00
ImageExportSettings settings = new ImageExportSettings ( Path . GetDirectoryName ( form . FilePath ) , Path . GetFileNameWithoutExtension ( form . FilePath ) , Path . GetExtension ( form . FilePath ) , form . Floor , form . Fullbright , form . Brightmap , form . Tiles , form . GetPixelFormat ( ) , form . GetImageFormat ( ) ) ;
ImageExporter exporter = new ImageExporter ( sectors , settings ) ;
2020-06-17 20:22:00 +00:00
2020-06-24 20:10:17 +00:00
string text = "The following images will be created:\n\n" + string . Join ( "\n" , exporter . GetImageNames ( ) ) ;
DialogResult result = MessageBox . Show ( text , "Export to image" , MessageBoxButtons . OKCancel ) ;
if ( result = = DialogResult . OK )
2020-06-17 20:22:00 +00:00
{
2020-06-24 20:10:17 +00:00
try
{
exporter . Export ( ) ;
MessageBox . Show ( "Export successful." , "Export to image" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
}
catch ( ArgumentException e ) // Happens if there's not enough consecutive memory to create the file
{
MessageBox . Show ( "Exporting failed. There's likely not enough consecutive free memory to create the image. Try a lower color depth or file format" , "Export failed" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
2020-06-17 20:22:00 +00:00
}
}
}
2013-03-18 13:52:27 +00:00
#endregion
2009-04-19 18:07:22 +00:00
}
}