mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-27 22:31:15 +00:00
Allow changing sector texture offsets, if the sector has tagless flat alignment.
This commit is contained in:
parent
738fcfe2c3
commit
cde434af8c
3 changed files with 143 additions and 19 deletions
Source/Plugins/BuilderModes/VisualModes
|
@ -446,7 +446,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
protected void ClearFields(IEnumerable<string> keys, string undodescription, string resultdescription)
|
||||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
if(!General.Map.UDMF && !General.Map.SRB2) return;
|
||||
|
||||
mode.CreateUndo(undodescription);
|
||||
mode.SetActionResult(resultdescription);
|
||||
|
@ -902,7 +902,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(horizontal == 0 && vertical == 0) return; //mxd
|
||||
|
||||
//mxd
|
||||
if(!General.Map.UDMF)
|
||||
if(!General.Map.UDMF && !General.Map.SRB2)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Floor/ceiling texture offsets cannot be changed in this map format!");
|
||||
return;
|
||||
|
@ -912,7 +912,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
undoticket = mode.CreateUndo("Change texture offsets");
|
||||
|
||||
//mxd
|
||||
if(doSurfaceAngleCorrection)
|
||||
if(General.Map.UDMF && doSurfaceAngleCorrection)
|
||||
{
|
||||
Point p = new Point(horizontal, vertical);
|
||||
float angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
|
||||
|
|
|
@ -237,13 +237,55 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
Sector s = GetControlSector();
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float nx = (s.Fields.GetValue("xpanningceiling", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscaleceiling", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningceiling", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscaleceiling", 1.0f));
|
||||
s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
Linedef alignment = null;
|
||||
foreach (Sidedef side in s.Sidedefs)
|
||||
if (side.Line.IsFlatAlignment && side.Line.Tag == 0 && side.Sector == s) alignment = side.Line;
|
||||
if (alignment == null)
|
||||
{
|
||||
mode.SetActionResult("Sector has no flat alignment line!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alignment.IsFlagSet("4096"))
|
||||
alignment.SetFlag("4096", false);
|
||||
|
||||
mode.SetActionResult("Changed ceiling texture offsets to " + nx + ", " + ny + ".");
|
||||
if (!alignment.IsFlagSet("8192"))
|
||||
alignment.SetFlag("8192", true);
|
||||
|
||||
alignment.Front.OffsetX += xy.X;
|
||||
alignment.Front.OffsetY += xy.Y;
|
||||
|
||||
float rotation = General.ClampAngle(90f - alignment.Angle * Angle2D.PIDEG);
|
||||
float rotationrad = rotation / Angle2D.PIDEG;
|
||||
float rx = (float)Math.Cos(rotationrad) * alignment.Front.OffsetX - (float)Math.Sin(rotationrad) * -alignment.Front.OffsetY;
|
||||
float ry = (float)Math.Sin(rotationrad) * alignment.Front.OffsetX + (float)Math.Cos(rotationrad) * -alignment.Front.OffsetY;
|
||||
|
||||
if (s.Fields.ContainsKey("xpanningceiling")) s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, rx);
|
||||
else s.Fields.Add("xpanningceiling", new UniValue(UniversalType.Float, rx));
|
||||
if (s.Fields.ContainsKey("ypanningceiling")) s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, -ry);
|
||||
else s.Fields.Add("ypanningceiling", new UniValue(UniversalType.Float, -ry));
|
||||
if (s.Fields.ContainsKey("rotationfloor")) s.Fields["rotationfloor"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationfloor", new UniValue(UniversalType.Float, rotation));
|
||||
if (s.Fields.ContainsKey("rotationceiling")) s.Fields["rotationceiling"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationceiling", new UniValue(UniversalType.Float, rotation));
|
||||
|
||||
s.UpdateNeeded = true;
|
||||
mode.SetActionResult("Changed ceiling texture offsets to " + alignment.Front.OffsetX + ", " + alignment.Front.OffsetY + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float nx = (s.Fields.GetValue("xpanningceiling", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscaleceiling", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningceiling", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscaleceiling", 1.0f));
|
||||
s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
|
||||
mode.SetActionResult("Changed ceiling texture offsets to " + nx + ", " + ny + ".");
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Texture scale change
|
||||
|
@ -286,9 +328,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
public override void OnResetTextureOffset()
|
||||
public override void OnResetTextureOffset()
|
||||
{
|
||||
ClearFields(new[] { "xpanningceiling", "ypanningceiling" }, "Reset texture offsets", "Texture offsets reset.");
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
Sector s = GetControlSector();
|
||||
foreach (Sidedef side in s.Sidedefs)
|
||||
if (side.Line.IsFlatAlignment && side.Line.Tag == 0 && side.Sector == s && side.Line.IsFlagSet("8192"))
|
||||
{
|
||||
float rotation = General.ClampAngle(90f - side.Angle * Angle2D.PIDEG);
|
||||
if (s.Fields.ContainsKey("rotationfloor")) s.Fields["rotationfloor"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationfloor", new UniValue(UniversalType.Float, rotation));
|
||||
if (s.Fields.ContainsKey("rotationceiling")) s.Fields["rotationceiling"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationceiling", new UniValue(UniversalType.Float, rotation));
|
||||
|
||||
side.Line.Front.OffsetX = side.Line.Front.OffsetY = 0;
|
||||
|
||||
ClearFields(new[] { "xpanningfloor", "ypanningfloor", "xpanningceiling", "ypanningceiling" },
|
||||
"Reset texture offsets", "Texture offsets reset.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
ClearFields(new[] { "xpanningceiling", "ypanningceiling" }, "Reset texture offsets", "Texture offsets reset.");
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
|
@ -225,13 +225,53 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
Sector s = GetControlSector();
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float nx = (s.Fields.GetValue("xpanningfloor", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscalefloor", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningfloor", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscalefloor", 1.0f));
|
||||
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
Linedef alignment = null;
|
||||
foreach (Sidedef side in s.Sidedefs)
|
||||
if (side.Line.IsFlatAlignment && side.Line.Tag == 0 && side.Sector == s) alignment = side.Line;
|
||||
if (alignment == null)
|
||||
{
|
||||
mode.SetActionResult("Sector has no flat alignment line!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alignment.IsFlagSet("2048"))
|
||||
alignment.SetFlag("2048", false);
|
||||
|
||||
mode.SetActionResult("Changed floor texture offsets to " + nx + ", " + ny + ".");
|
||||
if (!alignment.IsFlagSet("8192"))
|
||||
alignment.SetFlag("8192", true);
|
||||
|
||||
alignment.Front.OffsetX += xy.X;
|
||||
alignment.Front.OffsetY += xy.Y;
|
||||
|
||||
float rotation = General.ClampAngle(90f - alignment.Angle * Angle2D.PIDEG);
|
||||
float rotationrad = rotation / Angle2D.PIDEG;
|
||||
float rx = (float)Math.Cos(rotationrad) * alignment.Front.OffsetX - (float)Math.Sin(rotationrad) * -alignment.Front.OffsetY;
|
||||
float ry = (float)Math.Sin(rotationrad) * alignment.Front.OffsetX + (float)Math.Cos(rotationrad) * -alignment.Front.OffsetY;
|
||||
|
||||
if (s.Fields.ContainsKey("xpanningfloor")) s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, rx);
|
||||
else s.Fields.Add("xpanningfloor", new UniValue(UniversalType.Float, rx));
|
||||
if (s.Fields.ContainsKey("ypanningfloor")) s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, -ry);
|
||||
else s.Fields.Add("ypanningfloor", new UniValue(UniversalType.Float, -ry));
|
||||
if (s.Fields.ContainsKey("rotationfloor")) s.Fields["rotationfloor"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationfloor", new UniValue(UniversalType.Float, rotation));
|
||||
|
||||
s.UpdateNeeded = true;
|
||||
mode.SetActionResult("Changed floor texture offsets to " + alignment.Front.OffsetX + ", " + alignment.Front.OffsetY + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float nx = (s.Fields.GetValue("xpanningfloor", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscalefloor", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningfloor", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscalefloor", 1.0f));
|
||||
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
|
||||
mode.SetActionResult("Changed floor texture offsets to " + nx + ", " + ny + ".");
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Texture scale change
|
||||
|
@ -274,9 +314,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
public override void OnResetTextureOffset()
|
||||
public override void OnResetTextureOffset()
|
||||
{
|
||||
ClearFields(new[] { "xpanningfloor", "ypanningfloor" }, "Reset texture offsets", "Texture offsets reset.");
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
Sector s = GetControlSector();
|
||||
foreach (Sidedef side in s.Sidedefs)
|
||||
if (side.Line.IsFlatAlignment && side.Line.Tag == 0 && side.Sector == s && side.Line.IsFlagSet("8192"))
|
||||
{
|
||||
float rotation = General.ClampAngle(90f - side.Angle * Angle2D.PIDEG);
|
||||
if (s.Fields.ContainsKey("rotationfloor")) s.Fields["rotationfloor"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationfloor", new UniValue(UniversalType.Float, rotation));
|
||||
if (s.Fields.ContainsKey("rotationceiling")) s.Fields["rotationceiling"] = new UniValue(UniversalType.Float, rotation);
|
||||
else s.Fields.Add("rotationceiling", new UniValue(UniversalType.Float, rotation));
|
||||
|
||||
side.Line.Front.OffsetX = side.Line.Front.OffsetY = 0;
|
||||
|
||||
ClearFields(new[] { "xpanningfloor", "ypanningfloor", "xpanningceiling", "ypanningceiling" },
|
||||
"Reset texture offsets", "Texture offsets reset.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
ClearFields(new[] { "xpanningfloor", "ypanningfloor" }, "Reset texture offsets", "Texture offsets reset.");
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
Loading…
Reference in a new issue