protected virtual void SetupInterface()
        {
            //Add options docker
            panel = new DrawLineOptionsPanel();
            panel.OnContinuousDrawingChanged += OnContinuousDrawingChanged;
            panel.OnAutoCloseDrawingChanged  += OnAutoCloseDrawingChanged;
            panel.OnShowGuidelinesChanged    += OnShowGuidelinesChanged;

            // Needs to be set after adding the events...
            panel.ContinuousDrawing = General.Settings.ReadPluginSetting("drawlinesmode.continuousdrawing", false);
            panel.AutoCloseDrawing  = General.Settings.ReadPluginSetting("drawlinesmode.autoclosedrawing", false);
            panel.ShowGuidelines    = General.Settings.ReadPluginSetting("drawlinesmode.showguidelines", false);

            // Create guide labels
            guidelabels = new LineLengthLabel[4];
            for (int i = 0; i < guidelabels.Length; i++)
            {
                guidelabels[i] = new LineLengthLabel {
                    ShowAngle = false, Color = General.Colors.InfoLine
                };
            }

            // Create map boudary lines
            Vector2D btl = new Vector2D(General.Map.Config.LeftBoundary, General.Map.Config.TopBoundary);
            Vector2D btr = new Vector2D(General.Map.Config.RightBoundary, General.Map.Config.TopBoundary);
            Vector2D bbl = new Vector2D(General.Map.Config.LeftBoundary, General.Map.Config.BottomBoundary);
            Vector2D bbr = new Vector2D(General.Map.Config.RightBoundary, General.Map.Config.BottomBoundary);

            top    = new Line2D(btl, btr);
            right  = new Line2D(btr, bbr);
            bottom = new Line2D(bbl, bbr);
            left   = new Line2D(btl, bbl);
        }
Пример #2
0
        // Constructor to start dragging immediately
        protected void StartDrag(Vector2D dragstartmappos)
        {
            // Initialize
            this.dragstartmappos = dragstartmappos;

            Cursor.Current = Cursors.AppStarting;

            // We don't want to record this for undoing while we move the geometry around.
            // This will be set back to normal when we're done.
            General.Map.UndoRedo.IgnorePropChanges = true;

            // Make list of selected vertices
            selectedverts = General.Map.Map.GetMarkedVertices(true);

            // Make list of non-selected vertices
            // This will be used for snapping to nearest items
            unselectedverts = General.Map.Map.GetMarkedVertices(false);

            // Get the nearest vertex for snapping
            dragitem = MapSet.NearestVertex(selectedverts, dragstartmappos);

            // Lines to snap to
            snaptolines = General.Map.Map.LinedefsFromMarkedVertices(true, false, false);

            // Make old positions list
            // We will use this as reference to move the vertices, or to move them back on cancel
            oldpositions = new List <Vector2D>(selectedverts.Count);
            foreach (Vertex v in selectedverts)
            {
                oldpositions.Add(v.Position);
            }

            // Also keep old position of the dragged item
            dragitemposition = dragitem.Position;

            // Keep view information
            lastoffsetx = renderer.OffsetX;
            lastoffsety = renderer.OffsetY;
            lastscale   = renderer.Scale;

            // Make list of unstable lines only
            // These will have their length displayed during the drag
            unstablelines = MapSet.UnstableLinedefsFromVertices(selectedverts);

            // Make text labels
            labels = new LineLengthLabel[unstablelines.Count];
            int index = 0;

            foreach (Linedef l in unstablelines)
            {
                labels[index++] = new LineLengthLabel(l.Start.Position, l.End.Position);
            }

            Cursor.Current = Cursors.Default;
        }
