From 13aabd4257af2117ff0e8ea6a6a3e039260c96f0 Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 25 Apr 2016 14:48:39 +0000 Subject: [PATCH] Added, Drag Vertices\Linedefs\Sectors\Edit Selection modes: sidedefs facing outside of current selection are now reattached/added/removed after moving the selection. Currently this will work as intended only if the selection ends up either completely inside a single sector or completely outside of any sector. Also this logic won't be applied if the selection contains the lines with only start or end vertex selected. Internal: some TextLabel refactoring. --- .../Includes/ZDoom_linedefs.cfg | 12 ++ Source/Core/Builder.csproj | 1 + Source/Core/Geometry/Plane.cs | 17 +- Source/Core/Geometry/Tools.cs | 169 ++++++++++++++++++ Source/Core/Map/MapSet.cs | 34 +++- Source/Core/Rendering/CustomTextLabel.cs | 30 ++++ Source/Core/Rendering/IRenderer2D.cs | 4 +- Source/Core/Rendering/Renderer2D.cs | 8 +- Source/Core/Rendering/TextLabel.cs | 26 ++- .../ClassicModes/DragLinedefsMode.cs | 16 +- .../ClassicModes/DragSectorsMode.cs | 18 +- .../ClassicModes/DragVerticesMode.cs | 20 ++- .../ClassicModes/DrawCurveMode.cs | 4 +- .../ClassicModes/DrawGeometryMode.cs | 11 +- .../ClassicModes/EditSelectionMode.cs | 14 +- .../BuilderModes/ClassicModes/LinedefsMode.cs | 4 +- .../BuilderModes/ClassicModes/SectorsMode.cs | 4 +- .../BuilderModes/ClassicModes/ThingsMode.cs | 4 +- .../BuilderModes/ClassicModes/VerticesMode.cs | 2 +- .../Plugins/BuilderModes/General/HintLabel.cs | 2 - .../BuilderModes/General/LineLengthLabel.cs | 8 +- 21 files changed, 355 insertions(+), 53 deletions(-) create mode 100644 Source/Core/Rendering/CustomTextLabel.cs diff --git a/Build/Configurations/Includes/ZDoom_linedefs.cfg b/Build/Configurations/Includes/ZDoom_linedefs.cfg index 26259202..fb52a756 100644 --- a/Build/Configurations/Includes/ZDoom_linedefs.cfg +++ b/Build/Configurations/Includes/ZDoom_linedefs.cfg @@ -2171,6 +2171,18 @@ zdoom } 71 // Teleport_NoFog { + arg1 + { + title = "Teleport Dest. angle usage"; + type = 11; + enum + { + 0 = "Don't change angle and velocity (Hexen-compat)"; + 1 = "Always use the teleport exit's angle (Strife-compat)"; + 2 = "Adjust relatively to the teleport exit's angle, but in the wrong direction (Boom-compat)"; + 3 = "Adjust relatively to the teleport exit's angle (Boom-fixed)"; + } + } arg3 { title = "Keep rel. Height"; diff --git a/Source/Core/Builder.csproj b/Source/Core/Builder.csproj index 1f3e8566..29e0ee72 100644 --- a/Source/Core/Builder.csproj +++ b/Source/Core/Builder.csproj @@ -920,6 +920,7 @@ + diff --git a/Source/Core/Geometry/Plane.cs b/Source/Core/Geometry/Plane.cs index 56487a11..9d91bde5 100644 --- a/Source/Core/Geometry/Plane.cs +++ b/Source/Core/Geometry/Plane.cs @@ -144,8 +144,7 @@ namespace CodeImp.DoomBuilder.Geometry /// public Vector3D ClosestOnPlane(Vector3D p) { - float d = this.Distance(p); - return p - normal * d; + return p - normal * this.Distance(p); } /// @@ -171,6 +170,20 @@ namespace CodeImp.DoomBuilder.Geometry { return new Plane(-normal, -offset); } + + //mxd. Addeed to make compiler a bit more happy... + public override int GetHashCode() + { + return base.GetHashCode(); + } + + //mxd. Addeed to make compiler a bit more happy... + public override bool Equals(object obj) + { + if(!(obj is Plane)) return false; + Plane other = (Plane)obj; + return (normal != other.normal) || (offset != other.offset); + } #endregion diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 727542fa..6fee304a 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2255,6 +2255,175 @@ namespace CodeImp.DoomBuilder.Geometry return 0; } + //mxd. Try to create/remove/reassign outer sidedefs. Selected linedefs and verts are marked + public static void AdjustOuterSidedefs(HashSet selectedsectors, ICollection selectedlines) + { + HashSet outersides = new HashSet(); + HashSet singlesidedlines = new HashSet(); + HashSet lineswithoutsides = new HashSet(); + + // Collect lines without sidedefs and lines, which don't reference selected sectors + foreach(Linedef line in selectedlines) + { + if(line.Front == null && line.Back == null) + { + lineswithoutsides.Add(line); + } + else + { + if(line.Back != null && line.Back.Sector != null && !selectedsectors.Contains(line.Back.Sector)) + outersides.Add(line.Back); + if(line.Front != null && line.Front.Sector != null && !selectedsectors.Contains(line.Front.Sector)) + outersides.Add(line.Front); + } + } + + // Collect outer sides and single-sided lines + foreach(Sector sector in selectedsectors) + { + foreach(Sidedef side in sector.Sidedefs) + { + if(side.Other == null) singlesidedlines.Add(side.Line); + else if(!selectedsectors.Contains(side.Other.Sector)) outersides.Add(side.Other); + } + } + + // Check lines without sidedefs. Add new sidedefs if necessary + foreach(Linedef line in lineswithoutsides) + { + bool sideschanged = false; + + // Add front side? + Vector2D testpoint = line.GetSidePoint(true); + Linedef nl = General.Map.Map.NearestLinedef(testpoint, selectedlines); + if(nl != null) + { + Sidedef ns = (nl.SideOfLine(testpoint) <= 0 ? nl.Front : nl.Back); + if(ns != null) + { + // Create new sidedef + Sidedef newside = General.Map.Map.CreateSidedef(line, true, ns.Sector); + + // Copy props from the other side + ns.CopyPropertiesTo(newside); + newside.RemoveUnneededTextures(true, true, true); + + sideschanged = true; + } + } + + // Add back side? + testpoint = line.GetSidePoint(false); + nl = General.Map.Map.NearestLinedef(testpoint, selectedlines); + if(nl != null) + { + Sidedef ns = (nl.SideOfLine(testpoint) <= 0 ? nl.Front : nl.Back); + if(ns != null) + { + // Create new sidedef + Sidedef newside = General.Map.Map.CreateSidedef(line, false, ns.Sector); + + // Copy props from the other side + ns.CopyPropertiesTo(newside); + newside.RemoveUnneededTextures(true, true, true); + + sideschanged = true; + } + } + + // Correct the sided flags + if(sideschanged) + { + // Correct the linedef + if((line.Front == null) && (line.Back != null)) + { + line.FlipVertices(); + line.FlipSidedefs(); + } + + // Correct the sided flags + line.ApplySidedFlags(); + } + } + + // Check single-sided lines. Add new sidedefs if necessary + foreach(Linedef line in singlesidedlines) + { + // Line is now inside a sector? + Vector2D testpoint = line.GetSidePoint(line.Front == null); + Linedef nl = General.Map.Map.NearestLinedef(testpoint, selectedlines); + if(nl != null) + { + Sidedef ns = (nl.SideOfLine(testpoint) <= 0 ? nl.Front : nl.Back); + if(ns != null) + { + // Create new sidedef + Sidedef newside = General.Map.Map.CreateSidedef(line, line.Front == null, ns.Sector); + + // Copy props from the other side + Sidedef propssource = ((line.Front ?? line.Back) ?? ns); + propssource.CopyPropertiesTo(newside); + newside.RemoveUnneededTextures(true, true, true); + newside.Other.RemoveUnneededTextures(true, true, true); + + // Correct the linedef + if((line.Front == null) && (line.Back != null)) + { + line.FlipVertices(); + line.FlipSidedefs(); + } + + // Correct the sided flags + line.ApplySidedFlags(); + } + } + } + + // Check outer sidedefs. Remove/change sector if necessary + foreach(Sidedef side in outersides) + { + // Side is inside a sector? + Vector2D testpoint = side.Line.GetSidePoint(side.IsFront); + Linedef nl = General.Map.Map.NearestLinedef(testpoint, selectedlines); + bool lineisoutside = true; + if(nl != null) + { + Sidedef ns = (nl.SideOfLine(testpoint) <= 0 ? nl.Front : nl.Back); + if(ns != null) + { + lineisoutside = false; + if(ns.Sector != null && side.Sector != ns.Sector) + { + // Reattach side + side.SetSector(ns.Sector); + side.RemoveUnneededTextures(true, true, true); + } + } + } + + // Side points nowhere. Remove it + if(lineisoutside) + { + // Remove the sidedef + Linedef l = side.Line; + side.Dispose(); + + // Correct the linedef + if((l.Front == null) && (l.Back != null)) + { + l.FlipVertices(); + l.FlipSidedefs(); + } + + // Correct the sided flags + l.ApplySidedFlags(); + } + } + + // Update map geometry + General.Map.Map.Update(); + } + #endregion #region ================== Misc Exported Functions diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs index d6fa809b..d2ddbe61 100644 --- a/Source/Core/Map/MapSet.cs +++ b/Source/Core/Map/MapSet.cs @@ -2589,7 +2589,7 @@ namespace CodeImp.DoomBuilder.Map } /// mxd. This finds the line closest to the specified position excluding given list of linedefs. - public Linedef NearestLinedef(Vector2D pos, List linesToExclude) + public Linedef NearestLinedef(Vector2D pos, ICollection linesToExclude) { Linedef closest = null; float distance = float.MaxValue; @@ -3113,6 +3113,38 @@ namespace CodeImp.DoomBuilder.Map return null; } + //mxd + /// Gets unselected sectors, which have all their linedefs selected + public HashSet GetUnselectedSectorsFromLinedefs(IEnumerable lines) + { + HashSet result = new HashSet(); + Dictionary> sectorsbysides = new Dictionary>(); + HashSet selectedsectors = new HashSet(General.Map.Map.GetSelectedSectors(true)); + + // Collect unselected sectors, which sidedefs belong to selected lines + foreach(Linedef line in lines) + { + if(line.Front != null && line.Front.Sector != null && !selectedsectors.Contains(line.Front.Sector)) + { + if(!sectorsbysides.ContainsKey(line.Front.Sector)) sectorsbysides.Add(line.Front.Sector, new HashSet()); + sectorsbysides[line.Front.Sector].Add(line.Front); + } + if(line.Back != null && line.Back.Sector != null && !selectedsectors.Contains(line.Back.Sector)) + { + if(!sectorsbysides.ContainsKey(line.Back.Sector)) sectorsbysides.Add(line.Back.Sector, new HashSet()); + sectorsbysides[line.Back.Sector].Add(line.Back); + } + } + + // Add sectors, which have all their lines selected + foreach(var group in sectorsbysides) + { + if(group.Key.Sidedefs.Count == group.Value.Count) result.Add(group.Key); + } + + return result; + } + /// This finds the line closest to the specified position. public Linedef NearestLinedef(Vector2D pos) { return MapSet.NearestLinedef(linedefs, pos); } diff --git a/Source/Core/Rendering/CustomTextLabel.cs b/Source/Core/Rendering/CustomTextLabel.cs new file mode 100644 index 00000000..9320d38a --- /dev/null +++ b/Source/Core/Rendering/CustomTextLabel.cs @@ -0,0 +1,30 @@ +using System.Drawing; +using SlimDX.Direct3D9; +using Font = System.Drawing.Font; + +namespace CodeImp.DoomBuilder.Rendering +{ + //mxd. TextLabel wrapper + public abstract class CustomTextLabel : ITextLabel + { + protected TextLabel label; // Derived classes must create this! + + // Required to render text label + public bool SkipRendering { get { return label.SkipRendering; } } + public Texture Texture { get { return label.Texture; } } + public VertexBuffer VertexBuffer { get { return label.VertexBuffer; } } + public Font Font { get { return label.Font; } set { label.Font = value; } } + public string Text { get { return label.Text; } set { label.Text = value; } } + + // Access/setup + public TextLabel TextLabel { get { return label; } } + public PixelColor Color { get { return label.Color; } set { label.Color = value; } } + public PixelColor BackColor { get { return label.BackColor; } set { label.BackColor = value; } } + public SizeF TextSize { get { return label.TextSize; } } + + public void Update(float translatex, float translatey, float scalex, float scaley) + { + label.Update(translatex, translatey, scalex, scaley); + } + } +} diff --git a/Source/Core/Rendering/IRenderer2D.cs b/Source/Core/Rendering/IRenderer2D.cs index 6a4ae52d..551bcd1f 100644 --- a/Source/Core/Rendering/IRenderer2D.cs +++ b/Source/Core/Rendering/IRenderer2D.cs @@ -74,8 +74,8 @@ namespace CodeImp.DoomBuilder.Rendering void RenderLine(Vector2D start, Vector2D end, float thickness, PixelColor c, bool transformcoords); void RenderArrows(ICollection line); //mxd void RenderArrows(ICollection line, bool transformcoords); //mxd - void RenderText(TextLabel text); - void RenderText(List labels); //mxd + void RenderText(ITextLabel text); + void RenderText(IList labels); //mxd void RenderGeometry(FlatVertex[] vertices, ImageData texture, bool transformcoords); void RenderHighlight(FlatVertex[] vertices, int color); //mxd void RedrawSurface(); diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index c3c770a6..41d6385a 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -1626,7 +1626,7 @@ namespace CodeImp.DoomBuilder.Rendering } // This renders text - public void RenderText(TextLabel label) + public void RenderText(ITextLabel label) { //mxd. Update the text if needed label.Update(translatex, translatey, scale, -scale); @@ -1653,11 +1653,11 @@ namespace CodeImp.DoomBuilder.Rendering } //mxd. This renders text - public void RenderText(List labels) + public void RenderText(IList labels) { // Update labels int skipped = 0; - foreach(TextLabel label in labels) + foreach(ITextLabel label in labels) { // Update the text if needed label.Update(translatex, translatey, scale, -scale); @@ -1680,7 +1680,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Shaders.Display2D.Begin(); graphics.Shaders.Display2D.BeginPass(1); - foreach(TextLabel label in labels) + foreach(ITextLabel label in labels) { // Text is created? if(!label.SkipRendering) diff --git a/Source/Core/Rendering/TextLabel.cs b/Source/Core/Rendering/TextLabel.cs index f84f30b3..b1516729 100644 --- a/Source/Core/Rendering/TextLabel.cs +++ b/Source/Core/Rendering/TextLabel.cs @@ -31,7 +31,23 @@ using Font = System.Drawing.Font; namespace CodeImp.DoomBuilder.Rendering { - public class TextLabel : IDisposable, ID3DResource + public interface ITextLabel //mxd. Methods and properties required to render a textlabel + { + // Required to render text label + bool SkipRendering { get; } + Texture Texture { get; } + VertexBuffer VertexBuffer { get; } + + // Access/setup + Font Font { get; } + string Text { get; set; } + PixelColor Color { get; set; } + PixelColor BackColor { get; set; } + + void Update(float translatex, float translatey, float scalex, float scaley); + } + + public class TextLabel : IDisposable, ID3DResource, ITextLabel { #region ================== Constants @@ -90,9 +106,9 @@ namespace CodeImp.DoomBuilder.Rendering public PixelColor Color { get { return color; } set { if(!color.Equals(value)) { color = value; textureupdateneeded = true; } } } public PixelColor BackColor { get { return backcolor; } set { if(!backcolor.Equals(value)) { backcolor = value; textureupdateneeded = true; } } } public bool DrawBackground { get { return drawbg; } set { if(drawbg != value) { drawbg = value; textureupdateneeded = true; } } } //mxd - internal Texture Texture { get { return texture; } } //mxd - internal VertexBuffer VertexBuffer { get { return textbuffer; } } - internal bool SkipRendering { get { return skiprendering; } } //mxd + public Texture Texture { get { return texture; } } //mxd + public VertexBuffer VertexBuffer { get { return textbuffer; } } + public bool SkipRendering { get { return skiprendering; } } //mxd // Disposing public bool IsDisposed { get { return isdisposed; } } @@ -146,7 +162,7 @@ namespace CodeImp.DoomBuilder.Rendering #region ================== Methods // This updates the text if needed - internal void Update(float translatex, float translatey, float scalex, float scaley) + public void Update(float translatex, float translatey, float scalex, float scaley) { // Check if transformation changed and needs to be updated if(transformcoords && (translatex != lasttranslatex || translatey != lasttranslatey || diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs index ab513b41..ea973917 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs @@ -111,6 +111,17 @@ namespace CodeImp.DoomBuilder.BuilderModes // When not cancelled if(!cancelled) { + //mxd. Reattach/add/remove sidedefs only when there are no unstable lines in selection + if(unstablelines.Count == 0) + { + // Add sectors, which have all their linedefs selected + // (otherwise those would be destroyed after moving the selection) + HashSet toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines); + + // Process outer sidedefs + Tools.AdjustOuterSidedefs(toadjust, selectedlines); + } + // If only a single linedef was selected, deselect it now if(selectedlines.Count == 1) General.Map.Map.ClearSelectedLinedefs(); } @@ -168,10 +179,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Redraw overlay if(renderer.StartOverlay(true)) { - foreach(LineLengthLabel l in labels) - { - renderer.RenderText(l.TextLabel); - } + renderer.RenderText(labels); renderer.Finish(); } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs index 1509cab5..1bbcec61 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs @@ -118,6 +118,19 @@ namespace CodeImp.DoomBuilder.BuilderModes // When not cancelled if(!cancelled) { + //mxd. Reattach/add/remove sidedefs only when there are no unstable lines in selection + if(unstablelines.Count == 0) + { + HashSet toadjust = new HashSet(selectedsectors); + + // Add sectors, which are not selected, but have all their linedefs selected + // (otherwise those would be destroyed after moving the selection) + toadjust.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines)); + + // Process outer sidedefs + Tools.AdjustOuterSidedefs(toadjust, selectedlines); + } + // If only a single sector was selected, deselect it now if(selectedsectors.Count == 1) { @@ -188,10 +201,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Redraw overlay if(renderer.StartOverlay(true)) { - foreach(LineLengthLabel l in labels) - { - renderer.RenderText(l.TextLabel); - } + renderer.RenderText(labels); renderer.Finish(); } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs index 5ee76869..a455326d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs @@ -17,6 +17,7 @@ #region ================== Namespaces using System; +using System.Collections.Generic; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Geometry; @@ -53,7 +54,7 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Constructor / Disposer // Constructor to start dragging immediately - public DragVerticesMode(Vertex dragitem, Vector2D dragstartmappos) + public DragVerticesMode(Vector2D dragstartmappos) { // Mark what we are dragging General.Map.Map.ClearAllMarks(false); @@ -97,6 +98,18 @@ namespace CodeImp.DoomBuilder.BuilderModes // When not cancelled if(!cancelled) { + //mxd. Reattach/add/remove sidedefs only when there are no unstable lines in selection + if(selectedverts.Count > 1 && unstablelines.Count == 0) + { + // Add sectors, which have all their linedefs selected + // (otherwise those would be destroyed after moving the selection) + ICollection selectedlines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false); + HashSet toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines); + + // Process outer sidedefs + Tools.AdjustOuterSidedefs(toadjust, selectedlines); + } + // If only a single vertex was selected, deselect it now if(selectedverts.Count == 1) General.Map.Map.ClearSelectedVertices(); } @@ -156,10 +169,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Redraw overlay if(renderer.StartOverlay(true)) { - foreach(LineLengthLabel l in labels) - { - renderer.RenderText(l.TextLabel); - } + renderer.RenderText(labels); renderer.Finish(); } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/DrawCurveMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DrawCurveMode.cs index 330e1276..b7552123 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DrawCurveMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DrawCurveMode.cs @@ -140,8 +140,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // Render vertex at cursor renderer.RenderRectangleFilled(new RectangleF(curp.pos.x - vsize, curp.pos.y - vsize, vsize * 2.0f, vsize * 2.0f), color, true); - // Go for all labels - foreach(LineLengthLabel l in labels) renderer.RenderText(l.TextLabel); + // Render labels + renderer.RenderText(labels.ToArray()); //Render info label Vector2D start = new Vector2D(mousemappos.x + (32 / renderer.Scale), mousemappos.y - (16 / renderer.Scale)); diff --git a/Source/Plugins/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DrawGeometryMode.cs index ca6dc319..b56ec485 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DrawGeometryMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DrawGeometryMode.cs @@ -262,10 +262,10 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Render guide labels? - if(renderguidelabels) - { - foreach(LineLengthLabel l in guidelabels) renderer.RenderText(l.TextLabel); - } + if(renderguidelabels) renderer.RenderText(guidelabels); + + // Render labels + renderer.RenderText(labels.ToArray()); } // Determine point color @@ -274,9 +274,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Render vertex at cursor renderer.RenderRectangleFilled(new RectangleF(curp.pos.x - vsize, curp.pos.y - vsize, vsize * 2.0f, vsize * 2.0f), color, true); - // Go for all labels - foreach(LineLengthLabel l in labels) renderer.RenderText(l.TextLabel); - // Done renderer.Finish(); } diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 40bdaa84..6d57ac5d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Windows.Forms; using CodeImp.DoomBuilder.Actions; @@ -160,6 +161,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private List thingangle; private ICollection unselectedvertices; private ICollection unselectedlines; + private ICollection unstablelines; //mxd // Modification private float rotation; @@ -1088,6 +1090,7 @@ namespace CodeImp.DoomBuilder.BuilderModes foreach(Linedef l in markedlines) l.Selected = true; selectedlines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false); unselectedlines = General.Map.Map.LinedefsFromMarkedVertices(true, false, false); + unstablelines = (pasting ? new Collection() : General.Map.Map.LinedefsFromMarkedVertices(false, false, true)); //mxd // Array to keep original coordinates vertexpos = new List(selectedvertices.Count); @@ -1475,7 +1478,16 @@ namespace CodeImp.DoomBuilder.BuilderModes // Remove any virtual sectors General.Map.Map.RemoveVirtualSectors(); } - + + //mxd. Reattach/add/remove sidedefs only when there are no unstable lines in selection + if(unstablelines.Count == 0) + { + // Update outer sides of the selection + HashSet affectedsectors = new HashSet(General.Map.Map.GetSelectedSectors(true)); + affectedsectors.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines)); + Tools.AdjustOuterSidedefs(affectedsectors, selectedlines); + } + // Stitch geometry if(snaptonearest) General.Map.Map.StitchGeometry(); diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 4176e8de..a8c516b1 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -633,7 +633,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Render sector tag labels if(BuilderPlug.Me.ViewSelectionEffects) { - List torender = new List(sectorlabels.Count); + List torender = new List(sectorlabels.Count); foreach(KeyValuePair group in sectortexts) { // Pick which text variant to use @@ -668,7 +668,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Render selection labels if(BuilderPlug.Me.ViewSelectionNumbers) { - List torender = new List(labels.Count); + List torender = new List(labels.Count); foreach(KeyValuePair group in labels) { // Render only when enough space for the label to see diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 32e698fa..d5f3438d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -193,7 +193,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(BuilderPlug.Me.ViewSelectionNumbers && orderedselection.Count < MAX_SECTOR_LABELS) { - List torender = new List(orderedselection.Count); + List torender = new List(orderedselection.Count); foreach(Sector s in orderedselection) { //mxd. Self-referencing (and probably some other) sectors don't have labels... @@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd private void RenderEffectLabels(Dictionary labelsGroup) { - List torender = new List(labelsGroup.Count); + List torender = new List(labelsGroup.Count); foreach(KeyValuePair group in labelsGroup) { // Pick which text variant to use diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 6a51d176..10138120 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -266,7 +266,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Render sector tag labels if(BuilderPlug.Me.ViewSelectionEffects && General.Map.FormatInterface.HasThingAction) { - List torender = new List(sectorlabels.Count); + List torender = new List(sectorlabels.Count); foreach(KeyValuePair group in sectortexts) { // Pick which text variant to use @@ -301,7 +301,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Render selection labels if(BuilderPlug.Me.ViewSelectionNumbers) { - List torender = new List(labels.Count); + List torender = new List(labels.Count); foreach(KeyValuePair group in labels) { // Render only when enough space for the label to see diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 6367caf4..6e72d257 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -586,7 +586,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Start dragging the selection if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd - General.Editing.ChangeMode(new DragVerticesMode(highlighted, mousedownmappos)); + General.Editing.ChangeMode(new DragVerticesMode(mousedownmappos)); } } } diff --git a/Source/Plugins/BuilderModes/General/HintLabel.cs b/Source/Plugins/BuilderModes/General/HintLabel.cs index b62ce681..6e5ec7af 100644 --- a/Source/Plugins/BuilderModes/General/HintLabel.cs +++ b/Source/Plugins/BuilderModes/General/HintLabel.cs @@ -7,8 +7,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { public class HintLabel : LineLengthLabel { - public string Text { get { return label.Text; } set { label.Text = value; } } - public HintLabel() : base(false, false) { } public HintLabel(PixelColor textcolor) : base(false, false) { diff --git a/Source/Plugins/BuilderModes/General/LineLengthLabel.cs b/Source/Plugins/BuilderModes/General/LineLengthLabel.cs index aca4c2fb..4c420fdc 100644 --- a/Source/Plugins/BuilderModes/General/LineLengthLabel.cs +++ b/Source/Plugins/BuilderModes/General/LineLengthLabel.cs @@ -25,7 +25,7 @@ using System.Drawing; namespace CodeImp.DoomBuilder.BuilderModes { - public class LineLengthLabel : IDisposable + public class LineLengthLabel : CustomTextLabel, IDisposable { #region ================== Constants @@ -35,7 +35,6 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Variables - protected TextLabel label; protected Vector2D start; protected Vector2D end; @@ -47,14 +46,9 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties - public TextLabel TextLabel { get { return label; } } - //mxd. Display options public bool ShowAngle { get { return showangle; } set { showangle = value; UpdateText(); } } public bool OffsetPosition { get { return offsetposition; } set { offsetposition = value; Move(start, end); } } - public PixelColor Color { get { return label.Color; } set { label.Color = value; } } - public PixelColor BackColor { get { return label.BackColor; } set { label.BackColor = value; } } - public SizeF TextSize { get { return label.TextSize; } } #endregion