Beispiel #1
0
        public ArrayList ImportObstructionTiles(Vsp24 vsp)
        {
            ArrayList tiles = new ArrayList();

            foreach (VspObstructionTile vt in vsp.ObstructionTiles)
            {
                VspObstructionTile vot = vt.Clone();
                vot.parent = this;
                tiles.Add(vot);
            }
            return(tiles);
        }
Beispiel #2
0
        public ArrayList AddBlankObstructionTiles(int count)
        {
            ArrayList tiles = new ArrayList();

            // add count blank tiles
            for (int i = 0; i < count; i++)
            {
                VspObstructionTile vt = new VspObstructionTile(this, new int[16 * 16]);
                tiles.Add(vt);
            }
            return(tiles);
        }
Beispiel #3
0
        public unsafe ArrayList ImportObstructionTiles(Bitmap bmp, int gridsize)
        {
            ArrayList  tiles = new ArrayList();
            BitmapData bd    = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            int *      ptr   = (int *)bd.Scan0;
            int        pitch = bd.Stride / sizeof(int *);

            int tw = (bmp.Width - gridsize) / (16 + gridsize);
            int th = (bmp.Height - gridsize) / (16 + gridsize);

            int xofs = 16 + gridsize;
            int yofs = 16 + gridsize;

            try {
                ptr += pitch * gridsize;

                int count = 0;

                for (int y = 0; y < th; y++)
                {
                    for (int x = 0; x < tw; x++)
                    {
                        int[] t = new int[16 * 16];
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                int c = ptr[gridsize + (x * xofs) + yy * pitch + xx];
                                if (nonZero(c))
                                {
                                    t[yy * 16 + xx] = c;
                                }
                            }
                        }
                        VspObstructionTile vt = new VspObstructionTile(this, t);
                        tiles.Add(vt);
                        count++;
                    }
                    ptr += yofs * pitch;
                }
                return(tiles);
            } finally {
                bmp.UnlockBits(bd);
            }
        }
Beispiel #4
0
        public VspObstructionTile Clone()
        {
            VspObstructionTile vot = new VspObstructionTile(parent, image.GetArray());

            return(vot);
        }
Beispiel #5
0
 public VspObstructionTile Clone()
 {
     VspObstructionTile vot = new VspObstructionTile(parent, image.GetArray());
     return vot;
 }
Beispiel #6
0
        public unsafe ArrayList ImportObstructionTiles(Bitmap bmp, int gridsize)
        {
            ArrayList tiles = new ArrayList();
            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            int* ptr = (int*)bd.Scan0;
            int pitch = bd.Stride / sizeof(int*);

            int tw = (bmp.Width - gridsize) / (16 + gridsize);
            int th = (bmp.Height - gridsize) / (16 + gridsize);

            int xofs = 16 + gridsize;
            int yofs = 16 + gridsize;

            try {
                ptr += pitch * gridsize;

                int count = 0;

                for (int y = 0; y < th; y++) {
                    for (int x = 0; x < tw; x++) {
                        int[] t = new int[16 * 16];
                        for (int yy = 0; yy < 16; yy++)
                            for (int xx = 0; xx < 16; xx++) {
                                int c = ptr[gridsize + (x * xofs) + yy * pitch + xx];
                                if (nonZero(c))
                                    t[yy * 16 + xx] = c;
                            }
                        VspObstructionTile vt = new VspObstructionTile(this, t);
                        tiles.Add(vt);
                        count++;
                    }
                    ptr += yofs * pitch;
                }
                return tiles;
            } finally {
                bmp.UnlockBits(bd);
            }
        }
Beispiel #7
0
 public ArrayList AddBlankObstructionTiles(int count)
 {
     ArrayList tiles = new ArrayList();
     // add count blank tiles
     for (int i = 0; i < count; i++) {
         VspObstructionTile vt = new VspObstructionTile(this, new int[16 * 16]);
         tiles.Add(vt);
     }
     return tiles;
 }
Beispiel #8
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();
        }