コード例 #1
0
        private void Flip(string type)
        {
            if (draggedTiles != null)
            {
                Defloat(draggedTiles);
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int        x_     = overlay.SelectTS.Location.X / 16;
            int        y_     = overlay.SelectTS.Location.Y / 16;
            CopyBuffer buffer = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);

            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tilesets_tiles[Layer][(y + y_) * 16 + x + x_].Copy();
                }
            }
            if (type == "mirror")
            {
                Do.FlipHorizontal(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            else if (type == "invert")
            {
                Do.FlipVertical(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            buffer.Tiles = copiedTiles;
            Defloat(buffer);
        }
コード例 #2
0
 /// <summary>
 /// Returns an array of RGB pixel data of this mold's tilemap
 /// using the specified tileset and animation data.
 /// </summary>
 /// <param name="animation">The effect animation containing the data needed for this operation.</param>
 /// <param name="tileset">The tileset containing the tiles to draw the tilemap with.</param>
 /// <returns></returns>
 public int[] GetPixels(Animation animation, Tileset tileset)
 {
     int[] pixels = new int[(animation.Width * 16) * (animation.Height * 16)];
     for (int y = 0; y < animation.Height; y++)
     {
         for (int x = 0; x < animation.Width; x++)
         {
             if (y * animation.Width + x >= Tiles.Length)
             {
                 continue;
             }
             if (Tiles[y * animation.Width + x] == 0xFF)
             {
                 continue;
             }
             int[] tile = new int[16 * 16];
             ((Tile)tileset.Tiles[Tiles[y * animation.Width + x] & 0x3F]).Pixels.CopyTo(tile, 0);
             if ((Tiles[y * animation.Width + x] & 0x40) == 0x40)
             {
                 Do.FlipHorizontal(tile, 16, 16);
             }
             if ((Tiles[y * animation.Width + x] & 0x80) == 0x80)
             {
                 Do.FlipVertical(tile, 16, 16);
             }
             Do.PixelsToPixels(tile, pixels, animation.Width * 16, new Rectangle(x * 16, y * 16, 16, 16));
         }
     }
     return(pixels);
 }
コード例 #3
0
        private void ImportTilemap(byte[] array, int layer, int offset)
        {
            if (!checkBox4.Checked || tilemap.Tilemaps_Tiles[layer] == null)
            {
                return;
            }
            int  counter = 0;
            int  extratiles = 256;
            bool mirror, invert;

            for (int i = 0; i < tilemap.Tilemaps_Tiles[layer].Length; i++)
            {
                int tile = Bits.GetShort(array, offset) & 0x1FF;
                mirror = Bits.GetBit(array, offset + 1, 6);
                invert = Bits.GetBit(array, offset + 1, 7);
                tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][tile];
                if (layer != 2)
                {
                    Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter, tile);
                    counter += 2; offset += 2;
                }
                else
                {
                    tilemap.Tilemaps_Bytes[layer][counter] = (byte)tile;
                    counter++; offset += 2;
                }
                if (tileset.Tilesets_tiles[layer] == null || tileset.Tilesets_tiles[layer].Length != 512)
                {
                    continue;
                }
                if (mirror || invert)
                {
                    Tile copy = tileset.Tilesets_tiles[layer][tile].Copy();
                    if (mirror)
                    {
                        Do.FlipHorizontal(copy);
                    }
                    if (invert)
                    {
                        Do.FlipVertical(copy);
                    }
                    Tile contains = Do.Contains(tileset.Tilesets_tiles[layer], copy);
                    if (contains == null)
                    {
                        tileset.Tilesets_tiles[layer][extratiles]       = copy;
                        tileset.Tilesets_tiles[layer][extratiles].Index = extratiles;
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][extratiles];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, extratiles);
                        extratiles++;
                    }
                    else
                    {
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][contains.Index];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, contains.Index);
                    }
                }
            }
        }
コード例 #4
0
 private void buttonMirrorTile_Click(object sender, EventArgs e)
 {
     Do.FlipHorizontal(tile);
     InitializeSubtile();
     SetTileImage();
     SetSubtileImage();
     if (autoUpdate.Checked)
     {
         update.DynamicInvoke();
     }
 }
