2014-02-10 09:26:13 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2014-01-16 09:32:05 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2013-04-08 13:28:04 +00:00
|
|
|
|
{
|
|
|
|
|
[EditMode(DisplayName = "Draw Curve Mode",
|
|
|
|
|
SwitchAction = "drawcurvemode",
|
2014-02-26 14:11:06 +00:00
|
|
|
|
ButtonImage = "DrawCurveMode.png", //mxd
|
|
|
|
|
ButtonOrder = int.MinValue + 2, //mxd
|
|
|
|
|
ButtonGroup = "000_drawing", //mxd
|
2013-04-08 13:28:04 +00:00
|
|
|
|
AllowCopyPaste = false,
|
|
|
|
|
Volatile = true,
|
|
|
|
|
Optional = false)]
|
|
|
|
|
|
|
|
|
|
public class DrawCurveMode : DrawGeometryMode
|
|
|
|
|
{
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
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 readonly HintLabel hintlabel;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
private Curve curve;
|
2016-03-04 13:41:55 +00:00
|
|
|
|
private int segmentlength;
|
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 const int MIN_SEGMENT_LENGTH = 16;
|
|
|
|
|
private const int MAX_SEGMENT_LENGTH = 4096; //just some arbitrary number
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Interface
|
|
|
|
|
private DrawCurveOptionsPanel panel;
|
2014-02-26 14:11:06 +00:00
|
|
|
|
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor/Disposer
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public DrawCurveMode()
|
|
|
|
|
{
|
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
|
|
|
|
hintlabel = new HintLabel(General.Colors.InfoLine);
|
|
|
|
|
labeluseoffset = false;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
2015-09-16 12:10:43 +00:00
|
|
|
|
// Not already disposed?
|
|
|
|
|
if(!isdisposed)
|
|
|
|
|
{
|
|
|
|
|
// Clean up
|
|
|
|
|
if(hintlabel != null) hintlabel.Dispose();
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
base.Dispose();
|
|
|
|
|
}
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
PixelColor stitchcolor = General.Colors.Highlight;
|
|
|
|
|
PixelColor losecolor = General.Colors.Selection;
|
|
|
|
|
|
2015-07-09 22:32:12 +00:00
|
|
|
|
snaptocardinaldirection = General.Interface.ShiftState && General.Interface.AltState;
|
|
|
|
|
snaptogrid = snaptocardinaldirection || General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
|
|
|
|
|
|
|
|
|
DrawnVertex curp = GetCurrentPosition();
|
2014-02-10 09:26:13 +00:00
|
|
|
|
float vsize = (renderer.VertexSize + 1.0f) / renderer.Scale;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2015-08-24 21:49:15 +00:00
|
|
|
|
// Update label positions (mxd)
|
|
|
|
|
if(labels.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// Update labels for already drawn lines
|
|
|
|
|
for(int i = 0; i < labels.Count - 1; i++)
|
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
|
|
|
|
labels[i].Move(points[i].pos, points[i + 1].pos);
|
2015-08-24 21:49:15 +00:00
|
|
|
|
|
|
|
|
|
// Update label for active line
|
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
|
|
|
|
labels[labels.Count - 1].Move(points[points.Count - 1].pos, curp.pos);
|
2015-08-24 21:49:15 +00:00
|
|
|
|
}
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render drawing lines
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(renderer.StartOverlay(true))
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Go for all points to draw lines
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(points.Count > 0)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
//update curve
|
|
|
|
|
List<Vector2D> verts = new List<Vector2D>();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = 0; i < points.Count; i++) verts.Add(points[i].pos);
|
|
|
|
|
if(curp.pos != verts[verts.Count-1]) verts.Add(curp.pos);
|
2016-02-17 22:23:18 +00:00
|
|
|
|
curve = CurveTools.CurveThroughPoints(verts, 0.5f, 0.75f, segmentlength);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render lines
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = 1; i < curve.Shape.Count; i++)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Determine line color
|
2015-12-28 15:01:53 +00:00
|
|
|
|
PixelColor c = snaptonearest ? stitchcolor : losecolor;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render line
|
2015-12-28 15:01:53 +00:00
|
|
|
|
renderer.RenderLine(curve.Shape[i - 1], curve.Shape[i], LINE_THICKNESS, c, true);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//render "inactive" vertices
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = 1; i < curve.Shape.Count - 1; i++)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Determine vertex color
|
2015-12-28 15:01:53 +00:00
|
|
|
|
PixelColor c = !snaptonearest ? stitchcolor : losecolor;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render vertex
|
2015-12-28 15:01:53 +00:00
|
|
|
|
renderer.RenderRectangleFilled(new RectangleF(curve.Shape[i].x - vsize, curve.Shape[i].y - vsize, vsize * 2.0f, vsize * 2.0f), c, true);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(points.Count > 0)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Render vertices
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = 0; i < points.Count; i++)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Determine vertex color
|
2015-12-28 15:01:53 +00:00
|
|
|
|
PixelColor c = points[i].stitch ? stitchcolor : losecolor;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render vertex
|
2015-12-28 15:01:53 +00:00
|
|
|
|
renderer.RenderRectangleFilled(new RectangleF(points[i].pos.x - vsize, points[i].pos.y - vsize, vsize * 2.0f, vsize * 2.0f), c, true);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine point color
|
2015-12-28 15:01:53 +00:00
|
|
|
|
PixelColor color = snaptonearest ? stitchcolor : losecolor;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Render vertex at cursor
|
|
|
|
|
renderer.RenderRectangleFilled(new RectangleF(curp.pos.x - vsize, curp.pos.y - vsize, vsize * 2.0f, vsize * 2.0f), color, true);
|
|
|
|
|
|
2016-04-25 14:48:39 +00:00
|
|
|
|
// Render labels
|
|
|
|
|
renderer.RenderText(labels.ToArray());
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
//Render info label
|
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
|
|
|
|
Vector2D start = new Vector2D(mousemappos.x + (32 / renderer.Scale), mousemappos.y - (16 / renderer.Scale));
|
|
|
|
|
Vector2D end = new Vector2D(mousemappos.x + (96 / renderer.Scale), mousemappos.y);
|
|
|
|
|
hintlabel.Move(start, end);
|
2016-02-17 22:23:18 +00:00
|
|
|
|
hintlabel.Text = "SEG LEN: " + segmentlength;
|
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
|
|
|
|
renderer.RenderText(hintlabel.TextLabel);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
renderer.Finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
renderer.Present();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnEngage()
|
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
base.OnEngage();
|
|
|
|
|
|
|
|
|
|
//setup settings panel
|
2016-02-17 22:23:18 +00:00
|
|
|
|
panel.SegmentLength = segmentlength;
|
2014-02-28 14:32:20 +00:00
|
|
|
|
panel.Register();
|
2014-02-26 14:11:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnAccept()
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
Cursor.Current = Cursors.AppStarting;
|
|
|
|
|
General.Settings.FindDefaultDrawSettings();
|
|
|
|
|
|
|
|
|
|
// When points have been drawn
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(points.Count > 0)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
// Make undo for the draw
|
|
|
|
|
General.Map.UndoRedo.CreateUndo("Curve draw");
|
|
|
|
|
|
|
|
|
|
// Make an analysis and show info
|
2016-03-14 10:25:27 +00:00
|
|
|
|
string[] adjectives =
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-02-28 14:32:20 +00:00
|
|
|
|
"beautiful", "lovely", "romantic", "stylish", "cheerful", "comical",
|
2013-04-08 13:28:04 +00:00
|
|
|
|
"awesome", "accurate", "adorable", "adventurous", "attractive", "cute",
|
|
|
|
|
"elegant", "glamorous", "gorgeous", "handsome", "magnificent", "unusual",
|
2014-02-28 14:32:20 +00:00
|
|
|
|
"outstanding", "mysterious", "amusing", "charming", "fantastic", "jolly"
|
|
|
|
|
};
|
2013-04-08 13:28:04 +00:00
|
|
|
|
string word = adjectives[points.Count % adjectives.Length];
|
|
|
|
|
word = (points.Count > adjectives.Length) ? "very " + word : word;
|
2013-04-15 10:54:55 +00:00
|
|
|
|
string a = ((word[0] == 'a') || (word[0] == 'e') || (word[0] == 'o') || (word[0] == 'u')) ? "an " : "a ";
|
2013-04-12 11:06:57 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Action, "Created " + a + word + " curve.");
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
|
|
|
|
List<DrawnVertex> verts = new List<DrawnVertex>();
|
|
|
|
|
|
2016-03-14 10:25:27 +00:00
|
|
|
|
// If we have a curve...
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(points.Count > 2)
|
|
|
|
|
{
|
2016-03-14 10:25:27 +00:00
|
|
|
|
// Is it an (auto)closed curve?
|
|
|
|
|
int lastpoint;
|
|
|
|
|
if(drawingautoclosed || points[0].pos == points[points.Count - 1].pos)
|
|
|
|
|
lastpoint = curve.Segments.Count;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
else
|
2016-03-14 10:25:27 +00:00
|
|
|
|
lastpoint = curve.Segments.Count - 1;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-03-14 10:25:27 +00:00
|
|
|
|
for(int i = 0; i < lastpoint; i++)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
int next = (i == curve.Segments.Count - 1 ? 0 : i + 1);
|
|
|
|
|
bool stitch = points[i].stitch && points[next].stitch;
|
|
|
|
|
bool stitchline = points[i].stitchline && points[next].stitchline;
|
|
|
|
|
|
2016-03-14 10:25:27 +00:00
|
|
|
|
// Add segment points except the last one
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int c = 0; c < curve.Segments[i].Points.Length - 1; c++)
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
DrawnVertex dv = new DrawnVertex();
|
|
|
|
|
dv.pos = curve.Segments[i].Points[c];
|
|
|
|
|
dv.stitch = stitch;
|
|
|
|
|
dv.stitchline = stitchline;
|
|
|
|
|
verts.Add(dv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 10:25:27 +00:00
|
|
|
|
// Add the last point
|
2013-04-08 13:28:04 +00:00
|
|
|
|
DrawnVertex end = new DrawnVertex();
|
2016-03-14 10:25:27 +00:00
|
|
|
|
end.pos = curve.Segments[lastpoint - 1].End;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
end.stitch = verts[verts.Count - 1].stitch;
|
|
|
|
|
end.stitchline = verts[verts.Count - 1].stitchline;
|
|
|
|
|
verts.Add(end);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-08 13:28:04 +00:00
|
|
|
|
verts = points;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make the drawing
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(Tools.DrawLines(verts, true, BuilderPlug.Me.AutoAlignTextureOffsetsOnCreate)) //mxd
|
2013-04-08 13:28:04 +00:00
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Snap to map format accuracy
|
|
|
|
|
General.Map.Map.SnapAllToAccuracy();
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Clear selection
|
|
|
|
|
General.Map.Map.ClearAllSelected();
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Update cached values
|
|
|
|
|
General.Map.Map.Update();
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-05-18 20:31:40 +00:00
|
|
|
|
//mxd. Outer sectors may require some splittin...
|
2016-06-15 22:02:51 +00:00
|
|
|
|
if(General.Settings.SplitJoinedSectors) Tools.SplitOuterSectors(General.Map.Map.GetMarkedLinedefs(true));
|
2016-05-18 20:31:40 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Edit new sectors?
|
|
|
|
|
List<Sector> newsectors = General.Map.Map.GetMarkedSectors(true);
|
|
|
|
|
if(BuilderPlug.Me.EditNewSector && (newsectors.Count > 0))
|
|
|
|
|
General.Interface.ShowEditSectors(newsectors);
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Update the used textures
|
|
|
|
|
General.Map.Data.UpdateUsedTextures();
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
//mxd
|
|
|
|
|
General.Map.Renderer2D.UpdateExtraFloorFlag();
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Map is changed
|
|
|
|
|
General.Map.IsChanged = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Drawing failed
|
|
|
|
|
// NOTE: I have to call this twice, because the first time only cancels this volatile mode
|
|
|
|
|
General.Map.UndoRedo.WithdrawUndo();
|
|
|
|
|
General.Map.UndoRedo.WithdrawUndo();
|
|
|
|
|
}
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
Cursor.Current = Cursors.Default;
|
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(continuousdrawing)
|
|
|
|
|
{
|
|
|
|
|
// Reset settings
|
|
|
|
|
points.Clear();
|
|
|
|
|
labels.Clear();
|
2016-03-14 10:25:27 +00:00
|
|
|
|
drawingautoclosed = false;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Redraw display
|
|
|
|
|
General.Interface.RedrawDisplay();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Return to original mode
|
|
|
|
|
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
|
|
|
|
|
}
|
2014-02-26 14:11:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void OptionsPanelOnValueChanged(object sender, EventArgs eventArgs)
|
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
segmentlength = panel.SegmentLength;
|
2014-02-26 14:11:06 +00:00
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override void OnHelp()
|
|
|
|
|
{
|
2014-02-10 09:26:13 +00:00
|
|
|
|
General.ShowHelp("/gzdb/features/classic_modes/mode_drawcurve.html");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
#region ================== mxd. Settings panel
|
|
|
|
|
|
|
|
|
|
protected override void SetupInterface()
|
|
|
|
|
{
|
2016-03-04 13:41:55 +00:00
|
|
|
|
// Load stored settings
|
|
|
|
|
segmentlength = General.Clamp(General.Settings.ReadPluginSetting("drawcurvemode.segmentlength", 32), MIN_SEGMENT_LENGTH, MAX_SEGMENT_LENGTH);
|
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
// Add options docker
|
|
|
|
|
panel = new DrawCurveOptionsPanel(MIN_SEGMENT_LENGTH, MAX_SEGMENT_LENGTH);
|
2016-03-04 13:41:55 +00:00
|
|
|
|
panel.SegmentLength = segmentlength;
|
2016-02-17 22:23:18 +00:00
|
|
|
|
panel.OnValueChanged += OptionsPanelOnValueChanged;
|
|
|
|
|
panel.OnContinuousDrawingChanged += OnContinuousDrawingChanged;
|
2016-03-14 10:25:27 +00:00
|
|
|
|
panel.OnAutoCloseDrawingChanged += OnAutoCloseDrawingChanged;
|
2016-03-04 13:41:55 +00:00
|
|
|
|
|
2016-03-14 10:25:27 +00:00
|
|
|
|
// Needs to be set after adding the events...
|
2016-03-04 13:41:55 +00:00
|
|
|
|
panel.ContinuousDrawing = General.Settings.ReadPluginSetting("drawcurvemode.continuousdrawing", false);
|
2016-03-14 10:25:27 +00:00
|
|
|
|
panel.AutoCloseDrawing = General.Settings.ReadPluginSetting("drawlinesmode.autoclosedrawing", false);
|
2016-02-17 22:23:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void AddInterface()
|
|
|
|
|
{
|
|
|
|
|
panel.Register();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void RemoveInterface()
|
|
|
|
|
{
|
2016-03-04 13:41:55 +00:00
|
|
|
|
// Store settings
|
|
|
|
|
General.Settings.WritePluginSetting("drawcurvemode.segmentlength", segmentlength);
|
|
|
|
|
General.Settings.WritePluginSetting("drawcurvemode.continuousdrawing", panel.ContinuousDrawing);
|
2016-03-14 10:25:27 +00:00
|
|
|
|
General.Settings.WritePluginSetting("drawlinesmode.autoclosedrawing", panel.AutoCloseDrawing);
|
2016-03-04 13:41:55 +00:00
|
|
|
|
|
|
|
|
|
// Remove the buttons
|
2016-02-17 22:23:18 +00:00
|
|
|
|
panel.Unregister();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-02-10 09:26:13 +00:00
|
|
|
|
#region ================== Actions
|
|
|
|
|
|
2013-04-08 13:28:04 +00:00
|
|
|
|
[BeginAction("increasesubdivlevel")]
|
2014-12-03 23:15:26 +00:00
|
|
|
|
protected virtual void IncreaseSubdivLevel()
|
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(segmentlength < MAX_SEGMENT_LENGTH)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
int increment = Math.Max(MIN_SEGMENT_LENGTH, segmentlength / 32 * 16);
|
|
|
|
|
segmentlength += increment;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(segmentlength > MAX_SEGMENT_LENGTH) segmentlength = MAX_SEGMENT_LENGTH;
|
|
|
|
|
panel.SegmentLength = segmentlength;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BeginAction("decreasesubdivlevel")]
|
2014-12-03 23:15:26 +00:00
|
|
|
|
protected virtual void DecreaseSubdivLevel()
|
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(segmentlength > MIN_SEGMENT_LENGTH)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-02-17 22:23:18 +00:00
|
|
|
|
int increment = Math.Max(MIN_SEGMENT_LENGTH, segmentlength / 32 * 16);
|
|
|
|
|
segmentlength -= increment;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
|
2016-02-17 22:23:18 +00:00
|
|
|
|
if(segmentlength < MIN_SEGMENT_LENGTH) segmentlength = MIN_SEGMENT_LENGTH;
|
|
|
|
|
panel.SegmentLength = segmentlength;
|
2013-04-08 13:28:04 +00:00
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-10 09:26:13 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-04-08 13:28:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|