Add "Place Things" option to curve, ellipse and rectangle drawing modes

This commit is contained in:
spherallic 2023-09-08 02:57:22 +02:00
parent 925c50bfd3
commit 5f408e2c6e
10 changed files with 128 additions and 11 deletions

View file

@ -237,7 +237,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Make the drawing
if(Tools.DrawLines(verts, true, BuilderPlug.Me.AutoAlignTextureOffsetsOnCreate)) //mxd
if (drawthingsatvertices)
{
List<Vector2D> points = new List<Vector2D>();
for (int i = 0; i < verts.Count; i++)
if (!points.Contains(verts[i].pos)) points.Add(verts[i].pos);
PlaceThingsAtPositions(points);
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();
// Clear selection
General.Map.Map.ClearAllSelected();
// Update cached values
General.Map.Map.Update();
// Map is changed
General.Map.IsChanged = true;
}
else if (Tools.DrawLines(verts, true, BuilderPlug.Me.AutoAlignTextureOffsetsOnCreate)) //mxd
{
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();
@ -249,11 +269,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.Map.Update();
//mxd. Outer sectors may require some splittin...
if(General.Settings.SplitJoinedSectors) Tools.SplitOuterSectors(General.Map.Map.GetMarkedLinedefs(true));
if (General.Settings.SplitJoinedSectors) Tools.SplitOuterSectors(General.Map.Map.GetMarkedLinedefs(true));
// Edit new sectors?
List<Sector> newsectors = General.Map.Map.GetMarkedSectors(true);
if(BuilderPlug.Me.EditNewSector && (newsectors.Count > 0))
if (BuilderPlug.Me.EditNewSector && (newsectors.Count > 0))
General.Interface.ShowEditSectors(newsectors);
// Update the used textures

View file

@ -69,11 +69,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
panel.OnContinuousDrawingChanged += OnContinuousDrawingChanged;
panel.OnShowGuidelinesChanged += OnShowGuidelinesChanged;
panel.OnRadialDrawingChanged += OnRadialDrawingChanged;
panel.OnDrawThingsAtVerticesChanged += OnDrawThingsAtVerticesChanged;
// Needs to be set after adding the OnContinuousDrawingChanged event...
panel.ContinuousDrawing = General.Settings.ReadPluginSetting("drawellipsemode.continuousdrawing", false);
panel.ShowGuidelines = General.Settings.ReadPluginSetting("drawellipsemode.showguidelines", false);
panel.RadialDrawing = General.Settings.ReadPluginSetting("drawellipsemode.radialdrawing", false);
panel.DrawThingsAtVertices = General.Settings.ReadPluginSetting("drawthingsatvertices.drawthingsatvertices", false);
}
override protected void AddInterface()

View file

@ -65,6 +65,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected bool autoclosedrawing; //mxd. Finish drawing when new points and existing geometry form a closed shape
protected bool drawingautoclosed; //mxd
protected bool showguidelines; //mxd
protected bool drawthingsatvertices; //sphere: place things at vertices?
//mxd. Map area bounds
private Line2D top, bottom, left, right;
@ -952,11 +953,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
showguidelines = (bool)value;
General.Interface.RedrawDisplay();
}
protected void OnDrawThingsAtVerticesChanged(object value, EventArgs e)
{
drawthingsatvertices = (bool)value;
General.Interface.RedrawDisplay();
}
#endregion
#region ================== Actions
// Drawing a point
[BeginAction("drawpoint")]
public void DrawPoint()

View file

