예제 #1
0
        // Mode starts
        public override void OnEngage()
        {
            Cursor.Current = Cursors.WaitCursor;
            base.OnEngage();

            //mxd
            bool haveNodes   = General.Map.LumpExists("NODES");
            bool haveZnodes  = General.Map.LumpExists("ZNODES");
            bool haveSectors = General.Map.LumpExists("SSECTORS");
            bool haveSegs    = General.Map.LumpExists("SEGS");
            bool haveVerts   = General.Map.LumpExists("VERTEXES");

            if (General.Map.IsChanged || !(haveZnodes || (haveNodes || haveSectors || haveSegs || haveVerts)))
            {
                // We need to build the nodes!
                if (!General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderSave, true))
                {
                    return;
                }

                //mxd. Update nodes availability
                haveNodes   = General.Map.LumpExists("NODES");
                haveZnodes  = General.Map.LumpExists("ZNODES");
                haveSectors = General.Map.LumpExists("SSECTORS");
                haveSegs    = General.Map.LumpExists("SEGS");
                haveVerts   = General.Map.LumpExists("VERTEXES");
            }

            //mxd
            if (haveZnodes)
            {
                General.Interface.DisplayStatus(StatusType.Busy, "Reading map nodes...");
                if (!LoadZNodes())
                {
                    General.Interface.DisplayStatus(StatusType.Warning, "Failed to read map nodes.");
                    General.Editing.CancelMode();
                    return;
                }
            }
            else
            {
                if (!haveNodes)
                {
                    MessageBox.Show("Unable to find the NODES lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    General.Editing.CancelMode();
                    return;
                }

                if (!haveSectors)
                {
                    MessageBox.Show("Unable to find the SSECTORS lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    General.Editing.CancelMode();
                    return;
                }

                if (!haveSegs)
                {
                    MessageBox.Show("Unable to find the SEGS lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    General.Editing.CancelMode();
                    return;
                }

                if (!haveVerts)
                {
                    MessageBox.Show("Unable to find the VERTEXES lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    General.Editing.CancelMode();
                    return;
                }

                General.Interface.DisplayStatus(StatusType.Busy, "Reading map nodes...");
                if (!LoadClassicStructures())
                {
                    General.Interface.DisplayStatus(StatusType.Warning, "Failed to read map nodes.");
                    General.Editing.CancelMode();
                    return;
                }
            }

            // Setup presentation
            CustomPresentation presentation = new CustomPresentation();

            presentation.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask, General.Settings.BackgroundAlpha));
            presentation.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
            presentation.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
            presentation.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(presentation);

            General.Interface.DisplayStatus(StatusType.Busy, "Building subsectors...");

            RecursiveBuildSubsectorPoly(nodes.Length - 1, new Stack <Split>(nodes.Length / 2 + 1));

            // Load and display dialog window
            form       = new NodesForm(this);
            form.Text += " (" + nodesformat + " format)";
            form.Show((Form)General.Interface);

            Cursor.Current = Cursors.Default;
            General.Interface.DisplayReady();
            General.Interface.RedrawDisplay();
        }
예제 #2
0
        // Mode starts
        public override void OnEngage()
        {
            Cursor.Current = Cursors.WaitCursor;
            base.OnEngage();

            if (!General.Map.LumpExists("NODES") || !General.Map.LumpExists("SSECTORS") || !General.Map.LumpExists("SEGS") || !General.Map.LumpExists("VERTEXES"))
            {
                // We need to build the nodes!
                if (!General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderSave, true))
                {
                    return;
                }
            }

            if (!General.Map.LumpExists("NODES"))
            {
                MessageBox.Show("Unable to find the NODES lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                General.Editing.CancelMode();
                return;
            }

            if (!General.Map.LumpExists("SSECTORS"))
            {
                MessageBox.Show("Unable to find the SSECTORS lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                General.Editing.CancelMode();
                return;
            }

            if (!General.Map.LumpExists("SEGS"))
            {
                MessageBox.Show("Unable to find the SEGS lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                General.Editing.CancelMode();
                return;
            }

            if (!General.Map.LumpExists("VERTEXES"))
            {
                MessageBox.Show("Unable to find the VERTEXES lump. It may be that the nodes could not be built correctly.", "Nodes Viewer mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
                General.Editing.CancelMode();
                return;
            }

            General.Interface.DisplayStatus(StatusType.Busy, "Reading map nodes...");

            LoadStructures();

            // Setup presentation
            CustomPresentation presentation = new CustomPresentation();

            presentation.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask, General.Settings.BackgroundAlpha));
            presentation.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
            presentation.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
            presentation.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(presentation);

            General.Interface.DisplayStatus(StatusType.Busy, "Building subsectors...");

            RecursiveBuildSubsectorPoly(nodes.Length - 1, new Stack <Split>(nodes.Length / 2 + 1));

            // Load and display dialog window
            form = new NodesForm(this);
            form.Show((Form)General.Interface);

            Cursor.Current = Cursors.Default;
            General.Interface.DisplayReady();
            General.Interface.RedrawDisplay();
        }