internal void Copy() { if (MapBase != null && FirstClick) { ToolstripFactory.Instance.EnablePasteButton(); var start = GetAbsoluteDragStart(); var end = GetAbsoluteDragEnd(); _copied = new MapTileBase[end.Y - start.Y + 1, end.X - start.X + 1]; XCMapTile @base, copy; for (int col = start.X; col <= end.X; ++col) { for (int row = start.Y; row <= end.Y; ++row) { @base = (XCMapTile)MapBase[row, col]; copy = new XCMapTile( @base.Ground, @base.West, @base.North, @base.Content); _copied[row - start.Y, col - start.X] = copy; } } } }
/// <summary> /// Inherited from IMapObserver through MapObserverControl0. /// </summary> /// <param name="args"></param> public override void OnLocationSelectedObserver(LocationSelectedEventArgs args) { //LogFile.WriteLine(""); //LogFile.WriteLine("QuadrantPanel.OnLocationSelectedObserver"); _tile = args.SelectedTile as XCMapTile; _location = args.Location; Refresh(); }
/// <summary> /// Inherited from IMapObserver through MapObserverControl0. /// </summary> /// <param name="args"></param> public override void OnLevelChangedObserver(LevelChangedEventArgs args) { if (_location != null) { _tile = MapBase[_location.Row, _location.Col] as XCMapTile; _location.Lev = args.Level; } Refresh(); }
/// <summary> /// Draws any wall and/or content indicators. /// </summary> private void DrawBlobs() { if (_toolWall == null) { _toolWall = new ColorTools(RoutePens[RouteView.WallColor]); } if (_toolContent == null) { _toolContent = new ColorTools(RouteBrushes[RouteView.ContentColor], _toolWall.Pen.Width); } XCMapTile tile = null; for (int r = 0, startX = Origin.X, startY = Origin.Y; r != MapFile.MapSize.Rows; ++r, startX -= DrawAreaWidth, startY += DrawAreaHeight) { for (int c = 0, x = startX, y = startY; c != MapFile.MapSize.Cols; ++c, x += DrawAreaWidth, y += DrawAreaHeight) { if (MapFile[r, c] != null) { tile = MapFile[r, c] as XCMapTile; if (tile.Content != null) { BlobService.DrawContent(_graphics, _toolContent, x, y, tile.Content); } if (tile.West != null) { BlobService.DrawContent(_graphics, _toolWall, x, y, tile.West); } if (tile.North != null) { BlobService.DrawContent(_graphics, _toolWall, x, y, tile.North); } } } } }
public BottomPanel() { _mapTile = null; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true); SelectedQuadrant = XCMapTile.MapQuadrant.Ground; Globals.LoadExtras(); _drawService = new BottomPanelDrawService(); _drawService.Brush = new SolidBrush(Color.FromArgb(204, 204, 255)); _drawService.Font = new Font("Verdana", 7); }
private void RmpPanel_MouseMove(object sender, MouseEventArgs e) { XCMapTile t = _rmpPanel.GetTile(e.X, e.Y); if (t != null && t.Rmp != null) { lblMouseOver.Text = "Over " + t.Rmp.Index; } else { lblMouseOver.Text = ""; } _rmpPanel.Position = new Point(e.X, e.Y); _rmpPanel.Refresh(); }
private void DrawWallsAndContent(Graphics g) { if (_wallColor == null) { _wallColor = new SolidPenBrush(MapPens["WallColor"]); } _drawContentService.HWidth = DrawAreaWidth; _drawContentService.HHeight = DrawAreaHeight; var map = Map; for (int row = 0, startX = Origin.X, startY = Origin.Y; row < map.MapSize.Rows; row++, startX -= DrawAreaWidth, startY += DrawAreaHeight) { for (int col = 0, x = startX, y = startY; col < map.MapSize.Cols; col++, x += DrawAreaWidth, y += DrawAreaHeight) { if (map[row, col] != null) { XCMapTile tile = (XCMapTile)map[row, col]; if (tile.North != null) { _drawContentService.DrawContent(g, _wallColor, x, y, tile.North); } if (tile.West != null) { _drawContentService.DrawContent(g, _wallColor, x, y, tile.West); } if (tile.Content != null) { _drawContentService.DrawContent(g, _wallColor, x, y, tile.Content); } } } } }
internal void Paste() { if (MapBase != null && _copied != null) { MapBase.MapChanged = true; XCMapTile tile = null; XCMapTile tileCopy = null; for (int row = DragStart.Y; row != MapBase.MapSize.Rows && (row - DragStart.Y) < _copied.GetLength(0); ++row) { for (int col = DragStart.X; col != MapBase.MapSize.Cols && (col - DragStart.X) < _copied.GetLength(1); ++col) { if ((tile = MapBase[row, col] as XCMapTile) != null) { if ((tileCopy = _copied[row - DragStart.Y, col - DragStart.X] as XCMapTile) != null) { tile.Ground = tileCopy.Ground; tile.Content = tileCopy.Content; tile.West = tileCopy.West; tile.North = tileCopy.North; } } } } ((MapFileChild)MapBase).CalculateOccultations(); RefreshViewers(); } }
private void DrawTileGray(Graphics g, XCMapTile mt, int x, int y) { var topView = MainWindowsManager.TopView.TopViewControl; if (mt.Ground != null && topView.GroundVisible) { DrawTileGray(g, x, y, mt.Ground); } if (mt.North != null && topView.NorthVisible) { DrawTileGray(g, x, y, mt.North); } if (mt.West != null && topView.WestVisible) { DrawTileGray(g, x, y, mt.West); } if (mt.Content != null && topView.ContentVisible) { DrawTileGray(g, x, y, mt.Content); } }
internal void Draw( Graphics graphics, XCMapTile tile, QuadrantType selectedQuadrant) { if (!Inited) { Inited = true; DoorWidth = (int)graphics.MeasureString(Door, Font).Width; FloorWidth = (int)graphics.MeasureString(Floor, Font).Width; WestWidth = (int)graphics.MeasureString(West, Font).Width; NorthWidth = (int)graphics.MeasureString(North, Font).Width; ContentWidth = (int)graphics.MeasureString(Content, Font).Width; } var topView = ViewerFormsManager.TopView.Control; // fill the background of the selected quadrant type switch (selectedQuadrant) { case QuadrantType.Ground: if (topView.GroundVisible) { graphics.FillPath(Brush, _pathFloor); } break; case QuadrantType.West: if (topView.WestVisible) { graphics.FillPath(Brush, _pathWest); } break; case QuadrantType.North: if (topView.NorthVisible) { graphics.FillPath(Brush, _pathNorth); } break; case QuadrantType.Content: if (topView.ContentVisible) { graphics.FillPath(Brush, _pathContent); } break; } // fill the background of !Visible quads incl/ the selected-quad if (!topView.GroundVisible) { graphics.FillPath(System.Drawing.Brushes.DarkGray, _pathFloor); } if (!topView.WestVisible) { graphics.FillPath(System.Drawing.Brushes.DarkGray, _pathWest); } if (!topView.NorthVisible) { graphics.FillPath(System.Drawing.Brushes.DarkGray, _pathNorth); } if (!topView.ContentVisible) { graphics.FillPath(System.Drawing.Brushes.DarkGray, _pathContent); } // draw the Sprites // Ground -> if (tile != null && tile.Ground != null) { graphics.DrawImage( tile.Ground[MainViewUnderlay.AniStep].Image, StartX, StartY - tile.Ground.Record.TileOffset); if (tile.Ground.Record.HumanDoor || tile.Ground.Record.UfoDoor) { DrawDoorString(graphics, QuadrantType.Ground); } } else { graphics.DrawImage( Globals.ExtraSprites[3].Image, StartX, StartY); } // Westwall -> if (tile != null && tile.West != null) { graphics.DrawImage( tile.West[MainViewUnderlay.AniStep].Image, StartX + QuadWidthTotal, StartY - tile.West.Record.TileOffset); if (tile.West.Record.HumanDoor || tile.West.Record.UfoDoor) { DrawDoorString(graphics, QuadrantType.West); } } else { graphics.DrawImage( Globals.ExtraSprites[1].Image, StartX + QuadWidthTotal, StartY); } // Northwall -> if (tile != null && tile.North != null) { graphics.DrawImage( tile.North[MainViewUnderlay.AniStep].Image, StartX + QuadWidthTotal * 2, StartY - tile.North.Record.TileOffset); if (tile.North.Record.HumanDoor || tile.North.Record.UfoDoor) { DrawDoorString(graphics, QuadrantType.North); } } else { graphics.DrawImage( Globals.ExtraSprites[2].Image, StartX + QuadWidthTotal * 2, StartY); } // Content -> if (tile != null && tile.Content != null) { graphics.DrawImage( tile.Content[MainViewUnderlay.AniStep].Image, StartX + QuadWidthTotal * 3, StartY - tile.Content.Record.TileOffset); if (tile.Content.Record.HumanDoor || tile.Content.Record.UfoDoor) { DrawDoorString(graphics, QuadrantType.Content); } } else { graphics.DrawImage( Globals.ExtraSprites[4].Image, StartX + QuadWidthTotal * 3, StartY); } // draw each quadrant's bounding rectangle graphics.DrawPath(System.Drawing.Pens.Black, _pathFloor); graphics.DrawPath(System.Drawing.Pens.Black, _pathWest); graphics.DrawPath(System.Drawing.Pens.Black, _pathNorth); graphics.DrawPath(System.Drawing.Pens.Black, _pathContent); // draw the quad-type label under each quadrant DrawTypeString(graphics, QuadrantType.Ground); DrawTypeString(graphics, QuadrantType.West); DrawTypeString(graphics, QuadrantType.North); DrawTypeString(graphics, QuadrantType.Content); // fill the color-swatch under each quadrant-label if (Brushes != null && Pens != null) { FillSwatchColor(graphics, QuadrantType.Ground); FillSwatchColor(graphics, QuadrantType.West); FillSwatchColor(graphics, QuadrantType.North); FillSwatchColor(graphics, QuadrantType.Content); } }
private void startAnalyzing() { groupAnalyze.Visible = true; Hashtable imgHash = new Hashtable(); Hashtable mcdHash = new Hashtable(); groupInfo.Text = "Map: " + map.Name; lblDimensions.Text = map.MapSize.Rows + "," + map.MapSize.Cols + "," + map.MapSize.Height; lblPckFiles.Text = ""; bool one = true; int totalImages = 0; int totalMcd = 0; if (map is XCMapFile) { foreach (string s in ((XCMapFile)map).Dependencies) { if (one) { one = false; } else { lblPckFiles.Text += ","; } totalImages += GameInfo.ImageInfo[s].GetPckFile().Count; totalMcd += GameInfo.ImageInfo[s].GetMcdFile().Count; lblPckFiles.Text += s; } } pBar.Maximum = map.MapSize.Rows * map.MapSize.Cols * map.MapSize.Height; pBar.Value = 0; for (int h = 0; h < map.MapSize.Height; h++) { for (int r = 0; r < map.MapSize.Rows; r++) { for (int c = 0; c < map.MapSize.Cols; c++) { XCMapTile tile = (XCMapTile)map[r, c, h]; if (!tile.Blank) { if (tile.Ground != null) { count(imgHash, mcdHash, tile.Ground); if (tile.Ground is XCTile) { count(imgHash, mcdHash, ((XCTile)tile.Ground).Dead); } slotsUsed++; } if (tile.West != null) { count(imgHash, mcdHash, tile.West); if (tile.West is XCTile) { count(imgHash, mcdHash, ((XCTile)tile.West).Dead); } slotsUsed++; } if (tile.North != null) { count(imgHash, mcdHash, tile.North); if (tile.North is XCTile) { count(imgHash, mcdHash, ((XCTile)tile.North).Dead); } slotsUsed++; } if (tile.Content != null) { count(imgHash, mcdHash, tile.Content); if (tile.Content is XCTile) { count(imgHash, mcdHash, ((XCTile)tile.Content).Dead); } slotsUsed++; } pBar.Value = (r + 1) * (c + 1) * (h + 1); pBar.Refresh(); } } } } var pct = Math.Round(100 * ((mcdHash.Keys.Count * 1.0) / totalMcd), 2); lblMcd.Text = mcdHash.Keys.Count + "/" + totalMcd + " - " + pct + "%"; pct = Math.Round(100 * ((imgHash.Keys.Count * 1.0) / totalImages), 2); lblPckImages.Text = imgHash.Keys.Count + "/" + totalImages + " - " + pct + "%"; pct = Math.Round(100 * ((slotsUsed * 1.0) / (pBar.Maximum * 4)), 2); lblFilled.Text = slotsUsed + "/" + (pBar.Maximum * 4) + " - " + pct + "%"; groupAnalyze.Visible = false; }
/// <summary> /// Draws the tileparts in the Tile. /// </summary> /// <param name="tile"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="isGray"></param> private void DrawTile( XCMapTile tile, int x, int y, bool isGray) { // NOTE: The width and height args are based on a sprite that's 32x40. // Going back to a universal sprite-size would do this: // (int)(sprite.Width * Globals.Scale) // (int)(sprite.Height * Globals.Scale) // with its attendent consequences. TilepartBase part = null; var topView = ViewerFormsManager.TopView.Control; if (topView.GroundVisible) { if ((part = tile.Ground) != null) { var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray : part[MainViewUnderlay.AniStep].Image; DrawSprite( sprite, new Rectangle( x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst, HalfWidth * 2, HalfHeight * 5)); } } if (topView.WestVisible) { if ((part = tile.West) != null) { var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray : part[MainViewUnderlay.AniStep].Image; DrawSprite( sprite, new Rectangle( x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst, HalfWidth * 2, HalfHeight * 5)); } } if (topView.NorthVisible) { if ((part = tile.North) != null) { var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray : part[MainViewUnderlay.AniStep].Image; DrawSprite( sprite, new Rectangle( x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst, HalfWidth * 2, HalfHeight * 5)); } } if (topView.ContentVisible) { if ((part = tile.Content) != null) { var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray : part[MainViewUnderlay.AniStep].Image; DrawSprite( sprite, new Rectangle( x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst, HalfWidth * 2, HalfHeight * 5)); } } }
public override void SelectedTileChanged(IMap_Base sender, SelectedTileChangedEventArgs e) { _mapTile = (XCMapTile)e.SelectedTile; _lastLoc = e.MapPosition; Refresh(); }
public override void HeightChanged(IMap_Base sender, HeightChangedEventArgs e) { _lastLoc.Height = e.NewHeight; _mapTile = map[_lastLoc.Row, _lastLoc.Col] as XCMapTile; Refresh(); }
public void Draw( Graphics g, XCMapTile mapTile, XCMapTile.MapQuadrant selectedQuadrant) { // Draw selection if (selectedQuadrant == XCMapTile.MapQuadrant.Ground) { g.FillRectangle( Brush, startX, startY, tileWidth + 1, tileHeight + 2); } else if (selectedQuadrant == XCMapTile.MapQuadrant.West) { g.FillRectangle( Brush, startX + (TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } else if (selectedQuadrant == XCMapTile.MapQuadrant.North) { g.FillRectangle( Brush, startX + (2 * TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } else if (selectedQuadrant == XCMapTile.MapQuadrant.Content) { g.FillRectangle( Brush, startX + (3 * TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } var topView = MainWindowsManager.TopView.TopViewControl; // Ground not visible if (!topView.GroundVisible) { g.FillRectangle( System.Drawing.Brushes.DarkGray, startX, startY, tileWidth + 1, tileHeight + 2); } if (mapTile != null && mapTile.Ground != null) { g.DrawImage( mapTile.Ground[MapViewPanel.Current].Image, startX, startY - mapTile.Ground.Info.TileOffset); if (mapTile.Ground.Info.HumanDoor || mapTile.Ground.Info.UFODoor) { g.DrawString( "Door", Font, System.Drawing.Brushes.Black, startX, startY + PckImage.Height - Font.Height); } } else { g.DrawImage( Globals.ExtraTiles[3].Image, startX, startY); } if (!topView.WestVisible) { g.FillRectangle( System.Drawing.Brushes.DarkGray, startX + (TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } if (mapTile != null && mapTile.West != null) { g.DrawImage( mapTile.West[MapViewPanel.Current].Image, startX + (TOTAL_QUADRAN_SPACE), startY - mapTile.West.Info.TileOffset); if (mapTile.West.Info.HumanDoor || mapTile.West.Info.UFODoor) { g.DrawString( "Door", Font, System.Drawing.Brushes.Black, startX + (TOTAL_QUADRAN_SPACE), startY + PckImage.Height - Font.Height); } } else { g.DrawImage( Globals.ExtraTiles[1].Image, startX + (TOTAL_QUADRAN_SPACE), startY); } if (!topView.NorthVisible) { g.FillRectangle( System.Drawing.Brushes.DarkGray, startX + (2 * TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } if (mapTile != null && mapTile.North != null) { g.DrawImage( mapTile.North[MapViewPanel.Current].Image, startX + (2 * TOTAL_QUADRAN_SPACE), startY - mapTile.North.Info.TileOffset); if (mapTile.North.Info.HumanDoor || mapTile.North.Info.UFODoor) { g.DrawString( "Door", Font, System.Drawing.Brushes.Black, startX + (2 * TOTAL_QUADRAN_SPACE), startY + PckImage.Height - Font.Height); } } else { g.DrawImage( Globals.ExtraTiles[2].Image, startX + (2 * TOTAL_QUADRAN_SPACE), startY); } if (!topView.ContentVisible) { g.FillRectangle( System.Drawing.Brushes.DarkGray, startX + (3 * TOTAL_QUADRAN_SPACE), startY, tileWidth + 1, tileHeight + 2); } if (mapTile != null && mapTile.Content != null) { g.DrawImage( mapTile.Content[MapViewPanel.Current].Image, startX + (3 * TOTAL_QUADRAN_SPACE), startY - mapTile.Content.Info.TileOffset); if (mapTile.Content.Info.HumanDoor || mapTile.Content.Info.UFODoor) { g.DrawString( "Door", Font, System.Drawing.Brushes.Black, startX + (3 * TOTAL_QUADRAN_SPACE), startY + PckImage.Height - Font.Height); } } else { g.DrawImage( Globals.ExtraTiles[4].Image, startX + (3 * TOTAL_QUADRAN_SPACE), startY); } DrawGroundAndContent(g); g.DrawString( "Gnd", Font, System.Drawing.Brushes.Black, new RectangleF( startX, startY + tileHeight + space, tileWidth, 50)); g.DrawString( "West", Font, System.Drawing.Brushes.Black, new RectangleF( startX + (TOTAL_QUADRAN_SPACE), startY + tileHeight + space, tileWidth, 50)); g.DrawString( "North", Font, System.Drawing.Brushes.Black, new RectangleF( startX + (2 * TOTAL_QUADRAN_SPACE), startY + tileHeight + space, tileWidth, 50)); g.DrawString( "Object", Font, System.Drawing.Brushes.Black, new RectangleF( startX + (3 * TOTAL_QUADRAN_SPACE), startY + tileHeight + space, tileWidth + 50, 50)); for (int i = 0; i < 4; i++) { g.DrawRectangle( System.Drawing.Pens.Black, startX - 1 + (i * TOTAL_QUADRAN_SPACE), startY, tileWidth + 2, tileHeight + 2); } }