@ -104,11 +104,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
panel.OnContinuousDrawingChanged += OnContinuousDrawingChanged;
panel.OnShowGuidelinesChanged += OnShowGuidelinesChanged;
panel.OnRadialDrawingChanged += OnRadialDrawingChanged;
panel.OnDrawThingsAtVerticesChanged += OnDrawThingsAtVerticesChanged;
// Needs to be set after adding the OnContinuousDrawingChanged event...
panel.ContinuousDrawing = General.Settings.ReadPluginSetting("drawrectanglemode.continuousdrawing", false);
panel.ShowGuidelines = General.Settings.ReadPluginSetting("drawrectanglemode.showguidelines", false);
panel.RadialDrawing = General.Settings.ReadPluginSetting("drawrectanglemode.radialdrawing", false);
panel.DrawThingsAtVertices = General.Settings.ReadPluginSetting("drawthingsatvertices.drawthingsatvertices", false);
}
protected override void AddInterface()
@ -124,6 +126,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Settings.WritePluginSetting("drawrectanglemode.continuousdrawing", panel.ContinuousDrawing);
General.Settings.WritePluginSetting("drawrectanglemode.showguidelines", panel.ShowGuidelines);
General.Settings.WritePluginSetting("drawrectanglemode.radialdrawing", panel.RadialDrawing);
General.Settings.WritePluginSetting("drawrectanglemode.drawthingsatvertices", panel.DrawThingsAtVertices);
// Remove the buttons
panel.Unregister();
@ -440,7 +443,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Created " + a + word + " " + shapename + ".");
// Make the drawing
if(Tools.DrawLines(points, true, BuilderPlug.Me.AutoAlignTextureOffsetsOnCreate))
if (drawthingsatvertices)
{
List<Vector2D> verts = new List<Vector2D>();
for (int i = 0; i < points.Count; i++)
if (!verts.Contains(new Vector2D(points[i].pos.x, points[i].pos.y))) verts.Add(new Vector2D(points[i].pos.x, points[i].pos.y));
PlaceThingsAtPositions(verts);
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();
// Clear selection
General.Map.Map.ClearAllSelected();
// Update cached values
General.Map.Map.Update();
// Map is changed
General.Map.IsChanged = true;
}
else if (Tools.DrawLines(points, true, BuilderPlug.Me.AutoAlignTextureOffsetsOnCreate))
{
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();

View file

@ -31,6 +31,7 @@
this.toolstrip = new System.Windows.Forms.ToolStrip();
this.continuousdrawing = new System.Windows.Forms.ToolStripButton();
this.autoclosedrawing = new System.Windows.Forms.ToolStripButton();
this.drawthingsatvertices = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.seglabel = new System.Windows.Forms.ToolStripLabel();
this.seglen = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
@ -43,7 +44,8 @@
this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.continuousdrawing,
this.autoclosedrawing,
this.toolStripSeparator1,
this.drawthingsatvertices,
this.toolStripSeparator1,
this.seglabel,
this.seglen,
this.reset});
@ -74,6 +76,16 @@
this.autoclosedrawing.Text = "Auto-close drawing";
this.autoclosedrawing.CheckedChanged += new System.EventHandler(this.autoclosedrawing_CheckedChanged);
//
// drawthingsatvertices
//
this.drawthingsatvertices.CheckOnClick = true;
this.drawthingsatvertices.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.PlaceThings;
this.drawthingsatvertices.ImageTransparentColor = System.Drawing.Color.Magenta;
this.drawthingsatvertices.Name = "drawthingsatvertices";
this.drawthingsatvertices.Size = new System.Drawing.Size(135, 22);
this.drawthingsatvertices.Text = "Place things";
this.drawthingsatvertices.CheckedChanged += new System.EventHandler(this.drawthingsatvertices_CheckedChanged);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -142,6 +154,6 @@
private System.Windows.Forms.ToolStripButton continuousdrawing;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton autoclosedrawing;
private System.Windows.Forms.ToolStripButton drawthingsatvertices;
}
}

View file