コード例 #5
0
ファイル: MoldsForm.cs プロジェクト: jpmac26/LazyShell
        /// <summary>
        /// Flips the mold selection vertically or horizontally.
        /// </summary>
        /// <param name="flipType">The direction to flip the mold selection.</param>
        private void Flip(FlipType flipType)
        {
            if (overlay.Select.Empty)
            {
                return;
            }
            if (tileset.Tiles == null || overlay.Select.Size == new Size(0, 0))
            {
                return;
            }
            Point location = overlay.Select.Location;
            Point terminal = overlay.Select.Terminal;

            byte[] flippedTiles = new byte[(overlay.Select.Width / 16) * (overlay.Select.Height / 16)];
            for (int y = 0, y_ = overlay.Select.Y / 16; y < overlay.Select.Height / 16; y++, y_++)
            {
                for (int x = 0, x_ = overlay.Select.X / 16; x < overlay.Select.Width / 16; x++, x_++)
                {
                    flippedTiles[y * (overlay.Select.Width / 16) + x] = mold.Tiles[y_ * (width / 16) + x_];
                    if (flipType == FlipType.Horizontal && flippedTiles[y * (overlay.Select.Width / 16) + x] != 0xFF)
                    {
                        flippedTiles[y * (overlay.Select.Width / 16) + x] ^= 0x40;
                    }
                    if (flipType == FlipType.Vertical && flippedTiles[y * (overlay.Select.Width / 16) + x] != 0xFF)
                    {
                        flippedTiles[y * (overlay.Select.Width / 16) + x] ^= 0x80;
                    }
                }
            }
            if (flipType == FlipType.Horizontal)
            {
                Do.FlipHorizontal(flippedTiles, overlay.Select.Width / 16, overlay.Select.Height / 16);
            }
            if (flipType == FlipType.Vertical)
            {
                Do.FlipVertical(flippedTiles, overlay.Select.Width / 16, overlay.Select.Height / 16);
            }
            commandStack.Push(new MoldEdit(
                                  mold.Tiles, width / 16, height / 16, flippedTiles,
                                  overlay.Select.X / 16, overlay.Select.Y / 16, overlay.Select.Width / 16, overlay.Select.Height / 16));
            commandStack.Push(1);
            SetTilemapImage();
            if (sequencesForm != null)
            {
                sequencesForm.SetFrameImages();
                sequencesForm.RealignFrames();
            }
            animation.WriteToBuffer();
        }
コード例 #6
0
        /// <summary>
        /// Flips the mold selection vertically or horizontally.
        /// </summary>
        /// <param name="type">Either "mirror" or "invert".</param>
        private void Flip(string type)
        {
            if (overlay.Select.Empty)
            {
                return;
            }
            if (tileset.Tileset == null || overlay.Select.Size == new Size(0, 0))
            {
                return;
            }
            Point location = overlay.Select.Location;
            Point terminal = overlay.Select.Terminal;

            byte[] flippedTiles = new byte[(overlay.Select.Width / 16) * (overlay.Select.Height / 16)];
            for (int y = 0, y_ = overlay.Select.Y / 16; y < overlay.Select.Height / 16; y++, y_++)
            {
                for (int x = 0, x_ = overlay.Select.X / 16; x < overlay.Select.Width / 16; x++, x_++)
                {
                    flippedTiles[y * (overlay.Select.Width / 16) + x] = mold.Mold[y_ * (width / 16) + x_];
                    if (type == "mirror" && flippedTiles[y * (overlay.Select.Width / 16) + x] != 0xFF)
                    {
                        flippedTiles[y * (overlay.Select.Width / 16) + x] ^= 0x40;
                    }
                    if (type == "invert" && flippedTiles[y * (overlay.Select.Width / 16) + x] != 0xFF)
                    {
                        flippedTiles[y * (overlay.Select.Width / 16) + x] ^= 0x80;
                    }
                }
            }
            if (type == "mirror")
            {
                Do.FlipHorizontal(flippedTiles, overlay.Select.Width / 16, overlay.Select.Height / 16);
            }
            if (type == "invert")
            {
                Do.FlipVertical(flippedTiles, overlay.Select.Width / 16, overlay.Select.Height / 16);
            }
            commandStack.Push(new TilemapCommand(
                                  mold.Mold, width / 16, height / 16, flippedTiles,
                                  overlay.Select.X / 16, overlay.Select.Y / 16, overlay.Select.Width / 16, overlay.Select.Height / 16));
            commandStack.Push(1);
            SetTilemapImage();
            if (sequences != null)
            {
                sequences.SetSequenceFrameImages();
                sequences.RealignFrames();
            }
            animation.Assemble();
        }
