예제 #1
0
        private void editZone_Paint(object sender, PaintEventArgs e)
        {
            if (tls == null)
            {
                return;
            }
            if (obj == null)
            {
                return;
            }

            Graphics g = e.Graphics;

            g.FillRectangle(Brushes.LightSteelBlue, 0, 0, editZone.Width, editZone.Height);

            int x = 16;
            int y = 0;

            foreach (List <NSMBTileset.ObjectDefTile> row in obj.tiles)
            {
                foreach (NSMBTileset.ObjectDefTile t in row)
                {
                    if (t.controlTile)
                    {
                        g.FillRectangle(Brushes.White, x, y, 15, 15);
                        g.DrawRectangle(Pens.Black, x, y, 15, 15);
                        g.DrawString(String.Format("{0:X2}", t.controlByte), NSMBGraphics.InfoFont, Brushes.Black, x, y);
                    }
                    else if (!t.emptyTile)
                    {
                        g.DrawImage(tls.Map16Buffer, x, y, Image2D.getTileRectangle(tls.Map16Buffer, 16, t.tileID), GraphicsUnit.Pixel);
                        if ((t.controlByte & 1) != 0)
                        {
                            g.DrawRectangle(Pens.Red, x, y, 15, 15);
                        }
                        if ((t.controlByte & 2) != 0)
                        {
                            g.DrawRectangle(Pens.Blue, x + 1, y + 1, 13, 13);
                        }
                    }
                    if (t == selTile)
                    {
                        g.DrawRectangle(Pens.White, x, y, 15, 15);
                    }
                    x += 16;
                }
                g.DrawString((y / 16) + "", NSMBGraphics.InfoFont, Brushes.White, 0, y);
                if (selRow == row && selTile == null)
                {
                    g.DrawRectangle(Pens.White, 0, y, 15, 15);
                }

                x  = 16;
                y += 16;
            }
        }
예제 #2
0
        public Bitmap reRender(int xMin, int yMin, int width, int height)
        {
            for (int x = xMin; x < xMin + width; x++)
            {
                for (int y = yMin; y < yMin + height; y++)
                {
                    if (x >= this.width)
                    {
                        continue;
                    }
                    if (y >= this.height)
                    {
                        continue;
                    }
                    Tile t = tiles[x, y];

                    if (t.tileNum < 0 || t.tileNum >= tileCount)
                    {
                        bufferGx.FillRectangle(Brushes.Transparent, x * 8, y * 8, 8, 8);
                        continue;
                    }
                    if (t.palNum >= palettes.Length)
                    {
                        continue;
                    }
                    if (t.palNum < 0)
                    {
                        continue;
                    }
//                    if (t.hflip == false && t.vflip == false)

                    Rectangle rect = Image2D.getTileRectangle(buffers[t.palNum], 8, t.tileNum);
                    Bitmap    tile = new Bitmap(8, 8, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                    Graphics  g    = Graphics.FromImage(tile);
                    g.DrawImage(buffers[t.palNum], new Rectangle(0, 0, 8, 8), rect, GraphicsUnit.Pixel);
                    if (t.hflip == true && t.vflip == false)
                    {
                        tile.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    }
                    else if (t.hflip == false && t.vflip == true)
                    {
                        tile.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }
                    else if (t.hflip == true && t.vflip == true)
                    {
                        tile.RotateFlip(RotateFlipType.RotateNoneFlipXY);
                    }

                    bufferGx.DrawImage(tile, new Rectangle(x * 8, y * 8, 8, 8), new Rectangle(0, 0, 8, 8), GraphicsUnit.Pixel);
                }
            }
            return(buffer);
        }