Another new cleanup action: Reset flags (for linedefs and things)

This commit is contained in:
sphere 2021-05-10 13:45:19 +02:00
parent ae0812145b
commit c1ff954692
3 changed files with 100 additions and 0 deletions

View file

@ -1307,6 +1307,52 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RedrawDisplay();
}
}
[BeginAction("resetflags")]
public void ResetFlags()
{
// 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 flags of " + selected.Count + " linedefs");
General.Interface.DisplayStatus(StatusType.Action, "Reset flags of " + selected.Count + " linedefs.");
}
else
{
General.Map.UndoRedo.CreateUndo("Reset flags of 1 linedef");
General.Interface.DisplayStatus(StatusType.Action, "Reset flags of 1 linedef.");
}
foreach (Linedef l in selected)
{
l.ClearFlags();
if (l.Back != null && l.Back.Sector != null)
l.SetFlag(General.Map.Config.DoubleSidedFlag, true);
else
l.SetFlag(General.Map.Config.ImpassableFlag, true);
}
// 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

@ -1041,6 +1041,50 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
[BeginAction("resetflags")]
public void ResetFlags()
{
// Make list of selected things
ICollection<Thing> selected = General.Map.Map.GetSelectedThings(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 flags of " + selected.Count + " things");
General.Interface.DisplayStatus(StatusType.Action, "Reset flags of " + selected.Count + " things.");
}
else
{
General.Map.UndoRedo.CreateUndo("Reset flags of 1 thing");
General.Interface.DisplayStatus(StatusType.Action, "Reset flags of 1 thing.");
}
foreach (Thing t in selected)
{
t.ClearFlags();
}
// Update cache values
General.Map.IsChanged = true;
General.Map.Map.Update();
//mxd. Update helper lines
UpdateHelperObjects();
// 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.Interface.RedrawDisplay();
}
}
//mxd
[BeginAction("thingaligntowall")]
public void AlignThingsToWall()

View file

@ -331,6 +331,16 @@ resetactionsandtags
allowscroll = true;
}
resetflags
{
title = "Reset flags";
category = "classic";
description = "This resets the flags of all lines or things in your selection.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
selectnonessential
{
title = "Select non-essential vertices";