Пример #1
0
        public static Vsp24 FromVsp8(Vsp8 src)
        {
            Vsp24 v24 = new Vsp24();
            foreach (Vsp8Tile v8t in src.Tiles)
            {
                int[] data = new int[256];
                for (int y = 0; y < Global.TILE_SIZE; y++)
                {
                    for (int x = 0; x < Global.TILE_SIZE; x++)
                    {
                        if (v8t.Pixels[y * Global.TILE_SIZE + x] > 0)
                        {
                            data[y * Global.TILE_SIZE + x] = v8t.parent.Palette[v8t.Pixels[y * Global.TILE_SIZE + x]].IntColor;
                        }
                        else
                        {
                            unchecked
                            {
                                data[y * Global.TILE_SIZE + x] = ((int)0xFFFF00FF);
                            }
                        }
                    }
                }

                Vsp24Tile v24t = new Vsp24Tile(v24, new pr2.BufferImage(Global.TILE_SIZE, Global.TILE_SIZE, data));
                v24.Tiles.Add(v24t);
            }
            v24.FileOnDisk = src.FileOnDisk;
            v24.Animations = src.Animations;
            return v24;
        }
Пример #2
0
        public static Vsp24 FromVsp8(Vsp8 src)
        {
            Vsp24 v24 = new Vsp24();

            foreach (Vsp8Tile v8t in src.Tiles)
            {
                int[] data = new int[256];
                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        if (v8t.Pixels[y * 16 + x] > 0)
                        {
                            data[y * 16 + x] = v8t.parent.Palette[v8t.Pixels[y * 16 + x]].IntColor;
                        }
                        else
                        {
                            unchecked {
                                data[y * 16 + x] = ((int)0xFFFF00FF);
                            }
                        }
                    }
                }

                Vsp24Tile v24t = new Vsp24Tile(v24, new pr2.BufferImage(16, 16, data));
                v24.Tiles.Add(v24t);
            }
            v24.FileOnDisk = src.FileOnDisk;
            v24.Animations = src.Animations;
            return(v24);
        }
Пример #3
0
        public ArrayList GetTiles(Vsp24 vsp)
        {
            ArrayList tiles = new ArrayList();

            foreach (Vsp24Tile vt in vsp.Tiles)
            {
                Vsp24Tile vtt = vt.Clone();
                vtt.parent = this;
                tiles.Add(vtt);
            }
            return(tiles);
        }
Пример #4
0
        public ArrayList GetTiles(int count)
        {
            // add count blank tiles
            ArrayList tiles = new ArrayList();

            for (int i = 0; i < count; i++)
            {
                Vsp24Tile vt = new Vsp24Tile(this);
                tiles.Add(vt);
            }
            return(tiles);
        }
Пример #5
0
        private void n_end_ValueChanged(object sender, System.EventArgs e)
        {
            if (n_end.Value != vspc.VspView.SelectedTileB)
            {
                vspc.VspView.SelectedTileB = (int)n_end.Value;
            }
            int t = (int)n_end.Value;

            if (t >= currVsp.tileCount)
            {
                return;
            }
            Vsp24Tile vt = (Vsp24Tile)currVsp.Tiles[t];

            tv_end.ActiveTile = vt;
        }
Пример #6
0
        private void n_start_ValueChanged(object sender, System.EventArgs e)
        {
            if (n_start.Value != vspc.VspView.SelectedTileF)
            {
                vspc.VspView.SelectedTileF = (int)n_start.Value;
            }
            int t = (int)n_start.Value;

            if (t >= currVsp.tileCount)
            {
                return;
            }
            Vsp24Tile vt = (Vsp24Tile)currVsp.Tiles[t];

            tv_start.ActiveTile        = vt;
            tv_preview.ActiveTileIndex = (int)n_start.Value;
        }
Пример #7
0
        public unsafe ArrayList ImportTiles(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, th;

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

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

                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++)
                            {
                                t[yy * 16 + xx] = ptr[gridsize + (x * xofs) + yy * pitch + xx];
                            }
                        }
                        Vsp24Tile vt = new Vsp24Tile(this, new pr2.BufferImage(16, 16, t));
                        tiles.Add(vt);
                        count++;
                    }
                    ptr += yofs * pitch;
                }
                return(tiles);
            } finally {
                bmp.UnlockBits(bd);
            }
        }
