Exemple #1
0
 private void fromMDPaletteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fd = new OpenFileDialog())
     {
         fd.DefaultExt       = "png";
         fd.Filter           = "Palette Files|*.bin";
         fd.RestoreDirectory = true;
         if (fd.ShowDialog(this) == DialogResult.OK)
         {
             byte[]  file   = File.ReadAllBytes(fd.FileName);
             Color[] colors = new Color[file.Length / 2];
             for (int i = 0; i < colors.Length; i++)
             {
                 colors[i] = Color.FromArgb(((file[(i * 2) + 1]) & 0xF) << 4, (file[(i * 2) + 1]) & 0xF0, ((file[i * 2]) & 0xF) << 4);
             }
             using (PaletteImportDialog pd = new PaletteImportDialog(colors))
                 if (pd.ShowDialog(this) == DialogResult.OK)
                 {
                     palette = pd.palette;
                     PalettePanel.Invalidate();
                     SpritePicture.Invalidate();
                     tileList1.Invalidate();
                     foreach (ToolStripMenuItem item in palettesToolStripMenuItem.DropDownItems)
                     {
                         item.Checked = false;
                     }
                 }
         }
     }
 }
Exemple #2
0
        private void palettesToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            int sel = palettesToolStripMenuItem.DropDownItems.IndexOf(e.ClickedItem);

            foreach (ToolStripMenuItem item in palettesToolStripMenuItem.DropDownItems)
            {
                item.Checked = false;
            }
            ((ToolStripMenuItem)e.ClickedItem).Checked = true;
            if (sel == 0)
            {
                Array.Copy(defaultpalette, palette, 256);
            }
            else
            {
                byte[]  file   = File.ReadAllBytes(palettes[sel - 1]);
                Color[] colors = new Color[file.Length / 4];
                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] = Color.FromArgb(file[i * 4], file[i * 4 + 1], file[i * 4 + 2]);
                }
                Array.Copy(colors, palette, colors.Length);
            }
            PalettePanel.Invalidate();
            SpritePicture.Invalidate();
            tileList1.Invalidate();
        }
Exemple #3
0
 private void fromPCPaletteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fd = new OpenFileDialog())
     {
         fd.DefaultExt       = "png";
         fd.Filter           = "Palette Files|*.bin;*.scdpal";
         fd.RestoreDirectory = true;
         if (fd.ShowDialog(this) == DialogResult.OK)
         {
             byte[]  file   = File.ReadAllBytes(fd.FileName);
             Color[] colors = new Color[file.Length / 4];
             for (int i = 0; i < colors.Length; i++)
             {
                 colors[i] = Color.FromArgb(file[i * 4], file[i * 4 + 1], file[i * 4 + 2]);
             }
             using (PaletteImportDialog pd = new PaletteImportDialog(colors))
                 if (pd.ShowDialog(this) == DialogResult.OK)
                 {
                     palette = pd.palette;
                     Array.Copy(palette, curpal * 16, palslice, 0, 16);
                     PalettePanel.Invalidate();
                     SpritePicture.Invalidate();
                     tileList1.Invalidate();
                     foreach (ToolStripMenuItem item in palettesToolStripMenuItem.DropDownItems)
                     {
                         item.Checked = false;
                     }
                 }
         }
     }
 }
Exemple #4
0
 private void fromImageToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fd = new OpenFileDialog())
     {
         fd.DefaultExt       = "png";
         fd.Filter           = "Image Files|*.bmp;*.png;*.jpg;*.gif";
         fd.RestoreDirectory = true;
         if (fd.ShowDialog(this) == DialogResult.OK)
         {
             Color[] colors;
             using (Bitmap bmp = new Bitmap(fd.FileName))
                 colors = bmp.Palette.Entries;
             using (PaletteImportDialog pd = new PaletteImportDialog(colors))
                 if (pd.ShowDialog(this) == DialogResult.OK)
                 {
                     palette = pd.palette;
                     PalettePanel.Invalidate();
                     SpritePicture.Invalidate();
                     tileList1.Invalidate();
                     foreach (ToolStripMenuItem item in palettesToolStripMenuItem.DropDownItems)
                     {
                         item.Checked = false;
                     }
                 }
         }
     }
 }