@ -8,11 +8,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
public event EventHandler OnValueChanged;
public event EventHandler OnContinuousDrawingChanged;
public event EventHandler OnAutoCloseDrawingChanged;
public event EventHandler OnDrawThingsAtVerticesChanged;
private bool blockevents;
public int SegmentLength { get { return (int)seglen.Value; } set { blockevents = true; seglen.Value = value; blockevents = false; } }
public bool ContinuousDrawing { get { return continuousdrawing.Checked; } set { continuousdrawing.Checked = value; } }
public bool AutoCloseDrawing { get { return autoclosedrawing.Checked; } set { autoclosedrawing.Checked = value; } }
public bool DrawThingsAtVertices { get { return drawthingsatvertices.Checked; } set { drawthingsatvertices.Checked = value; } }
public DrawCurveOptionsPanel(int minLength, int maxLength)
{
@ -29,6 +31,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.BeginToolbarUpdate();
General.Interface.AddButton(continuousdrawing);
General.Interface.AddButton(autoclosedrawing);
General.Interface.AddButton(drawthingsatvertices);
General.Interface.AddButton(toolStripSeparator1);
General.Interface.AddButton(seglabel);
General.Interface.AddButton(seglen);
@ -43,6 +46,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(seglen);
General.Interface.RemoveButton(seglabel);
General.Interface.RemoveButton(toolStripSeparator1);
General.Interface.RemoveButton(drawthingsatvertices);
General.Interface.RemoveButton(autoclosedrawing);
General.Interface.RemoveButton(continuousdrawing);
General.Interface.EndToolbarUpdate();
@ -67,5 +71,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(OnAutoCloseDrawingChanged != null) OnAutoCloseDrawingChanged(autoclosedrawing.Checked, EventArgs.Empty);
}
private void drawthingsatvertices_CheckedChanged(object sender, EventArgs e)
{
if (OnDrawThingsAtVerticesChanged != null) OnDrawThingsAtVerticesChanged(drawthingsatvertices.Checked, EventArgs.Empty);
}
}
}

View file

@ -31,6 +31,7 @@
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.continuousdrawing = new System.Windows.Forms.ToolStripButton();
this.radialdrawing = new System.Windows.Forms.ToolStripButton();
this.drawthingsatvertices = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.subdivslabel = new System.Windows.Forms.ToolStripLabel();
this.subdivs = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
@ -49,7 +50,8 @@
this.continuousdrawing,
this.showguidelines,
this.radialdrawing,
this.toolStripSeparator1,
this.drawthingsatvertices,
this.toolStripSeparator1,
this.subdivslabel,
this.subdivs,
this.spikinesslabel,
@ -73,6 +75,16 @@
this.continuousdrawing.Text = "Continuous drawing";
this.continuousdrawing.CheckedChanged += new System.EventHandler(this.continuousdrawing_CheckedChanged);
//
// drawthingsatvertices
//
this.drawthingsatvertices.CheckOnClick = true;
this.drawthingsatvertices.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.PlaceThings;
this.drawthingsatvertices.ImageTransparentColor = System.Drawing.Color.Magenta;
this.drawthingsatvertices.Name = "drawthingsatvertices";
this.drawthingsatvertices.Size = new System.Drawing.Size(135, 22);
this.drawthingsatvertices.Text = "Place things";
this.drawthingsatvertices.CheckedChanged += new System.EventHandler(this.drawthingsatvertices_CheckedChanged);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -225,5 +237,6 @@
private System.Windows.Forms.ToolStripLabel anglelabel;
private CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown angle;
private System.Windows.Forms.ToolStripButton showguidelines;
private System.Windows.Forms.ToolStripButton drawthingsatvertices;
}
}

View file

@ -9,6 +9,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public event EventHandler OnContinuousDrawingChanged;
public event EventHandler OnShowGuidelinesChanged;
public event EventHandler OnRadialDrawingChanged;
public event EventHandler OnDrawThingsAtVerticesChanged;
private bool blockevents;
@ -22,7 +23,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool ContinuousDrawing { get { return continuousdrawing.Checked; } set { continuousdrawing.Checked = value; } }
public bool ShowGuidelines { get { return showguidelines.Checked; } set { showguidelines.Checked = value; } }
public bool RadialDrawing { get { return radialdrawing.Checked; } set { radialdrawing.Checked = value; } }
public bool DrawThingsAtVertices { get { return drawthingsatvertices.Checked; } set { drawthingsatvertices.Checked = value; } }
public DrawEllipseOptionsPanel()
{
InitializeComponent();
@ -38,6 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.AddButton(continuousdrawing);
General.Interface.AddButton(showguidelines);
General.Interface.AddButton(radialdrawing);
General.Interface.AddButton(drawthingsatvertices);
General.Interface.AddButton(toolStripSeparator1);
General.Interface.AddButton(subdivslabel);
General.Interface.AddButton(subdivs);
@ -63,6 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(showguidelines);
General.Interface.RemoveButton(continuousdrawing);
General.Interface.RemoveButton(radialdrawing);
General.Interface.RemoveButton(drawthingsatvertices);
General.Interface.EndToolbarUpdate();
}
@ -98,5 +102,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(OnRadialDrawingChanged != null) OnRadialDrawingChanged(radialdrawing.Checked, EventArgs.Empty);
}
private void drawthingsatvertices_CheckedChanged(object sender, EventArgs e)
{
if (OnDrawThingsAtVerticesChanged != null) OnDrawThingsAtVerticesChanged(drawthingsatvertices.Checked, EventArgs.Empty);
}
}
}

