public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
        {
            var rect = layer.GetBlockRectangle(block.Position);

            var chunkPos    = block.Position.GetChunkPosition();
            var chunkBounds = chunkPos.GetBlockBounds();

            var chunkRect = layer.GetChunkRectangle(chunkPos);

            var rX = block.Position.X % 16;
            var rZ = block.Position.Z % 16;


            if (rX == 15 && rZ == 15)
            {
                graphics.DrawRectangle(_chunkPen, chunkRect);
            }

            graphics.DrawRectangle(_gridPen, rect);

            if (rX == 15 && rZ == 15)
            {
                DrawText(graphics, chunkPos.ToString(), chunkRect, _chunkCoordFont);

                var min = chunkBounds.Min;
                var max = chunkBounds.Max;

                var tl = min;
                var tr = new BlockPosition(min.X, max.Z);
                var bl = new BlockPosition(max.X, min.Z);
                var br = max;

                DrawText(graphics, tl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Near);
                DrawText(graphics, tr.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Near);
                DrawText(graphics, bl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Far);
                DrawText(graphics, br.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Far);
            }
        }
Beispiel #2
0
        public override string ToString()
        {
            // Json format

            StringBuilder sb = new StringBuilder();

            string tabs_lvl  = string.Concat(Enumerable.Repeat("\t", level));
            string tabs_lvl1 = tabs_lvl + "\t";

            sb.Append(tabs_lvl)
            .Append("{\r\n");
            sb.Append(tabs_lvl1)
            .Append("\"node_type\": ").Append("\"" + ASTType.ToString() + "\"").Append(",\r\n");

            if (AASTType.Type != VarType.ERAType.NO_TYPE || Program.config.ExtendedSemanticMessages)
            {
                sb.Append(tabs_lvl1)
                .Append("\"var_type\": ").Append("\"" + AASTType.ToString() + "\"").Append(",\r\n");
            }

            if (AASTValue != 0 || Program.config.ExtendedSemanticMessages)
            {
                sb.Append(tabs_lvl1)
                .Append("\"var_value\": ").Append("\"" + AASTValue.ToString() + "\"").Append(",\r\n");
            }

            if (BlockPosition != 0 || Program.config.ExtendedSemanticMessages)
            {
                sb.Append(tabs_lvl1)
                .Append("\"block_position\": ").Append("\"" + BlockPosition.ToString() + "\"").Append(",\r\n");
            }

            if (Context != null)
            {
                Context.Level = level + 1; // To make the output correct
                sb.Append(tabs_lvl1)
                .Append("\"context\": ");
                sb.Append("\r\n").Append(Context.ToString()).Append(",\r\n");
            }

            sb.Append(tabs_lvl1)
            .Append("\"token\": ").Append("\"" + Token.Value + "\"").Append(",\r\n");
            sb.Append(tabs_lvl1)
            .Append("\"children\": [");

            if (Children.Count > 0)
            {
                foreach (ASTNode child in Children)
                {
                    sb.Append("\r\n").Append(child?.ToString()).Append(',');
                }
                sb.Remove(sb.Length - 1, 1); // Remove last ','
                sb.Append("\r\n");
                sb.Append(tabs_lvl1)
                .Append("]\r\n");
            }
            else
            {
                sb.Append("]\r\n");
            }

            sb.Append(tabs_lvl)
            .Append('}');

            return(sb.ToString());
        }