From 5bae9320139304ee44a8a9b6bf86b0623cdbf0de Mon Sep 17 00:00:00 2001 From: MaxED Date: Thu, 28 Mar 2013 11:37:08 +0000 Subject: [PATCH] Fixed: Assigning new tag using "New tag" button when selection already had a tag was not working. Fixed: "Automatic clear selection in classic modes" option was broken. --- Source/Core/GZBuilder/Controls/TagSelector.cs | 2 ++ .../Plugins/BuilderModes/ClassicModes/BridgeMode.cs | 12 +++--------- .../BuilderModes/ClassicModes/LinedefsMode.cs | 8 ++++++-- .../Plugins/BuilderModes/ClassicModes/SectorsMode.cs | 9 +++++++-- .../Plugins/BuilderModes/ClassicModes/ThingsMode.cs | 8 ++++++-- .../BuilderModes/ClassicModes/VerticesMode.cs | 8 ++++++-- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Source/Core/GZBuilder/Controls/TagSelector.cs b/Source/Core/GZBuilder/Controls/TagSelector.cs index e9f0fbb7..0216814b 100644 --- a/Source/Core/GZBuilder/Controls/TagSelector.cs +++ b/Source/Core/GZBuilder/Controls/TagSelector.cs @@ -90,6 +90,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls if(tags.Contains(newTag)) { cbTagPicker.SelectedIndex = tags.IndexOf(newTag); } else { + cbTagPicker.SelectedIndex = -1; cbTagPicker.Text = newTag.ToString(); } tag = newTag; @@ -150,6 +151,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls private void newTag_Click(object sender, EventArgs e) { //todo: check tag labels? tag = General.Map.Map.GetNewTag(); + cbTagPicker.SelectedIndex = -1; cbTagPicker.Text = tag.ToString(); valid = true; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs b/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs index f734434e..b7ad92da 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs @@ -126,7 +126,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes { ControlHandle handle = controlHandles[curControlHandle]; if (snaptogrid) { - handle.Position = DrawGeometryMode.GetCurrentPosition(mousemappos, false, true, renderer, new List()).pos; + handle.Position = General.Map.Grid.SnappedToGrid(mousemappos);// DrawGeometryMode.GetCurrentPosition(mousemappos, false, true, renderer, new List()).pos; } else { handle.Position = mousemappos; } @@ -475,7 +475,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes { relLenGroup[0] = 0.0f; //get length and angle of line, which defines the shape - float length = getLineLength(pointGroup[0], pointGroup[segmentsCount - 1]); + float length = Vector2D.Distance(pointGroup[0], pointGroup[segmentsCount - 1]);// getLineLength(pointGroup[0], pointGroup[segmentsCount - 1]); float angle = (float)Math.Atan2(pointGroup[0].y - pointGroup[segmentsCount - 1].y, pointGroup[0].x - pointGroup[segmentsCount - 1].x); float curAngle, diff, segLen; @@ -487,7 +487,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes { p1 = pointGroup[i]; curAngle = (float)Math.Atan2(p0.y - p1.y, p0.x - p1.x); diff = (angle + (float)Math.PI) - (curAngle + (float)Math.PI); - segLen = (int)(getLineLength(p0, p1) * Math.Cos(diff)); + segLen = (int)(Vector2D.Distance(p0, p1) * Math.Cos(diff)); relLenGroup[i] = relLenGroup[i - 1] + segLen / length; } @@ -496,12 +496,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes { return relLenGroup; } - private float getLineLength(Vector2D p0, Vector2D p1) { - float vx = Math.Abs(p0.x - p1.x); - float vy = Math.Abs(p0.y - p1.y); - return (float)Math.Sqrt(vx * vx + vy * vy); - } - //this returns relative handle location private Vector2D getHandleLocation(Vector2D start, Vector2D end, Vector2D direction) { float angle = -(float)Math.Atan2(start.y - end.y, start.x - end.x); diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index a6f96c85..768bd349 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -332,6 +332,10 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.Finish(); renderer.Present(); } + //mxd + } else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedLinedefsCount > 0) { + General.Map.Map.ClearSelectedLinedefs(); + General.Interface.RedrawDisplay(); } } @@ -540,8 +544,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { bool selectionvolume = ((Math.Abs(base.selectionrect.Width) > 0.1f) && (Math.Abs(base.selectionrect.Height) > 0.1f)); - if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) - General.Map.Map.ClearSelectedLinedefs(); + //if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) + //General.Map.Map.ClearSelectedLinedefs(); if(selectionvolume) { diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 23cc03e5..a53464f2 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -555,6 +555,11 @@ namespace CodeImp.DoomBuilder.BuilderModes foreach(TextLabel l in labelarray) l.Color = General.Colors.Highlight; UpdateOverlay(); renderer.Present(); + //mxd + } else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedSectorsCount > 0) { + General.Map.Map.ClearSelectedLinedefs(); + General.Map.Map.ClearSelectedSectors(); + General.Interface.RedrawDisplay(); } } @@ -819,11 +824,11 @@ namespace CodeImp.DoomBuilder.BuilderModes { bool selectionvolume = ((Math.Abs(base.selectionrect.Width) > 0.1f) && (Math.Abs(base.selectionrect.Height) > 0.1f)); - if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) + /*if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) { General.Map.Map.ClearSelectedLinedefs(); General.Map.Map.ClearSelectedSectors(); - } + }*/ if(selectionvolume) { diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index a16673e7..4230bd6b 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -318,6 +318,10 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.Finish(); renderer.Present(); } + //mxd + } else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedThingsCount > 0) { + General.Map.Map.ClearSelectedThings(); + General.Interface.RedrawDisplay(); } } @@ -544,8 +548,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { bool selectionvolume = ((Math.Abs(base.selectionrect.Width) > 0.1f) && (Math.Abs(base.selectionrect.Height) > 0.1f)); - if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) - General.Map.Map.ClearSelectedThings(); + //if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) + //General.Map.Map.ClearSelectedThings(); if(selectionvolume) { diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 64040711..63d6514d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -232,6 +232,10 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.Finish(); renderer.Present(); } + //mxd + } else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedVerticessCount > 0) { + General.Map.Map.ClearSelectedVertices(); + General.Interface.RedrawDisplay(); } } @@ -501,8 +505,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { bool selectionvolume = ((Math.Abs(base.selectionrect.Width) > 0.1f) && (Math.Abs(base.selectionrect.Height) > 0.1f)); - if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) - General.Map.Map.ClearSelectedVertices(); + //if(BuilderPlug.Me.AutoClearSelection && !selectionvolume) + //General.Map.Map.ClearSelectedVertices(); if(selectionvolume) {