Пример #1
0
        public void DrawItem(Graphics gfx, MapRenderContext context, Rectangle itemRect, Item item)
        {
            var colorScheme = colorSchemeProvider.GetColorScheme();

            itemRect = context.ApplyStandardPaddingForTiles(itemRect);

            Brush brush = context.ResourceCache.GetSolidBrush(colorScheme.GetItemColor(item));

            if (item.IsDropped)
            {
                gfx.FillPolygon(brush,
                                new Point[]
                {
                    itemRect.Location,
                    new Point(itemRect.Right, itemRect.Top),
                    new Point(itemRect.Right, itemRect.Bottom - itemRect.Width / 2),
                    new Point(itemRect.Left + itemRect.Width / 2, itemRect.Bottom),
                    new Point(itemRect.Left, itemRect.Bottom - itemRect.Width / 2)
                }
                                );
            }
            else
            {
                gfx.FillRectangle(brush, itemRect);
            }
        }
Пример #2
0
        public override void Paint(Graphics gfx, MapRenderContext context)
        {
            using (var stringFormat = new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            })
            {
                using (Pen pen = new Pen(Color.Coral, 1))
                {
                    using (Brush brush = new SolidBrush(Color.Coral))
                    {
                        foreach (var building in map.Buildings)
                        {
                            Size buildingSize = GetBuildingSize(building);

                            // From observation, a building is centered on its coordinate...
                            var buildingRect = context.ToViewport(building.X - 32 - buildingSize.Width / 2,
                                                                  building.Y - 32 - buildingSize.Height / 2, buildingSize.Width, buildingSize.Height);
                            buildingRect = buildingRect.Shrink(4, 4, 3, 3);

                            gfx.FillRectangle(brush, buildingRect);
                            gfx.DrawString(building.BuildingType.ToString(), font, Brushes.White, buildingRect, stringFormat);
                        }
                    }
                }
            }
        }
Пример #3
0
        public void DrawItem(Graphics gfx, MapRenderContext context, Rectangle itemRect, Item item)
        {
            var colorScheme = colorSchemeProvider.GetColorScheme();

            itemRect = context.ApplyStandardPaddingForTiles(itemRect);

            Brush brush = context.ResourceCache.GetSolidBrush(colorScheme.GetItemColor(item));

            gfx.FillRectangle(brush, itemRect);

            ItemKind kind = ItemInfo.GetItemKind(item);

            if (kind == ItemKind.Kind_DIYRecipe)
            {
                gfx.FillPolygon(Brushes.PaleVioletRed,
                                new Point[]
                {
                    new Point(itemRect.Left, itemRect.Bottom),
                    new Point(itemRect.Left + itemRect.Width / 2, itemRect.Top + itemRect.Height / 2),
                    new Point(itemRect.Right, itemRect.Bottom),
                });
            }
            else if (!item.IsDropped && !item.IsBuried)
            {
                gfx.DrawLine(Pens.Black, itemRect.Left, itemRect.Top, itemRect.Right, itemRect.Bottom);
                gfx.DrawLine(Pens.Black, itemRect.Left, itemRect.Bottom, itemRect.Right, itemRect.Top);
            }
        }
Пример #4
0
        public override void Paint(Graphics gfx, MapRenderContext context)
        {
            if (!marqueeBounds.IsEmpty)
            {
                gfx.DrawRectangle(Pens.White, marqueeBounds);
                gfx.DrawRectangle(pen, marqueeBounds);
            }

            if (fragment != null)
            {
                foreach (var entry in fragment)
                {
                    var itemRect = context.ToViewport(entry.TileRect).Shrink(2, 2, 1, 1);
                    var brush    = entry.IsConflicted ? Brushes.Red : Brushes.LawnGreen;
                    gfx.FillRectangle(brush, itemRect);
                }
            }

            if (!string.IsNullOrEmpty(hint))
            {
                Size      hintSize = Size.Ceiling(gfx.MeasureString(hint, font));
                Rectangle hintRect = new Rectangle(
                    marqueeBounds.Right - hintSize.Width,
                    marqueeBounds.Bottom - hintSize.Height,
                    hintSize.Width,
                    hintSize.Height);
                gfx.FillRectangle(Brushes.Black, hintRect);
                gfx.DrawString(hint, font, Brushes.White, hintRect);
            }
        }
Пример #5
0
 public override void Paint(Graphics gfx, MapRenderContext context)
 {
     foreach (var area in document.PersistentTemplate.Areas)
     {
         var viewportBounds = context.ToViewport(area.TileBounds);
         viewportBounds = context.ApplyStandardPaddingForTiles(viewportBounds);
         gfx.FillRectangle(brush, viewportBounds);
         gfx.DrawRectangle(Pens.White, viewportBounds);
         gfx.DrawString(area.TemplateConfig?.Name, this.font, this.brush, viewportBounds, format);
     }
 }
Пример #6
0
 public override void Paint(Graphics gfx, MapRenderContext context)
 {
     // Each terrain tile occupies 4 map tiles (i.e. 2x2) so we need to cope with partial
     // terrain tiles...
     for (int tileX = context.TileRange.Left - context.TileRange.Left % 2; tileX < context.TileRange.Right; tileX += 2)
     {
         for (int tileY = context.TileRange.Top - context.TileRange.Top % 2; tileY < context.TileRange.Bottom; tileY += 2)
         {
             Color color = Color.FromArgb(map.Terrain.GetTileColor(tileX / 2, tileY / 2));
             gfx.FillRectangle(context.ResourceCache.GetSolidBrush(color),
                               context.ToViewport(tileX, tileY, 2, 2));
         }
     }
 }
Пример #7
0
        public override void Paint(Graphics gfx, MapRenderContext context)
        {
            for (int x = context.TileRange.Left; x < context.TileRange.Right; x++)
            {
                var leftEdge = context.GetLeftEdge(x);
                gfx.DrawLine(x % 2 == 0 ? majorPen : minorPen, leftEdge, context.ViewRect.Top, leftEdge, context.ViewRect.Bottom);
            }

            for (int y = context.TileRange.Top; y < context.TileRange.Bottom; y++)
            {
                var topEdge = context.GetTopEdge(y);
                gfx.DrawLine(y % 2 == 0 ? majorPen : minorPen, context.ViewRect.Left, topEdge, context.ViewRect.Right, topEdge);
            }
        }
Пример #8
0
 public override void Paint(Graphics gfx, MapRenderContext context)
 {
     gfx.FillRectangle(brush, context.ViewRect);
 }
Пример #9
0
        public override void Paint(Graphics gfx, MapRenderContext context)
        {
            var itemRenderStyle = itemRenderStyleProvider.GetStyle();
            var layer           = map.CurrentLayer;

            bool[,] drawn = new bool[context.TileRange.Width, context.TileRange.Height];

            for (int x = context.TileRange.Left; x < context.TileRange.Right; x++)
            {
                for (int y = context.TileRange.Top; y < context.TileRange.Bottom; y++)
                {
                    if (drawn[x - context.TileRange.Left, y - context.TileRange.Top])
                    {
                        continue;
                    }

                    var tile = layer.GetTile(x, y);
                    if (tile.IsNone)
                    {
                        continue;
                    }

                    /*if (tile.IsBuried)
                     * {
                     *  // DrawX(data, (x - x0) * scale, (y - y0) * scale, scale, w);
                     * }
                     * else if (tile.IsDropped)
                     * {
                     *  //Rectangle itemRect = context.GetTileRectangle(x, y, 1, 1).Shrink(2, 2, 1, 1);
                     *  //gfx.FillRectangle(Brushes.DeepPink, itemRect);
                     *  //  DrawPlus(data, (x - x0) * scale, (y - y0) * scale, scale, w);
                     * }*/

                    Item? root         = null;
                    Point rootLocation = Point.Empty;

                    if (tile.IsRoot)
                    {
                        root         = tile;
                        rootLocation = new Point(x, y);
                    }
                    else if (tile.IsExtension)
                    {
                        rootLocation = new Point(x - tile.ExtensionX, y - tile.ExtensionY);
                        root         = layer.GetTile(rootLocation.X, rootLocation.Y);

                        //Debug.Assert(root.IsRoot);
                        //Rectangle itemRect = context.GetTileRectangle(x, y, 1, 1).Shrink(2, 2, 1, 1);
                        //gfx.FillRectangle(Brushes.BlueViolet, itemRect);
                    }


                    if (root != null)
                    {
                        var       type     = ItemInfo.GetItemSize(root);
                        var       itemSize = root.GetSize();
                        Rectangle itemRect = context.ToViewport(rootLocation.X, rootLocation.Y, itemSize.Width, itemSize.Height);

                        itemRenderStyle?.DrawItem(gfx, context, itemRect, root);

                        for (int ix = 0; ix < itemSize.Width; ix++)
                        {
                            int drawnX = rootLocation.X + ix - context.TileRange.Left;
                            if (drawnX < 0)
                            {
                                continue;
                            }
                            if (drawnX >= context.TileRange.Width)
                            {
                                break;
                            }

                            for (int iy = 0; iy < itemSize.Height; iy++)
                            {
                                int drawnY = rootLocation.Y + iy - context.TileRange.Top;

                                if (drawnY < 0)
                                {
                                    continue;
                                }
                                if (drawnY >= context.TileRange.Height)
                                {
                                    break;
                                }

                                drawn[drawnX, drawnY] = true;
                            }
                        }
                    }
                }
            }
        }
Пример #10
0
 public abstract void Paint(Graphics gfx, MapRenderContext context);