mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Support "Align floor/ceiling to front side" actions in SRB2 maps
This commit is contained in:
parent
5133ff3040
commit
5bb6488ca0
1 changed files with 66 additions and 9 deletions
|
@ -211,18 +211,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(lines.Count == 0 && highlighted != null && !highlighted.IsDisposed)
|
||||
lines.Add(highlighted);
|
||||
|
||||
if(lines.Count == 0)
|
||||
if (lines.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection");
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(General.Map.SRB2 && !alignToFrontSide)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "SRB2 only supports front-side alignment.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Create Undo
|
||||
string rest = (alignFloors ? "Floors" : "Ceilings") + " to " + (alignToFrontSide ? "Front" : "Back")+ " Side";
|
||||
string rest = (alignFloors ? "floors" : "ceilings") + " to " + (alignToFrontSide ? "front" : "back")+ " side";
|
||||
General.Map.UndoRedo.CreateUndo("Align " + rest);
|
||||
int counter = 0;
|
||||
|
||||
foreach(Linedef l in lines)
|
||||
foreach (Linedef l in lines)
|
||||
{
|
||||
Sector s = null;
|
||||
|
||||
|
@ -240,6 +246,61 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
s.Fields.BeforeFieldsChange();
|
||||
|
||||
// hack for SRB2 flat alignment
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
bool existing = true;
|
||||
|
||||
// don't overwrite existing tags or actions
|
||||
if (l.Tag != 0 || (!l.IsFlatAlignment && l.Action != 0))
|
||||
continue;
|
||||
|
||||
// add flat alignment effect to new linedefs
|
||||
if (!l.IsFlatAlignment)
|
||||
{
|
||||
l.Action = General.Map.FormatInterface.FlatAlignmentType;
|
||||
existing = false;
|
||||
}
|
||||
|
||||
if (alignFloors)
|
||||
{
|
||||
if (l.IsFlagSet("2048"))
|
||||
l.SetFlag("2048", false); // enable floor alignment for existing lines
|
||||
else if (!existing)
|
||||
l.SetFlag("4096", true); // disable ceiling alignment for new lines
|
||||
else
|
||||
l.SetFlag("2048", true); // toggle floor alignment
|
||||
s.UpdateFloorSurface();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l.IsFlagSet("4096"))
|
||||
l.SetFlag("4096", false); // enable ceiling alignment for existing lines
|
||||
else if (!existing)
|
||||
l.SetFlag("2048", true); // disable floor alignment for new lines
|
||||
else
|
||||
l.SetFlag("4096", true); // toggle ceiling alignment
|
||||
s.UpdateCeilingSurface();
|
||||
}
|
||||
|
||||
if (l.IsFlagSet("2048") && l.IsFlagSet("4096")) // clear action if it does nothing
|
||||
{
|
||||
l.SetFlag("2048", false);
|
||||
l.SetFlag("4096", false);
|
||||
l.Action = 0;
|
||||
}
|
||||
|
||||
s.UpdateNeeded = true;
|
||||
s.UpdateCache();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!General.Map.UDMF && !General.Map.SRB2)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action only works in UDMF or SRB2 map format.");
|
||||
return;
|
||||
}
|
||||
|
||||
float sourceAngle = (float)Math.Round(General.ClampAngle(alignToFrontSide ? -Angle2D.RadToDeg(l.Angle) + 90 : -Angle2D.RadToDeg(l.Angle) - 90), 1);
|
||||
if(!alignToFrontSide) sourceAngle = General.ClampAngle(sourceAngle + 180);
|
||||
|
||||
|
@ -269,7 +330,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
s.UpdateCache();
|
||||
}
|
||||
|
||||
General.Interface.DisplayStatus(StatusType.Info, "Aligned " +counter + " " + rest);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "Aligned " + counter + " " + rest + ".");
|
||||
|
||||
//update
|
||||
General.Map.Map.Update();
|
||||
|
@ -1569,7 +1630,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("alignfloortofront")]
|
||||
public void AlignFloorToFront()
|
||||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
AlignTextureToLine(true, true);
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1637,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("alignfloortoback")]
|
||||
public void AlignFloorToBack()
|
||||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
AlignTextureToLine(true, false);
|
||||
}
|
||||
|
||||
|
@ -1585,7 +1644,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("alignceilingtofront")]
|
||||
public void AlignCeilingToFront()
|
||||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
AlignTextureToLine(false, true);
|
||||
}
|
||||
|
||||
|
@ -1593,7 +1651,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("alignceilingtoback")]
|
||||
public void AlignCeilingToBack()
|
||||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
AlignTextureToLine(false, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue