Add actions to toggle slope skewing and midtexture pegging

This commit is contained in:
spherallic 2024-07-12 13:37:14 +02:00
parent 122c7928b7
commit cf892c3e85
9 changed files with 124 additions and 3 deletions

View file

@ -1135,6 +1135,26 @@ togglelowerunpegged
allowscroll = true;
}
togglepegmidtexture
{
title = "Toggle Peg Midtexture";
category = "visual";
description = "Toggles the Peg Midtexture setting on the selected or targeted linedef.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
toggleslopeskew
{
title = "Toggle Slope Skew";
category = "visual";
description = "Toggles the Slope Skew setting on the selected or targeted linedef.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
togglegravity
{
title = "Toggle Gravity";

View file

@ -390,6 +390,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnTextureFit(FitTextureOptions options) { } //mxd
public virtual void OnToggleUpperUnpegged() { }
public virtual void OnToggleLowerUnpegged() { }
public virtual void OnTogglePegMidtexture() { }
public virtual void OnToggleSlopeSkew() { }
public virtual void OnResetTextureOffset() { }
public virtual void OnResetLocalTextureOffset() { } //mxd
public virtual void OnCopyTextureOffsets() { }
@ -398,6 +400,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected virtual void SetTexture(string texturename) { }
public virtual void ApplyUpperUnpegged(bool set) { }
public virtual void ApplyLowerUnpegged(bool set) { }
public virtual void ApplyLineFlag(Linedef line, string flag, string name) { }
protected abstract void MoveTextureOffset(int offsetx, int offsety);
protected abstract Point GetTextureOffset();
public virtual void OnPaintSelectEnd() { } // biwa

View file

@ -1060,7 +1060,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
// Toggle midtexture pegging
public virtual void OnTogglePegMidtexture()
{
mode.ApplyLineFlag(this.Sidedef.Line, "midpeg", "Peg Midtexture");
}
// Toggle slope skew
public virtual void OnToggleSlopeSkew()
{
switch (this.GeometryType)
{
case VisualGeometryType.WALL_LOWER:
case VisualGeometryType.WALL_UPPER:
mode.ApplyLineFlag(this.Sidedef.Line, "skewtd", "Slope Skew");
break;
case VisualGeometryType.WALL_MIDDLE_3D:
mode.ApplyLineFlag(this.GetControlLinedef(), "skewtd", "Slope Skew");
break;
case VisualGeometryType.WALL_MIDDLE:
mode.ApplyLineFlag(this.Sidedef.Line, "noskew", "No Midtexture Skew");
break;
}
}
// This sets the Upper Unpegged flag
public virtual void ApplyUpperUnpegged(bool set)
{
@ -1092,7 +1117,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
// This sets the Lower Unpegged flag
public virtual void ApplyLowerUnpegged(bool set)
{
@ -1124,6 +1148,37 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
// This sets a specified flag
public virtual void ApplyLineFlag(Linedef line, string flag, string name)
{
if (line.IsFlagSet(flag))
{
// Remove flag
mode.CreateUndo("Remove " + name + " flag");
mode.SetActionResult("Removed " + name + " flag.");
line.SetFlag(flag, false);
}
else
{
// Add flag
mode.CreateUndo("Set " + name + " flag");
mode.SetActionResult("Set " + name + " flag.");
line.SetFlag(flag, true);
}
// Update sidedef geometry
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
parts.SetupAllParts();
// Update other sidedef geometry
if (Sidedef.Other != null)
{
BaseVisualSector othersector = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector);
parts = othersector.GetSidedefParts(Sidedef.Other);
parts.SetupAllParts();
}
}
// Flood-fill textures
public virtual void OnTextureFloodfill()

View file

@ -2248,6 +2248,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
// Apply specified flag
public void ApplyLineFlag(Linedef line, string flag, string name)
{
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
foreach (IVisualEventReceiver i in objs)
{
i.ApplyLineFlag(line, flag, name);
}
}
// Apply texture change
public void ApplySelectTexture(string texture, bool flat)
{
@ -3775,6 +3785,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
PostAction();
}
[BeginAction("togglepegmidtexture")]
public void TogglePegMidtexture()
{
PreAction(UndoGroup.None);
GetTargetEventReceiver(false).OnTogglePegMidtexture();
PostAction();
}
[BeginAction("toggleslopeskew")]
public void ToggleSlopeSkew()
{
PreAction(UndoGroup.None);
GetTargetEventReceiver(false).OnToggleSlopeSkew();
PostAction();
}
[BeginAction("togglegravity")]
public void ToggleGravity()
{

View file

@ -120,6 +120,8 @@ namespace CodeImp.DoomBuilder.VisualModes
public void OnTextureAlign(bool alignx, bool aligny) { }
public void OnToggleUpperUnpegged() { }
public void OnToggleLowerUnpegged() { }
public void OnTogglePegMidtexture() { }
public void OnToggleSlopeSkew() { }
public void OnProcess(long deltatime) { }
public void OnTextureFloodfill() { }
public void OnInsert() { }
@ -127,6 +129,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public void ApplyTexture(string texture) { }
public void ApplyUpperUnpegged(bool set) { }
public void ApplyLowerUnpegged(bool set) { }
public void ApplyLineFlag(Linedef line, string flag, string name) { }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight, bool stopatselected) { } //mxd
public virtual void OnPaintSelectEnd() { } // biwa
public void OnChangeScale(int x, int y) { }

View file

@ -714,6 +714,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnTextureAlign(bool alignx, bool aligny) { }
public void OnToggleUpperUnpegged() { }
public void OnToggleLowerUnpegged() { }
public void OnTogglePegMidtexture() { }
public void OnToggleSlopeSkew() { }
public void OnProcess(long deltatime) { }
public void OnTextureFloodfill() { }
public void OnInsert() { }
@ -721,6 +723,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyTexture(string texture) { }
public void ApplyUpperUnpegged(bool set) { }
public void ApplyLowerUnpegged(bool set) { }
public void ApplyLineFlag(Linedef line, string flag, string name) { }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight, bool stopatselected) { } //mxd
public virtual void OnPaintSelectEnd() { } // biwa

View file

@ -252,6 +252,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnTextureFit(FitTextureOptions options) { } //mxd
public void OnToggleUpperUnpegged() { }
public void OnToggleLowerUnpegged() { }
public void OnTogglePegMidtexture() { }
public void OnToggleSlopeSkew() { }
public void OnResetTextureOffset() { }
public void OnResetLocalTextureOffset() { } //mxd
public void OnProcess(long deltatime) { }
@ -260,6 +262,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyTexture(string texture) { }
public void ApplyUpperUnpegged(bool set) { }
public void ApplyLowerUnpegged(bool set) { }
public void ApplyLineFlag(Linedef line, string flag, string name) { }
public string GetTextureName() { return ""; }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight, bool stopatselected) { } //mxd
public virtual void OnPaintSelectBegin() { } // biwa

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using CodeImp.DoomBuilder.Map;
using System.Windows.Forms;
#endregion
@ -51,6 +52,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
void OnTextureFloodfill();
void OnToggleUpperUnpegged();
void OnToggleLowerUnpegged();
void OnTogglePegMidtexture();
void OnToggleSlopeSkew();
void OnProcess(long deltatime);
void OnInsert();
void OnDelete();
@ -61,7 +64,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
void ApplyTexture(string texture);
void ApplyUpperUnpegged(bool set);
void ApplyLowerUnpegged(bool set);
void ApplyLineFlag(Linedef line, string flag, string name);
// Other methods
string GetTextureName();
void SelectNeighbours(bool select, bool matchtexture, bool matchheight, bool stopatselected); //mxd

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using CodeImp.DoomBuilder.Map;
using System.Windows.Forms;
#endregion
@ -50,6 +51,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnTextureFloodfill() { }
public void OnToggleUpperUnpegged() { }
public void OnToggleLowerUnpegged() { }
public void OnTogglePegMidtexture() { }
public void OnToggleSlopeSkew() { }
public void OnProcess(long deltatime) { }
public void OnInsert() { }
public void OnDelete() { }
@ -58,6 +61,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyTexture(string texture) { }
public void ApplyUpperUnpegged(bool set) { }
public void ApplyLowerUnpegged(bool set) { }
public void ApplyLineFlag(Linedef line, string flag, string name) { }
public string GetTextureName() { return ""; }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight, bool stopatselected) { } //mxd
}