Ejemplo n.º 1
0
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.toolBox1.SelectedTab == null || this.toolBox1.SelectedTab.SelectedItem == null ||
                !(this.toolBox1.SelectedTab.SelectedItem.Object is Sprite))
            {
                return;
            }
            Sprite sprite     = (Sprite)this.toolBox1.SelectedTab.SelectedItem.Object;
            Regex  rgx        = new Regex("[^a-zA-Z0-9]");
            string spriteName = rgx.Replace(Path.GetFileNameWithoutExtension(sprite.Path), String.Empty);

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.FileName = String.Format("Sprite{0}.h", spriteName);
                dlg.Filter   = "C header file|*.h";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(dlg.FileName, SegaSaturnConverter.ToSourceFile(new SegaSaturnTexture
                    {
                        Image = sprite.Img,
                        Name  = spriteName
                    }, true));
                    MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 2
0
        private void exportAsRaw15BitsImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.toolBox1.SelectedTab == null || this.toolBox1.SelectedTab.SelectedItem == null ||
                !(this.toolBox1.SelectedTab.SelectedItem.Object is Sprite))
            {
                return;
            }
            Sprite sprite     = (Sprite)this.toolBox1.SelectedTab.SelectedItem.Object;
            Regex  rgx        = new Regex("[^a-zA-Z0-9]");
            string spriteName = rgx.Replace(Path.GetFileNameWithoutExtension(sprite.Path), String.Empty).ToUpper();

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.FileName   = String.Format("{0}.RAW", spriteName);
                dlg.DefaultExt = ".RAW";
                dlg.Filter     = "15 bits raw image|*.RAW";
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                using (Bitmap bitmap = new Bitmap(sprite.Img))
                {
                    using (FileStream stream = new FileStream(dlg.FileName, FileMode.Create))
                    {
                        SegaSaturnConverter.ToBinFile(new SegaSaturnTexture
                        {
                            Image = bitmap
                        }, stream, false);
                    }
                }
                MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        public void ExportAsBin(bool onlySelected = false)
        {
            if (this.Empty)
            {
                return;
            }
            Regex  rgx        = new Regex("[^a-zA-Z0-9]");
            string spriteName = rgx.Replace(Path.GetFileNameWithoutExtension(this.Text), String.Empty).ToUpper();

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.FileName = String.Format("{0}.BIN", spriteName);
                dlg.Filter   = "Jo Engine binary file|*.BIN";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    using (Bitmap bitmap = this.GetBitmap(onlySelected))
                    {
                        using (FileStream stream = new FileStream(dlg.FileName, FileMode.Create))
                        {
                            SegaSaturnConverter.ToBinFile(new SegaSaturnTexture
                            {
                                Image = bitmap
                            }, stream, true);
                        }
                    }
                    MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 4
0
        public void ExportAsSegaSaturnGraphic(bool onlySelected = false)
        {
            if (this.Empty)
            {
                return;
            }
            Regex  rgx        = new Regex("[^a-zA-Z0-9]");
            string spriteName = rgx.Replace(Path.GetFileNameWithoutExtension(this.Text), String.Empty);

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.FileName = String.Format("SegaSaturnGraphic{0}.h", spriteName);
                dlg.Filter   = "C header file|*.h";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    using (Bitmap bitmap = this.GetBitmap(onlySelected))
                    {
                        File.WriteAllText(dlg.FileName, SegaSaturnConverter.ToSourceFile(new SegaSaturnGraphic
                        {
                            Image = bitmap,
                            Name  = spriteName
                        }, true));
                    }
                    MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 5
0
        public void ExportAsJoImageTileset(bool onlySelected = false)
        {
            if (this.Empty)
            {
                return;
            }
            Regex  rgx         = new Regex("[^a-zA-Z0-9]");
            string tilesetName = rgx.Replace(Path.GetFileNameWithoutExtension(this.Text), String.Empty);

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.FileName = String.Format("Tileset{0}.h", tilesetName);
                dlg.Filter   = "C header file|*.h";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    List <Tile>      tiles  = onlySelected ? this._selectedTiles : this.panelGrid.Controls.Cast <Control>().Where(item => item is Tile).Cast <Tile>().ToList();
                    List <Rectangle> toSave = new List <Rectangle>();
                    int xOrigin             = tiles.Min(tile => (int)(tile.Left * this._zoomFactor));
                    int yOrigin             = tiles.Min(tile => (int)(tile.Top * this._zoomFactor));
                    foreach (Tile tile in tiles.OrderBy(item => item.Left).ThenBy(item => item.Top))
                    {
                        int x      = this.panelGrid.HorizontalScroll.Value + (int)(tile.Left * this._zoomFactor) - xOrigin;
                        int y      = this.panelGrid.VerticalScroll.Value + (int)(tile.Top * this._zoomFactor) - yOrigin;
                        int width  = (int)(tile.Width * this._zoomFactor);
                        int height = (int)(tile.Height * this._zoomFactor);
                        toSave.Add(new Rectangle(x, y, width, height));
                    }
                    File.WriteAllText(dlg.FileName, SegaSaturnConverter.ToSourceFile(toSave, tilesetName, true));
                    MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 6
0
        public string ToSourceFile(string filename, Option option)
        {
            List <SegaSaturnPolygonData> list = this.Geometries.ConvertAll(geometry => geometry.GetPolygonData(this.Textures, option));

            return(SegaSaturnConverter.ToSourceFile(list, true, true, filename));
        }
Ejemplo n.º 7
0
 public static string ToSourceFile(string filename, List <SegaSaturnPolygonData> list)
 {
     return(SegaSaturnConverter.ToSourceFile(list, true, true, filename));
 }