mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-19 18:41:26 +00:00
The raisesectortonearest and lowersectortonearest now work with visual slope handles
This commit is contained in:
parent
7b0adadbfb
commit
f5baa09684
2 changed files with 395 additions and 307 deletions
|
@ -2405,6 +2405,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
[BeginAction("raisesectortonearest")]
|
||||
public void RaiseSectorToNearest()
|
||||
{
|
||||
List<VisualSidedefSlope> selectedhandles = GetSelectedSlopeHandles();
|
||||
|
||||
if (selectedhandles.Count > 0)
|
||||
{
|
||||
if (selectedhandles.Count > 1)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can only raise to nearest when one visual slope handle is selected");
|
||||
return;
|
||||
}
|
||||
|
||||
int startheight = (int)selectedhandles[0].GetCenterPoint().z;
|
||||
int targetheight = int.MaxValue;
|
||||
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle != selectedhandles[0] && handle.Sidedef.Line == selectedhandles[0].Sidedef.Line)
|
||||
{
|
||||
int z = (int)handle.GetCenterPoint().z;
|
||||
|
||||
if (z > startheight && z < targetheight)
|
||||
targetheight = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetheight != int.MaxValue)
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
selectedhandles[0].OnChangeTargetHeight(targetheight - startheight);
|
||||
PostAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can't raise: already at the highest level");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<Sector, VisualFloor> floors = new Dictionary<Sector, VisualFloor>();
|
||||
Dictionary<Sector, VisualCeiling> ceilings = new Dictionary<Sector, VisualCeiling>();
|
||||
|
@ -2601,10 +2641,51 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
PostAction();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("lowersectortonearest")]
|
||||
public void LowerSectorToNearest()
|
||||
{
|
||||
List<VisualSidedefSlope> selectedhandles = GetSelectedSlopeHandles();
|
||||
|
||||
if (selectedhandles.Count > 0)
|
||||
{
|
||||
if (selectedhandles.Count > 1)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can only lower to nearest when one visual slope handle is selected");
|
||||
return;
|
||||
}
|
||||
|
||||
int startheight = (int)selectedhandles[0].GetCenterPoint().z;
|
||||
int targetheight = int.MinValue;
|
||||
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle != selectedhandles[0] && handle.Sidedef.Line == selectedhandles[0].Sidedef.Line)
|
||||
{
|
||||
int z = (int)handle.GetCenterPoint().z;
|
||||
|
||||
if (z < startheight && z > targetheight)
|
||||
targetheight = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetheight != int.MinValue)
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
selectedhandles[0].OnChangeTargetHeight(-(startheight - targetheight));
|
||||
PostAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can't lower: already at the lowest level");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<Sector, VisualFloor> floors = new Dictionary<Sector, VisualFloor>();
|
||||
Dictionary<Sector, VisualCeiling> ceilings = new Dictionary<Sector, VisualCeiling>();
|
||||
|
@ -2798,6 +2879,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
PostAction();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("matchbrightness")]
|
||||
|
|
|
@ -60,6 +60,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
public Vector3D GetCenterPoint()
|
||||
{
|
||||
Vector2D p = sidedef.Line.GetCenterPoint();
|
||||
return new Vector3D(p, level.plane.GetZ(p));
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
plane = new Plane(level.plane.Normal, level.plane.Offset - 0.1f);
|
||||
|
|
Loading…
Reference in a new issue