Beispiel #1
0
        private void ItemSpriteForm_Load(object sender, System.EventArgs e)
        {
            _sheetImage = new Bitmap(512, 512);

            using (var g = Graphics.FromImage(_sheetImage))
            {
                for (int y = 0; y < 16; ++y)
                {
                    for (int x = 0; x < 16; ++x)
                    {
                        g.DrawImage(Properties.Resources.InventorySlot, 32 * x, 32 * y);

                        int i = GetFrameFromPoint(x, y);

                        if (i < _epfImage.Frames.Length)
                        {
                            var bmp = DAGraphics.RenderImage(_epfImage[i], _palette);
                            g.DrawImage(bmp, 32 * x, 32 * y);
                        }
                    }
                }
            }

            statusLabel.Text = string.Empty;

            GC.Collect();

            UpdateSpriteBox();
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        static SignForm()
        {
            var epf = EPFImage.FromArchive("woodbk.epf", DATArchive.Legend);
            var pal = Palette256.FromArchive("legend.pal", DATArchive.Legend);

            woodbk = DAGraphics.RenderImage(epf[0], pal);
        }
Beispiel #4
0
        private void SetItemSheet(int index)
        {
            if (index < 0 || index >= epfImages.Count || index == currentIndex)
            {
                return;
            }

            this.currentIndex = index;

            statusLabel.Text = "Loading items...";
            statusStrip1.Update();

            int fileNumber = epfImages[index].Item1;
            var epfImage   = epfImages[index].Item2;

            itemSheetImage = new Bitmap(628, 463);

            using (var g = Graphics.FromImage(itemSheetImage))
            {
                for (int y = 0; y < 14; ++y)
                {
                    for (int x = 0; x < 19; ++x)
                    {
                        g.DrawImage(Properties.Resources.InventorySlot, 1 + x * 33, 1 + y * 33);

                        int i = 19 * y + x;
                        if (i < epfImage.ExpectedFrames)
                        {
                            int spriteId = fileNumber * 266 + i;

                            var frame = epfImage[i];

                            if (!spriteCache.ContainsKey(spriteId))
                            {
                                spriteCache.Add(spriteId, DAGraphics.RenderImage(frame, palTable[fileNumber * 266]));
                            }

                            g.DrawImage(spriteCache[spriteId], 1 + x * 33 + frame.Top, 1 + y * 33 + frame.Left);
                        }
                    }
                }
            }

            GC.Collect();

            UpdateSpriteBox();

            statusLabel.Text = string.Empty;
            statusStrip1.Update();

            prevButton.Enabled = index > 0;
            nextButton.Enabled = index < epfImages.Count - 1;

            if (pageComboBox.SelectedIndex != index)
            {
                ignoreComboBox             = true;
                pageComboBox.SelectedIndex = index;
            }
        }
Beispiel #5
0
        private void UpdateIcon()
        {
            string epfFilename;

            switch (cmbBook.SelectedIndex)
            {
            case 0:
            case 2:
            case 4:
                epfFilename = "skill001.epf";
                break;

            default:
                epfFilename = "spell001.epf";
                break;
            }
            var _epfImage = EPFImage.FromArchive(epfFilename, DATArchive.Setoa);
            var _palette  = Palette256.FromArchive("gui06.pal", DATArchive.Setoa);
            var bitmap    = DAGraphics.RenderImage(_epfImage[_skill.Icon], _palette);

            imgIcon.Image = bitmap;
        }
Beispiel #6
0
        private void DisplayItems(int number)
        {
            DATArchive   archive      = DATArchive.FromFile(filename);
            PaletteTable paletteTable = new PaletteTable("item", archive);

            foreach (DATFileEntry file in archive.Files)
            {
                Match match = new Regex("(item)(\\d+)(\\.epf)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(file.Name);
                if (match.Success)
                {
                    EPFImage epfImage = EPFImage.FromArchive(file.Name, archive);
                    int      num1     = int.Parse(match.Groups[2].ToString());
                    if (num1 == number)
                    {
                        panelItemFill.Controls.Clear();
                        for (int index = 0; index < epfImage.Frames.Length; ++index)
                        {
                            int        num2       = (num1 - 1) * 266 + (index + 1);
                            PictureBox pictureBox = new PictureBox();
                            pictureBox.Name   = string.Format("Sprite ID: {0} ({1} for Npc)", (object)num2, (object)(num2 + 16384));
                            pictureBox.Image  = (Image)DAGraphics.RenderImage(epfImage.Frames[index], paletteTable[num1 * 266]);
                            pictureBox.Click += (EventHandler)((o, ea) =>
                            {
                                txtSprite.Text = (o as PictureBox).Name;
                            });
                            pictureBox.BorderStyle = BorderStyle.FixedSingle;
                            if (pictureBox.Image.Width > 1 || pictureBox.Image.Height > 1)
                            {
                                panelItemFill.Controls.Add((Control)pictureBox);
                            }
                        }
                        break;
                    }
                }
            }
            current             = number;
            buttonLeft.Enabled  = this.current > this.minimum;
            buttonRight.Enabled = this.current < this.maximum;
        }
Beispiel #7
0
        public void DisplayItem(int SpriteID)
        {
            DATArchive   archive      = DATArchive.FromFile(filename);
            PaletteTable paletteTable = new PaletteTable("item", archive);

            foreach (DATFileEntry file in archive.Files)
            {
                Match match = new Regex("(item)(\\d+)(\\.epf)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(file.Name);
                if (match.Success)
                {
                    EPFImage epfImage = EPFImage.FromArchive(file.Name, archive);
                    int      num1     = int.Parse(match.Groups[2].ToString());
                    for (int index = 0; index < epfImage.Frames.Length; ++index)
                    {
                        int num2 = (num1 - 1) * 266 + (index + 1);
                        if (num2 == SpriteID)
                        {
                            Bitmap bmp = new Bitmap(DAGraphics.RenderImage(epfImage.Frames[index], paletteTable[num1 * 266]));
                            picSelectedItem.Image = bmp;
                        }
                    }
                }
            }
        }