コード例 #1
0
ファイル: GameMap.cs プロジェクト: Trass3r/BBTools
        public void Load(ContentManager content, GraphicsDevice graphicsDevice,
                         SpriteBatch spriteBatch, SpriteFont spriteFont, SpriteFont spriteFontBig)
        {
            this.spriteBatch    = spriteBatch;
            this.graphicsDevice = graphicsDevice;

            this.spriteFont    = spriteFont;
            this.spriteFontBig = spriteFontBig;
            this.content       = content;

            Map = new MAPFile(Environment.CurrentDirectory + @"\savegam0.sav");

            Textures = new GameTextures(graphicsDevice, Environment.CurrentDirectory + @"\VIDEO.BOX");
        }
コード例 #2
0
        public void Load(ContentManager content, GraphicsDevice graphicsDevice,
                         SpriteBatch spriteBatch, SpriteFont spriteFont, SpriteFont spriteFontBig)
        {
            this.spriteBatch    = spriteBatch;
            this.graphicsDevice = graphicsDevice;

            this.spriteFont    = spriteFont;
            this.spriteFontBig = spriteFontBig;
            this.content       = content;

            Map = new MAPFile(@"D:\beasts\savegam0.sav");

            Textures = new GameTextures(graphicsDevice, @"D:\beasts\VIDEO.BOX");
        }
コード例 #3
0
        private void displayFileDetails(DATFileEntry entry)
        {
            Text = baseTitle + " - " + entry.Filename;

            savePNGButton.Visible  = false;
            savePNGSButton.Visible = false;

            currentExportBitmap  = null;
            currentExportBitmaps = null;

            switch (entry.Type)
            {
            case "MAP":
                MAPFile map = new MAPFile(entry);
                if (map.Error != "")
                {
                    MessageBox.Show(map.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Palette palette   = Palette.Default;
                Bitmap  mapBitmap = null;

                // find matching ICO tileset and PCC for palette
                if (entry.Filename.StartsWith("W"))
                {
                    string baseName = entry.Filename.Substring(0, 2);
                    if (container.Entries.ContainsKey(baseName + ".ICO"))
                    {
                        palette = getPaletteFrom(baseName + ".PCC");
                        if (palette == null)
                        {
                            palette = Palette.Default;
                        }
                        else if (baseName != "W2")
                        {
                            addW2Palette(palette);
                        }

                        ICOFile icoFile = new ICOFile(container.Entries[baseName + ".ICO"], palette);
                        int     scale   = 1;
                        mapBitmap           = MAPPainter.Paint(map, icoFile, scale);
                        currentExportBitmap = scale == 1 ? mapBitmap : MAPPainter.Paint(map, icoFile, 1);
                    }
                }

                imgPictureBox.Image = mapBitmap;
                setPaletteImage(palette);
                log($"MAP loaded: name={entry.Filename}, width={map.Width}, height={map.Height}, palette={palette.Name}");
                break;

            case "ARE":
                AREFile area = new AREFile(entry);
                if (area.Error != "")
                {
                    MessageBox.Show(area.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //imgPictureBox.Image = BitmapScaler.PixelScale(, 3);
                //palettePictureBox.Image = BitmapScaler.PixelScale(Palette.ToBitmap(Palette.Default), 6);
                break;

            case "BOB":
                string name = Path.GetFileNameWithoutExtension(entry.Filename);
                if (container.Entries.ContainsKey(name + ".PCC"))
                {
                    palette = getPaletteFrom(name + ".PCC");
                }
                else if (name.Length == 1)
                {
                    palette = getPaletteFrom("ANTS.PCC");                            // the ants have names like A.BOB to O.BOB
                }
                else
                {
                    palette           = getPaletteFrom("W2.PCC");
                    palette.Colors[0] = Color.Black;
                    palette.Name     += " (mod)";
                }

                BOBFile b = new BOBFile(entry, palette);
                if (b.Error != "")
                {
                    MessageBox.Show(b.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                log($"BOB contains {b.Elements.Count} images");
                currentExportBitmaps = b.Elements.ToArray();
                currentExportBitmap  = BOBPainter.MakeSheet(b);
                imgPictureBox.Image  = BitmapScaler.PixelScale(currentExportBitmap, 3);
                setPaletteImage(palette);
                break;

            case "ICO":     // tileset / spritesheet
                string world = entry.Filename.Contains("W1") ? "W1" : (entry.Filename.Contains("W2") ? "W2" : "W3");
                palette = getPaletteFrom(world + ".PCC");
                if (palette == null)
                {
                    palette = Palette.Default;
                }
                else if (world != "W2")
                {
                    addW2Palette(palette);
                }

                ICOFile ico = new ICOFile(entry, palette);
                if (ico.Error != "")
                {
                    MessageBox.Show("Failed to load ICO, sorry!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                log($"ICO contains {ico.Bitmaps.Length} tiles");
                currentExportBitmaps = ico.Bitmaps;
                currentExportBitmap  = ICOPainter.TileSetFromBitmaps(ico.Bitmaps);
                imgPictureBox.Image  = BitmapScaler.PixelScale(currentExportBitmap, 3);
                setPaletteImage(palette);
                break;


            case "PCC":     // these are actually PCX files, version 5, encoded, 8 bits per pixel
                PCXFile pcx = new PCXFile();
                if (!pcx.Load(entry.Data))
                {
                    MessageBox.Show(pcx.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentExportBitmap = pcx.Bitmap;
                imgPictureBox.Image = BitmapScaler.PixelScale(pcx.Bitmap, 4);
                setPaletteImage(Palette.ToBitmap(pcx.Palette), "own");
                log($"PCC loaded: name={entry.Filename}, width={pcx.Bitmap.Width}, height={pcx.Bitmap.Height}, palette=own");
                break;

            default:
                break;
            }

            if (currentExportBitmap != null)
            {
                savePNGButton.Visible = true;
            }
            if (currentExportBitmaps != null && currentExportBitmaps.Length > 0)
            {
                savePNGSButton.Visible = true;
            }
        }