コード例 #7
0
ファイル: Mold.cs プロジェクト: jpmac26/LazyShell
            public int[] GetGridplanePixels()
            {
                int[] pixels = new int[32 * 32];
                if (Subtile_tiles == null)
                {
                    return(pixels);
                }
                //
                int w; int h;
                int r; int c;

                switch (Format)
                {
                case 0: w = h = 24; break;

                case 1: w = 24; h = 32; break;

                case 2: w = 32; h = 24; break;

                case 3: w = 32; h = 32; break;

                default: goto case 0;
                }
                for (int i = 0; i < ((h / 8) * (w / 8)); i++)
                {
                    r = (i / (w / 8)) * 8; c = (i % (w / 8)) * 8;
                    for (int y = 0; y < 8; y++)
                    {
                        if (Subtile_tiles[i] == null)
                        {
                            break;
                        }
                        for (int x = 0; x < 8; x++)
                        {
                            pixels[x + c + ((y + r) * 32)] = Subtile_tiles[i].Pixels[y * 8 + x];
                        }
                    }
                }
                if (Mirror)
                {
                    Do.FlipHorizontal(pixels, 32, 0, 0, w, h);
                }
                if (Invert)
                {
                    Do.FlipVertical(pixels, 32, 0, 0, w, h);
                }
                return(pixels);
            }
コード例 #8
0
ファイル: Mold.cs プロジェクト: jpmac26/LazyShell
            // RGB pixel retrieval
            public int[] Get16x16TilePixels()
            {
                int[] pixels = new int[16 * 16];
                int   color  = 0;

                if (Subtile_tiles == null)
                {
                    color = Color.Red.ToArgb();
                }
                if (Bits.Empty(Subtile_bytes))
                {
                    color = Color.Gray.ToArgb();
                }
                if (Subtile_tiles == null || Bits.Empty(Subtile_bytes))
                {
                    for (int i = 0; i < 16; i++)
                    {
                        pixels[i * 16 + i]      = color; // UL to LR
                        pixels[i * 16 + 15 - i] = color; // UR to LL
                        pixels[i]           = color;     // top line
                        pixels[i * 16]      = color;     // left line
                        pixels[i * 16 + 15] = color;     // right line
                        pixels[15 * 16 + i] = color;     // bottom line
                    }
                    return(pixels);
                }
                for (int i = 0, a = 0, b = 0; i < 4; i++)
                {
                    a = (i == 0) || (i == 2) ? 0 : 8;
                    b = (i == 0) || (i == 1) ? 0 : 8;
                    for (int y = 0; y < 8; y++)
                    {
                        for (int x = 0; x < 8; x++)
                        {
                            pixels[x + a + ((y + b) * 16)] = Subtile_tiles[i].Pixels[y * 8 + x];
                        }
                    }
                }
                if (Mirror)
                {
                    Do.FlipHorizontal(pixels, 16, 16);
                }
                if (Invert)
                {
                    Do.FlipVertical(pixels, 16, 16);
                }
                return(pixels);
            }
