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 ;
2014-01-23 13:55:03 +00:00
using System.Drawing ;
2015-05-26 20:10:09 +00:00
using System.Linq ;
2009-04-19 18:07:22 +00:00
using System.Windows.Forms ;
using CodeImp.DoomBuilder.Actions ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
using CodeImp.DoomBuilder.BuilderModes.Interface ;
2013-05-30 12:52:27 +00:00
using CodeImp.DoomBuilder.Data ;
2015-06-24 21:21:19 +00:00
using CodeImp.DoomBuilder.Editing ;
using CodeImp.DoomBuilder.Geometry ;
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Rendering ;
using CodeImp.DoomBuilder.Windows ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[ EditMode ( DisplayName = "Linedefs Mode" ,
SwitchAction = "linedefsmode" , // Action name used to switch to this mode
ButtonImage = "LinesMode.png" , // Image resource name for the button
ButtonOrder = int . MinValue + 100 , // Position of the button (lower is more to the left)
ButtonGroup = "000_editing" ,
2009-07-09 15:15:49 +00:00
UseByDefault = true ,
SafeStartMode = true ) ]
2009-04-19 18:07:22 +00:00
public class LinedefsMode : BaseClassicMode
{
#region = = = = = = = = = = = = = = = = = = Constants
2016-04-04 22:20:49 +00:00
private const int MAX_LINEDEF_LABELS = 256 ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
// Highlighted item
private Linedef highlighted ;
2020-07-16 20:01:37 +00:00
private readonly Association highlightasso ;
2015-06-25 22:44:13 +00:00
private Vector2D insertpreview = new Vector2D ( float . NaN , float . NaN ) ; //mxd
2016-04-04 22:20:49 +00:00
//mxd. Text labels
2016-04-17 22:52:03 +00:00
private Dictionary < Linedef , SelectionLabel > labels ;
2016-04-04 22:20:49 +00:00
private Dictionary < Sector , TextLabel [ ] > sectorlabels ;
private Dictionary < Sector , string [ ] > sectortexts ;
2009-04-19 18:07:22 +00:00
// Interface
2016-10-28 21:32:52 +00:00
new private bool editpressed ;
2020-10-31 15:09:22 +00:00
// The blockmap makes is used to make finding lines faster
BlockMap < BlockEntry > blockmap ;
2020-10-31 20:06:24 +00:00
// Stores sizes of the text for text labels so that they only have to be computed once
private Dictionary < string , float > textlabelsizecache ;
2022-09-20 21:52:41 +00:00
// Linedefs that will be edited
ICollection < Linedef > editlines ;
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
2009-05-17 14:00:36 +00:00
public override object HighlightedObject { get { return highlighted ; } }
2022-02-06 11:19:03 +00:00
public override bool AlwaysShowVertices { get { return true ; } }
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
2015-07-28 15:04:21 +00:00
public LinedefsMode ( )
{
//mxd. Associations now requre initializing...
2020-07-16 20:01:37 +00:00
highlightasso = new Association ( renderer ) ;
2020-10-31 20:06:24 +00:00
textlabelsizecache = new Dictionary < string , float > ( ) ;
2015-07-28 15:04:21 +00:00
}
2016-04-04 22:20:49 +00:00
//mxd
public override void Dispose ( )
{
// Not already disposed?
if ( ! isdisposed )
{
// Dispose old labels
2016-04-17 22:52:03 +00:00
if ( labels ! = null ) foreach ( SelectionLabel l in labels . Values ) l . Dispose ( ) ;
2016-04-04 22:20:49 +00:00
if ( sectorlabels ! = null )
{
foreach ( TextLabel [ ] lbl in sectorlabels . Values )
foreach ( TextLabel l in lbl ) l . Dispose ( ) ;
}
// Dispose base
base . Dispose ( ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
// This highlights a new item
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
private void Highlight ( Linedef l )
2009-04-19 18:07:22 +00:00
{
bool completeredraw = false ;
// Often we can get away by simply undrawing the previous
// highlight and drawing the new highlight. But if associations
// are or were drawn we need to redraw the entire display.
2016-04-04 22:20:49 +00:00
if ( highlighted ! = null )
{
//mxd. Update label color?
if ( labels . ContainsKey ( highlighted ) )
{
labels [ highlighted ] . Color = General . Colors . Highlight ;
completeredraw = true ;
}
2020-07-16 20:01:37 +00:00
2016-04-04 22:20:49 +00:00
// Previous association highlights something?
2020-07-16 20:01:37 +00:00
if ( ! highlightasso . IsEmpty ) completeredraw = true ;
2016-04-04 22:20:49 +00:00
}
2009-04-19 18:07:22 +00:00
// Set highlight association
2016-04-04 22:20:49 +00:00
if ( l ! = null )
{
//mxd. Update label color?
if ( labels . ContainsKey ( l ) )
{
labels [ l ] . Color = General . Colors . Selection ;
completeredraw = true ;
}
// New association highlights something?
2020-07-16 20:01:37 +00:00
highlightasso . Set ( l ) ;
2009-04-19 18:07:22 +00:00
2020-07-16 20:01:37 +00:00
// Only need a complete redraw if the association contains elements
if ( ! highlightasso . IsEmpty ) completeredraw = true ;
2009-04-19 18:07:22 +00:00
}
else
{
2020-07-16 20:01:37 +00:00
// Only need a complete redraw if the old association wasn't empty
if ( ! highlightasso . IsEmpty ) completeredraw = true ;
highlightasso . Clear ( ) ;
2009-04-19 18:07:22 +00:00
}
2020-07-16 20:01:37 +00:00
2009-04-19 18:07:22 +00:00
// If we're changing associations, then we
// need to redraw the entire display
if ( completeredraw )
{
// Set new highlight and redraw completely
highlighted = l ;
General . Interface . RedrawDisplay ( ) ;
}
else
{
// Update display
if ( renderer . StartPlotter ( false ) )
{
// Undraw previous highlight
2015-07-14 23:34:31 +00:00
Linedef possiblecommentline = l ? ? highlighted ; //mxd
2009-04-19 18:07:22 +00:00
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
renderer . PlotLinedef ( highlighted , renderer . DetermineLinedefColor ( highlighted ) ) ;
renderer . PlotVertex ( highlighted . Start , renderer . DetermineVertexColor ( highlighted . Start ) ) ;
renderer . PlotVertex ( highlighted . End , renderer . DetermineVertexColor ( highlighted . End ) ) ;
}
// Set new highlight
highlighted = l ;
// Render highlighted item
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
renderer . PlotLinedef ( highlighted , General . Colors . Highlight ) ;
renderer . PlotVertex ( highlighted . Start , renderer . DetermineVertexColor ( highlighted . Start ) ) ;
renderer . PlotVertex ( highlighted . End , renderer . DetermineVertexColor ( highlighted . End ) ) ;
}
2015-07-14 23:34:31 +00:00
// Done with highlight
2009-04-19 18:07:22 +00:00
renderer . Finish ( ) ;
2015-07-14 23:34:31 +00:00
//mxd. Update comment highlight?
if ( General . Map . UDMF & & General . Settings . RenderComments
& & possiblecommentline ! = null & & ! possiblecommentline . IsDisposed
& & renderer . StartOverlay ( false ) )
{
RenderComment ( possiblecommentline ) ;
renderer . Finish ( ) ;
}
2009-04-19 18:07:22 +00:00
renderer . Present ( ) ;
}
}
// Show highlight info
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
2015-07-14 09:02:48 +00:00
{
2009-04-19 18:07:22 +00:00
General . Interface . ShowLinedefInfo ( highlighted ) ;
2015-07-14 09:02:48 +00:00
}
2009-04-19 18:07:22 +00:00
else
2015-07-14 09:02:48 +00:00
{
General . Interface . Display . HideToolTip ( ) ; //mxd
2009-04-19 18:07:22 +00:00
General . Interface . HideInfo ( ) ;
2015-07-14 09:02:48 +00:00
}
2009-04-19 18:07:22 +00:00
}
2013-05-30 12:52:27 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void AlignTextureToLine ( bool alignFloors , bool alignToFrontSide )
{
2013-05-30 12:52:27 +00:00
ICollection < Linedef > lines = General . Map . Map . GetSelectedLinedefs ( true ) ;
2014-04-02 10:57:52 +00:00
if ( lines . Count = = 0 & & highlighted ! = null & & ! highlighted . IsDisposed )
lines . Add ( highlighted ) ;
2014-12-03 23:15:26 +00:00
if ( lines . Count = = 0 )
{
2016-10-31 18:52:29 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires a selection!" ) ;
2013-05-30 12:52:27 +00:00
return ;
}
//Create Undo
string rest = ( alignFloors ? "Floors" : "Ceilings" ) + " to " + ( alignToFrontSide ? "Front" : "Back" ) + " Side" ;
General . Map . UndoRedo . CreateUndo ( "Align " + rest ) ;
int counter = 0 ;
2014-12-03 23:15:26 +00:00
foreach ( Linedef l in lines )
{
2013-05-30 12:52:27 +00:00
Sector s = null ;
2014-12-03 23:15:26 +00:00
if ( alignToFrontSide )
{
2013-05-30 12:52:27 +00:00
if ( l . Front ! = null & & l . Front . Sector ! = null ) s = l . Front . Sector ;
2014-12-03 23:15:26 +00:00
}
else
{
2013-05-30 12:52:27 +00:00
if ( l . Back ! = null & & l . Back . Sector ! = null ) s = l . Back . Sector ;
}
if ( s = = null ) continue ;
counter + + ;
s . Fields . BeforeFieldsChange ( ) ;
2020-05-22 20:30:32 +00:00
double sourceAngle = Math . Round ( General . ClampAngle ( alignToFrontSide ? - Angle2D . RadToDeg ( l . Angle ) + 90 : - Angle2D . RadToDeg ( l . Angle ) - 90 ) , 1 ) ;
2013-05-30 12:52:27 +00:00
if ( ! alignToFrontSide ) sourceAngle = General . ClampAngle ( sourceAngle + 180 ) ;
//update angle
2020-05-22 20:30:32 +00:00
UniFields . SetFloat ( s . Fields , ( alignFloors ? "rotationfloor" : "rotationceiling" ) , sourceAngle , 0.0 ) ;
2013-05-30 12:52:27 +00:00
//update offset
Vector2D offset = ( alignToFrontSide ? l . Start . Position : l . End . Position ) . GetRotated ( Angle2D . DegToRad ( sourceAngle ) ) ;
ImageData texture = General . Map . Data . GetFlatImage ( s . LongFloorTexture ) ;
if ( ( texture = = null ) | | ( texture = = General . Map . Data . WhiteTexture ) | |
2014-12-03 23:15:26 +00:00
( texture . Width < = 0 ) | | ( texture . Height < = 0 ) | | ! texture . IsImageLoaded )
{
//meh...
}
else
{
2020-05-22 19:39:18 +00:00
offset . x % = texture . Width / s . Fields . GetValue ( ( alignFloors ? "xscalefloor" : "xscaleceiling" ) , 1.0 ) ;
offset . y % = texture . Height / s . Fields . GetValue ( ( alignFloors ? "yscalefloor" : "yscaleceiling" ) , 1.0 ) ;
2013-05-30 12:52:27 +00:00
}
2020-05-22 19:39:18 +00:00
UniFields . SetFloat ( s . Fields , ( alignFloors ? "xpanningfloor" : "xpanningceiling" ) , Math . Round ( - offset . x ) , 0.0 ) ;
UniFields . SetFloat ( s . Fields , ( alignFloors ? "ypanningfloor" : "ypanningceiling" ) , Math . Round ( offset . y ) , 0.0 ) ;
2013-05-30 12:52:27 +00:00
//update
s . UpdateNeeded = true ;
s . UpdateCache ( ) ;
}
General . Interface . DisplayStatus ( StatusType . Info , "Aligned " + counter + " " + rest ) ;
//update
General . Map . Map . Update ( ) ;
General . Interface . RedrawDisplay ( ) ;
General . Interface . RefreshInfo ( ) ;
General . Map . IsChanged = true ;
}
2013-11-29 14:45:29 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private bool IsInSelectionRect ( Linedef l , List < Line2D > selectionOutline )
{
if ( BuilderPlug . Me . MarqueSelectTouching )
{
2020-05-21 12:20:02 +00:00
bool selected = selectionrect . Contains ( ( float ) l . Start . Position . x , ( float ) l . Start . Position . y ) | | selectionrect . Contains ( ( float ) l . End . Position . x , ( float ) l . End . Position . y ) ;
2013-11-29 14:45:29 +00:00
//check intersections with outline
2014-12-03 23:15:26 +00:00
if ( ! selected )
{
foreach ( Line2D line in selectionOutline )
{
if ( Line2D . GetIntersection ( l . Line , line ) ) return true ;
2013-11-29 14:45:29 +00:00
}
}
return selected ;
}
2020-05-21 12:20:02 +00:00
return selectionrect . Contains ( ( float ) l . Start . Position . x , ( float ) l . Start . Position . y ) & & selectionrect . Contains ( ( float ) l . End . Position . x , ( float ) l . End . Position . y ) ;
2013-11-29 14:45:29 +00:00
}
2016-04-04 22:20:49 +00:00
2016-04-22 20:17:21 +00:00
//mxd. Gets map elements inside of selectionoutline and sorts them by distance to targetpoint
private List < Linedef > GetOrderedSelection ( Vector2D targetpoint , List < Line2D > selectionoutline )
{
// Gather affected sectors
List < Linedef > result = new List < Linedef > ( ) ;
foreach ( Linedef l in General . Map . Map . Linedefs )
{
if ( IsInSelectionRect ( l , selectionoutline ) ) result . Add ( l ) ;
}
if ( result . Count = = 0 ) return result ;
// Sort by distance to targetpoint
result . Sort ( delegate ( Linedef l1 , Linedef l2 )
{
if ( l1 = = l2 ) return 0 ;
// Get closest distance from l1 to selectstart
2020-05-21 12:20:02 +00:00
double closest1 = double . MaxValue ;
2016-04-22 20:17:21 +00:00
Vector2D pos = l1 . Start . Position ;
2020-05-21 12:20:02 +00:00
double curdistance = Vector2D . DistanceSq ( pos , targetpoint ) ;
2016-04-22 20:17:21 +00:00
if ( curdistance < closest1 ) closest1 = curdistance ;
pos = l1 . End . Position ;
curdistance = Vector2D . DistanceSq ( pos , targetpoint ) ;
if ( curdistance < closest1 ) closest1 = curdistance ;
// Get closest distance from l2 to selectstart
2020-05-21 12:20:02 +00:00
double closest2 = double . MaxValue ;
2016-04-22 20:17:21 +00:00
pos = l2 . Start . Position ;
curdistance = Vector2D . DistanceSq ( pos , targetpoint ) ;
if ( curdistance < closest2 ) closest2 = curdistance ;
pos = l2 . End . Position ;
curdistance = Vector2D . DistanceSq ( pos , targetpoint ) ;
if ( curdistance < closest2 ) closest2 = curdistance ;
// Return closer one
return ( int ) ( closest1 - closest2 ) ;
} ) ;
return result ;
}
2016-04-04 22:20:49 +00:00
//mxd. This sets up new labels
private void SetupSectorLabels ( )
{
2022-02-08 20:30:54 +00:00
// Dummy label we need for the font
TextLabel dummylabel = new TextLabel ( ) ;
// The "+" is always shown if the space for the label isn't big enough to show the full text
textlabelsizecache [ "+" ] = General . Interface . MeasureString ( "+" , dummylabel . Font ) . Width ;
2016-04-04 22:20:49 +00:00
// Dispose old labels
2022-02-08 20:30:54 +00:00
if ( sectorlabels ! = null )
2016-04-04 22:20:49 +00:00
{
foreach ( TextLabel [ ] larr in sectorlabels . Values )
foreach ( TextLabel l in larr ) l . Dispose ( ) ;
}
// Make text labels for sectors
sectorlabels = new Dictionary < Sector , TextLabel [ ] > ( ) ;
sectortexts = new Dictionary < Sector , string [ ] > ( ) ;
foreach ( Sector s in General . Map . Map . Sectors )
{
// Setup labels
if ( s . Tag = = 0 ) continue ;
// Make tag text
string [ ] tagdescarr = new string [ 2 ] ;
if ( s . Tags . Count > 1 )
{
string [ ] stags = new string [ s . Tags . Count ] ;
for ( int i = 0 ; i < s . Tags . Count ; i + + ) stags [ i ] = s . Tags [ i ] . ToString ( ) ;
tagdescarr [ 0 ] = "Tags " + string . Join ( ", " , stags ) ;
tagdescarr [ 1 ] = "T" + string . Join ( "," , stags ) ;
}
else
{
tagdescarr [ 0 ] = "Tag " + s . Tag ;
tagdescarr [ 1 ] = "T" + s . Tag ;
}
2022-02-08 20:30:54 +00:00
// Add string lengths to the label size cache
if ( ! textlabelsizecache . ContainsKey ( tagdescarr [ 0 ] ) )
textlabelsizecache [ tagdescarr [ 0 ] ] = General . Interface . MeasureString ( tagdescarr [ 0 ] , dummylabel . Font ) . Width ;
if ( ! textlabelsizecache . ContainsKey ( tagdescarr [ 1 ] ) )
textlabelsizecache [ tagdescarr [ 1 ] ] = General . Interface . MeasureString ( tagdescarr [ 1 ] , dummylabel . Font ) . Width ;
2016-04-04 22:20:49 +00:00
// Add to collection
sectortexts . Add ( s , tagdescarr ) ;
TextLabel [ ] larr = new TextLabel [ s . Labels . Count ] ;
for ( int i = 0 ; i < s . Labels . Count ; i + + )
{
TextLabel l = new TextLabel ( ) ;
l . TransformCoords = true ;
2016-04-19 20:40:42 +00:00
l . Location = s . Labels [ i ] . position ;
2016-04-04 22:20:49 +00:00
l . AlignX = TextAlignmentX . Center ;
l . AlignY = TextAlignmentY . Middle ;
l . Color = General . Colors . InfoLine ;
2016-04-06 11:44:38 +00:00
l . BackColor = General . Colors . Background . WithAlpha ( 128 ) ;
2016-04-04 22:20:49 +00:00
larr [ i ] = l ;
}
// Add to collection
sectorlabels . Add ( s , larr ) ;
}
}
//mxd. Also update labels for the selected linedefs
public override void UpdateSelectionInfo ( )
{
base . UpdateSelectionInfo ( ) ;
2016-09-27 19:39:46 +00:00
if ( labels ! = null )
{
// Dispose old labels
foreach ( SelectionLabel l in labels . Values ) l . Dispose ( ) ;
}
2016-04-04 22:20:49 +00:00
// Make text labels for selected linedefs
ICollection < Linedef > orderedselection = General . Map . Map . GetSelectedLinedefs ( true ) ;
2016-04-17 22:52:03 +00:00
labels = new Dictionary < Linedef , SelectionLabel > ( orderedselection . Count ) ;
2016-04-04 22:20:49 +00:00
// Otherwise significant delays will occure.
// Also we probably won't care about selection ordering when selecting this many anyway
if ( orderedselection . Count > MAX_LINEDEF_LABELS ) return ;
int index = 0 ;
foreach ( Linedef linedef in orderedselection )
{
2016-04-17 22:52:03 +00:00
SelectionLabel l = new SelectionLabel ( ) ;
l . OffsetPosition = true ;
2016-04-04 22:20:49 +00:00
l . Color = ( linedef = = highlighted ? General . Colors . Selection : General . Colors . Highlight ) ;
2016-04-06 11:44:38 +00:00
l . BackColor = General . Colors . Background . WithAlpha ( 192 ) ;
2016-04-17 22:52:03 +00:00
l . TextLabel . Text = ( + + index ) . ToString ( ) ;
2016-04-04 22:20:49 +00:00
labels . Add ( linedef , l ) ;
}
}
2020-10-31 15:09:22 +00:00
/// <summary>
/// Create a blockmap containing linedefs. This is used to speed up determining the closest line
/// to the mouse cursor
/// </summary>
private void CreateBlockmap ( )
{
RectangleF area = MapSet . CreateArea ( General . Map . Map . Vertices ) ;
blockmap = new BlockMap < BlockEntry > ( area ) ;
blockmap . AddLinedefsSet ( General . Map . Map . Linedefs ) ;
}
2022-02-06 12:55:37 +00:00
/// <summary>
/// Renders the overlay with the (selection) labels and insert vertex preview.
/// </summary>
private void RenderOverlay ( )
{
2022-04-09 15:52:38 +00:00
if ( General . Map . Map . IsSafeToAccess & & renderer . StartOverlay ( true ) )
2022-02-06 12:55:37 +00:00
{
if ( ! selecting ) //mxd
{
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed ) highlightasso . Render ( ) ; //mxd
}
else
{
RenderMultiSelection ( ) ;
}
//mxd. Render vertex insert preview
if ( insertpreview . IsFinite ( ) )
{
double dist = Math . Min ( Vector2D . Distance ( mousemappos , insertpreview ) , BuilderPlug . Me . HighlightRange ) ;
byte alpha = ( byte ) ( 255 - ( dist / BuilderPlug . Me . HighlightRange ) * 128 ) ;
float vsize = ( renderer . VertexSize + 1.0f ) / renderer . Scale ;
renderer . RenderRectangleFilled ( new RectangleF ( ( float ) ( insertpreview . x - vsize ) , ( float ) ( insertpreview . y - vsize ) , vsize * 2.0f , vsize * 2.0f ) , General . Colors . InfoLine . WithAlpha ( alpha ) , true ) ;
}
//mxd. Render sector tag labels
if ( BuilderPlug . Me . ViewSelectionEffects )
{
List < ITextLabel > torender = new List < ITextLabel > ( sectorlabels . Count ) ;
foreach ( KeyValuePair < Sector , string [ ] > group in sectortexts )
{
// Pick which text variant to use
TextLabel [ ] labelarray = sectorlabels [ group . Key ] ;
for ( int i = 0 ; i < group . Key . Labels . Count ; i + + )
{
2022-02-08 20:30:54 +00:00
// Only process this label if it's actually in view
if ( ! labelarray [ i ] . IsInViewport ( ) )
continue ;
2022-02-06 12:55:37 +00:00
TextLabel l = labelarray [ i ] ;
// Render only when enough space for the label to see
float requiredsize = textlabelsizecache [ group . Value [ 0 ] ] / 2 / renderer . Scale ;
if ( requiredsize > group . Key . Labels [ i ] . radius )
{
requiredsize = textlabelsizecache [ group . Value [ 1 ] ] / 2 / renderer . Scale ;
string newtext ;
if ( requiredsize > group . Key . Labels [ i ] . radius )
newtext = ( requiredsize > group . Key . Labels [ i ] . radius * 4 ? string . Empty : "+" ) ;
else
newtext = group . Value [ 1 ] ;
if ( l . Text ! = newtext )
l . Text = newtext ;
}
else
{
if ( group . Value [ 0 ] ! = l . Text )
l . Text = group . Value [ 0 ] ;
}
if ( ! string . IsNullOrEmpty ( l . Text ) ) torender . Add ( l ) ;
}
}
// Render labels
renderer . RenderText ( torender ) ;
}
//mxd. Render selection labels
if ( BuilderPlug . Me . ViewSelectionNumbers )
{
List < ITextLabel > torender = new List < ITextLabel > ( labels . Count ) ;
foreach ( KeyValuePair < Linedef , SelectionLabel > group in labels )
{
// Render only when enough space for the label to see
group . Value . Move ( group . Key . Start . Position , group . Key . End . Position ) ;
float requiredsize = ( group . Value . TextSize . Width ) / renderer . Scale ;
if ( group . Key . Length > requiredsize )
{
torender . Add ( group . Value . TextLabel ) ;
}
}
renderer . RenderText ( torender ) ;
}
//mxd. Render comments
if ( General . Map . UDMF & & General . Settings . RenderComments ) foreach ( Linedef l in General . Map . Map . Linedefs ) RenderComment ( l ) ;
renderer . Finish ( ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
2020-10-31 15:09:22 +00:00
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Events
public override void OnHelp ( )
{
General . ShowHelp ( "e_linedefs.html" ) ;
}
// Cancel mode
public override void OnCancel ( )
{
base . OnCancel ( ) ;
// Return to this mode
General . Editing . ChangeMode ( new LinedefsMode ( ) ) ;
}
// Mode engages
public override void OnEngage ( )
{
base . OnEngage ( ) ;
renderer . SetPresentation ( Presentation . Standard ) ;
// Add toolbar buttons
2016-04-04 22:20:49 +00:00
General . Interface . BeginToolbarUpdate ( ) ; //mxd
2010-08-15 13:45:43 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . CopyProperties ) ;
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . PasteProperties ) ;
2014-04-09 10:16:33 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . PastePropertiesOptions ) ; //mxd
2010-08-15 13:45:43 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . SeparatorCopyPaste ) ;
2016-04-04 22:20:49 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . ViewSelectionNumbers ) ; //mxd
BuilderPlug . Me . MenusForm . ViewSelectionEffects . Text = "View Sector Tags" ; //mxd
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . ViewSelectionEffects ) ; //mxd
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . SeparatorSectors1 ) ; //mxd
2015-02-24 20:25:42 +00:00
if ( General . Map . UDMF ) //mxd
{
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . MakeGradientBrightness ) ;
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . GradientInterpolationMenu ) ;
}
2009-04-19 18:07:22 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . CurveLinedefs ) ;
2015-11-03 08:54:56 +00:00
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . MarqueSelectTouching ) ; //mxd
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . SyncronizeThingEditButton ) ; //mxd
2020-05-03 15:25:07 +00:00
if ( General . Map . UDMF )
{
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . TextureOffsetLock , ToolbarSection . Geometry ) ; //mxd
General . Interface . AddButton ( BuilderPlug . Me . MenusForm . TextureOffset3DFloorLock , ToolbarSection . Geometry ) ;
}
2015-11-03 08:54:56 +00:00
//mxd. Update the tooltip
BuilderPlug . Me . MenusForm . SyncronizeThingEditButton . ToolTipText = "Synchronized Things Editing" + Environment . NewLine + BuilderPlug . Me . MenusForm . SyncronizeThingEditLinedefsItem . ToolTipText ;
2016-04-04 22:20:49 +00:00
General . Interface . EndToolbarUpdate ( ) ; //mxd
2015-11-03 08:54:56 +00:00
2020-10-31 15:09:22 +00:00
// Create the blockmap
CreateBlockmap ( ) ;
2009-04-19 18:07:22 +00:00
// Convert geometry selection to linedefs selection
General . Map . Map . ConvertSelection ( SelectionType . Linedefs ) ;
2014-05-08 09:24:32 +00:00
UpdateSelectionInfo ( ) ; //mxd
2016-04-04 22:20:49 +00:00
SetupSectorLabels ( ) ; //mxd
2009-04-19 18:07:22 +00:00
}
// Mode disengages
public override void OnDisengage ( )
{
base . OnDisengage ( ) ;
// Remove toolbar buttons
2016-04-04 22:20:49 +00:00
General . Interface . BeginToolbarUpdate ( ) ; //mxd
2010-08-15 13:45:43 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . CopyProperties ) ;
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . PasteProperties ) ;
2014-04-09 10:16:33 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . PastePropertiesOptions ) ; //mxd
2010-08-15 13:45:43 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . SeparatorCopyPaste ) ;
2016-04-04 22:20:49 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . ViewSelectionNumbers ) ; //mxd
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . ViewSelectionEffects ) ; //mxd
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . SeparatorSectors1 ) ; //mxd
2016-11-26 00:02:56 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . MakeGradientBrightness ) ;
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . GradientInterpolationMenu ) ;
2009-04-19 18:07:22 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . CurveLinedefs ) ;
2015-11-03 08:54:56 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . MarqueSelectTouching ) ; //mxd
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . SyncronizeThingEditButton ) ; //mxd
2016-11-26 00:02:56 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . TextureOffsetLock ) ; //mxd
2020-05-03 15:25:07 +00:00
General . Interface . RemoveButton ( BuilderPlug . Me . MenusForm . TextureOffset3DFloorLock ) ;
2016-04-04 22:20:49 +00:00
General . Interface . EndToolbarUpdate ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Going to EditSelectionMode?
2016-03-18 12:52:12 +00:00
EditSelectionMode mode = General . Editing . NewMode as EditSelectionMode ;
if ( mode ! = null )
2009-04-19 18:07:22 +00:00
{
2009-08-19 11:42:20 +00:00
// Not pasting anything?
2016-03-18 12:52:12 +00:00
if ( ! mode . Pasting )
2009-04-19 18:07:22 +00:00
{
2009-08-19 11:42:20 +00:00
// No selection made? But we have a highlight!
if ( ( General . Map . Map . GetSelectedLinedefs ( true ) . Count = = 0 ) & & ( highlighted ! = null ) )
{
// Make the highlight the selection
highlighted . Selected = true ;
}
2009-04-19 18:07:22 +00:00
}
}
2015-07-14 09:02:48 +00:00
// Hide highlight info and tooltip
2009-04-19 18:07:22 +00:00
General . Interface . HideInfo ( ) ;
2015-07-14 09:02:48 +00:00
General . Interface . Display . HideToolTip ( ) ; //mxd
2009-04-19 18:07:22 +00:00
}
// This redraws the display
public override void OnRedrawDisplay ( )
{
renderer . RedrawSurface ( ) ;
2015-06-24 21:21:19 +00:00
List < Line3D > eventlines = new List < Line3D > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Render lines
if ( renderer . StartPlotter ( true ) )
{
renderer . PlotLinedefSet ( General . Map . Map . Linedefs ) ;
2013-11-08 08:18:33 +00:00
2009-04-19 18:07:22 +00:00
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
2020-07-16 20:01:37 +00:00
//BuilderPlug.PlotReverseAssociations(renderer, highlightasso, eventlines);
highlightasso . Plot ( ) ;
2009-04-19 18:07:22 +00:00
renderer . PlotLinedef ( highlighted , General . Colors . Highlight ) ;
}
renderer . PlotVerticesSet ( General . Map . Map . Vertices ) ;
renderer . Finish ( ) ;
}
// Render things
if ( renderer . StartThings ( true ) )
{
2016-03-30 11:29:39 +00:00
renderer . RenderThingSet ( General . Map . ThingsFilter . HiddenThings , General . Settings . HiddenThingsAlpha ) ;
2016-04-01 10:49:19 +00:00
renderer . RenderThingSet ( General . Map . ThingsFilter . VisibleThings , General . Settings . ActiveThingsAlpha ) ;
2009-04-19 18:07:22 +00:00
renderer . Finish ( ) ;
}
2022-02-06 12:55:37 +00:00
// Render the overlay with the text labels and ve
RenderOverlay ( ) ;
2009-04-19 18:07:22 +00:00
renderer . Present ( ) ;
}
// Selection
protected override void OnSelectBegin ( )
{
// Item highlighted?
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
// Update display
if ( renderer . StartPlotter ( false ) )
{
// Redraw highlight to show selection
renderer . PlotLinedef ( highlighted , renderer . DetermineLinedefColor ( highlighted ) ) ;
renderer . PlotVertex ( highlighted . Start , renderer . DetermineVertexColor ( highlighted . Start ) ) ;
renderer . PlotVertex ( highlighted . End , renderer . DetermineVertexColor ( highlighted . End ) ) ;
renderer . Finish ( ) ;
renderer . Present ( ) ;
}
}
base . OnSelectBegin ( ) ;
}
// End selection
protected override void OnSelectEnd ( )
{
// Not stopping from multiselection?
if ( ! selecting )
{
// Item highlighted?
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
2013-03-18 13:52:27 +00:00
//mxd. Flip selection
highlighted . Selected = ! highlighted . Selected ;
2016-04-04 22:20:49 +00:00
UpdateSelectionInfo ( ) ; //mxd
//mxd. Full redraw when labels were changed
if ( BuilderPlug . Me . ViewSelectionNumbers )
{
General . Interface . RedrawDisplay ( ) ;
}
2009-04-19 18:07:22 +00:00
// Update display
2016-04-04 22:20:49 +00:00
else if ( renderer . StartPlotter ( false ) )
2009-04-19 18:07:22 +00:00
{
// Render highlighted item
renderer . PlotLinedef ( highlighted , General . Colors . Highlight ) ;
renderer . PlotVertex ( highlighted . Start , renderer . DetermineVertexColor ( highlighted . Start ) ) ;
renderer . PlotVertex ( highlighted . End , renderer . DetermineVertexColor ( highlighted . End ) ) ;
renderer . Finish ( ) ;
renderer . Present ( ) ;
}
2014-12-03 23:15:26 +00:00
}
else if ( BuilderPlug . Me . AutoClearSelection & & General . Map . Map . SelectedLinedefsCount > 0 ) //mxd
{
2013-03-28 11:37:08 +00:00
General . Map . Map . ClearSelectedLinedefs ( ) ;
2016-04-04 22:20:49 +00:00
UpdateSelectionInfo ( ) ; //mxd
2013-03-28 11:37:08 +00:00
General . Interface . RedrawDisplay ( ) ;
2009-04-19 18:07:22 +00:00
}
}
base . OnSelectEnd ( ) ;
}
// Start editing
protected override void OnEditBegin ( )
{
// Item highlighted?
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
// Edit pressed in this mode
editpressed = true ;
// Highlighted item not selected?
2022-09-18 14:54:09 +00:00
if ( ! highlighted . Selected )
2009-04-19 18:07:22 +00:00
{
// Make this the only selection
General . Map . Map . ClearSelectedLinedefs ( ) ;
2022-09-20 21:52:41 +00:00
editlines = new List < Linedef > { highlighted } ;
2016-09-27 19:39:46 +00:00
UpdateSelectionInfo ( ) ; //mxd
2009-04-19 18:07:22 +00:00
General . Interface . RedrawDisplay ( ) ;
}
2022-09-18 14:54:09 +00:00
else
{
2022-09-20 21:52:41 +00:00
editlines = General . Map . Map . GetSelectedLinedefs ( true ) ;
2022-09-18 14:54:09 +00:00
}
2009-04-19 18:07:22 +00:00
// Update display
if ( renderer . StartPlotter ( false ) )
{
// Redraw highlight to show selection
2022-09-18 14:54:09 +00:00
renderer . PlotLinedef ( highlighted , General . Colors . Highlight ) ;
2009-04-19 18:07:22 +00:00
renderer . PlotVertex ( highlighted . Start , renderer . DetermineVertexColor ( highlighted . Start ) ) ;
renderer . PlotVertex ( highlighted . End , renderer . DetermineVertexColor ( highlighted . End ) ) ;
renderer . Finish ( ) ;
renderer . Present ( ) ;
}
}
2013-12-05 09:24:55 +00:00
else if ( ! selecting & & BuilderPlug . Me . AutoDrawOnEdit ) //mxd. We don't want to draw while multiselecting
2009-04-19 18:07:22 +00:00
{
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode ( ) ;
bool snaptogrid = General . Interface . ShiftState ^ General . Interface . SnapToGrid ;
bool snaptonearest = General . Interface . CtrlState ^ General . Interface . AutoMerge ;
2016-04-21 21:00:58 +00:00
DrawnVertex v = DrawGeometryMode . GetCurrentPosition ( mousemappos , snaptonearest , snaptogrid , false , false , renderer , new List < DrawnVertex > ( ) ) ;
2010-08-13 18:32:21 +00:00
2015-12-28 15:01:53 +00:00
if ( drawmode . DrawPointAt ( v ) )
2010-08-13 18:32:21 +00:00
General . Editing . ChangeMode ( drawmode ) ;
else
General . Interface . DisplayStatus ( StatusType . Warning , "Failed to draw point: outside of map boundaries." ) ;
2009-04-19 18:07:22 +00:00
}
base . OnEditBegin ( ) ;
}
// Done editing
protected override void OnEditEnd ( )
{
// Edit pressed in this mode?
if ( editpressed )
{
2022-09-20 21:52:41 +00:00
if ( editlines ? . Count > 0 )
2009-04-19 18:07:22 +00:00
{
if ( General . Interface . IsActiveWindow )
{
// Show line edit dialog
2019-09-17 18:22:51 +00:00
General . Interface . OnEditFormValuesChanged + = linedefEditForm_OnValuesChanged ;
2022-09-18 14:54:09 +00:00
DialogResult result = General . Interface . ShowEditLinedefs ( editlines ) ;
2019-09-17 18:22:51 +00:00
General . Interface . OnEditFormValuesChanged - = linedefEditForm_OnValuesChanged ;
2009-04-19 18:07:22 +00:00
General . Map . Map . Update ( ) ;
// Update entire display
2019-09-17 18:22:51 +00:00
SetupSectorLabels ( ) ;
2013-07-29 08:50:50 +00:00
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ; //mxd
2016-09-27 19:39:46 +00:00
UpdateSelectionInfo ( ) ; //mxd
2009-04-19 18:07:22 +00:00
General . Interface . RedrawDisplay ( ) ;
}
}
}
editpressed = false ;
base . OnEditEnd ( ) ;
}
2016-04-04 22:20:49 +00:00
2019-09-17 18:22:51 +00:00
private void linedefEditForm_OnValuesChanged ( object sender , EventArgs e )
{
// This does nothing. It prevents automatic OnRedrawDisplay when closing the linedef edit form
// Required to prevent crash from issue #298
}
2016-04-04 22:20:49 +00:00
//mxd
public override void OnUndoEnd ( )
{
base . OnUndoEnd ( ) ;
2020-10-31 15:09:22 +00:00
// Recreate the blockmap to not include the potentially un-done lines anymore
CreateBlockmap ( ) ;
2021-10-24 17:22:00 +00:00
// Select changed map elements
if ( BuilderPlug . Me . SelectChangedafterUndoRedo )
{
General . Map . Map . SelectMarkedGeometry ( true , true ) ;
General . Map . Map . ConvertSelection ( SelectionType . Linedefs ) ;
}
2020-10-09 16:53:10 +00:00
// If something is highlighted make sure to update the association so that it contains valid data
if ( highlighted ! = null & & ! highlighted . IsDisposed )
highlightasso . Set ( highlighted ) ;
2016-09-18 23:46:24 +00:00
// Update selection info and labels
UpdateSelectionInfo ( ) ;
SetupSectorLabels ( ) ;
2016-04-04 22:20:49 +00:00
}
//mxd
public override void OnRedoEnd ( )
{
base . OnRedoEnd ( ) ;
2020-10-31 15:09:22 +00:00
// Recreate the blockmap to include the potentially re-done linedefs again
CreateBlockmap ( ) ;
2021-10-24 17:22:00 +00:00
// Select changed map elements
if ( BuilderPlug . Me . SelectChangedafterUndoRedo )
{
General . Map . Map . SelectMarkedGeometry ( true , true ) ;
General . Map . Map . ConvertSelection ( SelectionType . Linedefs ) ;
}
2020-10-09 16:53:10 +00:00
// If something is highlighted make sure to update the association so that it contains valid data
if ( highlighted ! = null & & ! highlighted . IsDisposed )
highlightasso . Set ( highlighted ) ;
2016-09-18 23:46:24 +00:00
// Update selection info and labels
UpdateSelectionInfo ( ) ;
SetupSectorLabels ( ) ;
2016-04-04 22:20:49 +00:00
}
2021-11-28 13:00:24 +00:00
public override void OnScriptRunEnd ( )
{
base . OnScriptRunEnd ( ) ;
// The script might have added new geometry
CreateBlockmap ( ) ;
UpdateSelectionInfo ( ) ;
SetupSectorLabels ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
2009-04-19 18:07:22 +00:00
// Mouse moves
public override void OnMouseMove ( MouseEventArgs e )
{
base . OnMouseMove ( e ) ;
2022-02-04 23:44:04 +00:00
2015-06-24 21:21:19 +00:00
if ( panning ) return ; //mxd. Skip all this jazz while panning
2009-04-19 18:07:22 +00:00
2013-03-18 13:52:27 +00:00
//mxd
2014-12-03 23:15:26 +00:00
if ( selectpressed & & ! editpressed & & ! selecting )
{
2013-03-18 13:52:27 +00:00
// Check if moved enough pixels for multiselect
Vector2D delta = mousedownpos - mousepos ;
2017-08-24 13:24:03 +00:00
if ( ( Math . Abs ( delta . x ) > BuilderPlug . Me . MouseSelectionThreshold ) | |
( Math . Abs ( delta . y ) > BuilderPlug . Me . MouseSelectionThreshold ) )
2014-12-03 23:15:26 +00:00
{
2013-03-18 13:52:27 +00:00
// Start multiselecting
StartMultiSelection ( ) ;
}
}
2013-03-28 12:31:37 +00:00
else if ( paintselectpressed & & ! editpressed & & ! selecting ) //mxd. Drag-select
2013-03-18 13:52:27 +00:00
{
// Find the nearest thing within highlight range
2020-10-31 15:09:22 +00:00
Linedef l = MapSet . NearestLinedefRange ( blockmap , mousemappos , BuilderPlug . Me . HighlightRange / renderer . Scale ) ;
2013-03-18 13:52:27 +00:00
2014-12-03 23:15:26 +00:00
if ( l ! = null )
{
if ( l ! = highlighted )
{
2013-03-18 13:52:27 +00:00
//toggle selected state
2019-06-20 13:38:41 +00:00
if ( General . Interface . ShiftState ^ BuilderPlug . Me . AdditivePaintSelect )
2013-03-18 13:52:27 +00:00
l . Selected = true ;
else if ( General . Interface . CtrlState )
l . Selected = false ;
else
l . Selected = ! l . Selected ;
highlighted = l ;
2014-05-08 09:24:32 +00:00
UpdateSelectionInfo ( ) ; //mxd
2013-07-09 11:29:10 +00:00
2013-03-18 13:52:27 +00:00
// Update entire display
General . Interface . RedrawDisplay ( ) ;
}
2014-12-03 23:15:26 +00:00
}
else if ( highlighted ! = null )
{
2013-03-18 13:52:27 +00:00
Highlight ( null ) ;
// Update entire display
General . Interface . RedrawDisplay ( ) ;
}
}
else if ( e . Button = = MouseButtons . None ) // Not holding any buttons?
2009-04-19 18:07:22 +00:00
{
// Find the nearest linedef within highlight range
2020-10-31 15:09:22 +00:00
Linedef l = MapSet . NearestLinedefRange ( blockmap , mousemappos , BuilderPlug . Me . HighlightRange / renderer . Scale ) ;
2009-04-19 18:07:22 +00:00
2014-01-23 13:55:03 +00:00
//mxd. Render insert vertex preview
2020-10-31 15:09:22 +00:00
Linedef sl = MapSet . NearestLinedefRange ( blockmap , mousemappos , BuilderPlug . Me . StitchRange / renderer . Scale ) ;
if ( sl ! = null )
2014-12-03 23:15:26 +00:00
{
2014-01-23 13:55:03 +00:00
bool snaptogrid = General . Interface . ShiftState ^ General . Interface . SnapToGrid ;
bool snaptonearest = General . Interface . CtrlState ^ General . Interface . AutoMerge ;
2022-02-04 23:44:04 +00:00
Vector2D v = DrawGeometryMode . GetCurrentPosition ( mousemappos , snaptonearest , snaptogrid , false , false , renderer , new List < DrawnVertex > ( ) , blockmap ) . pos ;
if ( v ! = insertpreview )
2014-12-03 23:15:26 +00:00
{
2015-06-25 22:44:13 +00:00
insertpreview = v ;
2022-02-04 23:44:04 +00:00
2022-02-06 12:55:37 +00:00
// Render overlay to show the new insert preview. Do not redraw the whole display for performance reasons.
// We need to present ourselves because RenderOverlay does not do it
RenderOverlay ( ) ;
renderer . Present ( ) ;
2014-01-23 13:55:03 +00:00
}
2014-12-03 23:15:26 +00:00
}
2015-06-25 22:44:13 +00:00
else if ( insertpreview . IsFinite ( ) )
2014-12-03 23:15:26 +00:00
{
2015-06-25 22:44:13 +00:00
insertpreview . x = float . NaN ;
2022-02-04 23:44:04 +00:00
2022-02-06 12:55:37 +00:00
// Render overlay to show the new insert preview. Do not redraw the whole display for performance reasons
// We need to present ourselves because RenderOverlay does not do it
RenderOverlay ( ) ;
renderer . Present ( ) ;
2014-01-23 13:55:03 +00:00
}
2009-04-19 18:07:22 +00:00
// Highlight if not the same
2022-02-06 12:55:37 +00:00
if ( l ! = highlighted ) Highlight ( l ) ;
2015-07-14 09:02:48 +00:00
//mxd. Show tooltip?
2015-07-15 09:09:47 +00:00
if ( General . Map . UDMF & & General . Settings . RenderComments & & mouselastpos ! = mousepos & & highlighted ! = null & & ! highlighted . IsDisposed & & highlighted . Fields . ContainsKey ( "comment" ) )
2015-07-14 09:02:48 +00:00
{
string comment = highlighted . Fields . GetValue ( "comment" , string . Empty ) ;
2015-07-14 23:34:31 +00:00
if ( comment . Length > 2 )
{
string type = comment . Substring ( 0 , 3 ) ;
int index = Array . IndexOf ( CommentType . Types , type ) ;
if ( index > 0 ) comment = comment . TrimStart ( type . ToCharArray ( ) ) ;
}
2015-07-14 09:02:48 +00:00
General . Interface . Display . ShowToolTip ( "Comment:" , comment , ( int ) ( mousepos . x + 32 * MainForm . DPIScaler . Width ) , ( int ) ( mousepos . y + 8 * MainForm . DPIScaler . Height ) ) ;
}
2013-03-18 13:52:27 +00:00
}
2009-04-19 18:07:22 +00:00
}
// Mouse leaves
public override void OnMouseLeave ( EventArgs e )
{
base . OnMouseLeave ( e ) ;
// Highlight nothing
Highlight ( null ) ;
}
2014-01-23 13:55:03 +00:00
//mxd
2014-12-03 23:15:26 +00:00
protected override void BeginViewPan ( )
{
2015-08-04 23:28:02 +00:00
// We don't want vertex preview while panning
2022-02-04 23:44:04 +00:00
insertpreview . x = double . NaN ;
2014-01-23 13:55:03 +00:00
base . BeginViewPan ( ) ;
}
2013-03-18 13:52:27 +00:00
//mxd
2014-12-03 23:15:26 +00:00
protected override void OnPaintSelectBegin ( )
{
2015-09-04 12:44:09 +00:00
// Highlight nothing
Highlight ( null ) ;
2013-03-18 13:52:27 +00:00
base . OnPaintSelectBegin ( ) ;
}
2009-04-19 18:07:22 +00:00
// Mouse wants to drag
protected override void OnDragStart ( MouseEventArgs e )
{
base . OnDragStart ( e ) ;
// Edit button used?
if ( General . Actions . CheckActionActive ( null , "classicedit" ) )
{
// Anything highlighted?
if ( ( highlighted ! = null ) & & ! highlighted . IsDisposed )
{
2022-09-20 21:52:41 +00:00
ICollection < Linedef > draglines ;
2022-09-18 14:54:09 +00:00
2009-04-19 18:07:22 +00:00
// Highlighted item not selected?
if ( ! highlighted . Selected )
{
// Select only this linedef for dragging
General . Map . Map . ClearSelectedLinedefs ( ) ;
2022-09-20 21:52:41 +00:00
draglines = new List < Linedef > { highlighted } ;
2022-09-18 14:54:09 +00:00
}
else
{
// Add all selected linedefs to the linedefs we want to drag
2022-09-20 21:52:41 +00:00
draglines = General . Map . Map . GetSelectedLinedefs ( true ) ;
2009-04-19 18:07:22 +00:00
}
// Start dragging the selection
2023-08-26 11:49:00 +00:00
if ( ! BuilderPlug . Me . DontMoveGeometryOutsideMapBoundary | | CanDrag ( draglines ) ) //mxd
2022-09-18 14:54:09 +00:00
General . Editing . ChangeMode ( new DragLinedefsMode ( mousedownmappos , draglines ) ) ;
2013-03-18 13:52:27 +00:00
}
}
}
//mxd. Check if any selected linedef is outside of map boundary
2023-08-26 11:49:00 +00:00
private static bool CanDrag ( ICollection < Linedef > draglines )
2014-05-20 09:09:28 +00:00
{
2013-03-18 13:52:27 +00:00
int unaffectedCount = 0 ;
2023-08-26 11:49:00 +00:00
foreach ( Linedef l in draglines )
2014-12-03 23:15:26 +00:00
{
2013-03-18 13:52:27 +00:00
// Make sure the linedef is inside the map boundary
if ( l . Start . Position . x < General . Map . Config . LeftBoundary | | l . Start . Position . x > General . Map . Config . RightBoundary
| | l . Start . Position . y > General . Map . Config . TopBoundary | | l . Start . Position . y < General . Map . Config . BottomBoundary
| | l . End . Position . x < General . Map . Config . LeftBoundary | | l . End . Position . x > General . Map . Config . RightBoundary
2014-12-03 23:15:26 +00:00
| | l . End . Position . y > General . Map . Config . TopBoundary | | l . End . Position . y < General . Map . Config . BottomBoundary )
{
2013-03-18 13:52:27 +00:00
unaffectedCount + + ;
2009-04-19 18:07:22 +00:00
}
}
2013-03-18 13:52:27 +00:00
2023-08-26 11:49:00 +00:00
if ( unaffectedCount = = draglines . Count )
2014-12-03 23:15:26 +00:00
{
2023-08-26 11:49:00 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Unable to drag selection: " + ( draglines . Count = = 1 ? "selected linedef is" : "all of selected linedefs are" ) + " outside of map boundary!" ) ;
2013-03-18 13:52:27 +00:00
General . Interface . RedrawDisplay ( ) ;
return false ;
}
2023-08-26 11:49:00 +00:00
if ( unaffectedCount > 0 )
{
2013-03-18 13:52:27 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , unaffectedCount + " of selected linedefs " + ( unaffectedCount = = 1 ? "is" : "are" ) + " outside of map boundary!" ) ;
2023-08-26 11:49:00 +00:00
return false ;
}
2013-03-18 13:52:27 +00:00
return true ;
2009-04-19 18:07:22 +00:00
}
// This is called wheh selection ends
protected override void OnEndMultiSelection ( )
{
2013-12-20 09:24:43 +00:00
bool selectionvolume = ( ( Math . Abs ( selectionrect . Width ) > 0.1f ) & & ( Math . Abs ( selectionrect . Height ) > 0.1f ) ) ;
2009-08-19 11:09:10 +00:00
if ( selectionvolume )
2009-04-19 18:07:22 +00:00
{
2016-04-22 20:17:21 +00:00
List < Line2D > selectionoutline = new List < Line2D >
2014-12-03 23:15:26 +00:00
{
2013-11-29 14:45:29 +00:00
new Line2D ( selectionrect . Left , selectionrect . Top , selectionrect . Right , selectionrect . Top ) ,
new Line2D ( selectionrect . Right , selectionrect . Top , selectionrect . Right , selectionrect . Bottom ) ,
new Line2D ( selectionrect . Left , selectionrect . Bottom , selectionrect . Right , selectionrect . Bottom ) ,
new Line2D ( selectionrect . Left , selectionrect . Bottom , selectionrect . Left , selectionrect . Top )
2014-12-03 23:15:26 +00:00
} ;
2013-11-29 14:45:29 +00:00
2013-03-18 13:52:27 +00:00
//mxd
2015-11-03 08:54:56 +00:00
bool selectthings = ( marqueSelectionIncludesThings ^ BuilderPlug . Me . SyncronizeThingEdit ) ;
2014-12-03 23:15:26 +00:00
switch ( marqueSelectionMode )
{
2013-12-20 09:24:43 +00:00
case MarqueSelectionMode . SELECT :
2016-04-22 20:17:21 +00:00
// Get ordered selection
List < Linedef > selectresult = GetOrderedSelection ( base . selectstart , selectionoutline ) ;
// First deselect everything...
foreach ( Linedef l in General . Map . Map . Linedefs ) l . Selected = false ;
// Then select lines in correct order
foreach ( Linedef l in selectresult ) l . Selected = true ;
2015-11-03 08:54:56 +00:00
if ( selectthings )
{
foreach ( Thing t in General . Map . ThingsFilter . VisibleThings )
2020-05-21 12:20:02 +00:00
t . Selected = selectionrect . Contains ( ( float ) t . Position . x , ( float ) t . Position . y ) ;
2015-11-03 08:54:56 +00:00
}
2013-12-20 09:24:43 +00:00
break ;
case MarqueSelectionMode . ADD :
2016-04-22 20:17:21 +00:00
// Get ordered selection
List < Linedef > addresult = GetOrderedSelection ( selectstart , selectionoutline ) ;
// First deselect everything inside of selection...
foreach ( Linedef l in addresult ) l . Selected = false ;
// Then reselect in correct order
foreach ( Linedef l in addresult ) l . Selected = true ;
2015-11-03 08:54:56 +00:00
if ( selectthings )
{
foreach ( Thing t in General . Map . ThingsFilter . VisibleThings )
2020-05-21 12:20:02 +00:00
t . Selected | = selectionrect . Contains ( ( float ) t . Position . x , ( float ) t . Position . y ) ;
2015-11-03 08:54:56 +00:00
}
2013-12-20 09:24:43 +00:00
break ;
case MarqueSelectionMode . SUBTRACT :
2016-04-22 20:17:21 +00:00
// Selection order doesn't matter here
2013-12-20 09:24:43 +00:00
foreach ( Linedef l in General . Map . Map . Linedefs )
2016-04-22 20:17:21 +00:00
if ( IsInSelectionRect ( l , selectionoutline ) ) l . Selected = false ;
2015-11-03 08:54:56 +00:00
if ( selectthings )
{
foreach ( Thing t in General . Map . ThingsFilter . VisibleThings )
2020-05-21 12:20:02 +00:00
if ( selectionrect . Contains ( ( float ) t . Position . x , ( float ) t . Position . y ) ) t . Selected = false ;
2015-11-03 08:54:56 +00:00
}
2013-12-20 09:24:43 +00:00
break ;
2016-04-22 20:17:21 +00:00
// Should be Intersect selection mode
2013-12-20 09:24:43 +00:00
default :
2016-04-22 20:17:21 +00:00
// Selection order doesn't matter here
2013-12-20 09:24:43 +00:00
foreach ( Linedef l in General . Map . Map . Linedefs )
2016-04-22 20:17:21 +00:00
if ( ! IsInSelectionRect ( l , selectionoutline ) ) l . Selected = false ;
2015-11-03 08:54:56 +00:00
if ( selectthings )
{
foreach ( Thing t in General . Map . ThingsFilter . VisibleThings )
2020-05-21 12:20:02 +00:00
if ( ! selectionrect . Contains ( ( float ) t . Position . x , ( float ) t . Position . y ) ) t . Selected = false ;
2015-11-03 08:54:56 +00:00
}
2013-12-20 09:24:43 +00:00
break ;
2009-04-19 18:07:22 +00:00
}
2013-07-09 11:29:10 +00:00
//mxd
2014-05-08 09:24:32 +00:00
UpdateSelectionInfo ( ) ;
2009-04-19 18:07:22 +00:00
}
base . OnEndMultiSelection ( ) ;
// Clear overlay
if ( renderer . StartOverlay ( true ) ) renderer . Finish ( ) ;
// Redraw
General . Interface . RedrawDisplay ( ) ;
}
// This is called when the selection is updated
protected override void OnUpdateMultiSelection ( )
{
base . OnUpdateMultiSelection ( ) ;
// Render selection
if ( renderer . StartOverlay ( true ) )
{
RenderMultiSelection ( ) ;
renderer . Finish ( ) ;
renderer . Present ( ) ;
}
}
// When copying
public override bool OnCopyBegin ( )
{
// No selection made? But we have a highlight!
if ( ( General . Map . Map . GetSelectedLinedefs ( true ) . Count = = 0 ) & & ( highlighted ! = null ) )
{
// Make the highlight the selection
highlighted . Selected = true ;
2015-04-16 13:03:12 +00:00
//mxd. Actually, we want it marked, not selected
bool result = base . OnCopyBegin ( ) ;
highlighted . Selected = false ;
return result ;
2009-04-19 18:07:22 +00:00
}
return base . OnCopyBegin ( ) ;
}
2022-02-03 18:35:10 +00:00
/// <summary>
/// If map elements have changed the blockmap needs to be recreated.
/// </summary>
public override void OnMapElementsChanged ( )
{
base . OnMapElementsChanged ( ) ;
CreateBlockmap ( ) ;
}
2015-07-14 23:34:31 +00:00
//mxd
private void RenderComment ( Linedef l )
{
if ( l . Fields . ContainsKey ( "comment" ) )
{
int iconindex = 0 ;
string comment = l . Fields . GetValue ( "comment" , string . Empty ) ;
if ( comment . Length > 2 )
{
string type = comment . Substring ( 0 , 3 ) ;
int index = Array . IndexOf ( CommentType . Types , type ) ;
if ( index ! = - 1 ) iconindex = index ;
}
Vector2D center = l . GetCenterPoint ( ) ;
2020-05-21 12:20:02 +00:00
RectangleF rect = new RectangleF ( ( float ) ( center . x - 8 / renderer . Scale ) , ( float ) ( center . y + 18 / renderer . Scale ) , 16 / renderer . Scale , - 16 / renderer . Scale ) ;
2015-07-14 23:34:31 +00:00
PixelColor c = ( l = = highlighted ? General . Colors . Highlight : ( l . Selected ? General . Colors . Selection : PixelColor . FromColor ( Color . White ) ) ) ;
renderer . RenderRectangleFilled ( rect , c , true , General . Map . Data . CommentTextures [ iconindex ] ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Actions
2010-08-15 13:45:43 +00:00
// This copies the properties
[BeginAction("classiccopyproperties")]
public void CopyProperties ( )
{
// Determine source linedefs
ICollection < Linedef > sel = null ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
if ( General . Map . Map . SelectedLinedefsCount > 0 ) sel = General . Map . Map . GetSelectedLinedefs ( true ) ;
else if ( highlighted ! = null ) sel = new List < Linedef > { highlighted } ;
2010-08-15 13:45:43 +00:00
if ( sel ! = null )
{
// Copy properties from first source linedef
BuilderPlug . Me . CopiedLinedefProps = new LinedefProperties ( General . GetByIndex ( sel , 0 ) ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Copied linedef properties." ) ;
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
else
{
//mxd
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires highlight or selection!" ) ;
}
2010-08-15 13:45:43 +00:00
}
// This pastes the properties
[BeginAction("classicpasteproperties")]
public void PasteProperties ( )
{
if ( BuilderPlug . Me . CopiedLinedefProps ! = null )
{
// Determine target linedefs
ICollection < Linedef > sel = null ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
if ( General . Map . Map . SelectedLinedefsCount > 0 ) sel = General . Map . Map . GetSelectedLinedefs ( true ) ;
else if ( highlighted ! = null ) sel = new List < Linedef > { highlighted } ;
2010-08-15 13:45:43 +00:00
if ( sel ! = null )
{
// Apply properties to selection
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
string rest = ( sel . Count = = 1 ? "a single linedef" : sel . Count + " linedefs" ) ; //mxd
General . Map . UndoRedo . CreateUndo ( "Paste properties to " + rest ) ;
2016-10-11 12:58:35 +00:00
BuilderPlug . Me . CopiedLinedefProps . Apply ( sel , false ) ;
foreach ( Linedef l in sel ) l . UpdateCache ( ) ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Pasted properties to " + rest + "." ) ;
2010-08-15 13:45:43 +00:00
// Update and redraw
General . Map . IsChanged = true ;
General . Interface . RefreshInfo ( ) ;
2013-07-29 08:50:50 +00:00
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ; //mxd
2010-08-15 13:45:43 +00:00
General . Interface . RedrawDisplay ( ) ;
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
else
{
//mxd
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires highlight or selection!" ) ;
}
}
else
{
//mxd
General . Interface . DisplayStatus ( StatusType . Warning , "Copy linedef properties first!" ) ;
}
}
//mxd. This pastes the properties with options
[BeginAction("classicpastepropertieswithoptions")]
public void PastePropertiesWithOptions ( )
{
if ( BuilderPlug . Me . CopiedLinedefProps ! = null )
{
// Determine target linedefs
ICollection < Linedef > sel = null ;
if ( General . Map . Map . SelectedLinedefsCount > 0 ) sel = General . Map . Map . GetSelectedLinedefs ( true ) ;
else if ( highlighted ! = null ) sel = new List < Linedef > { highlighted } ;
if ( sel ! = null )
{
PastePropertiesOptionsForm form = new PastePropertiesOptionsForm ( ) ;
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
if ( form . Setup ( MapElementType . LINEDEF ) & & form . ShowDialog ( General . Interface ) = = DialogResult . OK )
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
{
// Apply properties to selection
string rest = ( sel . Count = = 1 ? "a single linedef" : sel . Count + " linedefs" ) ;
General . Map . UndoRedo . CreateUndo ( "Paste properties with options to " + rest ) ;
2016-10-11 12:58:35 +00:00
BuilderPlug . Me . CopiedLinedefProps . Apply ( sel , true ) ;
foreach ( Linedef l in sel ) l . UpdateCache ( ) ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Pasted properties with options to " + rest + "." ) ;
// Update and redraw
General . Map . IsChanged = true ;
General . Interface . RefreshInfo ( ) ;
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ; //mxd
General . Interface . RedrawDisplay ( ) ;
}
}
else
{
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires highlight or selection!" ) ;
}
}
else
{
General . Interface . DisplayStatus ( StatusType . Warning , "Copy linedef properties first!" ) ;
2010-08-15 13:45:43 +00:00
}
}
2009-04-19 18:07:22 +00:00
// This keeps only the single-sided lines selected
[BeginAction("selectsinglesided")]
public void SelectSingleSided ( )
{
int counter = 0 ;
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
foreach ( Linedef ld in selected )
{
if ( ( ld . Front ! = null ) & & ( ld . Back ! = null ) )
ld . Selected = false ;
else
counter + + ;
}
2022-08-28 16:25:50 +00:00
UpdateSelectionInfo ( ) ;
2009-04-19 18:07:22 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Selected only single-sided linedefs (" + counter + ")" ) ;
General . Interface . RedrawDisplay ( ) ;
}
// This keeps only the double-sided lines selected
[BeginAction("selectdoublesided")]
public void SelectDoubleSided ( )
{
int counter = 0 ;
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
foreach ( Linedef ld in selected )
{
if ( ( ld . Front = = null ) | | ( ld . Back = = null ) )
ld . Selected = false ;
else
counter + + ;
}
2022-08-28 16:25:50 +00:00
UpdateSelectionInfo ( ) ;
2009-04-19 18:07:22 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Selected only double-sided linedefs (" + counter + ")" ) ;
General . Interface . RedrawDisplay ( ) ;
}
// This clears the selection
[BeginAction("clearselection", BaseAction = true)]
public void ClearSelection ( )
{
// Clear selection
General . Map . Map . ClearAllSelected ( ) ;
2013-12-12 09:07:30 +00:00
//mxd. Clear selection info
2013-07-09 11:29:10 +00:00
General . Interface . DisplayStatus ( StatusType . Selection , string . Empty ) ;
2016-04-04 22:20:49 +00:00
//mxd. Clear selection labels
2016-04-17 22:52:03 +00:00
foreach ( SelectionLabel l in labels . Values ) l . Dispose ( ) ;
2016-04-04 22:20:49 +00:00
labels . Clear ( ) ;
2009-04-19 18:07:22 +00:00
// Redraw
General . Interface . RedrawDisplay ( ) ;
}
// This creates a new vertex at the mouse position
[BeginAction("insertitem", BaseAction = true)]
Fixed, Draw Lines/Rectangle/Circle/Curve modes: line length labels displayed incorrect length.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: line length labels are now displayed the same way as in Draw modes.
Changed, Drag Linedefs/Vertices/Sectors/Things modes: "lock movement to cardinal directions" mode (Alt-Shift-Drag) now locks movement in 4 directions instead of 8 and doesn't snap map elements to nearest grid intersections when they are not aligned to it.
Added, Visual mode, GZDoom, DECORATE: FORCEXYBILLBOARD flag is now supported.
Added, Visual mode, GLOOME, DECORATE: FLOORSPRITE, CEILSPRITE, WALLSPRITE, ROLLSPRITE and STICKTOPLANE flags are now supported (implementation is somewhat broken ATM and probably doesn't work the same way as in GLOOME, because Windows build with most these features is nowhere to be found...).
Fixed, Visual mode: in some cases Thing brightness was calculated incorrectly.
Updated ZDoom_DECORATE.cfg.
2015-08-25 22:05:14 +00:00
public void InsertVertexAction ( )
2009-04-19 18:07:22 +00:00
{
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode ( ) ;
if ( mouseinside )
{
bool snaptogrid = General . Interface . ShiftState ^ General . Interface . SnapToGrid ;
bool snaptonearest = General . Interface . CtrlState ^ General . Interface . AutoMerge ;
2016-04-21 21:00:58 +00:00
DrawnVertex v = DrawGeometryMode . GetCurrentPosition ( mousemappos , snaptonearest , snaptogrid , false , false , renderer , new List < DrawnVertex > ( ) ) ;
2009-04-19 18:07:22 +00:00
drawmode . DrawPointAt ( v ) ;
}
General . Editing . ChangeMode ( drawmode ) ;
}
2014-01-08 09:46:57 +00:00
2009-04-19 18:07:22 +00:00
[BeginAction("deleteitem", BaseAction = true)]
2014-12-03 23:15:26 +00:00
public void DeleteItem ( )
{
2014-01-08 09:46:57 +00:00
// Make list of selected linedefs
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( ( selected . Count = = 0 ) & & ( highlighted ! = null ) & & ! highlighted . IsDisposed ) selected . Add ( highlighted ) ;
if ( selected . Count = = 0 ) return ;
// Make undo
2014-12-03 23:15:26 +00:00
if ( selected . Count > 1 )
{
2014-01-08 09:46:57 +00:00
General . Map . UndoRedo . CreateUndo ( "Delete " + selected . Count + " linedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Deleted " + selected . Count + " linedefs." ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2014-01-08 09:46:57 +00:00
General . Map . UndoRedo . CreateUndo ( "Delete linedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Deleted a linedef." ) ;
}
// Dispose selected linedefs
foreach ( Linedef ld in selected ) ld . Dispose ( ) ;
// Update cache values
General . Map . IsChanged = true ;
General . Map . Map . Update ( ) ;
2020-10-31 15:09:22 +00:00
// Recreate the blockmap since it shouldn't include the deleted linedefs anymore
CreateBlockmap ( ) ;
2014-01-08 09:46:57 +00:00
// Redraw screen
2016-04-22 13:28:23 +00:00
SetupSectorLabels ( ) ; //mxd
2015-06-30 18:34:08 +00:00
UpdateSelectionInfo ( ) ; //mxd
2015-04-06 19:33:57 +00:00
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ; //mxd
2014-01-08 09:46:57 +00:00
General . Interface . RedrawDisplay ( ) ;
2016-04-22 13:28:23 +00:00
// Invoke a new mousemove so that the highlighted item updates
OnMouseMove ( new MouseEventArgs ( MouseButtons . None , 0 , ( int ) mousepos . x , ( int ) mousepos . y , 0 ) ) ;
2014-01-08 09:46:57 +00:00
}
[BeginAction("dissolveitem", BaseAction = true)] //mxd
public void DissolveItem ( )
2009-04-19 18:07:22 +00:00
{
// Make list of selected linedefs
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( ( selected . Count = = 0 ) & & ( highlighted ! = null ) & & ! highlighted . IsDisposed ) selected . Add ( highlighted ) ;
// Anything to do?
if ( selected . Count > 0 )
{
// Make undo
if ( selected . Count > 1 )
{
2014-01-08 09:46:57 +00:00
General . Map . UndoRedo . CreateUndo ( "Dissolve " + selected . Count + " linedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Dissolved " + selected . Count + " linedefs." ) ;
2009-04-19 18:07:22 +00:00
}
else
{
2014-01-08 09:46:57 +00:00
General . Map . UndoRedo . CreateUndo ( "Dissolve linedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Dissolved a linedef." ) ;
2009-04-19 18:07:22 +00:00
}
2013-03-22 12:53:34 +00:00
//mxd. Find sectors, which will become invalid after linedefs removal.
Dictionary < Sector , Vector2D > toMerge = new Dictionary < Sector , Vector2D > ( ) ;
2014-12-03 23:15:26 +00:00
foreach ( Linedef l in selected )
{
2013-03-22 12:53:34 +00:00
if ( l . Front ! = null & & l . Front . Sector . Sidedefs . Count < 4 & & ! toMerge . ContainsKey ( l . Front . Sector ) )
toMerge . Add ( l . Front . Sector , new Vector2D ( l . Front . Sector . BBox . Location . X + l . Front . Sector . BBox . Width / 2 , l . Front . Sector . BBox . Location . Y + l . Front . Sector . BBox . Height / 2 ) ) ;
if ( l . Back ! = null & & l . Back . Sector . Sidedefs . Count < 4 & & ! toMerge . ContainsKey ( l . Back . Sector ) )
toMerge . Add ( l . Back . Sector , new Vector2D ( l . Back . Sector . BBox . Location . X + l . Back . Sector . BBox . Width / 2 , l . Back . Sector . BBox . Location . Y + l . Back . Sector . BBox . Height / 2 ) ) ;
}
2013-12-13 09:31:18 +00:00
General . Map . Map . BeginAddRemove ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Dispose selected linedefs
2014-12-03 23:15:26 +00:00
foreach ( Linedef ld in selected )
{
2013-03-26 12:31:07 +00:00
//mxd. If there are different sectors on both sides, join them
2014-12-03 23:15:26 +00:00
if ( ld . Front ! = null & & ld . Front . Sector ! = null & & ld . Back ! = null
& & ld . Back . Sector ! = null & & ld . Front . Sector . Index ! = ld . Back . Sector . Index )
{
2013-03-26 12:31:07 +00:00
if ( ld . Front . Sector . BBox . Width * ld . Front . Sector . BBox . Height > ld . Back . Sector . BBox . Width * ld . Back . Sector . BBox . Height )
ld . Back . Sector . Join ( ld . Front . Sector ) ;
else
ld . Front . Sector . Join ( ld . Back . Sector ) ;
}
ld . Dispose ( ) ;
}
2013-03-22 12:53:34 +00:00
//mxd
2013-12-13 09:31:18 +00:00
General . Map . Map . EndAddRemove ( ) ;
2013-03-22 12:53:34 +00:00
Tools . MergeInvalidSectors ( toMerge ) ;
2009-04-19 18:07:22 +00:00
// Update cache values
General . Map . IsChanged = true ;
General . Map . Map . Update ( ) ;
2020-10-31 15:09:22 +00:00
// Recreate the blockmap since it shouldn't include the dissolved linedefs anymore
CreateBlockmap ( ) ;
2009-04-19 18:07:22 +00:00
// Redraw screen
2016-04-22 13:28:23 +00:00
SetupSectorLabels ( ) ; //mxd
2015-06-30 18:34:08 +00:00
UpdateSelectionInfo ( ) ; //mxd
2015-04-06 19:33:57 +00:00
General . Map . Renderer2D . UpdateExtraFloorFlag ( ) ; //mxd
2009-04-19 18:07:22 +00:00
General . Interface . RedrawDisplay ( ) ;
2016-04-22 13:28:23 +00:00
// Invoke a new mousemove so that the highlighted item updates
OnMouseMove ( new MouseEventArgs ( MouseButtons . None , 0 , ( int ) mousepos . x , ( int ) mousepos . y , 0 ) ) ;
2009-04-19 18:07:22 +00:00
}
}
[BeginAction("splitlinedefs")]
public void SplitLinedefs ( )
{
// Make list of selected linedefs
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( ( selected . Count = = 0 ) & & ( highlighted ! = null ) & & ! highlighted . IsDisposed ) selected . Add ( highlighted ) ;
// Anything to do?
if ( selected . Count > 0 )
{
// Make undo
if ( selected . Count > 1 )
{
General . Map . UndoRedo . CreateUndo ( "Split " + selected . Count + " linedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Split " + selected . Count + " linedefs." ) ;
}
else
{
General . Map . UndoRedo . CreateUndo ( "Split linedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Split a linedef." ) ;
}
// Go for all linedefs to split
foreach ( Linedef ld in selected )
{
Vertex splitvertex ;
// Linedef highlighted?
if ( ld = = highlighted )
{
// Split at nearest position on the line
Vector2D nearestpos = ld . NearestOnLine ( mousemappos ) ;
splitvertex = General . Map . Map . CreateVertex ( nearestpos ) ;
}
else
{
// Split in middle of line
splitvertex = General . Map . Map . CreateVertex ( ld . GetCenterPoint ( ) ) ;
}
2010-08-15 19:43:00 +00:00
if ( splitvertex = = null )
{
General . Map . UndoRedo . WithdrawUndo ( ) ;
break ;
}
2009-04-19 18:07:22 +00:00
// Snap to map format accuracy
splitvertex . SnapToAccuracy ( ) ;
2010-08-15 19:43:00 +00:00
2009-04-19 18:07:22 +00:00
// Split the line
2010-08-15 19:43:00 +00:00
Linedef sld = ld . Split ( splitvertex ) ;
if ( sld = = null )
{
General . Map . UndoRedo . WithdrawUndo ( ) ;
break ;
}
2014-03-19 13:03:47 +00:00
//BuilderPlug.Me.AdjustSplitCoordinates(ld, sld);
2009-04-19 18:07:22 +00:00
}
2020-11-06 19:14:00 +00:00
// Create the blockmap
CreateBlockmap ( ) ;
2009-04-19 18:07:22 +00:00
// Update cache values
General . Map . IsChanged = true ;
General . Map . Map . Update ( ) ;
// Redraw screen
General . Interface . RedrawDisplay ( ) ;
}
}
[BeginAction("curvelinesmode")]
public void CurveLinedefs ( )
{
// No selected lines?
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( selected . Count = = 0 )
{
// Anything highlighted?
if ( highlighted ! = null )
{
// Select the highlighted item
highlighted . Selected = true ;
selected . Add ( highlighted ) ;
}
}
// Any selected lines?
if ( selected . Count > 0 )
{
// Go into curve linedefs mode
2016-10-26 22:33:36 +00:00
General . Editing . ChangeMode ( new CurveLinedefsMode ( ) ) ;
2009-04-19 18:07:22 +00:00
}
2016-10-31 18:52:29 +00:00
else
{
//mxd
General . Interface . DisplayStatus ( StatusType . Warning , "This action requres a selection!" ) ;
}
2009-04-19 18:07:22 +00:00
}
[BeginAction("fliplinedefs")]
public void FlipLinedefs ( )
{
2021-05-30 16:27:56 +00:00
bool deselect = false ;
2009-04-19 18:07:22 +00:00
// No selected lines?
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( selected . Count = = 0 )
{
// Anything highlighted?
if ( highlighted ! = null )
{
// Select the highlighted item
highlighted . Selected = true ;
selected . Add ( highlighted ) ;
2021-05-30 16:27:56 +00:00
// If nothing was selected we want to deselect the highlighted line when we're done
deselect = true ;
2009-04-19 18:07:22 +00:00
}
}
// Any selected lines?
2016-03-14 10:25:27 +00:00
if ( selected . Count = = 0 )
2009-04-19 18:07:22 +00:00
{
2016-03-14 10:25:27 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires a selection!" ) ;
return ;
}
2016-06-26 22:42:24 +00:00
//mxd. Remove single-sided lines with only front side
int selectedcount = selected . Count ; // Store initial selection size...
List < Linedef > filtered = new List < Linedef > ( selectedcount ) ;
foreach ( Linedef l in selected )
{
if ( l . Back ! = null | | l . Front = = null ) filtered . Add ( l ) ;
}
selected = filtered ;
//mxd. Any valid lines?
if ( selected . Count = = 0 )
{
General . Interface . DisplayStatus ( StatusType . Warning , ( selectedcount > 1 ? "Selected linedefs already point in the right direction!"
: "Selected linedef already points in the right direction!" ) ) ;
2021-05-30 16:27:56 +00:00
// There might be linedefs that were filtered out, so deselect all linedefs (if necessary) anyway
if ( deselect )
General . Map . Map . ClearSelectedLinedefs ( ) ;
2016-06-26 22:42:24 +00:00
return ;
}
2016-03-14 10:25:27 +00:00
// Make undo
if ( selected . Count > 1 )
{
General . Map . UndoRedo . CreateUndo ( "Flip " + selected . Count + " linedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Flipped " + selected . Count + " linedefs." ) ;
}
else
{
General . Map . UndoRedo . CreateUndo ( "Flip linedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Flipped a linedef." ) ;
}
2009-04-19 18:07:22 +00:00
2016-03-14 10:25:27 +00:00
// Flip all selected linedefs
foreach ( Linedef l in selected )
{
l . FlipVertices ( ) ;
l . FlipSidedefs ( ) ;
}
2014-07-07 14:17:49 +00:00
2021-05-30 16:27:56 +00:00
if ( deselect )
General . Map . Map . ClearSelectedLinedefs ( ) ;
2016-03-14 10:25:27 +00:00
// Redraw
General . Map . Map . Update ( ) ;
General . Map . IsChanged = true ;
General . Interface . RefreshInfo ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
[BeginAction("alignlinedefs")]
public void AlignLinedefs ( ) //mxd
{
// No selected lines?
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( selected . Count = = 0 )
{
// Anything highlighted?
if ( highlighted ! = null )
2009-04-19 18:07:22 +00:00
{
2016-03-14 10:25:27 +00:00
// Select the highlighted item
highlighted . Selected = true ;
selected . Add ( highlighted ) ;
2009-04-19 18:07:22 +00:00
}
2016-03-14 10:25:27 +00:00
}
2014-07-07 14:17:49 +00:00
2016-03-14 10:25:27 +00:00
// Any selected lines?
if ( selected . Count = = 0 )
{
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires a selection!" ) ;
return ;
}
2015-05-26 20:10:09 +00:00
2016-03-14 10:25:27 +00:00
// Make undo
if ( selected . Count > 1 )
{
General . Map . UndoRedo . CreateUndo ( "Align " + selected . Count + " linedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Aligned " + selected . Count + " linedefs." ) ;
}
else
{
General . Map . UndoRedo . CreateUndo ( "Align linedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Aligned a linedef." ) ;
}
2015-05-26 20:10:09 +00:00
2016-03-14 10:25:27 +00:00
//mxd. Do it sector-wise
Dictionary < Sector , int > sectors = new Dictionary < Sector , int > ( ) ;
2014-07-07 14:17:49 +00:00
2016-03-14 10:25:27 +00:00
foreach ( Linedef l in selected )
{
if ( l . Front ! = null & & l . Front . Sector ! = null )
{
if ( ! sectors . ContainsKey ( l . Front . Sector ) ) sectors . Add ( l . Front . Sector , 0 ) ;
sectors [ l . Front . Sector ] + + ;
}
if ( l . Back ! = null & & l . Back . Sector ! = null )
2009-04-19 18:07:22 +00:00
{
2016-03-14 10:25:27 +00:00
if ( ! sectors . ContainsKey ( l . Back . Sector ) ) sectors . Add ( l . Back . Sector , 0 ) ;
sectors [ l . Back . Sector ] + + ;
2009-04-19 18:07:22 +00:00
}
2016-03-14 10:25:27 +00:00
}
2009-04-19 18:07:22 +00:00
2016-03-14 10:25:27 +00:00
//mxd. Sort the collection so sectors with the most selected linedefs go first
List < KeyValuePair < Sector , int > > sortedlist = sectors . ToList ( ) ;
sortedlist . Sort ( ( firstPair , nextPair ) = > firstPair . Value . CompareTo ( nextPair . Value ) ) ;
sortedlist . Reverse ( ) ;
//mxd. Gather our ordered sectors
2016-03-18 12:52:12 +00:00
List < Sector > sectorslist = new List < Sector > ( sortedlist . Count ) ;
2016-03-14 10:25:27 +00:00
sectorslist . AddRange ( sortedlist . Select ( pair = > pair . Key ) ) ;
//mxd. Flip the lines
Tools . FlipSectorLinedefs ( sectorslist , true ) ;
// Remove selection if only one linedef was selected
if ( selected . Count = = 1 )
{
foreach ( Linedef ld in selected ) ld . Selected = false ;
selected . Clear ( ) ;
2009-04-19 18:07:22 +00:00
}
2016-03-14 10:25:27 +00:00
// Redraw
General . Map . Map . Update ( ) ;
General . Map . IsChanged = true ;
General . Interface . RefreshInfo ( ) ;
General . Interface . RedrawDisplay ( ) ;
2009-04-19 18:07:22 +00:00
}
[BeginAction("flipsidedefs")]
public void FlipSidedefs ( )
{
// No selected lines?
ICollection < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( selected . Count = = 0 )
{
// Anything highlighted?
if ( highlighted ! = null )
{
selected . Add ( highlighted ) ;
}
}
2016-03-14 10:25:27 +00:00
//mxd. Any selected lines?
if ( selected . Count = = 0 )
{
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires a selection!" ) ;
return ;
}
2014-07-07 14:17:49 +00:00
//mxd. Do this only with double-sided linedefs
List < Linedef > validlines = new List < Linedef > ( ) ;
foreach ( Linedef l in selected )
{
if ( l . Front ! = null & & l . Back ! = null ) validlines . Add ( l ) ;
}
2016-03-14 10:25:27 +00:00
//mxd. Any double-sided lines selected?
if ( validlines . Count = = 0 )
2009-04-19 18:07:22 +00:00
{
2016-03-14 10:25:27 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "No sidedefs to flip! Only 2-sided linedefs can be flipped." ) ;
return ;
}
2009-04-19 18:07:22 +00:00
2016-03-14 10:25:27 +00:00
// Make undo
if ( validlines . Count > 1 )
{
General . Map . UndoRedo . CreateUndo ( "Flip " + validlines . Count + " sidedefs" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Flipped " + validlines . Count + " sidedefs." ) ;
}
else
{
General . Map . UndoRedo . CreateUndo ( "Flip sidedef" ) ;
General . Interface . DisplayStatus ( StatusType . Action , "Flipped a sidedef." ) ;
}
2009-04-19 18:07:22 +00:00
2016-03-14 10:25:27 +00:00
// Flip sidedefs in all selected linedefs
foreach ( Linedef l in validlines )
2014-07-07 14:17:49 +00:00
{
2016-03-14 10:25:27 +00:00
l . FlipSidedefs ( ) ;
l . Front . Sector . UpdateNeeded = true ;
l . Back . Sector . UpdateNeeded = true ;
2009-04-19 18:07:22 +00:00
}
2016-03-14 10:25:27 +00:00
// Redraw
General . Map . Map . Update ( ) ;
General . Map . IsChanged = true ;
General . Interface . RefreshInfo ( ) ;
General . Interface . RedrawDisplay ( ) ;
2009-04-19 18:07:22 +00:00
}
2013-03-18 13:52:27 +00:00
//mxd. Make gradient brightness
[BeginAction("gradientbrightness")]
2014-12-03 23:15:26 +00:00
public void MakeGradientBrightness ( )
{
2013-03-18 13:52:27 +00:00
if ( ! General . Map . UDMF ) return ;
// Need at least 3 selected linedefs
// The first and last are not modified
ICollection < Linedef > orderedselection = General . Map . Map . GetSelectedLinedefs ( true ) ;
2014-12-03 23:15:26 +00:00
if ( orderedselection . Count > 2 )
{
2015-02-24 20:25:42 +00:00
// Gather values
2013-03-18 13:52:27 +00:00
Linedef start = General . GetByIndex ( orderedselection , 0 ) ;
Linedef end = General . GetByIndex ( orderedselection , orderedselection . Count - 1 ) ;
2015-02-24 20:25:42 +00:00
float startbrightness = GetLinedefBrighness ( start ) ;
float endbrightness = GetLinedefBrighness ( end ) ;
2013-03-18 13:52:27 +00:00
2015-02-24 20:25:42 +00:00
if ( float . IsNaN ( startbrightness ) )
2014-12-03 23:15:26 +00:00
{
2015-02-24 20:25:42 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Start linedef doesn't have visible parts!" ) ;
return ;
2013-03-18 13:52:27 +00:00
}
2015-02-24 20:25:42 +00:00
if ( float . IsNaN ( endbrightness ) )
2014-12-03 23:15:26 +00:00
{
2015-02-24 20:25:42 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "End linedef doesn't have visible parts!" ) ;
return ;
2013-03-18 13:52:27 +00:00
}
2015-02-24 20:25:42 +00:00
//Make undo
General . Interface . DisplayStatus ( StatusType . Action , "Created gradient brightness over selected linedefs." ) ;
General . Map . UndoRedo . CreateUndo ( "Linedefs gradient brightness" ) ;
2013-03-18 13:52:27 +00:00
2015-02-24 20:25:42 +00:00
// Apply changes
InterpolationTools . Mode interpolationmode = ( InterpolationTools . Mode ) BuilderPlug . Me . MenusForm . GradientInterpolationMenu . SelectedIndex ;
2013-03-18 13:52:27 +00:00
int index = 0 ;
2015-02-24 20:25:42 +00:00
// Go for all lines in between first and last
2014-12-03 23:15:26 +00:00
foreach ( Linedef l in orderedselection )
{
2013-09-05 13:03:17 +00:00
float u = index / ( float ) ( orderedselection . Count - 1 ) ;
2016-06-03 20:22:07 +00:00
int b = ( int ) Math . Round ( InterpolationTools . Interpolate ( startbrightness , endbrightness , u , interpolationmode ) ) ;
2015-02-24 20:25:42 +00:00
if ( SidedefHasVisibleParts ( l . Front ) ) ApplySidedefBrighness ( l . Front , b ) ;
if ( SidedefHasVisibleParts ( l . Back ) ) ApplySidedefBrighness ( l . Back , b ) ;
2013-03-18 13:52:27 +00:00
index + + ;
}
2014-04-02 10:57:52 +00:00
// Update
General . Map . Map . Update ( ) ;
General . Interface . RedrawDisplay ( ) ;
General . Interface . RefreshInfo ( ) ;
General . Map . IsChanged = true ;
2014-12-03 23:15:26 +00:00
}
else
{
2013-03-18 13:52:27 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Select at least 3 linedefs first!" ) ;
}
2020-04-11 08:42:41 +00:00
}
[BeginAction("smartgridtransform", BaseAction = true)]
protected void SmartGridTransform ( )
{
if ( General . Map . Map . SelectedLinedefsCount > 1 )
{
General . Interface . DisplayStatus ( StatusType . Warning , "Either nothing or exactly one linedef must be selected" ) ;
General . Interface . MessageBeep ( MessageBeepType . Warning ) ;
return ;
}
Linedef linedef = null ;
if ( General . Map . Map . SelectedLinedefsCount = = 1 )
linedef = General . Map . Map . GetSelectedLinedefs ( true ) . First ( ) ;
else if ( highlighted ! = null )
linedef = highlighted ;
if ( linedef ! = null )
{
// Get the vertex that's closest to the mouse cursor
Vertex vertex = ( new Vertex [ ] { linedef . Start , linedef . End } ) . OrderBy ( v = > Vector2D . Distance ( v . Position , mousemappos ) ) . First ( ) ;
General . Map . Grid . SetGridRotation ( linedef . Angle ) ;
General . Map . Grid . SetGridOrigin ( vertex . Position . x , vertex . Position . y ) ;
General . Map . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
else
{
General . Map . Grid . SetGridRotation ( 0.0f ) ;
General . Map . Grid . SetGridOrigin ( 0 , 0 ) ;
General . Map . GridVisibilityChanged ( ) ;
General . Interface . RedrawDisplay ( ) ;
}
2013-03-18 13:52:27 +00:00
}
2015-02-24 20:25:42 +00:00
//mxd. gradientbrightness utility
private static bool SidedefHasVisibleParts ( Sidedef side )
{
if ( side = = null | | side . Sector = = null ) return false ;
return side . HighRequired ( ) | | side . LowRequired ( ) | | ( side . MiddleRequired ( ) | | ( side . Other ! = null & & side . MiddleTexture ! = "-" ) ) ;
}
//mxd. gradientbrightness utility
private static float GetLinedefBrighness ( Linedef line )
{
float frontbrightness = ( SidedefHasVisibleParts ( line . Front ) ? GetSidedefBrighness ( line . Front ) : float . NaN ) ;
float backbrightness = ( SidedefHasVisibleParts ( line . Back ) ? GetSidedefBrighness ( line . Back ) : float . NaN ) ;
if ( float . IsNaN ( frontbrightness ) & & float . IsNaN ( backbrightness ) ) return float . NaN ;
if ( float . IsNaN ( frontbrightness ) ) return backbrightness ;
if ( float . IsNaN ( backbrightness ) ) return frontbrightness ;
return ( frontbrightness + backbrightness ) / 2 ;
}
//mxd. gradientbrightness utility
private static float GetSidedefBrighness ( Sidedef side )
{
if ( side . Fields . GetValue ( "lightabsolute" , false ) ) return side . Fields . GetValue ( "light" , 0 ) ;
return Math . Min ( 255 , Math . Max ( 0 , ( float ) side . Sector . Brightness + side . Fields . GetValue ( "light" , 0 ) ) ) ;
}
//mxd. gradientbrightness utility
private static void ApplySidedefBrighness ( Sidedef side , int brightness )
{
side . Fields . BeforeFieldsChange ( ) ;
//absolute flag set?
if ( side . Fields . GetValue ( "lightabsolute" , false ) )
side . Fields [ "light" ] . Value = brightness ;
else
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
UniFields . SetInteger ( side . Fields , "light" , brightness - side . Sector . Brightness , 0 ) ;
2015-03-27 11:43:28 +00:00
//apply lightfog flag?
if ( General . Map . UDMF ) Tools . UpdateLightFogFlag ( side ) ;
2015-02-24 20:25:42 +00:00
}
2013-09-11 13:14:45 +00:00
[BeginAction("placethings")] //mxd
2014-12-03 23:15:26 +00:00
public void PlaceThings ( )
{
2013-09-11 13:14:45 +00:00
// Make list of selected linedefs
ICollection < Linedef > lines = General . Map . Map . GetSelectedLinedefs ( true ) ;
List < Vector2D > positions = new List < Vector2D > ( ) ;
2014-12-03 23:15:26 +00:00
if ( lines . Count = = 0 )
{
2015-12-28 15:01:53 +00:00
if ( highlighted ! = null & & ! highlighted . IsDisposed )
2014-12-03 23:15:26 +00:00
{
2013-09-11 13:14:45 +00:00
lines . Add ( highlighted ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2013-09-11 13:14:45 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires selection of some description!" ) ;
return ;
}
}
// Make list of vertex positions
2014-12-03 23:15:26 +00:00
foreach ( Linedef l in lines )
{
2013-09-11 13:14:45 +00:00
if ( ! positions . Contains ( l . Start . Position ) ) positions . Add ( l . Start . Position ) ;
if ( ! positions . Contains ( l . End . Position ) ) positions . Add ( l . End . Position ) ;
}
2014-12-03 23:15:26 +00:00
if ( positions . Count < 1 )
{
2013-09-11 13:14:45 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Unable to get vertex positions from selection!" ) ;
return ;
}
2014-12-03 23:15:26 +00:00
PlaceThingsAtPositions ( positions ) ;
2013-09-11 13:14:45 +00:00
}
2013-05-30 12:52:27 +00:00
//mxd
[BeginAction("alignfloortofront")]
2014-12-03 23:15:26 +00:00
public void AlignFloorToFront ( )
{
2013-05-30 12:52:27 +00:00
if ( ! General . Map . UDMF ) return ;
2014-12-03 23:15:26 +00:00
AlignTextureToLine ( true , true ) ;
2013-05-30 12:52:27 +00:00
}
//mxd
[BeginAction("alignfloortoback")]
2014-12-03 23:15:26 +00:00
public void AlignFloorToBack ( )
{
2013-05-30 12:52:27 +00:00
if ( ! General . Map . UDMF ) return ;
2014-12-03 23:15:26 +00:00
AlignTextureToLine ( true , false ) ;
2013-05-30 12:52:27 +00:00
}
//mxd
[BeginAction("alignceilingtofront")]
2014-12-03 23:15:26 +00:00
public void AlignCeilingToFront ( )
{
2013-05-30 12:52:27 +00:00
if ( ! General . Map . UDMF ) return ;
2014-12-03 23:15:26 +00:00
AlignTextureToLine ( false , true ) ;
2013-05-30 12:52:27 +00:00
}
//mxd
[BeginAction("alignceilingtoback")]
2014-12-03 23:15:26 +00:00
public void AlignCeilingToBack ( )
{
2013-05-30 12:52:27 +00:00
if ( ! General . Map . UDMF ) return ;
2014-12-03 23:15:26 +00:00
AlignTextureToLine ( false , false ) ;
2013-05-30 12:52:27 +00:00
}
2014-05-08 09:24:32 +00:00
//mxd
[BeginAction("selectsimilar")]
2014-12-03 23:15:26 +00:00
public void SelectSimilar ( )
{
2014-05-08 09:24:32 +00:00
ICollection < Linedef > selection = General . Map . Map . GetSelectedLinedefs ( true ) ;
2014-12-03 23:15:26 +00:00
if ( selection . Count = = 0 )
{
2014-05-08 09:24:32 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires a selection!" ) ;
return ;
}
var form = new SelectSimilarElementOptionsPanel ( ) ;
2016-06-20 13:36:10 +00:00
if ( form . Setup ( this ) ) form . ShowDialog ( General . Interface ) ;
2014-05-08 09:24:32 +00:00
}
2015-02-01 18:44:30 +00:00
//mxd
[BeginAction("applylightfogflag")]
private void ApplyLightFogFlag ( )
{
if ( ! General . Map . UDMF ) return ;
// Make list of selected linedefs
ICollection < Linedef > lines = General . Map . Map . GetSelectedLinedefs ( true ) ;
if ( lines . Count = = 0 )
{
if ( highlighted ! = null & & ! highlighted . IsDisposed )
{
lines . Add ( highlighted ) ;
}
else
{
General . Interface . DisplayStatus ( StatusType . Warning , "This action requires selection of some description!" ) ;
return ;
}
}
// Make undo
General . Map . UndoRedo . CreateUndo ( "Apply 'lightfog' flag" ) ;
// Apply the flag
int addedcout = 0 ;
int removedcount = 0 ;
foreach ( Linedef l in lines )
{
2015-02-12 22:04:49 +00:00
if ( l . Front ! = null )
2015-02-01 18:44:30 +00:00
{
2015-02-12 22:04:49 +00:00
int result = Tools . UpdateLightFogFlag ( l . Front ) ;
switch ( result )
{
case 1 : addedcout + + ; break ;
case - 1 : removedcount + + ; break ;
}
2015-02-01 18:44:30 +00:00
}
2015-02-12 22:04:49 +00:00
if ( l . Back ! = null )
2015-02-01 18:44:30 +00:00
{
2015-02-12 22:04:49 +00:00
int result = Tools . UpdateLightFogFlag ( l . Back ) ;
switch ( result )
{
case 1 : addedcout + + ; break ;
case - 1 : removedcount + + ; break ;
}
2015-02-01 18:44:30 +00:00
}
}
2015-02-12 22:04:49 +00:00
// Display info
General . Interface . DisplayStatus ( StatusType . Action , "Added 'lightfog' flag to " + addedcout + " sidedefs, removed it from " + removedcount + " sidedefs." ) ;
2015-02-01 18:44:30 +00:00
}
2023-06-09 09:17:01 +00:00
[BeginAction("changemapelementindex")]
private void ChangeMapElementIndex ( )
{
// Make list of selected linedefs
List < Linedef > selected = General . Map . Map . GetSelectedLinedefs ( true ) . ToList ( ) ;
if ( ( selected . Count = = 0 ) & & ( highlighted ! = null ) & & ! highlighted . IsDisposed ) selected . Add ( highlighted ) ;
if ( selected . Count ! = 1 )
{
General . ToastManager . ShowToast ( ToastMessages . CHANGEMAPELEMENTINDEX , ToastType . WARNING , "Changing linedef index failed" , "You need to select or highlight exactly 1 linedef." ) ;
return ;
}
ChangeMapElementIndexForm f = new ChangeMapElementIndexForm ( "linedef" , selected [ 0 ] . Index , General . Map . Map . Linedefs . Count - 1 ) ;
if ( f . ShowDialog ( ) = = DialogResult . OK )
{
int newindex = f . GetNewIndex ( ) ;
int oldindex = selected [ 0 ] . Index ;
General . Map . UndoRedo . CreateUndo ( "Change linedef index" ) ;
selected [ 0 ] . ChangeIndex ( newindex ) ;
General . ToastManager . ShowToast ( ToastMessages . CHANGEMAPELEMENTINDEX , ToastType . INFO , "Successfully change linedef index" , $"Changed index of linedef {oldindex} to {newindex}." ) ;
}
}
2009-04-19 18:07:22 +00:00
#endregion
}
}