Add "clear midtextures" action

This commit is contained in:
spherallic 2023-04-21 02:29:53 +02:00
parent 8c12299583
commit c76ff0aab9
3 changed files with 102 additions and 2 deletions

View file

@ -1722,7 +1722,52 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RedrawDisplay();
}
}
[BeginAction("clearmidtextures")]
public void ClearMidtextures()
{
// 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("Cleared midtextures of " + selected.Count + " linedefs");
General.Interface.DisplayStatus(StatusType.Action, "Cleared midtextures of " + selected.Count + " linedefs.");
}
else
{
General.Map.UndoRedo.CreateUndo("Cleared midtextures of 1 linedef");
General.Interface.DisplayStatus(StatusType.Action, "Cleared midtextures of 1 linedef.");
}
foreach (Linedef l in selected)
{
l.SetFlag(General.Map.Config.PegMidtextureFlag, false);
l.Front.SetTextureMid("-");
l.Back.SetTextureMid("-");
}
// 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.Interface.RefreshInfo();
General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd
General.Interface.RedrawDisplay();
}
}
[BeginAction("splitlinedefs")]
public void SplitLinedefs()
{

View file

@ -356,7 +356,7 @@ resetactionsandtags
{
title = "Reset actions and tags";
category = "classic";
description = "This resets the actions, effects and tags of all lines or sectors in your selection.";
description = "This resets the actions, effects and tags of all lines/sectors/things in your selection.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -374,6 +374,17 @@ resetflags
default = 327762;
}
clearmidtextures
{
title = "Clear midtextures";
category = "classic";
description = "This removes all midtextures from the selected lines, and removes their Peg Midtexture flag.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
default = 327762;
}
selectnonessential
{
title = "Select non-essential vertices/lines";

View file

@ -3934,6 +3934,50 @@ namespace CodeImp.DoomBuilder.BuilderModes
selection2.Count + (selection2.Count == 1 ? " thing." : " things."));
}
[BeginAction("clearmidtextures")]
public void ClearMidtextures()
{
// Make list of selected linedefs
List<VisualGeometry> selection = GetSelectedSurfaces();
// Anything to do?
if (selection.Count > 0)
{
// Make undo
if (selection.Count > 1)
{
General.Map.UndoRedo.CreateUndo("Cleared midtextures of " + selection.Count + " linedefs");
General.Interface.DisplayStatus(StatusType.Action, "Cleared midtextures of " + selection.Count + " linedefs.");
}
else
{
General.Map.UndoRedo.CreateUndo("Cleared midtextures of 1 linedef");
General.Interface.DisplayStatus(StatusType.Action, "Cleared midtextures of 1 linedef.");
}
//check selection
foreach (VisualGeometry vg in selection)
{
if (vg.GeometryType == VisualGeometryType.WALL_MIDDLE)
{
if (vg.Sidedef.Other != null)
{
vg.Sidedef.SetTextureMid("-");
vg.Sidedef.Other.SetTextureMid("-");
}
vg.Sidedef.Line.SetFlag(General.Map.Config.PegMidtextureFlag, false);
}
vg.Sector.UpdateSectorGeometry(true);
}
//update changed geometry
RebuildElementData();
UpdateChangedObjects();
General.Interface.DisplayStatus(StatusType.Action, "Cleared midtextures for " + selection.Count + (selection.Count == 1 ? " surface." : " surfaces."));
ShowTargetInfo();
}
}
//mxd
[BeginAction("toggleslope")]
public void ToggleSlope()