Esempio n. 1
0
 private static Action <Graphics> CreateRenderer(Map.Wall wall, MapViewRenderer mapView)
 {
     return(g => {
         if (EditorSettings.Default.Edit_PreviewMode)
         {
             mapView.DrawTexturedWall(g, wall, false, false);
         }
     });
 }
Esempio n. 2
0
        private void RenderPostWalls(Graphics g)
        {
            if (MapInterface.CurrentMode == EditMode.WALL_PLACE && EditorSettings.Default.Edit_PreviewMode && !mapView.picking)
            {
                Point pt = MapView.GetNearestWallPoint(mapView.mouseLocation);

                // Render the wall being created (if there is no other in place)
                if (mapView.WallMakeNewCtrl != null && !Map.Walls.ContainsKey(pt))
                {
                    Map.Wall fakeWall = mapView.WallMakeNewCtrl.NewWall(pt, true);
                    DrawTexturedWall(g, fakeWall, true, false);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Создаем новую стену, в соответствии с тем что указал пользователь
        /// </summary>
        public Map.Wall NewWall(Point location, bool fake = false)
        {
            byte material = GetSelWallTypeIndex();

            Map.Wall.WallFacing facing = (Map.Wall.WallFacing)wallFacing;

            Map.Wall wall = new Map.Wall(location, facing, material, (byte)MinimapGroup, (byte)numWallVari.Value);

            //wall.Destructable = checkBreakableWall.Checked;
            wall.Window = wallWindowed;

            // generate random variation
            if (autovari.Checked && !fake && !started)
            {
                if (wall.Window)
                {
                    return(wall);
                }
                if ((int)wall.Facing > 1)
                {
                    return(wall);
                }

                Random rnd     = new Random(location.Y + location.Y + (int)DateTime.Now.Ticks);
                int    randvar = rnd.Next((int)numWallVari.Value, (int)numWallVariMax.Value + 1);
                byte   rndvari = Convert.ToByte(randvar);

                wall.Variation = (byte)rnd.Next((int)numWallVari.Value, (int)numWallVariMax.Value + 1);
                if (wall.Window)
                {
                    wall.Variation = 0;
                }

                if ((int)wall.Facing == 2)
                {
                    wall.Variation = 0;
                }
            }
            started = false;

            return(wall);
        }
Esempio n. 4
0
        public void Update(Point mousePt)
        {
            bool iWalls = (MapInterface.CurrentMode >= EditMode.WALL_PLACE && MapInterface.CurrentMode <= EditMode.WALL_CHANGE);
            bool iTiles = (MapInterface.CurrentMode >= EditMode.FLOOR_PLACE && MapInterface.CurrentMode <= EditMode.EDGE_PLACE);
            bool iObjs  = (MapInterface.CurrentMode == EditMode.OBJECT_SELECT);

            // Search for walls/tiles/objects under cursor

            statusLocation = String.Format(FORMAT_COORDINATES, mousePt.X, mousePt.Y);
            statusMapItem  = "";
            statusPolygon  = "";

            // Wall tracking
            if (iWalls)
            {
                var      wallPt = MapView.GetNearestWallPoint(mousePt);
                Map.Wall wall   = map.Walls.ContainsKey(wallPt) ? map.Walls[wallPt] : null;
                statusLocation = String.Format(FORMAT_COORDINATES, wallPt.X, wallPt.Y);

                if (wall != null)
                {
                    statusMapItem = String.Format(FORMAT_WALL_INFO, wall.Material, wall.Variation);
                }



                if (prevWall != wall)
                {
                    prevWall         = wall;
                    updateStatusbars = true;
                }
            }
            else
            {
                prevWall = null;
            }



            // Tile tracking
            if (iTiles)
            {
                var      tilePt = MapView.GetNearestTilePoint(mousePt);
                Map.Tile tile   = map.Tiles.ContainsKey(tilePt) ? map.Tiles[tilePt] : null;
                statusLocation = String.Format(FORMAT_COORDINATES, tilePt.X, tilePt.Y);

                if (tile != null)
                {
                    statusMapItem = String.Format(FORMAT_TILE_INFO, tile.Graphic, tile.Variation);
                    edgeCount     = tile.EdgeTiles.Count;
                    if (tile.EdgeTiles.Count > 0)
                    {
                        statusMapItem += String.Format(FORMAT_EDGE_COUNT, tile.EdgeTiles.Count);

                        foreach (Map.Tile.EdgeTile edge in tile.EdgeTiles)
                        {
                            statusMapItem += String.Format(FORMAT_EDGE_INFO, ThingDb.FloorTileNames[edge.Graphic], edge.Variation, edge.Dir, ThingDb.EdgeTileNames[edge.Edge]);
                        }
                    }
                }

                if (prevTile != tile)
                {
                    prevTile         = tile;
                    updateStatusbars = true;
                }
                if (prevEdge != edgeCount && tile != null)
                {
                    prevEdge         = tile.EdgeTiles.Count;
                    updateStatusbars = true;
                }
            }
            else
            {
                prevTile = null;
            }



            // Object tracking
            if (iObjs)
            {
                Map.Object obj = MapInterface.ObjectSelect(mousePt);
                if (obj == null)
                {
                    return;
                }

                statusMapItem = String.Format(FORMAT_OBJECT_INFO, obj.Name, obj.Extent);



                if (prevObj != obj)
                {
                    prevObj          = obj;
                    updateStatusbars = true;
                }
            }
            else
            {
                prevObj = null;
            }


            // Polygon tracking
            Map.Polygon ins   = null;
            var         ptFlt = new PointF(mousePt.X, mousePt.Y);
            int         i     = -1;

            foreach (Map.Polygon poly in map.Polygons)
            {
                i++;
                if (poly.IsPointInside(ptFlt))
                {
                    statusPolygon = poly.Name;
                    ins           = poly;

                    if (MainWindow.Instance.mapView.PolygonEditDlg.Visible && !MainWindow.Instance.mapView.PolygonEditDlg.LockedBox.Checked && MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE && (MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon != MainWindow.Instance.mapView.PolygonEditDlg.SuperPolygon || MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon == null))
                    {
                        MainWindow.Instance.mapView.PolygonEditDlg.listBoxPolygons.SelectedIndex = i;
                        MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon = ins;
                        //System.Windows.Forms.MessageBox.Show("ON:");
                    }
                    break;
                }
            }

            /*
             * if (ins == null)
             * {
             *
             *  MainWindow.Instance.mapView.PolygonEditDlg.listBoxPolygons.ClearSelected();
             *  MainWindow.Instance.mapView.PolygonEditDlg.SelectedPolygon = null;
             *   // System.Windows.Forms.MessageBox.Show("OFF:");
             * }
             */
            if (prevPoly != ins)
            {
                prevPoly         = ins;
                updateStatusbars = true;
            }
        }
Esempio n. 5
0
 public FakeWallObject(int index, Map.Wall wall, MapViewRenderer mapView) : base(CreateRenderer(wall, mapView))
 {
     this.index = index;
     this.wall  = wall;
 }
Esempio n. 6
0
        /// <summary>
        /// Renders the map using current settings and editing stuff.
        /// </summary>
        public void RenderTo(Graphics g, bool ToImage = false)
        {
            PointF nwCorner, neCorner, seCorner, swCorner, center;
            bool   DrawTextured  = EditorSettings.Default.Edit_PreviewMode;
            bool   DrawExtents3D = EditorSettings.Default.Draw_Extents_3D;
            bool   DrawText      = EditorSettings.Default.Draw_AllText;

            // enable transparency only in textured preview mode
            if (DrawTextured)
            {
                g.CompositingMode = CompositingMode.SourceOver;
            }
            else
            {
                g.CompositingMode = CompositingMode.SourceCopy;
            }
            // optimizations
            g.CompositingQuality = CompositingQuality.HighSpeed;
            g.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            g.InterpolationMode  = InterpolationMode.Low;
            g.SmoothingMode      = SmoothingMode.HighSpeed;
            proDefault           = (!mapView.picking && mapView.mapPanel.Cursor != Cursors.SizeAll && Form.ActiveForm == MainWindow.Instance);
            proHand = (!mapView.picking && !MapInterface.KeyHelper.ShiftKey && MapInterface.SelectedObjects.Items.Count > 1 && !mapView.contextMenuOpen);
            // expand clip rectangle a bit
            const int sqSize2 = squareSize * 2;

            Rectangle clip = new Rectangle((int)g.ClipBounds.X - sqSize2, (int)g.ClipBounds.Y - sqSize2, (int)g.ClipBounds.Width + sqSize2, (int)g.ClipBounds.Height + sqSize2);

            if (ToImage)
            {
                clip             = new Rectangle(0, 0, 5880, 5880);
                updCanvasObjects = true;
                updCanvasTiles   = true;
            }
            if (updCanvasObjects)
            {
                objectRenderer.UpdateCanvas(clip);
                updCanvasObjects = false;
            }
            if (updCanvasTiles)
            {
                floorRenderer.UpdateCanvas(clip);
                updCanvasTiles = false;
            }
            // Paint it black
            Size size = mapView.mapPanel.Size;

            g.Clear(ColorLayout.Background);
            Point mouseLocation = mapView.mouseLocation;
            Pen   pen;

            // Draw tiles and edges
            if (MapInterface.CurrentMode == EditMode.FLOOR_PLACE || EditorSettings.Default.Draw_FloorTiles || MapInterface.CurrentMode == EditMode.EDGE_PLACE)
            {
                floorRenderer.Render(g);
            }

            // Draw grid
            if (EditorSettings.Default.Draw_Grid)
            {
                using (pen = new Pen(Color.Gray, 1F))
                {
                    //draw the grid sloppily (an extra screen's worth of lines along either axis)
                    for (int x = -squareSize * (size.Width / squareSize) - 3 * squareSize / 2 % (2 * squareSize); x < 2 * size.Width; x += 2 * squareSize)
                    {
                        int y = -3 * squareSize / 2 % (2 * squareSize);
                        g.DrawLine(pen, new Point(x - 1, y), new Point(y, x - 1));
                        g.DrawLine(pen, new Point(x, y), new Point(size.Width + x, size.Width + y));
                    }
                }
            }

            if (MapInterface.CurrentMode >= EditMode.FLOOR_PLACE && MapInterface.CurrentMode <= EditMode.EDGE_PLACE)
            {
                // Draw the overlay to show tile location
                Point  pt          = new Point(mouseLocation.X, mouseLocation.Y);
                PointF tilePt      = (PointF)MapView.GetNearestTilePoint(pt);
                int    squareSize2 = squareSize;

                int bs = (int)MainWindow.Instance.mapView.TileMakeNewCtrl.BrushSize.Value;

                if ((MapInterface.CurrentMode == EditMode.FLOOR_BRUSH || MapInterface.CurrentMode == EditMode.FLOOR_PLACE) && !mapView.picking)
                {
                    squareSize2 *= bs;
                    if (bs > 1)
                    {
                        tilePt.X -= (float)(-0.5 + 0.5 * bs);
                        tilePt.Y -= (float)(1.5 + 0.5 * bs);
                        //tilePt.Y -= 1;
                        tilePt.Y -= ((bs - 1) + ((bs % 2 == 0) ? 1 : 0));
                        tilePt.Y += 2;
                    }
                }

                // Change overlay color depending on editor EditMode
                Color tileOverlayCol = Color.Yellow;
                if (MapInterface.CurrentMode == EditMode.EDGE_PLACE)
                {
                    tileOverlayCol = MainWindow.Instance.mapView.EdgeMakeNewCtrl.AutoEgeBox.Checked ? Color.Green : Color.Aqua;
                }
                if (MapInterface.CurrentMode == EditMode.FLOOR_BRUSH)
                {
                    tileOverlayCol = Color.LawnGreen;
                }

                if (mapView.picking)
                {
                    tileOverlayCol = Color.GhostWhite;
                }

                tilePt.X *= squareSize;
                tilePt.Y *= squareSize;

                center   = new PointF(tilePt.X + squareSize / 2f, tilePt.Y + (3 / 2f) * squareSize);
                nwCorner = new PointF(tilePt.X - squareSize2 / 2f, tilePt.Y + (3 / 2f) * squareSize2);
                neCorner = new PointF(nwCorner.X + squareSize2, nwCorner.Y - squareSize2);
                swCorner = new PointF(nwCorner.X + squareSize2, nwCorner.Y + squareSize2);
                seCorner = new PointF(neCorner.X + squareSize2, neCorner.Y + squareSize2);

                g.DrawPolygon(new Pen(tileOverlayCol, 2), new PointF[] { nwCorner, neCorner, seCorner, swCorner });
            }

            Pen destructablePen = new Pen(ColorLayout.WallsBreakable, 2);
            Pen windowPen       = new Pen(ColorLayout.WallsWindowed, 2);
            Pen secretPen       = new Pen(ColorLayout.WallsSecret, 2);
            Pen invisiblePen    = new Pen(Color.DarkGray, 2);
            Pen FakeWallPen     = new Pen(Color.LightGray, 2);
            Pen OpenPen         = new Pen(Color.FromArgb(255, 110, 170, 110), 2);
            Pen wallPen         = new Pen(ColorLayout.Walls, 2);

            // Draw [BELOW] objects
            objectRenderer.RenderBelow(g);

            // Draw walls
            if (EditorSettings.Default.Draw_Walls)
            {
                Map.Wall removing = mapView.GetWallUnderCursor();

                Point highlightUndoRedo = mapView.highlightUndoRedo;



                if (MapInterface.CurrentMode == EditMode.WALL_BRUSH && !mapView.picking)
                {
                    removing = null;
                }


                if (FakeWalls.Count > 0 && !EditorSettings.Default.Edit_PreviewMode)
                {
                    foreach (Map.Wall wall in FakeWalls.Values)
                    {
                        Point pt = wall.Location;
                        int   x = pt.X * squareSize, y = pt.Y * squareSize;
                        Point txtPoint = new Point(x, y);
                        pen    = invisiblePen;
                        center = new PointF(x + squareSize / 2f, y + squareSize / 2f);
                        Point nCorner = new Point(x, y);
                        Point sCorner = new Point(x + squareSize, y + squareSize);
                        Point wCorner = new Point(x + squareSize, y);
                        Point eCorner = new Point(x, y + squareSize);

                        Point  nCornerUp = new Point(x, y - 40);
                        Point  sCornerUp = new Point(x + squareSize, y + squareSize - 40);
                        Point  wCornerUp = new Point(x + squareSize, y - 40);
                        Point  eCornerUp = new Point(x, y + squareSize - 40);
                        PointF centerUp  = new PointF(x + squareSize / 2f, (y + squareSize / 2f) - 40);

                        switch (wall.Facing)
                        {
                        case Map.Wall.WallFacing.NORTH:
                            g.DrawLine(pen, wCorner, eCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);

                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, eCornerUp, eCorner);

                            break;

                        case Map.Wall.WallFacing.WEST:
                            g.DrawLine(pen, nCorner, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);

                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            break;

                        case Map.Wall.WallFacing.CROSS:
                            g.DrawLine(pen, wCorner, eCorner);    //north wall
                            g.DrawLine(pen, nCorner, sCorner);    //south wall
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);    //north wall
                            g.DrawLine(pen, nCornerUp, sCornerUp);    //south wall

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);

                            break;

                        case Map.Wall.WallFacing.NORTH_T:
                            g.DrawLine(pen, wCorner, eCorner);   //north wall
                            g.DrawLine(pen, center, sCorner);    //tail towards south
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, sCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, center, centerUp);

                            break;

                        case Map.Wall.WallFacing.SOUTH_T:
                            g.DrawLine(pen, wCorner, eCorner);   //north wall
                            g.DrawLine(pen, center, nCorner);    //tail towards north
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, nCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.WEST_T:
                            g.DrawLine(pen, nCorner, sCorner);   //west wall
                            g.DrawLine(pen, center, eCorner);    //tail towards east
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, eCornerUp);    //tail towards south

                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.EAST_T:
                            g.DrawLine(pen, nCorner, sCorner);   //west wall
                            g.DrawLine(pen, center, wCorner);    //tail towards west
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, wCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.NE_CORNER:
                            g.DrawLine(pen, center, eCorner);
                            g.DrawLine(pen, center, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, eCornerUp);
                            g.DrawLine(pen, centerUp, sCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, eCornerUp, eCorner);
                            g.DrawLine(pen, sCornerUp, sCorner);
                            break;

                        case Map.Wall.WallFacing.NW_CORNER:
                            g.DrawLine(pen, center, wCorner);
                            g.DrawLine(pen, center, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, wCornerUp);
                            g.DrawLine(pen, centerUp, sCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, sCornerUp, sCorner);
                            break;

                        case Map.Wall.WallFacing.SW_CORNER:
                            g.DrawLine(pen, center, nCorner);
                            g.DrawLine(pen, center, wCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, nCornerUp);
                            g.DrawLine(pen, centerUp, wCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, nCornerUp, nCorner);
                            break;

                        case Map.Wall.WallFacing.SE_CORNER:
                            g.DrawLine(pen, center, nCorner);
                            g.DrawLine(pen, center, eCorner);

                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, nCornerUp);
                            g.DrawLine(pen, centerUp, eCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, eCornerUp, eCorner);
                            g.DrawLine(pen, nCornerUp, nCorner);
                            break;

                        default:
                            g.DrawRectangle(pen, x, y, squareSize, squareSize);
                            if (DrawText)
                            {
                                TextRenderer.DrawText(g, "?", drawFont, nCorner, Color.Red);
                            }
                            break;
                        }
                    }
                }

                foreach (Map.Wall wall in Map.Walls.Values)
                {
                    Point pt = wall.Location;
                    int   x = pt.X * squareSize, y = pt.Y * squareSize;
                    Point txtPoint = new Point(x, y);
                    if (clip.Contains(x, y))
                    {
                        if (DrawTextured && !wall.Material.Contains("Invisible"))
                        {
                            //DrawTexturedWall(g, wall, false, removing == wall);
                            continue;
                        }

                        continue;

                        //TODO: how to draw if a destructable window? is this even possible?

                        if (wall.Secret)
                        {
                            pen = wall.Secret_WallState == 4 ? OpenPen : secretPen;
                        }
                        else if (wall.Destructable)//if (wall.Destructable || MapInterface.GetLastWalls(wall))
                        {
                            pen = destructablePen;
                        }
                        else if (wall.Window)
                        {
                            pen = windowPen;
                        }
                        else if (wall.Material.Contains("Invisible"))
                        {
                            pen = invisiblePen;
                        }
                        else
                        {
                            pen = wallPen;
                        }

                        if (removing == wall)
                        {
                            if (mapView.picking)
                            {
                                pen = new Pen(Color.Aqua, 3);
                            }
                            else if (MapInterface.CurrentMode == EditMode.WALL_CHANGE)
                            {
                                pen = new Pen(Color.Purple, 3);
                            }
                        }
                        center = new PointF(x + squareSize / 2f, y + squareSize / 2f);
                        Point nCorner = new Point(x, y);
                        Point sCorner = new Point(x + squareSize, y + squareSize);
                        Point wCorner = new Point(x + squareSize, y);
                        Point eCorner = new Point(x, y + squareSize);

                        Point  nCornerUp = new Point(x, y - 40);
                        Point  sCornerUp = new Point(x + squareSize, y + squareSize - 40);
                        Point  wCornerUp = new Point(x + squareSize, y - 40);
                        Point  eCornerUp = new Point(x, y + squareSize - 40);
                        PointF centerUp  = new PointF(x + squareSize / 2f, (y + squareSize / 2f) - 40);

                        switch (wall.Facing)
                        {
                        case Map.Wall.WallFacing.NORTH:
                            g.DrawLine(pen, wCorner, eCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);

                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, eCornerUp, eCorner);

                            break;

                        case Map.Wall.WallFacing.WEST:
                            g.DrawLine(pen, nCorner, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);

                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            break;

                        case Map.Wall.WallFacing.CROSS:
                            g.DrawLine(pen, wCorner, eCorner);    //north wall
                            g.DrawLine(pen, nCorner, sCorner);    //south wall
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);    //north wall
                            g.DrawLine(pen, nCornerUp, sCornerUp);    //south wall

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);

                            break;

                        case Map.Wall.WallFacing.NORTH_T:
                            g.DrawLine(pen, wCorner, eCorner);   //north wall
                            g.DrawLine(pen, center, sCorner);    //tail towards south
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, sCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, center, centerUp);

                            break;

                        case Map.Wall.WallFacing.SOUTH_T:
                            g.DrawLine(pen, wCorner, eCorner);   //north wall
                            g.DrawLine(pen, center, nCorner);    //tail towards north
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, nCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.WEST_T:
                            g.DrawLine(pen, nCorner, sCorner);   //west wall
                            g.DrawLine(pen, center, eCorner);    //tail towards east
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, eCornerUp);    //tail towards south

                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, eCorner, eCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.EAST_T:
                            g.DrawLine(pen, nCorner, sCorner);   //west wall
                            g.DrawLine(pen, center, wCorner);    //tail towards west
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                            g.DrawLine(pen, centerUp, wCornerUp);    //tail towards south

                            g.DrawLine(pen, wCorner, wCornerUp);
                            g.DrawLine(pen, nCorner, nCornerUp);
                            g.DrawLine(pen, sCorner, sCornerUp);
                            g.DrawLine(pen, center, centerUp);
                            break;

                        case Map.Wall.WallFacing.NE_CORNER:
                            g.DrawLine(pen, center, eCorner);
                            g.DrawLine(pen, center, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, eCornerUp);
                            g.DrawLine(pen, centerUp, sCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, eCornerUp, eCorner);
                            g.DrawLine(pen, sCornerUp, sCorner);
                            break;

                        case Map.Wall.WallFacing.NW_CORNER:
                            g.DrawLine(pen, center, wCorner);
                            g.DrawLine(pen, center, sCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, wCornerUp);
                            g.DrawLine(pen, centerUp, sCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, sCornerUp, sCorner);
                            break;

                        case Map.Wall.WallFacing.SW_CORNER:
                            g.DrawLine(pen, center, nCorner);
                            g.DrawLine(pen, center, wCorner);
                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, nCornerUp);
                            g.DrawLine(pen, centerUp, wCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, wCornerUp, wCorner);
                            g.DrawLine(pen, nCornerUp, nCorner);
                            break;

                        case Map.Wall.WallFacing.SE_CORNER:
                            g.DrawLine(pen, center, nCorner);
                            g.DrawLine(pen, center, eCorner);

                            if (!DrawExtents3D)
                            {
                                break;
                            }
                            g.DrawLine(pen, centerUp, nCornerUp);
                            g.DrawLine(pen, centerUp, eCornerUp);

                            g.DrawLine(pen, centerUp, center);
                            g.DrawLine(pen, eCornerUp, eCorner);
                            g.DrawLine(pen, nCornerUp, nCorner);
                            break;

                        default:
                            g.DrawRectangle(pen, x, y, squareSize, squareSize);
                            if (DrawText)
                            {
                                TextRenderer.DrawText(g, "?", drawFont, nCorner, Color.Red);
                            }
                            break;
                        }
                        if (DrawText)
                        {
                            TextRenderer.DrawText(g, wall.Minimap.ToString(), drawFont, txtPoint, Color.Red);
                        }
                    }
                }
            }

            RenderPostLineWalls(g);

            RenderPostWalls(g);
            RenderPostObjects(g);
            RenderPostSelRect(g);

            // Draw objects
            objectRenderer.RenderNormal(g);
            RenderHelpMark(g);
            // Draw polygons
            if (EditorSettings.Default.Draw_Polygons)
            {
                foreach (Map.Polygon poly in Map.Polygons)
                {
                    pen = Pens.PaleGreen;
                    // Highlight the polygon being edited
                    if (MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE)
                    {
                        if (mapView.PolygonEditDlg.SelectedPolygon == poly || mapView.PolygonEditDlg.SuperPolygon == poly)
                        {
                            pen = Pens.PaleVioletRed;

                            foreach (PointF pt in poly.Points)
                            {
                                center = new PointF(pt.X - MapView.objectSelectionRadius, pt.Y - MapView.objectSelectionRadius);
                                Pen pen2 = MapInterface.SelectedPolyPoint == pt ? Pens.DodgerBlue : Pens.DeepPink;
                                g.DrawEllipse(pen2, new RectangleF(center, new Size(2 * MapView.objectSelectionRadius, 2 * MapView.objectSelectionRadius)));
                            }
                        }
                    }
                    if (poly.Points.Count > 2)
                    {
                        poly.Points.Add(poly.Points[0]);

                        if (MainWindow.Instance.mapView.PolygonEditDlg.ambientColors.Checked)
                        {
                            int        alphaa      = ((poly.AmbientLightColor.R + poly.AmbientLightColor.R + poly.AmbientLightColor.B + poly.AmbientLightColor.B + poly.AmbientLightColor.G + poly.AmbientLightColor.G) / 6);
                            FillMode   newFillMode = FillMode.Alternate;
                            Color      newColor    = Color.FromArgb(Math.Abs(255 - alphaa), poly.AmbientLightColor);
                            SolidBrush blueBrush   = new SolidBrush(newColor);
                            g.DrawPolygon(pen, poly.Points.ToArray());
                            g.FillPolygon(blueBrush, poly.Points.ToArray(), newFillMode);
                        }

                        if (mapView.PolygonEditDlg.SuperPolygon == poly && MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE)
                        {
                            pen = new Pen(Color.PaleVioletRed, 2);
                        }
                        g.DrawLines(pen, poly.Points.ToArray());
                        poly.Points.RemoveAt(poly.Points.Count - 1);
                    }
                }
            }

            // Draw waypoints
            if (EditorSettings.Default.Draw_Waypoints)
            {
                foreach (Map.Waypoint wp in Map.Waypoints)
                {
                    // highlight selected waypoint
                    pen = wp.Flags == 1 ? ColorLayout.WaypointNorm : ColorLayout.WaypointDis;
                    pen = MapInterface.SelectedWaypoint == wp ? ColorLayout.WaypointSel : pen;
                    // draw waypoint and related pathes
                    center = new PointF(wp.Point.X - MapView.objectSelectionRadius, wp.Point.Y - MapView.objectSelectionRadius);
                    g.DrawEllipse(pen, new RectangleF(center, new Size(2 * MapView.objectSelectionRadius, 2 * MapView.objectSelectionRadius)));
                    pen = ColorLayout.WaypointDis;
                    // Draw paths (code/idea from UndeadZeus)
                    foreach (Map.Waypoint.WaypointConnection wpc in wp.connections)
                    {
                        g.DrawLine(pen, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                        foreach (Map.Waypoint.WaypointConnection wpwp in wpc.wp.connections)//Checks if the waypoint connection is connecting to wp
                        {
                            if (wpwp.wp.Equals(wp))
                            {
                                // if there is two way connection

                                /*
                                 * if (MapInterface.SelectedWaypoint != wp) pen = ColorLayout.WaypointTwoPath;
                                 * g.DrawLine(pen, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                                 * break;
                                 */

                                if (MapInterface.SelectedWaypoint != null && wp == MapInterface.SelectedWaypoint)
                                {
                                    g.DrawLine(ColorLayout.WaypointSel, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                                }
                                else
                                {
                                    g.DrawLine(ColorLayout.WaypointTwoPath, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                                }
                                break;
                            }
                        }
                    }
                    Point wayPoint = new Point(Convert.ToInt32(center.X), Convert.ToInt32(center.Y));
                    // text rendering is slow - as such don't label unseen waypoints
                    if (DrawText && clip.Contains(wayPoint))
                    {
                        if (wp.Name.Length > 0)
                        {
                            TextRenderer.DrawText(g, wp.Number + ":" + wp.ShortName, drawFont, wayPoint, Color.YellowGreen);
                        }
                        else
                        {
                            TextRenderer.DrawText(g, wp.Number + "", drawFont, wayPoint, Color.MediumPurple);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Wall texture rendering routine
        /// </summary>
        public void DrawTexturedWall(Graphics g, Map.Wall wall, bool transparent, bool beingSelected)
        {
            ThingDb.Wall tt = ThingDb.Walls[wall.matId];
            try
            {
                int actualVari = (int)wall.Variation * 2;
                // для обычных стен все данные берутся отсюда
                ThingDb.Wall.WallRenderInfo wri = tt.RenderNormal[(int)wall.Facing][actualVari];
                // если стену можно сломать
                if (wall.Destructable)
                {
                    wri = tt.RenderBreakable[(int)wall.Facing][actualVari];
                }
                // если стена содержит окошко
                if (wall.Window)
                {
                    switch (wall.Facing)
                    {
                    case WallFacing.NORTH:
                        wri = tt.RenderNormal[11][actualVari];
                        break;

                    case WallFacing.WEST:
                        wri = tt.RenderNormal[12][actualVari];
                        break;
                    }
                }

                // достаем картинку
                Bitmap       bitmap = VideoBag.GetBitmap(wri.SpriteIndex);
                BitmapShader shader = null;
                // тонируем если стена необычная

                /*if (wall.Destructable || wall.Secret || transparent || beingSelected || mapView.picking)
                 * {
                 *  shader = new BitmapShader(bitmap);
                 *  shader.LockBitmap();
                 *  if (wall.Destructable)
                 *      shader.ColorShade(ColorLayout.WallsBreakable, 0.30F);
                 *  if (wall.Secret)
                 *      shader.ColorShade(ColorLayout.WallsSecret, 0.40F);
                 *  if (wall.Secret_WallState == 4)
                 *      shader.MakeSemitransparent(135);
                 *  if (beingSelected)
                 *  {
                 *      Color selCol = Color.GhostWhite;
                 *      if (MapInterface.CurrentMode == EditMode.WALL_PLACE && !mapView.picking)
                 *          selCol = ColorLayout.Removing;
                 *
                 *      if (MapInterface.CurrentMode == EditMode.WALL_CHANGE && !mapView.picking)
                 *          selCol = Color.Purple;
                 *
                 *
                 *      shader.ColorGradWaves(selCol, 4F, Environment.TickCount);
                 *
                 *  }
                 *
                 *
                 *
                 *  if (transparent)
                 *      shader.MakeSemitransparent();
                 *  bitmap = shader.UnlockBitmap();
                 * }*/

                // допускается что стена одновременно и секретная, и разрушаемая, и с окном
                int x, y;
                if (bitmap != null)
                {
                    x = 23 * wall.Location.X;
                    y = 23 * wall.Location.Y;
                    // коррекция координат
                    int offX = (0 - wri.unknown1) - videoBagProvider.DrawOffsets[wri.SpriteIndex][0];
                    int offY = wri.unknown2 - videoBagProvider.DrawOffsets[wri.SpriteIndex][1];
                    x -= offX + 50;
                    y -= offY + 72;
                    // собственно рисуем
                    g.DrawImage(bitmap, x, y, bitmap.Width, bitmap.Height);
                    // сразу чистим память если картинка не кэшируется
                    if (shader != null)
                    {
                        bitmap.Dispose();
                    }
                }
            }
            catch (Exception) { }
        }
Esempio n. 8
0
        public void SetWall(Map.Wall wall, bool read = false)
        {
            // Flags
            if (read)
            {
                polygonGroup.Value = 100;
                checkListFlags.SetItemChecked(0, false);
                checkListFlags.SetItemChecked(1, false);
                checkListFlags.SetItemChecked(2, false);
                checkListFlags.SetItemChecked(3, false);
                checkDestructable.Checked = false;
                numericCloseDelay.Value   = 3;

                //if (wall.Secret_WallState > 0) comboWallState.SelectedIndex = wall.Secret_WallState - 1;
                openWallBox.Checked       = wall.Secret_WallState == 4 ? true : false;
                checkDestructable.Checked = wall.Destructable;
                checkWindow.Checked       = wall.Window;
                polygonGroup.Value        = wall.Minimap;
                numericCloseDelay.Value   = wall.Secret_OpenWaitSeconds;
                if ((wall.Secret_ScanFlags & 1) == 1)
                {
                    checkListFlags.SetItemChecked(0, true);
                }
                if ((wall.Secret_ScanFlags & 2) == 2)
                {
                    checkListFlags.SetItemChecked(1, true);
                }
                if ((wall.Secret_ScanFlags & 4) == 4)
                {
                    checkListFlags.SetItemChecked(2, true);
                }
                if ((wall.Secret_ScanFlags & 8) == 8)
                {
                    checkListFlags.SetItemChecked(3, true);
                }
                if (mapView.WallMakeNewCtrl.checkListFlags.GetItemChecked(0))
                {
                    mapView.WallMakeNewCtrl.openWallBox.Enabled = true;
                }
                else
                {
                    mapView.WallMakeNewCtrl.openWallBox.Checked = false;
                    mapView.WallMakeNewCtrl.openWallBox.Enabled = false;
                }
            }
            else
            {
                flags = 0;
                if (checkListFlags.GetItemChecked(0))
                {
                    flags |= 1;
                }
                if (checkListFlags.GetItemChecked(1))
                {
                    flags |= 2;
                }
                if (checkListFlags.GetItemChecked(2))
                {
                    flags |= 4;
                }
                if (checkListFlags.GetItemChecked(3))
                {
                    flags |= 8;
                }
                wall.Secret_ScanFlags = flags;

                if (wall != null)
                {
                    wall.Secret_WallState = openWallBox.Checked ? (byte)4 : (byte)0;
                }

                wall.Secret_OpenWaitSeconds = (int)numericCloseDelay.Value;
                wall.Destructable           = checkDestructable.Checked;
                wall.Minimap = (byte)polygonGroup.Value;
                if (checkWindow.Checked)
                {
                    wall.Variation = 0x0; // Other variations don't support windows for straight walls
                    wall.Window    = checkWindow.Checked;
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Renders the map using current settings and editing stuff.
        /// </summary>
        public void RenderTo(Graphics g, bool ToImage = false)
        {
            PointF nwCorner, neCorner, seCorner, swCorner, center;
            bool   DrawTextured  = EditorSettings.Default.Edit_PreviewMode;
            bool   DrawExtents3D = EditorSettings.Default.Draw_Extents_3D;
            bool   DrawText      = EditorSettings.Default.Draw_AllText;

            // optimizations
            g.CompositingQuality = CompositingQuality.HighSpeed;
            g.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            g.InterpolationMode  = InterpolationMode.Low;
            g.SmoothingMode      = SmoothingMode.HighSpeed;

            proDefault = (!mapView.copyAreaMode && !mapView.pasteAreaMode &&
                          !mapView.wallBucket && !mapView.tileBucket && !mapView.picking &&
                          mapView.mapPanel.Cursor != Cursors.SizeAll && Form.ActiveForm == MainWindow.Instance);
            proHand = (!mapView.picking && !MapInterface.KeyHelper.ShiftKey &&
                       MapInterface.SelectedObjects.Items.Count > 1 && !mapView.contextMenuOpen);

            // expand clip rectangle a bit
            const int sqSize2 = squareSize * 2;

            Rectangle clip = new Rectangle((int)g.ClipBounds.X - sqSize2, (int)g.ClipBounds.Y - sqSize2, (int)g.ClipBounds.Width + sqSize2, (int)g.ClipBounds.Height + sqSize2);

            if (ToImage)
            {
                clip             = new Rectangle(0, 0, 5880, 5880);
                updCanvasObjects = true;
                updCanvasTiles   = true;
            }
            if (updCanvasObjects)
            {
                objectRenderer.UpdateCanvas(clip);
                updCanvasObjects = false;
            }
            if (teleCtrl)
            {
                objectRenderer.UpdateTele();
                teleCtrl = false;
            }
            if (updCanvasTiles)
            {
                floorRenderer.UpdateCanvas(clip);
                if (mapView.pasteAreaMode)
                {
                    floorRenderer.UpdateCanvasWithFakeTiles(clip);
                }

                updCanvasTiles = false;
            }
            // Paint it black
            Size size = mapView.mapPanel.Size;

            g.Clear(ColorLayout.Background);
            Point mouseLocation = mapView.mouseLocation;
            Pen   pen;

            // Draw tiles and edges
            if (MapInterface.CurrentMode == EditMode.FLOOR_PLACE || EditorSettings.Default.Draw_FloorTiles || MapInterface.CurrentMode == EditMode.EDGE_PLACE)
            {
                floorRenderer.Render(g);
            }

            // Draw grid
            if (EditorSettings.Default.Draw_Grid)
            {
                using (pen = new Pen(Color.Gray, 1F))
                {
                    //draw the grid sloppily (an extra screen's worth of lines along either axis)
                    for (int x = -squareSize * (size.Width / squareSize) - 3 * squareSize / 2 % (2 * squareSize); x < 2 * size.Width; x += 2 * squareSize)
                    {
                        int y = -3 * squareSize / 2 % (2 * squareSize);
                        g.DrawLine(pen, new Point(x - 1, y), new Point(y, x - 1));
                        g.DrawLine(pen, new Point(x, y), new Point(size.Width + x, size.Width + y));
                    }
                }
            }

            if (MapInterface.CurrentMode >= EditMode.FLOOR_PLACE && MapInterface.CurrentMode <= EditMode.EDGE_PLACE && !MainWindow.Instance.imgMode)
            {
                // Draw the overlay to show tile location
                Point  pt          = new Point(mouseLocation.X, mouseLocation.Y);
                PointF tilePt      = MapView.GetNearestTilePoint(pt);
                int    squareSize2 = squareSize;

                int bs = (int)MainWindow.Instance.mapView.TileMakeNewCtrl.BrushSize.Value;

                if ((MapInterface.CurrentMode == EditMode.FLOOR_BRUSH || MapInterface.CurrentMode == EditMode.FLOOR_PLACE) && !mapView.picking)
                {
                    squareSize2 *= bs;
                    if (bs > 1)
                    {
                        tilePt.X -= (float)(-0.5 + 0.5 * bs);
                        tilePt.Y -= (float)(1.5 + 0.5 * bs);
                        //tilePt.Y -= 1;
                        tilePt.Y -= ((bs - 1) + ((bs % 2 == 0) ? 1 : 0));
                        tilePt.Y += 2;
                    }
                }

                // Change overlay color depending on editor EditMode
                Color tileOverlayCol = Color.Yellow;
                if (MapInterface.CurrentMode == EditMode.EDGE_PLACE)
                {
                    tileOverlayCol = MainWindow.Instance.mapView.EdgeMakeNewCtrl.chkAutoEdge.Checked ? Color.Green : Color.Aqua;
                }
                if (MapInterface.CurrentMode == EditMode.FLOOR_BRUSH)
                {
                    tileOverlayCol = Color.LawnGreen;
                }

                if (mapView.picking)
                {
                    tileOverlayCol = Color.GhostWhite;
                }
                if (mapView.tileBucket)
                {
                    tileOverlayCol = Color.DeepSkyBlue;
                }

                tilePt.X *= squareSize;
                tilePt.Y *= squareSize;

                center   = new PointF(tilePt.X + squareSize / 2f, tilePt.Y + (3 / 2f) * squareSize);
                nwCorner = new PointF(tilePt.X - squareSize2 / 2f, tilePt.Y + (3 / 2f) * squareSize2);
                neCorner = new PointF(nwCorner.X + squareSize2, nwCorner.Y - squareSize2);
                swCorner = new PointF(nwCorner.X + squareSize2, nwCorner.Y + squareSize2);
                seCorner = new PointF(neCorner.X + squareSize2, neCorner.Y + squareSize2);

                g.DrawPolygon(new Pen(tileOverlayCol, 2), new PointF[] { nwCorner, neCorner, seCorner, swCorner });
            }

            // Draw [BELOW] objects
            objectRenderer.RenderBelow(g);

            // Draw walls
            Pen destructablePen = new Pen(ColorLayout.WallsBreakable, 2);
            Pen windowPen       = new Pen(ColorLayout.WallsWindowed, 2);
            Pen secretPen       = new Pen(ColorLayout.WallsSecret, 2);
            Pen invisiblePen    = new Pen(Color.DarkGray, 2);
            Pen fakeWallPen     = new Pen(Color.LightGray, 2);
            Pen openPen         = new Pen(Color.FromArgb(255, 110, 170, 110), 2);
            Pen wallPen         = new Pen(ColorLayout.Walls, 2);

            if (EditorSettings.Default.Draw_Walls)
            {
                Map.Wall removing          = mapView.GetWallUnderCursor();
                Point    highlightUndoRedo = mapView.highlightUndoRedo;

                if (MapInterface.CurrentMode == EditMode.WALL_BRUSH && !mapView.picking)
                {
                    removing = null;
                }

                // Render simple preview walls (Wall drawing modes)
                if (FakeWalls.Count > 0 && !EditorSettings.Default.Edit_PreviewMode)
                {
                    foreach (Map.Wall wall in FakeWalls.Values)
                    {
                        pen = invisiblePen;
                        DrawSimpleWall(g, wall, pen, false);
                    }
                }

                foreach (Map.Wall wall in Map.Walls.Values)
                {
                    Point pt = wall.Location;
                    int   x = pt.X * squareSize, y = pt.Y * squareSize;
                    Point txtPoint = new Point(x, y);
                    if (clip.Contains(x, y))
                    {
                        // Textured walls
                        if (DrawTextured && !wall.Material.Contains("Invisible"))
                        {
                            DrawTexturedWall(g, wall, false, removing == wall);
                            continue;
                        }

                        if (MainWindow.Instance.imgMode)
                        {
                            break;
                        }

                        // Simple walls
                        pen = wallPen;
                        if (EditorSettings.Default.Draw_ColorWalls || (MapInterface.CurrentMode == EditMode.WALL_CHANGE))
                        {
                            if (wall.Secret)
                            {
                                pen = wall.Secret_WallState == 4 ? openPen : secretPen;
                            }
                            else if (wall.Destructable)//if (wall.Destructable || MapInterface.GetLastWalls(wall))
                            {
                                pen = destructablePen;
                            }
                            else if (wall.Window)
                            {
                                pen = windowPen;
                            }
                            else if (wall.Material.Contains("Invisible"))
                            {
                                pen = invisiblePen;
                            }
                            else
                            {
                                pen = wallPen;
                            }
                        }

                        if (removing == wall)
                        {
                            if (mapView.picking)
                            {
                                pen = new Pen(Color.Aqua, 3);
                            }
                            else if (MapInterface.CurrentMode == EditMode.WALL_CHANGE)
                            {
                                pen = new Pen(Color.Purple, 3);
                            }
                        }

                        DrawSimpleWall(g, wall, pen, DrawText);
                    }
                }
            }

            if (!MainWindow.Instance.imgMode)
            {
                RenderPostLineWalls(g);
                RenderPostWalls(g);
                RenderPostObjects(g);
                RenderPostSelRect(g);
            }

            // Draw objects
            objectRenderer.RenderNormal(g);
            RenderHelpMark(g);
            // Draw polygons
            if (EditorSettings.Default.Draw_Polygons)
            {
                foreach (Map.Polygon poly in Map.Polygons)
                {
                    pen = Pens.PaleGreen;
                    // Highlight the polygon being edited
                    if (MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE)
                    {
                        if (mapView.PolygonEditDlg.SelectedPolygon == poly || mapView.PolygonEditDlg.SuperPolygon == poly)
                        {
                            pen = Pens.PaleVioletRed;

                            foreach (PointF pt in poly.Points)
                            {
                                center = new PointF(pt.X - MapView.objectSelectionRadius, pt.Y - MapView.objectSelectionRadius);
                                Pen pen2 = MapInterface.SelectedPolyPoint == pt ? Pens.DodgerBlue : Pens.DeepPink;
                                g.DrawEllipse(pen2, new RectangleF(center, new Size(2 * MapView.objectSelectionRadius, 2 * MapView.objectSelectionRadius)));
                            }
                        }
                    }
                    if (poly.Points.Count > 2)
                    {
                        poly.Points.Add(poly.Points[0]);

                        if (MainWindow.Instance.mapView.PolygonEditDlg.ambientColors.Checked)
                        {
                            int        alphaa      = ((poly.AmbientLightColor.R + poly.AmbientLightColor.R + poly.AmbientLightColor.B + poly.AmbientLightColor.B + poly.AmbientLightColor.G + poly.AmbientLightColor.G) / 6);
                            FillMode   newFillMode = FillMode.Alternate;
                            Color      newColor    = Color.FromArgb(Math.Abs(255 - alphaa), poly.AmbientLightColor);
                            SolidBrush blueBrush   = new SolidBrush(newColor);
                            g.DrawPolygon(pen, poly.Points.ToArray());
                            g.FillPolygon(blueBrush, poly.Points.ToArray(), newFillMode);
                        }

                        if (mapView.PolygonEditDlg.SuperPolygon == poly && MapInterface.CurrentMode == EditMode.POLYGON_RESHAPE)
                        {
                            pen = new Pen(Color.PaleVioletRed, 2);
                        }
                        g.DrawLines(pen, poly.Points.ToArray());
                        poly.Points.RemoveAt(poly.Points.Count - 1);
                    }
                }
            }

            // Draw copied selection
            if (MainWindow.Instance.mapView.selectionPoly.Count > 2)
            {
                var pen1 = new Pen(Brushes.DeepSkyBlue, 4);
                pen1.DashStyle = DashStyle.Dash;

                g.DrawLines(pen1, MainWindow.Instance.mapView.selectionPoly.ToArray());
            }

            // Draw waypoints
            if (EditorSettings.Default.Draw_Waypoints)
            {
                foreach (Map.Waypoint wp in Map.Waypoints)
                {
                    // Highlight selected waypoint
                    pen = wp.Flags == 1 ? ColorLayout.WaypointNorm : ColorLayout.WaypointDis;
                    pen = ((MapInterface.SelectedWaypoint == wp) || (MapInterface.SelectedWaypoints.Contains(wp))) ? ColorLayout.WaypointSel : pen;
                    // Draw waypoint and related pathes
                    center = new PointF(wp.Point.X - MapView.objectSelectionRadius, wp.Point.Y - MapView.objectSelectionRadius);
                    g.DrawEllipse(pen, new RectangleF(center, new Size(2 * MapView.objectSelectionRadius, 2 * MapView.objectSelectionRadius)));
                    pen = ColorLayout.WaypointDis;
                    // Draw paths (code/idea from UndeadZeus)
                    foreach (Map.Waypoint.WaypointConnection wpc in wp.connections)
                    {
                        g.DrawLine(pen, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                        foreach (Map.Waypoint.WaypointConnection wpwp in wpc.wp.connections)//Checks if the waypoint connection is connecting to wp
                        {
                            if (wpwp.wp.Equals(wp))
                            {
                                // Draw connections
                                if ((MapInterface.SelectedWaypoint != null) && (wp == MapInterface.SelectedWaypoint))
                                {
                                    g.DrawLine(ColorLayout.WaypointSel, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                                }
                                else
                                {
                                    g.DrawLine(ColorLayout.WaypointTwoPath, wp.Point.X, wp.Point.Y, wpc.wp.Point.X, wpc.wp.Point.Y);
                                }
                                break;
                            }
                        }
                    }

                    // Draw text
                    if (DrawText && clip.Contains(center.ToPoint()))
                    {
                        if (wp.Name.Length > 0)
                        {
                            g.DrawString(wp.Number + ":" + wp.ShortName, drawFont, Brushes.YellowGreen, center);
                        }
                        else
                        {
                            g.DrawString(wp.Number.ToString(), drawFont, Brushes.MediumPurple, center);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        public void DrawSimpleWall(Graphics g, Map.Wall wall, Pen pen, bool drawText)
        {
            bool DrawExtents3D = EditorSettings.Default.Draw_Extents_3D;

            if (pen == null)
            {
                pen = new Pen(Color.DarkGray, 2);  // invis pen
            }
            Point pt = wall.Location;
            int   x = pt.X * squareSize, y = pt.Y * squareSize;
            Point txtPoint = new Point(x, y);
            //Pen pen = !wall.Window ? (!wall.Material.Contains("Invisible") ? invisPen : fakeWallPen) : windowPen;
            PointF center  = new PointF(x + squareSize / 2f, y + squareSize / 2f);
            Point  nCorner = new Point(x, y);
            Point  sCorner = new Point(x + squareSize, y + squareSize);
            Point  wCorner = new Point(x + squareSize, y);
            Point  eCorner = new Point(x, y + squareSize);

            Point  nCornerUp = new Point(x, y - 40);
            Point  sCornerUp = new Point(x + squareSize, y + squareSize - 40);
            Point  wCornerUp = new Point(x + squareSize, y - 40);
            Point  eCornerUp = new Point(x, y + squareSize - 40);
            PointF centerUp  = new PointF(x + squareSize / 2f, (y + squareSize / 2f) - 40);

            switch (wall.Facing)
            {
            case WallFacing.NORTH:
                g.DrawLine(pen, wCorner, eCorner);
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, wCornerUp, eCornerUp);

                g.DrawLine(pen, wCornerUp, wCorner);
                g.DrawLine(pen, eCornerUp, eCorner);

                break;

            case WallFacing.WEST:
                g.DrawLine(pen, nCorner, sCorner);
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, nCornerUp, sCornerUp);

                g.DrawLine(pen, nCorner, nCornerUp);
                g.DrawLine(pen, sCorner, sCornerUp);
                break;

            case WallFacing.CROSS:
                g.DrawLine(pen, wCorner, eCorner);    //north wall
                g.DrawLine(pen, nCorner, sCorner);    //south wall
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, wCornerUp, eCornerUp);    //north wall
                g.DrawLine(pen, nCornerUp, sCornerUp);    //south wall

                g.DrawLine(pen, wCorner, wCornerUp);
                g.DrawLine(pen, nCorner, nCornerUp);
                g.DrawLine(pen, sCorner, sCornerUp);
                g.DrawLine(pen, eCorner, eCornerUp);

                break;

            case WallFacing.NORTH_T:
                g.DrawLine(pen, wCorner, eCorner);   //north wall
                g.DrawLine(pen, center, sCorner);    //tail towards south
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                g.DrawLine(pen, centerUp, sCornerUp);    //tail towards south

                g.DrawLine(pen, wCorner, wCornerUp);
                g.DrawLine(pen, eCorner, eCornerUp);
                g.DrawLine(pen, sCorner, sCornerUp);
                g.DrawLine(pen, center, centerUp);

                break;

            case WallFacing.SOUTH_T:
                g.DrawLine(pen, wCorner, eCorner);   //north wall
                g.DrawLine(pen, center, nCorner);    //tail towards north
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, wCornerUp, eCornerUp);   //north wall
                g.DrawLine(pen, centerUp, nCornerUp);    //tail towards south

                g.DrawLine(pen, wCorner, wCornerUp);
                g.DrawLine(pen, eCorner, eCornerUp);
                g.DrawLine(pen, nCorner, nCornerUp);
                g.DrawLine(pen, center, centerUp);
                break;

            case WallFacing.WEST_T:
                g.DrawLine(pen, nCorner, sCorner);   //west wall
                g.DrawLine(pen, center, eCorner);    //tail towards east
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                g.DrawLine(pen, centerUp, eCornerUp);    //tail towards south

                g.DrawLine(pen, nCorner, nCornerUp);
                g.DrawLine(pen, sCorner, sCornerUp);
                g.DrawLine(pen, eCorner, eCornerUp);
                g.DrawLine(pen, center, centerUp);
                break;

            case WallFacing.EAST_T:
                g.DrawLine(pen, nCorner, sCorner);   //west wall
                g.DrawLine(pen, center, wCorner);    //tail towards west
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, nCornerUp, sCornerUp);   //north wall
                g.DrawLine(pen, centerUp, wCornerUp);    //tail towards south

                g.DrawLine(pen, wCorner, wCornerUp);
                g.DrawLine(pen, nCorner, nCornerUp);
                g.DrawLine(pen, sCorner, sCornerUp);
                g.DrawLine(pen, center, centerUp);
                break;

            case WallFacing.NE_CORNER:
                g.DrawLine(pen, center, eCorner);
                g.DrawLine(pen, center, sCorner);
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, centerUp, eCornerUp);
                g.DrawLine(pen, centerUp, sCornerUp);

                g.DrawLine(pen, centerUp, center);
                g.DrawLine(pen, eCornerUp, eCorner);
                g.DrawLine(pen, sCornerUp, sCorner);
                break;

            case WallFacing.NW_CORNER:
                g.DrawLine(pen, center, wCorner);
                g.DrawLine(pen, center, sCorner);
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, centerUp, wCornerUp);
                g.DrawLine(pen, centerUp, sCornerUp);

                g.DrawLine(pen, centerUp, center);
                g.DrawLine(pen, wCornerUp, wCorner);
                g.DrawLine(pen, sCornerUp, sCorner);
                break;

            case WallFacing.SW_CORNER:
                g.DrawLine(pen, center, nCorner);
                g.DrawLine(pen, center, wCorner);
                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, centerUp, nCornerUp);
                g.DrawLine(pen, centerUp, wCornerUp);

                g.DrawLine(pen, centerUp, center);
                g.DrawLine(pen, wCornerUp, wCorner);
                g.DrawLine(pen, nCornerUp, nCorner);
                break;

            case WallFacing.SE_CORNER:
                g.DrawLine(pen, center, nCorner);
                g.DrawLine(pen, center, eCorner);

                if (!DrawExtents3D)
                {
                    break;
                }
                g.DrawLine(pen, centerUp, nCornerUp);
                g.DrawLine(pen, centerUp, eCornerUp);

                g.DrawLine(pen, centerUp, center);
                g.DrawLine(pen, eCornerUp, eCorner);
                g.DrawLine(pen, nCornerUp, nCorner);
                break;

            default:
                g.DrawRectangle(pen, x, y, squareSize, squareSize);
                if (drawText)
                {
                    g.DrawString("?", drawFont, Brushes.Red, nCorner);
                }
                break;
            }
            if (drawText)
            {
                g.DrawString(wall.Minimap.ToString(), drawFont, Brushes.Red, txtPoint);
            }
        }
Esempio n. 11
0
        public void SetWall(Map.Wall wall, bool read = false)
        {
            this.wall = wall;


            // Flags

            if (read)
            {
                polygonGroup.Value = 100;
                checkListFlags.SetItemChecked(0, false);
                checkListFlags.SetItemChecked(1, false);
                checkListFlags.SetItemChecked(2, false);
                checkListFlags.SetItemChecked(3, false);
                comboWallState.SelectedIndex = 0;
                checkDestructable.Checked    = false;
                numericCloseDelay.Value      = 3;


                if (wall.Secret_WallState > 0)
                {
                    comboWallState.SelectedIndex = wall.Secret_WallState - 1;
                }
                openWallBox.Checked       = wall.Secret_WallState == 4 ? true : false;
                checkDestructable.Checked = wall.Destructable;
                polygonGroup.Value        = wall.Minimap;
                numericCloseDelay.Value   = wall.Secret_OpenWaitSeconds;
                if ((wall.Secret_ScanFlags & 1) == 1)
                {
                    checkListFlags.SetItemChecked(0, true);
                }
                if ((wall.Secret_ScanFlags & 2) == 2)
                {
                    checkListFlags.SetItemChecked(1, true);
                }
                if ((wall.Secret_ScanFlags & 4) == 4)
                {
                    checkListFlags.SetItemChecked(2, true);
                }
                if ((wall.Secret_ScanFlags & 8) == 8)
                {
                    checkListFlags.SetItemChecked(3, true);
                }
            }
            else
            {
                flags = 0;
                if (checkListFlags.GetItemChecked(0))
                {
                    flags |= 1;
                }
                if (checkListFlags.GetItemChecked(1))
                {
                    flags |= 2;
                }
                if (checkListFlags.GetItemChecked(2))
                {
                    flags |= 4;
                }
                if (checkListFlags.GetItemChecked(3))
                {
                    flags |= 8;
                }
                wall.Secret_ScanFlags = flags;


                if (wall != null)
                {
                    wall.Secret_WallState = openWallBox.Checked ? (byte)4 : (byte)0;
                }

                //wall.Secret_WallState = (byte)(comboWallState.SelectedIndex + 1);

                wall.Secret_OpenWaitSeconds = (int)numericCloseDelay.Value;

                // Destructable
                wall.Destructable = checkDestructable.Checked;
                // Minimap
                wall.Minimap = (byte)polygonGroup.Value;
            }
        }
Esempio n. 12
0
        private void button4_Click(object sender, EventArgs e)
        {
            button3.Enabled = false;
            button4.Enabled = false;
            /*
            * This function copies all of the items and objects and flips them.
            *
            *
            */

            // Flip the walls
            if (chkFlipWall.Checked)
            {
                //int mapsize = 255 * 23;
                Map.WallMap temap = new Map.WallMap();
                foreach (Map.Wall wall in view.Map.Walls.Values)
                {
                    Map.Wall wal = new Map.Wall(wall.Location, wall.Facing, wall.matId);
                    wal.Location.Y = (255 - wall.Location.X)+1;
                    wal.Location.X = (255 - wall.Location.Y)+1;
                    if (chkAdv.Checked)
                    {
                        wal.matId = (byte)comboBox1.SelectedIndex;
                        wal.Minimap = Convert.ToByte(minimapGroup.Text);
                    }
                    switch (wal.Facing)
                    {
                        case Map.Wall.WallFacing.NORTH_T:
                            wal.Facing = Map.Wall.WallFacing.SOUTH_T; break;
                        case Map.Wall.WallFacing.SOUTH_T:
                            wal.Facing = Map.Wall.WallFacing.NORTH_T; break;

                        case Map.Wall.WallFacing.NE_CORNER:
                            wal.Facing = Map.Wall.WallFacing.SE_CORNER; break;
                        case Map.Wall.WallFacing.SE_CORNER:
                            wal.Facing = Map.Wall.WallFacing.NE_CORNER; break;
                        case Map.Wall.WallFacing.SW_CORNER:
                            wal.Facing = Map.Wall.WallFacing.NW_CORNER; break;
                        case Map.Wall.WallFacing.NW_CORNER:
                            wal.Facing = Map.Wall.WallFacing.SW_CORNER; break;
                    }
                    temap.Add(wal.Location, wal);
                }
                foreach (Map.Wall wa in temap.Values)
                {
                    if (!view.Map.Walls.ContainsKey(wa.Location))
                    {
                        view.Map.Walls.Add(wa.Location, wa);
                    }
                }
            }
            // Flip the waypoints now
            /*Map.WaypointList wp = new Map.WaypointList();
            foreach (Map.Waypoint wpt in view.Map.Waypoints)
            {
                Map.Waypoint wt = new Map.Waypoint(wpt.Name,wpt.Point,wpt.num);
                wt = wpt;
                float val = wt.Point.Y;
                val = (float)((float)(mapsize) - (float)(val));

                wt.Point.Y = (float)val;
                wp.Add(wt);
            }
            foreach (Map.Waypoint wpt in wp)
            {
                view.Map.Waypoints.Add(wpt);
            }*/

            // Flip the objects now
            if (chkFlipOb.Checked)
            {
                Map.ObjectTable tng2 = new Map.ObjectTable();
                foreach (Map.Object tng in view.Map.Objects)
                {
                    Map.Object tn = new Map.Object();
                    tn.Properties = tng.Properties;
                    tn.modbuf = (byte[])tng.modbuf.Clone();
                    tn.Extent = 0;

                    tn.Location.Y = ((256*23) - tng.Location.X)+23;
                    tn.Location.X = ((256*23) - tng.Location.Y)+23;

                    tng2.Add(tn);
                }
                foreach (Map.Object tng in tng2)
                {
                    view.Map.Objects.Add(tng);
                }
            }
        }