Ejemplo n.º 1
0
        // Subsector changes
        private void ssectorindex_ValueChanged(object sender, EventArgs e)
        {
            Subsector s = mode.Subsectors[(int)ssectorindex.Value];

            ssectornumsegs.Text = s.numsegs.ToString();
            segindex.Minimum    = s.firstseg;
            segindex.Maximum    = s.firstseg + s.numsegs - 1;
            segindex.Value      = s.firstseg;

            General.Interface.RedrawDisplay();
        }
Ejemplo n.º 2
0
        // Draw the display
        public override void OnRedrawDisplay()
        {
            base.OnRedrawDisplay();

            if (form == null)
            {
                return;
            }

            if (renderer.StartPlotter(true))
            {
                if (form.SelectedTab == 0)
                {
                    // Render all subsectors in original color
                    for (int si = 0; si < ssectors.Length; si++)
                    {
                        Subsector s = ssectors[si];
                        PlotSubsectorLines(s.points, PixelColor.FromColor(Color.Gray));
                    }

                    if (mouseinssector > -1)
                    {
                        PlotSubsectorLines(ssectors[mouseinssector].points, General.Colors.Highlight);
                    }

                    // Draw additional vertices
                    if (form.ShowSegsVertices)
                    {
                        for (int i = General.Map.Map.Vertices.Count; i < verts.Length; i++)
                        {
                            renderer.PlotVertexAt(verts[i], ColorCollection.VERTICES);
                        }
                    }
                }

                if (form.SelectedTab == 1)
                {
                    renderer.PlotLinedefSet(General.Map.Map.Linedefs);

                    // Render selected node split
                    if ((form.ViewSplitIndex >= 0) && (form.ViewSplitIndex < nodes.Length))
                    {
                        Node n = nodes[form.ViewSplitIndex];

                        // Draw parent splits
                        int parentsplit = n.parent;
                        while (parentsplit > -1)
                        {
                            Node pn = nodes[parentsplit];
                            renderer.PlotLine(pn.linestart, pn.linestart + pn.linedelta, General.Colors.Selection);
                            parentsplit = pn.parent;
                        }

                        // Draw this split
                        renderer.PlotLine(n.linestart, n.linestart + n.linedelta, General.Colors.Highlight);
                    }
                }

                if (form.SelectedTab == 2)
                {
                    renderer.PlotLinedefSet(General.Map.Map.Linedefs);

                    // Render selected subsector
                    if ((form.ViewSubsectorIndex >= 0) && (form.ViewSubsectorIndex < ssectors.Length))
                    {
                        Subsector s = ssectors[form.ViewSubsectorIndex];
                        PlotSubsectorLines(s.points, General.Colors.Highlight);
                    }

                    // Draw selected segment
                    if (form.ViewSegIndex > -1)
                    {
                        Seg sg = segs[form.ViewSegIndex];
                        renderer.PlotLine(verts[sg.startvertex], verts[sg.endvertex], General.Colors.Selection);
                    }
                }

                renderer.Finish();
            }

            if (renderer.StartOverlay(true))
            {
                switch (form.SelectedTab)
                {
                case 0:
                    if (mouseinssector > -1)
                    {
                        // Render all subsectors in original color
                        for (int si = 0; si < ssectors.Length; si++)
                        {
                            Subsector s = ssectors[si];
                            DrawSubsectorArea(s.vertices);
                        }
                        DrawSubsectorArea(ssectors[mouseinssector].vertices, General.Colors.Highlight);
                    }
                    else
                    {
                        // Render all subsectors with distinct colors
                        for (int si = 0; si < ssectors.Length; si++)
                        {
                            Subsector  s     = ssectors[si];
                            PixelColor color = distinctcolors[si % distinctcolors.Count];
                            DrawSubsectorArea(s.vertices, color);
                        }
                    }
                    break;

                case 1:
                    if ((form.ViewSplitIndex >= 0) && (form.ViewSplitIndex < nodes.Length))
                    {
                        Node n = nodes[form.ViewSplitIndex];

                        // Draw areas. We draw these first, because they would otherwise erase any splits we want to show.
                        DrawSplitArea(n.leftbox, form.ViewSplitIndex, true, new PixelColor(100, 50, 80, 255));
                        DrawSplitArea(n.rightbox, form.ViewSplitIndex, false, new PixelColor(100, 20, 220, 20));

                        // Draw parent splits
                        int parentsplit = n.parent;
                        while (parentsplit > -1)
                        {
                            Node pn = nodes[parentsplit];
                            renderer.RenderLine(pn.linestart, pn.linestart + pn.linedelta, 1f, General.Colors.Selection, true);
                            parentsplit = pn.parent;
                        }

                        // Draw this split
                        renderer.RenderLine(n.linestart, n.linestart + n.linedelta, 1f, General.Colors.Highlight, true);
                    }
                    break;

                case 2:
                    if ((form.ViewSubsectorIndex >= 0) && (form.ViewSubsectorIndex < ssectors.Length))
                    {
                        Subsector s = ssectors[form.ViewSubsectorIndex];

                        // Draw area
                        DrawSubsectorArea(s.vertices, General.Colors.Highlight);

                        // Draw selected segment
                        if (form.ViewSegIndex > -1)
                        {
                            Seg sg = segs[form.ViewSegIndex];
                            renderer.RenderLine(verts[sg.startvertex], verts[sg.endvertex], 1f, General.Colors.Selection, true);
                        }
                    }
                    break;
                }

                renderer.Finish();
            }

            renderer.Present();
        }