View file

@ -32,6 +32,7 @@
this.continuousdrawing = new System.Windows.Forms.ToolStripButton();
this.showguidelines = new System.Windows.Forms.ToolStripButton();
this.radialdrawing = new System.Windows.Forms.ToolStripButton();
this.drawthingsatvertices = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.radiuslabel = new System.Windows.Forms.ToolStripLabel();
this.radius = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
@ -47,6 +48,7 @@
this.continuousdrawing,
this.showguidelines,
this.radialdrawing,
this.drawthingsatvertices,
this.toolStripSeparator1,
this.radiuslabel,
this.radius,
@ -69,6 +71,16 @@
this.continuousdrawing.Text = "Continuous drawing";
this.continuousdrawing.CheckedChanged += new System.EventHandler(this.continuousdrawing_CheckedChanged);
//
// drawthingsatvertices
//
this.drawthingsatvertices.CheckOnClick = true;
this.drawthingsatvertices.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.PlaceThings;
this.drawthingsatvertices.ImageTransparentColor = System.Drawing.Color.Magenta;
this.drawthingsatvertices.Name = "drawthingsatvertices";
this.drawthingsatvertices.Size = new System.Drawing.Size(135, 22);
this.drawthingsatvertices.Text = "Place things";
this.drawthingsatvertices.CheckedChanged += new System.EventHandler(this.drawthingsatvertices_CheckedChanged);
//
// showguidelines
//
this.showguidelines.CheckOnClick = true;
@ -190,5 +202,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton showguidelines;
private System.Windows.Forms.ToolStripButton radialdrawing;
private System.Windows.Forms.ToolStripButton drawthingsatvertices;
}
}

View file

@ -9,6 +9,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public event EventHandler OnContinuousDrawingChanged;
public event EventHandler OnShowGuidelinesChanged;
public event EventHandler OnRadialDrawingChanged;
public event EventHandler OnDrawThingsAtVerticesChanged;
private bool blockevents;
@ -21,6 +22,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool ContinuousDrawing { get { return continuousdrawing.Checked; } set { continuousdrawing.Checked = value; } }
public bool ShowGuidelines { get { return showguidelines.Checked; } set { showguidelines.Checked = value; } }
public bool RadialDrawing { get { return radialdrawing.Checked; } set { radialdrawing.Checked = value; } }
public bool DrawThingsAtVertices { get { return drawthingsatvertices.Checked; } set { drawthingsatvertices.Checked = value; } }
public DrawRectangleOptionsPanel()
{
@ -36,6 +38,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.AddButton(continuousdrawing);
General.Interface.AddButton(showguidelines);
General.Interface.AddButton(radialdrawing);
General.Interface.AddButton(drawthingsatvertices);
General.Interface.AddButton(toolStripSeparator1);
General.Interface.AddButton(radiuslabel);
General.Interface.AddButton(radius);
@ -55,6 +58,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(radiuslabel);
General.Interface.RemoveButton(toolStripSeparator1);
General.Interface.RemoveButton(showguidelines);
General.Interface.RemoveButton(drawthingsatvertices);
General.Interface.RemoveButton(continuousdrawing);
General.Interface.RemoveButton(radialdrawing);
General.Interface.EndToolbarUpdate();
@ -91,5 +95,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(OnRadialDrawingChanged != null) OnRadialDrawingChanged(radialdrawing.Checked, EventArgs.Empty);
}
private void drawthingsatvertices_CheckedChanged(object sender, EventArgs e)
{
if (OnDrawThingsAtVerticesChanged != null) OnDrawThingsAtVerticesChanged(drawthingsatvertices.Checked, EventArgs.Empty);
}
}
}