Example #1
0
        public static void Render(Graphics g, Image[] bigBlocks, Rectangle?visibleRect, BlockLayer[] layers, int scrNo, float CurScale, bool ShowBorder, bool showBlocksAxis, int LeftMargin, int TopMargin, int WIDTH, int HEIGHT)
        {
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.Half;

            bool verticalScreen = ConfigScript.getScreenVertical();
            int  SIZE           = WIDTH * HEIGHT;

            for (int layerIndex = 0; layerIndex < layers.Length; layerIndex++)
            {
                var  layer           = layers[layerIndex];
                bool needRenderLayer = layer != null && layer.screens != null && layer.screens[scrNo] != null && layer.showLayer;
                if (!needRenderLayer)
                {
                    continue;
                }

                int TILE_SIZE_X = (int)(layer.blockWidth * CurScale);
                int TILE_SIZE_Y = (int)(layer.blockHeight * CurScale);

                for (int i = 0; i < SIZE; i++)
                {
                    int       bigBlockNo = ConfigScript.getBigTileNoFromScreen(layer.screens[scrNo], i);
                    Rectangle tileRect;
                    if (verticalScreen)
                    {
                        tileRect = new Rectangle(i / WIDTH * TILE_SIZE_X + LeftMargin, (i % WIDTH) * TILE_SIZE_Y + TopMargin, TILE_SIZE_X, TILE_SIZE_Y);
                    }
                    else
                    {
                        tileRect = new Rectangle((i % WIDTH) * TILE_SIZE_X + LeftMargin, i / WIDTH * TILE_SIZE_Y + TopMargin, TILE_SIZE_X, TILE_SIZE_Y);
                    }

                    if (visibleRect == null || visibleRect.Value.Contains(tileRect) || visibleRect.Value.IntersectsWith(tileRect))
                    {
                        if (bigBlockNo > -1 && bigBlockNo < bigBlocks.Length)
                        {
                            g.DrawImage(bigBlocks[bigBlockNo], tileRect);
                            if (showBlocksAxis)
                            {
                                g.DrawRectangle(new Pen(Color.FromArgb(255, 255, 255, 255)), tileRect);
                            }
                        }
                        //else
                        //    g.FillRectangle(Brushes.White, tileRect);
                    }
                }
            }

            if (ShowBorder)
            {
                int TILE_SIZE_X = (int)(layers[0].blockWidth * CurScale);
                int TILE_SIZE_Y = (int)(layers[0].blockHeight * CurScale);
                if (verticalScreen)
                {
                    g.DrawRectangle(new Pen(Color.Green, 4.0f), new Rectangle(0, TILE_SIZE_Y, TILE_SIZE_X * HEIGHT, TILE_SIZE_Y * WIDTH));
                }
                else
                {
                    g.DrawRectangle(new Pen(Color.Green, 4.0f), new Rectangle(TILE_SIZE_X, 0, TILE_SIZE_X * WIDTH, TILE_SIZE_Y * HEIGHT));
                }
            }

            //Additional rendering  //float to int!
            ConfigScript.renderToMainScreen(g, (int)CurScale);
        }