diff --git a/Build/ZoneBuilder.default.cfg b/Build/ZoneBuilder.default.cfg index 4305693..f1ab87b 100644 --- a/Build/ZoneBuilder.default.cfg +++ b/Build/ZoneBuilder.default.cfg @@ -228,6 +228,7 @@ shortcuts buildermodes_flooralignmode = 0; buildermodes_scaledowny = 101; buildermodes_toggleslope = 262227; + buildermodes_togglebackslope = 393299; buildermodes_resettextureudmf = 196690; buildermodes_rollcounterclockwise = 327675; buildermodes_visualfittextures = 393281; diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index 0f5c957..0caf9e2 100644 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -1119,15 +1119,26 @@ pastepropertieswithoptions //mxd toggleslope { - title = "Toggle Slope"; + title = "Toggle Slope (Front)"; category = "visual"; - description = "Toggles Slope for selected surfaces. Select or highlight upper/lower walls to add a slope. Select or highlight floors or ceilings to remove slope."; + description = "Toggles Slope for selected surfaces. Select or highlight upper/lower walls to add a slope to the front sector. Select or highlight floors or ceilings to remove slope."; allowkeys = true; allowmouse = true; allowscroll = true; default = 262227; //Alt-S } +togglebackslope +{ + title = "Toggle Slope (Back)"; + category = "visual"; + description = "Toggles Slope for selected surfaces. Select or highlight upper/lower walls to add a slope to the back sector. Select or highlight floors or ceilings to remove slope."; + allowkeys = true; + allowmouse = true; + allowscroll = true; + default = 393299; //Ctrl-Alt-S +} + placevisualstart { title = "Place Visual Mode Camera"; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 795155b..9ba1bf9 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -3746,7 +3746,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } List toUpdate = new List(); - General.Map.UndoRedo.CreateUndo("Toggle Slope"); + General.Map.UndoRedo.CreateUndo("Toggle Slope (Front)"); //check selection foreach(VisualGeometry vg in selection) @@ -3881,7 +3881,159 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Interface.DisplayStatus(StatusType.Action, "Toggled Slope for " + toUpdate.Count + (toUpdate.Count == 1 ? " surface." : " surfaces.")); } - + + [BeginAction("togglebackslope")] + public void ToggleBackSlope() + { + List selection = GetSelectedSurfaces(); + + if (selection.Count == 0) + { + General.Interface.DisplayStatus(StatusType.Warning, "Toggle Slope action requires selected surfaces!"); + return; + } + + List toUpdate = new List(); + General.Map.UndoRedo.CreateUndo("Toggle Slope (Back)"); + + //check selection + foreach (VisualGeometry vg in selection) + { + bool update = false; + + //assign/remove action + if (vg.GeometryType == VisualGeometryType.WALL_LOWER) + { + // MascaraSnake: Slope handling + if (vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.IsRegularSlope && vg.Sidedef.Line.Args[0] == 0)) + { + //check if the sector already has floor slopes + foreach (Sidedef side in vg.Sidedef.Other.Sector.Sidedefs) + { + if (side == vg.Sidedef || !side.Line.IsRegularSlope) continue; + + int arg = (side == side.Line.Front ? 2 : 1); + + if (side.Line.Args[0] == arg) + { + //if only floor is affected, remove action + if (side.Line.Args[1] == 0) + side.Line.Action = 0; + else + { //clear floor alignment + side.Line.Args[0] = 0; + side.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Arguments changed, so update slope type + } + } + } + + //set action + vg.Sidedef.Line.Args[0] = (vg.Sidedef == vg.Sidedef.Line.Front ? 2 : 1); + vg.Sidedef.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Set slope type + update = true; + } + } + else if (vg.GeometryType == VisualGeometryType.WALL_UPPER) + { + // MascaraSnake: Slope handling + if (vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.IsRegularSlope && vg.Sidedef.Line.Args[1] == 0)) + { + //check if the sector already has ceiling slopes + foreach (Sidedef side in vg.Sidedef.Other.Sector.Sidedefs) + { + if (side == vg.Sidedef || !side.Line.IsRegularSlope) continue; + + int arg = (side == side.Line.Front ? 2 : 1); + + if (side.Line.Args[1] == arg) + { + //if only ceiling is affected, remove action + if (side.Line.Args[0] == 0) + side.Line.Action = 0; + else + { //clear ceiling alignment + side.Line.Args[1] = 0; + side.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Arguments changed, so update slope type + } + } + } + + //set action + vg.Sidedef.Line.Args[1] = (vg.Sidedef == vg.Sidedef.Line.Front ? 2 : 1); + vg.Sidedef.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Set slope type + update = true; + } + } + else if (vg.GeometryType == VisualGeometryType.CEILING) + { + //check if the sector has ceiling slopes + foreach (Sidedef side in vg.Sector.Sector.Sidedefs) + { + // MascaraSnake: Slope handling + if (!side.Line.IsRegularSlope) continue; + + int arg = (side == side.Line.Front ? 1 : 2); + + if (side.Line.Args[1] == arg) + { + //if only ceiling is affected, remove action + if (side.Line.Args[0] == 0) + side.Line.Action = 0; + else + { //clear ceiling alignment + side.Line.Args[1] = 0; + side.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Arguments changed, so update slope type + } + + update = true; + } + } + } + else if (vg.GeometryType == VisualGeometryType.FLOOR) + { + //check if the sector has floor slopes + foreach (Sidedef side in vg.Sector.Sector.Sidedefs) + { + // MascaraSnake: Slope handling + if (!side.Line.IsRegularSlope) continue; + + int arg = (side == side.Line.Front ? 1 : 2); + + if (side.Line.Args[0] == arg) + { + //if only floor is affected, remove action + if (side.Line.Args[1] == 0) + side.Line.Action = 0; + else + { //clear floor alignment + side.Line.Args[0] = 0; + side.Line.SetSlopeTypeFromArgs(); //MascaraSnake: Arguments changed, so update slope type + } + update = true; + } + } + } + + //add to update list + if (update) toUpdate.Add(vg.Sector as BaseVisualSector); + } + + //update changed geometry + if (toUpdate.Count > 0) + { + RebuildElementData(); + + foreach (BaseVisualSector vs in toUpdate) + vs.UpdateSectorGeometry(true); + + UpdateChangedObjects(); + ClearSelection(); + ShowTargetInfo(); + } + + General.Interface.DisplayStatus(StatusType.Action, "Toggled Slope for " + toUpdate.Count + (toUpdate.Count == 1 ? " surface." : " surfaces.")); + } + #endregion #region ================== Texture Alignment