renderObsTile() public static method

public static renderObsTile ( pr2 img, int x0, int y0, pr2 src, bool clearbuf, int color ) : void
img pr2
x0 int
y0 int
src pr2
clearbuf bool
color int
return void
Example #1
0
        private void renderObstructionLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;



            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = mapLayer.Width;
            int layerHeight = mapLayer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = mapLayer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count)
                        {
                            Render.renderObsTile(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false, Preferences.Current.ObsColor);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count)
                        {
                            Render.renderObsTileFast(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false);
                        }
                    }
                }
            }
        }
Example #2
0
        private unsafe void paint(Graphics g)
        {
            const int BLACK = unchecked ((int)0xFF000000);

            g.PixelOffsetMode   = PixelOffsetMode.Half;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            Bitmap bmp = Render.createBitmap(16, 16);

            using (pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp)) {
                if (TileSourceType == SourceType.Vsp)
                {
                    if (active_tile != null)
                    {
                        if (!bAnimate)
                        {
                            Render.render(img, 0, 0, active_tile.Image, true);
                        }
                        else
                        {
                            int frame = Global.FrameCalc.getframe(atx);
                            Render.render(img, 0, 0, Global.ActiveMap.vsp.GetTile(frame).Image, true);
                        }
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
                else
                {
                    if (active_obstile != null)
                    {
                        Render.renderObsTile(img, 0, 0, active_obstile.Image, true, Preferences.Current.ObsColor);
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
            }
            g.DrawImage(bmp, 0, 0, Width, Height);
            bmp.Dispose();
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vsp == null)
            {
                return;
            }

            const int WHITE = unchecked ((int)0xFFFFFFFF);

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            CalculateScrollValues();

            Bitmap bmp = new Bitmap(TilesWide * 16, TilesHigh * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp)) {
                if (ControllerType == VSPController.ControllerType.VSP)
                {
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.Tiles.Count; i++)
                    {
                        Render.render(qimg, col * 16, row * 16, vsp.GetTile(i).Image, true);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        if (i == st1)
                        {
                            if (controller_mode == VSPController.ControllerMode.SelectorDual)
                            {
                                Render.renderBox(qimg, col * 16 + 2, row * 16 + 2, 12, 12, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 3, row * 16 + 3, 10, 10, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
                else if (ControllerType == VSPController.ControllerType.Obstruction)
                {
                    // render obs tiles
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.ObstructionTiles.Count; i++)
                    {
                        VspObstructionTile vot = ((VspObstructionTile)vsp.ObstructionTiles[i]);
                        Render.renderObsTile(qimg, col * 16, row * 16, vot.Image, true, Preferences.Current.ObsColor);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            e.Graphics.DrawImage(bmp, 0, 0, Size.Width, Size.Height);
            bmp.Dispose();
        }