Пример #3
0
        // Constructor to start dragging immediately
        protected void StartDrag(Vector2D dragstartmappos)
        {
            // Initialize
            this.dragstartmappos = dragstartmappos;

            Cursor.Current = Cursors.AppStarting;

            // We don't want to record this for undoing while we move the geometry around.
            // This will be set back to normal when we're done.
            General.Map.UndoRedo.IgnorePropChanges = true;

            // Make list of selected vertices and things
            selectedverts  = General.Map.Map.GetMarkedVertices(true);
            selectedthings = General.Map.Map.GetSelectedThings(true);                                    //mxd
            thingstodrag   = (BuilderPlug.Me.SyncronizeThingEdit ? selectedthings : new List <Thing>()); //mxd

            // Make list of non-selected vertices and things
            // Non-selected vertices will be used for snapping to nearest items
            unselectedverts  = General.Map.Map.GetMarkedVertices(false);
            unselectedthings = new List <Thing>();            //mxd
            foreach (Thing t in General.Map.ThingsFilter.VisibleThings)
            {
                if (!t.Selected)
                {
                    unselectedthings.Add(t);
                }
            }

            // Get the nearest vertex for snapping
            dragitem = MapSet.NearestVertex(selectedverts, dragstartmappos);

            //mxd. Get drag offset
            dragstartoffset = General.Map.Grid.SnappedToGrid(dragitem.Position) - dragitem.Position;

            // Lines to snap to
            snaptolines = General.Map.Map.LinedefsFromMarkedVertices(true, false, false);

            // Make old positions list
            // We will use this as reference to move the vertices, or to move them back on cancel
            oldpositions = new List <Vector2D>(selectedverts.Count);
            foreach (Vertex v in selectedverts)
            {
                oldpositions.Add(v.Position);
            }

            //mxd
            oldthingpositions = new List <Vector2D>(thingstodrag.Count);
            foreach (Thing t in thingstodrag)
            {
                oldthingpositions.Add(t.Position);
            }

            // Also keep old position of the dragged item
            dragitemposition = dragitem.Position;

            // Keep view information
            lastoffsetx = renderer.OffsetX;
            lastoffsety = renderer.OffsetY;
            lastscale   = renderer.Scale;

            // Make list of unstable lines only
            // These will have their length displayed during the drag
            unstablelines = MapSet.UnstableLinedefsFromVertices(selectedverts);

            //mxd. Collect selected sectors
            if (General.Map.UDMF)
            {
                ICollection <Linedef> selectedLines   = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
                List <Sector>         affectedSectors = new List <Sector>();
                foreach (Linedef l in selectedLines)
                {
                    if (l.Front != null && l.Front.Sector != null && !affectedSectors.Contains(l.Front.Sector))
                    {
                        affectedSectors.Add(l.Front.Sector);
                    }
                    if (l.Back != null && l.Back.Sector != null && !affectedSectors.Contains(l.Back.Sector))
                    {
                        affectedSectors.Add(l.Back.Sector);
                    }
                }

                selectedsectors = new List <Sector>();
                foreach (Sector s in affectedSectors)
                {
                    bool selected = true;
                    foreach (Sidedef side in s.Sidedefs)
                    {
                        if (!selectedLines.Contains(side.Line))
                        {
                            selected = false;
                            break;
                        }
                    }

                    if (selected)
                    {
                        selectedsectors.Add(s);
                    }
                }
            }

            // Make text labels
            labels = new LineLengthLabel[unstablelines.Count];
            int index = 0;

            foreach (Linedef l in unstablelines)
            {
                labels[index++] = new LineLengthLabel(l.Start.Position, l.End.Position);
            }

            Cursor.Current = Cursors.Default;
        }
Пример #4
0
        // Constructor to start dragging immediately
        protected void StartDrag(Vector2D dragstartmappos)
        {
            // Initialize
            this.dragstartmappos = dragstartmappos;

            Cursor.Current = Cursors.AppStarting;

            // Make list of selected vertices
            selectedverts = General.Map.Map.GetMarkedVertices(true);

            // ano - protection in case of inconsistent selection state
            // (sectors selected with linedefs or verts selected)
            if (selectedverts.Count == 0)
            {
                ICollection <Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);

                foreach (Sector s in selectedsectors)
                {
                    foreach (Sidedef side in s.Sidedefs)
                    {
                        side.Line.Selected = true;
                    }
                }

                ICollection <Linedef> selectedlines = General.Map.Map.GetSelectedLinedefs(true);

                foreach (Linedef l in selectedlines)
                {
                    l.Start.Selected = true;
                    l.End.Selected   = true;
                    l.Start.Marked   = true;
                    l.End.Marked     = true;
                }

                selectedverts = General.Map.Map.GetMarkedVertices(true);

                if (selectedverts.Count == 0)
                {
                    // ano - failed to find any geometry worth dragging
                    Cursor.Current = Cursors.Default;
                    cancelled      = true;
                    General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
                    return;
                }
            }

            // We don't want to record this for undoing while we move the geometry around.
            // This will be set back to normal when we're done.
            General.Map.UndoRedo.IgnorePropChanges = true;


            // Make list of non-selected vertices
            // This will be used for snapping to nearest items
            unselectedverts = General.Map.Map.GetMarkedVertices(false);

            // Get the nearest vertex for snapping
            dragitem = MapSet.NearestVertex(selectedverts, dragstartmappos);

            // Lines to snap to
            snaptolines = General.Map.Map.LinedefsFromMarkedVertices(true, false, false);

            // Make old positions list
            // We will use this as reference to move the vertices, or to move them back on cancel
            oldpositions = new List <Vector2D>(selectedverts.Count);
            foreach (Vertex v in selectedverts)
            {
                oldpositions.Add(v.Position);
            }

            // Also keep old position of the dragged item
            dragitemposition = dragitem.Position;

            // Keep view information
            lastoffsetx = renderer.OffsetX;
            lastoffsety = renderer.OffsetY;
            lastscale   = renderer.Scale;

            // Make list of unstable lines only
            // These will have their length displayed during the drag
            unstablelines = MapSet.UnstableLinedefsFromVertices(selectedverts);

            // Make text labels
            labels = new LineLengthLabel[unstablelines.Count];
            int index = 0;

            foreach (Linedef l in unstablelines)
            {
                labels[index++] = new LineLengthLabel(l.Start.Position, l.End.Position);
            }

            Cursor.Current = Cursors.Default;
        }