Пример #8
0
        public Vsp24Tile Clone()
        {
            Vsp24Tile vt = new Vsp24Tile(parent, image.Clone());

            return(vt);
        }
Пример #9
0
 public Vsp24Tile Clone()
 {
     Vsp24Tile vt = new Vsp24Tile(parent, image.Clone());
     return vt;
 }
Пример #10
0
        public unsafe ArrayList ImportTiles(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, th;

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

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

                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++) {
                                t[yy * 16 + xx] = ptr[gridsize + (x * xofs) + yy * pitch + xx];
                            }
                        }
                        Vsp24Tile vt = new Vsp24Tile(this, new pr2.BufferImage(16, 16, t));
                        tiles.Add(vt);
                        count++;
                    }
                    ptr += yofs * pitch;
                }
                return tiles;

            } finally {
                bmp.UnlockBits(bd);
            }
        }
Пример #11
0
 public ArrayList GetTiles(int count)
 {
     // add count blank tiles
     ArrayList tiles = new ArrayList();
     for (int i = 0; i < count; i++) {
         Vsp24Tile vt = new Vsp24Tile(this);
         tiles.Add(vt);
     }
     return tiles;
 }
Пример #12
0
        public unsafe ArrayList ImportTiles(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, th;

            try
            {
                tw = (bmp.Width - gridsize) / (Global.TILE_SIZE + gridsize);
                th = (bmp.Height - gridsize) / (Global.TILE_SIZE + gridsize);

                //zero 30-jan-2013 - it doesnt make sense to import art of the wrong width for the tile bank
                tw = Global.VSP_SIZE_TILES;

                int xofs = Global.TILE_SIZE + gridsize;
                int yofs = Global.TILE_SIZE + gridsize;

                ptr += pitch * gridsize;

                int count = 0;

                for (int y = 0; y < th; y++)
                {
                    for (int x = 0; x < tw; x++)
                    {
                        int[] t = new int[Global.TILE_SIZE * Global.TILE_SIZE];
                        for (int yy = 0; yy < Global.TILE_SIZE; yy++)
                        {
                            for (int xx = 0; xx < Global.TILE_SIZE; xx++)
                            {
                                t[yy * Global.TILE_SIZE + xx] = ptr[gridsize + (x * xofs) + yy * pitch + xx];
                            }
                        }
                        Vsp24Tile vt = new Vsp24Tile(this, new pr2.BufferImage(Global.TILE_SIZE, Global.TILE_SIZE, t));
                        tiles.Add(vt);
                        count++;
                    }
                    ptr += yofs * pitch;
                }
                return tiles;

            }
            finally
            {
                bmp.UnlockBits(bd);
            }
        }
Пример #13
0
        private void activateMouse(MouseEventArgs e)
        {
            int mx = e.X, my = e.Y;

            if (mx < 0)
            {
                mx = 0;
            }
            if (mx >= Width)
            {
                mx = Width - 1;
            }
            if (my < 0)
            {
                my = 0;
            }
            if (my >= Height)
            {
                my = Height - 1;
            }

            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                if (ControllerType == VSPController.ControllerType.VSP)
                {
                    int tile = ((scrollOffset / 16) + (my / 16)) * TilesWide + (mx / 16);
                    if (tile >= vsp.tileCount)
                    {
                        return;
                    }
                    Vsp24Tile vtile = (Vsp24Tile)vsp.Tiles[tile];
                    if (e.Button == MouseButtons.Left)
                    {
                        if (viewer_a != null)
                        {
                            viewer_a.ActiveTile = vtile;
                        }
                        st0 = tile;
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (viewer_b != null)
                        {
                            viewer_b.ActiveTile = vtile;
                        }
                        st1 = tile;
                    }
                }
                else if (ControllerType == VSPController.ControllerType.Obstruction)
                {
                    int tile = ((scrollOffset / 16) + (my / 16)) * TilesWide + (mx / 16);
                    if (tile >= vsp.ObstructionTiles.Count)
                    {
                        return;
                    }
                    if (e.Button == MouseButtons.Left)
                    {
                        st0 = tile;
                        if (viewer_a != null)
                        {
                            viewer_a.ActiveObsTile = (VspObstructionTile)vsp.ObstructionTiles[tile];
                        }
                    }
                    if (e.Button == MouseButtons.Right)
                    {
                        st1 = tile;
                    }
                }
                if (SelectionChanged != null)
                {
                    SelectionChanged();
                }
                Invalidate();
            }
        }