private void spriteList_SelectedIndexChanged(object sender, EventArgs e) { mpf = mpfImages[(int)spriteList.SelectedItem]; pal = Palette256.FromArchive(mpf.Palette, DATArchive.Hades); int maxThumbWidth = Math.Min(128, mpf.Width); int maxThumbHeight = Math.Min(128, mpf.Height); int thumbnailSize = Math.Max(maxThumbWidth, maxThumbHeight); flowLayoutPanel1.Controls.Clear(); for (int i = 0; i < mpf.ExpectedFrames; ++i) { var frame = mpf.Frames[i]; var thumbnail = new PictureBox(); thumbnail.Size = new Size(128, 128); thumbnail.SizeMode = frame.Width > thumbnail.Width || frame.Height > thumbnail.Height ? PictureBoxSizeMode.Zoom : PictureBoxSizeMode.CenterImage; if (frame.Height > 0 && frame.Width > 0) { thumbnail.Image = DAGraphics.RenderImage(frame, pal); } thumbnail.BackColor = Color.Teal; thumbnail.MouseClick += thumbnail_MouseClick; flowLayoutPanel1.Controls.Add(thumbnail); } }
private void spriteList_SelectedIndexChanged(object sender, EventArgs e) { scrollPos = 0; mpf = mpfImages[(int)spriteList.SelectedItem]; cachedFrames = new Bitmap[mpf.ExpectedFrames]; for (int i = 0; i < mpf.ExpectedFrames; ++i) { cachedFrames[i] = mpf.Render(i); } UpdateSpriteSheetImage(); }
public MonsterSpriteForm(int sprite, IWindowsFormsEditorService editorService) { InitializeComponent(); this.sprite = Math.Max(sprite, 1); this.mpfImages = new Dictionary <int, MPFImage>(); foreach (var file in DATArchive.Hades.Files) { var match = Regex.Match(file.Name, @"^MNS(\d+)\.MPF$"); if (match.Success) { int id = int.Parse(match.Groups[1].Value); var mpf = MPFImage.FromArchive(file.Name, DATArchive.Hades); mpfImages.Add(id, mpf); spriteList.Items.Add(id); } } }
private void DrawForeground(Bitmap image) { int xOrigin = ((image.Width / 2) - 1) - Tileset.HalfTileWidth + 1; int yOrigin = 256; for (int y = 0; y < map.Height; ++y) { for (int x = 0; x < map.Width; ++x) { var point = new Point(x, y); int tileIndex = y * map.Width + x; #region Npc if (showNpcs && map.Npcs.ContainsKey(point)) { var npc = map.Npcs[point]; string filename = string.Format("MNS{0:d3}.MPF", npc.Sprite); var mpf = MPFImage.FromArchive(filename, DATArchive.Hades); var pal = Palette256.FromArchive(mpf.Palette, DATArchive.Hades); var frame = mpf[0]; DrawBitmapData(image, frame.RawData, pal, new Rectangle( xOrigin + frame.Left + x * Tileset.HalfTileWidth, yOrigin + frame.Top + (x + 1) * Tileset.HalfTileHeight - mpf.Height + Tileset.HalfTileHeight, frame.Width, frame.Height)); } #endregion #region Left Wall int leftWall = map.Tiles[tileIndex].LeftWall; if (showLeftWalls && (leftWall % 10000) > 1) { string filename = string.Format("stc{0:d5}.hpf", leftWall); var hpf = HPFImage.FromArchive(filename, DATArchive.Ia); DrawBitmapData(image, hpf.RawData, stcPaletteTable[leftWall + 1], new Rectangle( xOrigin + x * Tileset.HalfTileWidth, yOrigin + (x + 1) * Tileset.HalfTileHeight - hpf.Height + Tileset.HalfTileHeight, hpf.Width, hpf.Height), map.Tiles[tileIndex].LeftBlends); } #endregion #region Right Wall int rightWall = map.Tiles[tileIndex].RightWall; if (showRightWalls && (rightWall % 10000) > 1) { string filename = string.Format("stc{0:d5}.hpf", rightWall); var hpf = HPFImage.FromArchive(filename, DATArchive.Ia); DrawBitmapData(image, hpf.RawData, stcPaletteTable[rightWall + 1], new Rectangle( xOrigin + (x + 1) * Tileset.HalfTileWidth, yOrigin + (x + 1) * Tileset.HalfTileHeight - hpf.Height + Tileset.HalfTileHeight, hpf.Width, hpf.Height), map.Tiles[tileIndex].RightBlends); } #endregion } xOrigin -= Tileset.HalfTileWidth; yOrigin += Tileset.HalfTileHeight; } }