Exemple #5
0
 private void PalettePanel_MouseDown(object sender, MouseEventArgs e)
 {
     selectedColor = new Point(e.X / 32, e.Y / 32);
     PalettePanel.Invalidate();
     if (tileList1.SelectedIndex > -1)
     {
         sprites[tileList1.SelectedIndex].palette = (selectedColor.Y * 16) + selectedColor.X;
     }
     SpritePicture.Invalidate();
 }
Exemple #6
0
 private void PalettePanel_MouseDown(object sender, MouseEventArgs e)
 {
     selectedColor = new Point(e.X / 32, e.Y / 32);
     PalettePanel.Invalidate();
     curpal = selectedColor.Y;
     Array.Copy(palette, curpal * 16, palslice, 0, 16);
     tileList1.SelectedIndex = -1;
     tileList1.ChangeSize();
     tileList1.Invalidate();
 }
Exemple #7
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     curpal = 0;
     Array.Copy(palette, curpal * 16, palslice, 0, 16);
     for (int i = 0; i < 4; i++)
     {
         sprites[i] = new List <BitmapBits>();
     }
     tileList1.SelectedIndex = -1;
     tileList1.ChangeSize();
     tileList1.Invalidate();
     PalettePanel.Invalidate();
 }
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            int maxlen = (int)Math.Min(importColors.Length - numericUpDown1.Value, palette.Length - numericUpDown2.Value);

            if (numericUpDown3.Value > maxlen)
            {
                numericUpDown3.Maximum = maxlen;
                return;
            }
            numericUpDown3.Maximum = maxlen;
            palette = new Color[MainForm.palette.Length];
            Array.Copy(MainForm.palette, palette, palette.Length);
            Array.Copy(importColors, (int)numericUpDown1.Value, palette, (int)numericUpDown2.Value, (int)numericUpDown3.Value);
            PalettePanel.Invalidate();
        }
Exemple #9
0
 private void tileList1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tileList1.SelectedIndex != -1)
     {
         SpritePicture.Size   = new Size(sprites[tileList1.SelectedIndex].sprite.Width, sprites[tileList1.SelectedIndex].sprite.Height);
         selectedColor        = new Point(sprites[tileList1.SelectedIndex].palette % 16, sprites[tileList1.SelectedIndex].palette / 16);
         groupBox1.Enabled    = true;
         numericUpDown1.Value = sprites[tileList1.SelectedIndex].offset.X;
         numericUpDown2.Value = sprites[tileList1.SelectedIndex].offset.Y;
     }
     else
     {
         SpritePicture.Size = Size.Empty;
         selectedColor      = Point.Empty;
         groupBox1.Enabled  = false;
     }
     SpritePicture.Invalidate();
     PalettePanel.Invalidate();
 }
Exemple #10
0
        private void LoadFile(string filename)
        {
            byte[] file = SZDDComp.SZDDComp.Decompress(filename);
            if (BitConverter.ToInt32(file, 0) != 0x4C524353)
            {
                MessageBox.Show("Not a valid tile file.");
                return;
            }
            for (int i = 0; i < 4; i++)
            {
                sprites[i] = new List <BitmapBits>();
            }
            curpal = 0;
            Array.Copy(palette, curpal * 16, palslice, 0, 16);
            int numSprites = BitConverter.ToInt32(file, 8);
            int spriteOff  = BitConverter.ToInt32(file, 0xC);
            int p          = 0;
            int pn         = BitConverter.ToInt16(file, 0x10);

            for (int i = 0; i < numSprites; i++)
            {
                int    data   = (i * 4) + 0x18;
                int    width  = BitConverter.ToInt16(file, data);
                int    height = BitConverter.ToInt16(file, data + 2);
                byte[] sprite = new byte[(width / 2) * height];
                Array.Copy(file, spriteOff, sprite, 0, sprite.Length);
                spriteOff += sprite.Length;
                sprites[p].Add(new BitmapBits(width, height, sprite));
                pn--;
                if (--pn == 0)
                {
                    p++;
                    pn = BitConverter.ToInt16(file, 0x10 + (2 * p));
                }
            }
            tileList1.SelectedIndex = 0;
            tileList1.ChangeSize();
            tileList1.Invalidate();
            PalettePanel.Invalidate();
        }
Exemple #11
0
 private void PalettePanel_MouseDown(object sender, MouseEventArgs e)
 {
     selectedColor = new Point(e.X / 16, e.Y / 16);
     PalettePanel.Invalidate();
 }