GetTile() public method

public GetTile ( int i ) : Vsp24Tile
i int
return Vsp24Tile
Beispiel #1
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();
        }
Beispiel #2
0
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            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 = layer.Width;
            int layerHeight = layer.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 = layer.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 (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            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 (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            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  = layer.Width;
            int layerHeight = layer.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 = layer.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 (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if ((drawZero || tile != 0) && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            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 (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }