diff --git a/Resources/Icons/ThingsListIcon.png b/Resources/Icons/ThingsListIcon.png new file mode 100644 index 00000000..4cd3d5ac Binary files /dev/null and b/Resources/Icons/ThingsListIcon.png differ diff --git a/Resources/ThingColors.png b/Resources/ThingColors.png new file mode 100644 index 00000000..ec524dc6 Binary files /dev/null and b/Resources/ThingColors.png differ diff --git a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs index 2c785433..aa49fa5b 100644 --- a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs @@ -745,6 +745,32 @@ namespace CodeImp.DoomBuilder.BuilderModes Update(); } + // This draws a point at a specific location + public void DrawPointAt(Vector2D pos, bool stitch) + { + DrawnVertex newpoint = new DrawnVertex(); + newpoint.pos = pos; + newpoint.stitch = stitch; + points.Add(newpoint); + labels.Add(new LineLengthLabel()); + labels[labels.Count - 1].Start = newpoint.pos; + if(labels.Count > 1) labels[labels.Count - 2].End = newpoint.pos; + Update(); + + // Check if point stitches with the first + if((points.Count > 1) && (points[points.Count - 1].stitch)) + { + Vector2D p1 = points[0].pos; + Vector2D p2 = points[points.Count - 1].pos; + Vector2D delta = p1 - p2; + if((Math.Abs(delta.x) <= 0.001f) && (Math.Abs(delta.y) <= 0.001f)) + { + // Finish drawing + FinishDraw(); + } + } + } + // Drawing a point [BeginAction("drawpoint")] public void DrawPoint() @@ -753,24 +779,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(General.Interface.MouseInDisplay) { DrawnVertex newpoint = GetCurrentPosition(); - points.Add(newpoint); - labels.Add(new LineLengthLabel()); - labels[labels.Count - 1].Start = newpoint.pos; - if(labels.Count > 1) labels[labels.Count - 2].End = newpoint.pos; - Update(); - - // Check if point stitches with the first - if((points.Count > 1) && (points[points.Count - 1].stitch)) - { - Vector2D p1 = points[0].pos; - Vector2D p2 = points[points.Count - 1].pos; - Vector2D delta = p1 - p2; - if((Math.Abs(delta.x) <= 0.001f) && (Math.Abs(delta.y) <= 0.001f)) - { - // Finish drawing - FinishDraw(); - } - } + DrawPointAt(newpoint.pos, newpoint.stitch); } } diff --git a/Source/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/BuilderModes/ClassicModes/LinedefsMode.cs index 44ec24f5..5f652c57 100644 --- a/Source/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/LinedefsMode.cs @@ -261,7 +261,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Edit pressed in this mode editpressed = true; - + // Highlighted item not selected? if(!highlighted.Selected) { @@ -282,7 +282,14 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.Present(); } } - + else + { + // Start drawing mode + DrawGeometryMode drawmode = new DrawGeometryMode(); + drawmode.DrawPointAt(mousemappos, true); + General.Map.ChangeMode(drawmode); + } + base.OnEdit(); } diff --git a/Source/BuilderModes/ClassicModes/SectorsMode.cs b/Source/BuilderModes/ClassicModes/SectorsMode.cs index 2173e238..c36015e1 100644 --- a/Source/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/BuilderModes/ClassicModes/SectorsMode.cs @@ -344,7 +344,14 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.Present(); } } - + else + { + // Start drawing mode + DrawGeometryMode drawmode = new DrawGeometryMode(); + drawmode.DrawPointAt(mousemappos, true); + General.Map.ChangeMode(drawmode); + } + base.OnEdit(); } diff --git a/Source/BuilderModes/ClassicModes/VerticesMode.cs b/Source/BuilderModes/ClassicModes/VerticesMode.cs index f905e581..7b5726a9 100644 --- a/Source/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/BuilderModes/ClassicModes/VerticesMode.cs @@ -46,6 +46,7 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Constants public const float VERTEX_HIGHLIGHT_RANGE = 20f; + public const float LINEDEF_SPLIT_RANGE = 8f; #endregion @@ -242,9 +243,48 @@ namespace CodeImp.DoomBuilder.BuilderModes // Start editing protected override void OnEdit() { - // Edit pressed in this mode - editpressed = true; + // Vertex highlighted? + if((highlighted != null) && !highlighted.IsDisposed) + { + // Edit pressed in this mode + editpressed = true; + } + else + { + // Find the nearest linedef within highlight range + Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, LINEDEF_SPLIT_RANGE / renderer.Scale); + // Found a line? + if(l != null) + { + // Create undo + General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0); + + // Create vertex at nearest point on line + Vector2D nearestpos = l.NearestOnLine(mousemappos); + Vertex v = General.Map.Map.CreateVertex(nearestpos); + + // Snap to map format accuracy + v.SnapToAccuracy(); + + // Split the line with this vertex + l.Split(v); + + // Highlight it + Highlight(v); + + // Redraw display + General.Interface.RedrawDisplay(); + } + else + { + // Start drawing mode + DrawGeometryMode drawmode = new DrawGeometryMode(); + drawmode.DrawPointAt(mousemappos, true); + General.Map.ChangeMode(drawmode); + } + } + base.OnEdit(); } diff --git a/Source/Controls/Action.cs b/Source/Controls/Action.cs index 7e5edf27..d4f2e80b 100644 --- a/Source/Controls/Action.cs +++ b/Source/Controls/Action.cs @@ -67,7 +67,9 @@ namespace CodeImp.DoomBuilder.Controls public bool AllowScroll { get { return allowscroll; } } public bool DisregardShift { get { return disregardshift; } } public bool Repeat { get { return repeat; } } - + public bool BeginBound { get { return (begindelegates.Count > 0); } } + public bool EndBound { get { return (enddelegates.Count > 0); } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Controls/ActionManager.cs b/Source/Controls/ActionManager.cs index 5a7b0e7c..731d9406 100644 --- a/Source/Controls/ActionManager.cs +++ b/Source/Controls/ActionManager.cs @@ -469,17 +469,22 @@ namespace CodeImp.DoomBuilder.Controls // This will call the associated actions for a keypress private void BeginActionByKey(int key, bool repeated) { - // Go for all actions + // Get all actions for which a begin is bound + List boundactions = new List(actions.Count); foreach(KeyValuePair a in actions) + if(a.Value.BeginBound) boundactions.Add(a.Value); + + // Go for all actions + foreach(Action a in boundactions) { // This action is associated with this key? - if(a.Value.KeyMatches(key)) + if(a.KeyMatches(key)) { // Allowed to repeat? - if(a.Value.Repeat || !repeated) + if(a.Repeat || !repeated) { // Invoke action - a.Value.Begin(); + a.Begin(); } else { diff --git a/Source/Editing/ClassicMode.cs b/Source/Editing/ClassicMode.cs index 2fa4eda7..59cf1a9a 100644 --- a/Source/Editing/ClassicMode.cs +++ b/Source/Editing/ClassicMode.cs @@ -89,6 +89,21 @@ namespace CodeImp.DoomBuilder.Editing // Initialize this.renderer = General.Map.Renderer2D; this.renderer2d = (Renderer2D)General.Map.Renderer2D; + + // If the current mode is a ClassicMode, copy mouse properties + if(General.Map.Mode is ClassicMode) + { + ClassicMode oldmode = General.Map.Mode as ClassicMode; + + // Copy mouse properties + mousepos = oldmode.mousepos; + mousemappos = oldmode.mousemappos; + mousedownpos = oldmode.mousedownpos; + mousedownmappos = oldmode.mousedownmappos; + mousebuttons = oldmode.mousebuttons; + mouseinside = oldmode.mouseinside; + mousedragging = oldmode.mousedragging; + } } // Disposer