コード例 #9
0
        private void Flip(string type)
        {
            if (draggedTiles != null)
            {
                Defloat(draggedTiles);
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int        x_     = overlay.SelectTS.Location.X / 16;
            int        y_     = overlay.SelectTS.Location.Y / 16;
            CopyBuffer buffer = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);

            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    int x__   = (x + x_) & 15;
                    int y__   = (y + y_) & 15;
                    int index = y__ * 16 + x__;
                    index += ((x + x_) >> 4) * 256;
                    index += ((y + y_) >> 4) * 512;
                    if (index >= tileset.Tileset_tiles.Length)
                    {
                        continue;
                    }
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tileset_tiles[index].Copy();
                }
            }
            if (type == "mirror")
            {
                Do.FlipHorizontal(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            else if (type == "invert")
            {
                Do.FlipVertical(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            buffer.Tiles = copiedTiles;
            Defloat(buffer);
            tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes);
            SetBattlefieldImage();
        }
コード例 #10
0
ファイル: WorldMapsForm.cs プロジェクト: jpmac26/LazyShell
        private void Flip(FlipType flipType)
        {
            if (draggedTiles != null)
            {
                Defloat(draggedTiles);
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int        x_     = overlay.SelectTS.Location.X / 16;
            int        y_     = overlay.SelectTS.Location.Y / 16;
            CopyBuffer buffer = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);

            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        Tileset.Tileset_tiles[(y + y_) * 16 + x + x_].Copy();
                }
            }
            if (flipType == FlipType.Horizontal)
            {
                Do.FlipHorizontal(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            else if (flipType == FlipType.Vertical)
            {
                Do.FlipVertical(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            buffer.Tiles = copiedTiles;
            Defloat(buffer);
            Tileset.ParseTileset(Tileset.Tileset_tiles, Tileset.Tileset_bytes);
            SetWorldMapImage();
        }
コード例 #11
0
 // constructors
 public Subtile(int index, byte[] graphics, int offset, int[] palette,
                bool mirror, bool invert, bool priority1, bool twobpp)
 {
     this.mirror    = mirror;
     this.invert    = invert;
     this.priority1 = priority1;
     this.index     = index;
     this.twobpp    = twobpp;
     if (twobpp == false)
     {
         for (int r = 0; r < 8; r++) // Number of Rows in an 8x8 Tile
         {
             // Get all the pixels in a row
             byte[] row = new byte[8];
             for (int i = 7, b = 1; i >= 0; i--, b *= 2)
             {
                 if ((graphics[offset + r * 2 + 0x11] & b) == b)
                 {
                     row[i] += 8;
                 }
             }
             for (int i = 7, b = 1; i >= 0; i--, b *= 2)
             {
                 if ((graphics[offset + r * 2 + 0x10] & b) == b)
                 {
                     row[i] += 4;
                 }
             }
             for (int i = 7, b = 1; i >= 0; i--, b *= 2)
             {
                 if ((graphics[offset + r * 2 + 1] & b) == b)
                 {
                     row[i] += 2;
                 }
             }
             for (int i = 7, b = 1; i >= 0; i--, b *= 2)
             {
                 if ((graphics[offset + r * 2] & b) == b)
                 {
                     row[i]++;
                 }
             }
             for (int c = 0; c < 8; c++) // Number of Columns in an 8x8 Tile
             {
                 colors[r * 8 + c] = row[c];
                 if (row[c] != 0)
                 {
                     pixels[r * 8 + c] = palette[row[c]]; // Set pixel in 8x8 tile
                 }
             }
         }
     }
     else
     {
         byte  b1, b2, t1, t2, col = 0;
         int[] pal = new int[4];
         for (int i = 0; i < 4; i++)
         {
             pal[i] = palette[i];
         }
         for (byte i = 0; i < 8; i++)
         {
             b1 = graphics[offset];
             b2 = graphics[offset + 1];
             for (byte z = 7; col < 8; z--)
             {
                 t1 = (byte)((b1 >> z) & 1);
                 t2 = (byte)((b2 >> z) & 1);
                 colors[(i * 8) + col] = (t2 * 2) + t1;
                 if ((t2 * 2) + t1 != 0)
                 {
                     pixels[(i * 8) + col] = pal[(t2 * 2) + t1];
                 }
                 col++;
             }
             col     = 0;
             offset += 2;
         }
     }
     if (mirror)
     {
         Do.FlipHorizontal(pixels, 8, 8);
     }
     if (invert)
     {
         Do.FlipVertical(pixels, 8, 8);
     }
 }