Some new cleanup actions: Select non-essential vertices & Reset actions and tags (for linedefs and sectors)

This commit is contained in:
sphere 2021-05-08 23:35:32 +02:00
parent 5bb6488ca0
commit 367a3ed6c6
4 changed files with 137 additions and 3 deletions

View file

@ -1264,6 +1264,49 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RedrawDisplay();
}
}
[BeginAction("resetactionsandtags")]
public void ResetActionsAndTags()
{
// 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("Reset actions and tags of " + selected.Count + " linedefs");
General.Interface.DisplayStatus(StatusType.Action, "Reset actions and tags of " + selected.Count + " linedefs.");
}
else
{
General.Map.UndoRedo.CreateUndo("Reset actions and tags of 1 linedef");
General.Interface.DisplayStatus(StatusType.Action, "Reset actions and tags of 1 linedef.");
}
foreach (Linedef l in selected)
{
l.Action = 0;
l.Tag = 0;
}
// Update cache values
General.Map.IsChanged = true;
General.Map.Map.Update();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Redraw screen
UpdateSelectionInfo(); //mxd
General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd
General.Interface.RedrawDisplay();
}
}
[BeginAction("splitlinedefs")]
public void SplitLinedefs()

View file

@ -1759,7 +1759,50 @@ namespace CodeImp.DoomBuilder.BuilderModes
//TODO handle this differently?..
DeleteItem();
}
[BeginAction("resetactionsandtags")]
public void ResetActionsAndTags()
{
// Make list of selected linedefs
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(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("Reset actions and tags of " + selected.Count + " sectors");
General.Interface.DisplayStatus(StatusType.Action, "Reset actions and tags of " + selected.Count + " sectors.");
}
else
{
General.Map.UndoRedo.CreateUndo("Reset actions and tags of 1 sector");
General.Interface.DisplayStatus(StatusType.Action, "Reset actions and tags of 1 sector.");
}
foreach (Sector s in selected)
{
s.Effect = 0;
s.Tag = 0;
}
// Update cache values
General.Map.IsChanged = true;
General.Map.Map.Update();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Redraw screen
UpdateSelectionInfo(); //mxd
General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd
General.Interface.RedrawDisplay();
}
}
// This joins sectors together and keeps all lines
[BeginAction("joinsectors")]
public void JoinSectors()

View file

@ -985,6 +985,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RedrawDisplay();
}
[BeginAction("selectnonessential")]
public void SelectNonEssential()
{
int counter = 0;
ICollection<Vertex> selected = General.Map.Map.GetSelectedVertices(true);
foreach (Vertex v in selected)
{
if (v.Linedefs.Count == 2)
{
Linedef ld1 = General.GetByIndex(v.Linedefs, 0);
Linedef ld2 = General.GetByIndex(v.Linedefs, 1);
int angle1 = (int)Math.Round(ld1.Angle * Angle2D.PIDEG);
int angle2 = (int)Math.Round(ld2.Angle * Angle2D.PIDEG);
if (ld1.Action == 0 && ld2.Action == 0 &&
(angle1 == angle2 || angle1 == angle2 + 180 || angle1 + 180 == angle2))
counter++;
else
v.Selected = false;
}
else
v.Selected = false;
}
General.Interface.DisplayStatus(StatusType.Action, "Selected only non-essential vertices (" + counter + ")");
General.Interface.RedrawDisplay();
}
[BeginAction("dissolveitem", BaseAction = true)] //mxd
public void DissolveItem()
{

View file

@ -6,6 +6,7 @@
categories
{
drawing = "Drawing";
vertices = "Vertices";
linedefs = "Lines";
sectors = "Sectors";
things = "Things";
@ -320,9 +321,29 @@ finishdraw
allowscroll = true;
}
resetactionsandtags
{
title = "Reset actions and tags";
category = "classic";
description = "This resets the actions, effects and tags of all lines or sectors in your selection.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
selectnonessential
{
title = "Select non-essential vertices";
category = "vertices";
description = "This selects all vertices that are not essential to sector shapes from your selection.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
selectsinglesided
{
title = "Select Single-sided";
title = "Select single-sided";
category = "linedefs";
description = "This keeps only the single-sided lines in your selection selected. Also works in Visual Mode.";
allowkeys = true;
@ -333,7 +354,7 @@ selectsinglesided
selectdoublesided
{
title = "Select Double-sided";
title = "Select double-sided";
category = "linedefs";
description = "This keeps only the double-sided lines in your selection selected. Also works in Visual Mode.";
allowkeys = true;