private void Draw3dBorder() { Gfx.Primitives.Line lineToDraw; int PenWidth = 1; lineToDraw = new SdlDotNet.Graphics.Primitives.Line(new Point(0, 0), new Point(base.Width - PenWidth, 0)); mBackground.Draw(lineToDraw, Color.DarkGray); lineToDraw = new SdlDotNet.Graphics.Primitives.Line(new Point(0, 0), new Point(0, base.Height - PenWidth)); mBackground.Draw(lineToDraw, Color.DarkGray); lineToDraw = new SdlDotNet.Graphics.Primitives.Line(new Point(0, base.Height - PenWidth), new Point(base.Width - PenWidth, base.Height - PenWidth)); mBackground.Draw(lineToDraw, Color.FromArgb(255, 255, 255, 254)); lineToDraw = new SdlDotNet.Graphics.Primitives.Line(new Point(base.Width - PenWidth, 0), new Point(base.Width - PenWidth, base.Height - PenWidth)); mBackground.Draw(lineToDraw, Color.FromArgb(255, 255, 255, 254)); }
public void DrawLine(int x, int y, int a, int b, Color color) { SdlDotNet.Graphics.Primitives.Line line = new SdlDotNet.Graphics.Primitives.Line((short)x, (short)y, (short)a, (short)b); surface.Draw(line, ConvertColor(color)); }
public static void DrawMapGrid(RendererDestinationData destData, Map activeMap, int cameraX, int cameraX2, int cameraY, int cameraY2) { int startX = cameraX; int startY = cameraY; if (ScreenRenderer.MapXOffset < 0) { startX--; } if (ScreenRenderer.MapYOffset < 0) { startY--; } else if (ScreenRenderer.MapYOffset > 0) { startY--; } //if (locYSub) { // cameraY--; // cameraY2++; //} for (int x = startX; x < cameraX2; x++) { for (int y = startY; y < cameraY2; y++) { if (x >= 0 && x <= activeMap.MaxX && y >= 0 && y <= activeMap.MaxY) { DrawTile(destData, 10, 0, x - cameraX, y - cameraY, false); if (x == 0) { SdlDotNet.Graphics.Primitives.Line line = new SdlDotNet.Graphics.Primitives.Line((short)(((x - cameraX) * Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)(((y - cameraY) * Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset), (short)(((x - cameraX) * Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)((((y - cameraY) * Constants.TILE_HEIGHT) + Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset)); destData.Surface.Draw(line, Color.Red); } else if (x == activeMap.MaxX) { SdlDotNet.Graphics.Primitives.Line line = new SdlDotNet.Graphics.Primitives.Line((short)((((x - cameraX) * Constants.TILE_WIDTH) + Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)(((y - cameraY) * Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset), (short)((((x - cameraX) * Constants.TILE_WIDTH) + Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)((((y - cameraY) * Constants.TILE_HEIGHT) + Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset)); destData.Surface.Draw(line, Color.Red); } if (y == 0) { SdlDotNet.Graphics.Primitives.Line line = new SdlDotNet.Graphics.Primitives.Line((short)(((x - cameraX) * Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)(((y - cameraY) * Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset), (short)((((x - cameraX) * Constants.TILE_WIDTH) + Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)(((y - cameraY) * Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset)); destData.Surface.Draw(line, Color.Red); } else if (y == activeMap.MaxY) { SdlDotNet.Graphics.Primitives.Line line = new SdlDotNet.Graphics.Primitives.Line((short)(((x - cameraX) * Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)((((y - cameraY) * Constants.TILE_HEIGHT) + Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset), (short)((((x - cameraX) * Constants.TILE_WIDTH) + Constants.TILE_WIDTH) - ScreenRenderer.MapXOffset), (short)((((y - cameraY) * Constants.TILE_HEIGHT) + Constants.TILE_HEIGHT) - ScreenRenderer.MapYOffset)); destData.Surface.Draw(line, Color.Red); } } } } }
private void UpdateTemp() { /* The dispose method of Surface didn't release memory */ this.TempSurf = null; this.TempSurf = new Surface(this.levelSize * this.GridSize, this.levelSize * this.GridSize); this.TempSurf.Transparent = true; /* Add a temporary block if user is currently drawing */ if (this.isDrawingBlock) { IPrimitive p = new SdlDotNet.Graphics.Primitives.Box( (short)((original_x * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-original_y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((current_x * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-current_y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p, Color.Orange); } /* Draw Selected Blocks */ List<Block> classRef; classRef = (List<Block>)this.blocks; for (int i = 0; i < classRef.Count(); i++) { if (classRef.ElementAt(i).selected && layerStatus[(int)classRef.ElementAt(i)._layer]) { IPrimitive p; p = new SdlDotNet.Graphics.Primitives.Box(0, 0, 0, 0); if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (classRef.ElementAt(i).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (-classRef.ElementAt(i).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.Z * this.GridSize) + (classRef.ElementAt(i).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Y * this.GridSize) + (-classRef.ElementAt(i).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { p = new SdlDotNet.Graphics.Primitives.Box( (short)((classRef.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(i).Position.X * this.GridSize) + (classRef.ElementAt(i).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(i).Position.Z * this.GridSize) + (-classRef.ElementAt(i).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); } this.TempSurf.Draw(p, Color.LightGreen); } } if (this.isResizingBlock) { if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { #region ResizeXY if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeXY } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { #region ResizeZY if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Y * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Y * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeZY } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { #region ResizeXZ if (this.resizePosX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeX) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizePosY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } else if (this.resizeSizeY) { IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line( (short)((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((classRef.ElementAt(this.block_id).Position.X * this.GridSize) + (classRef.ElementAt(this.block_id).Size.X * this.GridSize)) + (this.levelSize * this.GridSize / 2)), (short)(((-classRef.ElementAt(this.block_id).Position.Z * this.GridSize) + (-classRef.ElementAt(this.block_id).Size.Z * this.GridSize)) + (this.levelSize * this.GridSize / 2))); this.TempSurf.Draw(p2, Color.Orange); } #endregion ResizeXY } } /* Mark selected items */ List<Item> classRef2; classRef2 = (List<Item>)this.items; for (int i = 0; i < classRef2.Count(); i++) { if (classRef2.ElementAt(i).selected && layerStatus[(int)classRef2.ElementAt(i)._layer]) { IPrimitive p; p = new SdlDotNet.Graphics.Primitives.Box(0, 0, 0, 0); if (this.View == "XY") // "Front" view, Axis1 = X, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "ZY") // "Left" view, Axis1 = Z, Axis2 = Y { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Y * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } else if (this.View == "XZ") // "Top" view, Axis1 = X, Axis2 = Z { p = new SdlDotNet.Graphics.Primitives.Box( (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) - (this.GridSize / 2)), (short)(((classRef2.ElementAt(i).Position.X * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2)), (short)(((-classRef2.ElementAt(i).Position.Z * this.GridSize) + (this.levelSize * this.GridSize / 2)) + (this.GridSize / 2))); } this.TempSurf.Draw(p, Color.LightGreen); } } this.surfaceUpdated = 1; }
private void UpdateGrid() { Console.WriteLine("updategrid"); //this.GridSurf.Dispose(); this.GridSurf = null; this.GridSurf = new Surface(this.levelSize * this.GridSize, this.levelSize * this.GridSize); IPrimitive p1 = new SdlDotNet.Graphics.Primitives.Line((short)(this.levelSize * this.GridSize / 2), 0, (short)(this.levelSize * this.GridSize / 2), (short)(this.levelSize * this.GridSize)); IPrimitive p2 = new SdlDotNet.Graphics.Primitives.Line(0, (short)(this.levelSize * this.GridSize / 2), (short)(this.levelSize * this.GridSize), (short)(this.levelSize * this.GridSize / 2)); this.GridSurf.Draw(p1, Color.FromArgb(255,64,64,64)); this.GridSurf.Draw(p2, Color.FromArgb(255,64,64,64)); for (int x = this.GridSize; x < this.levelSize*this.GridSize; x += this.GridSize) { for (int y = this.GridSize; y < this.levelSize * this.GridSize; y += this.GridSize) { Point p = new Point(x, y); this.GridSurf.Draw(p, Color.FromArgb(255,96,96,96)); } } this.surfaceUpdated = 1; }