示例#1
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);
        }
示例#2
0
        public SkillIconForm(int icon, string type)
        {
            InitializeComponent();

            Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type) + " Icon";

            _icon     = icon;
            _epfImage = EPFImage.FromArchive(type + "001.epf", DATArchive.Setoa);
            _palette  = Palette256.FromArchive("gui06.pal", DATArchive.Setoa);
        }
示例#3
0
        public ItemSpriteForm(int sprite, IWindowsFormsEditorService editorService)
        {
            InitializeComponent();

            this.sprite    = sprite;
            this.palTable  = PaletteTable.FromArchive("item", DATArchive.Legend);
            this.epfImages = new List <Tuple <int, EPFImage> >();
            foreach (var file in DATArchive.Legend.Files)
            {
                var match = Regex.Match(file.Name, @"^item(\d+)\.epf$");
                if (match.Success)
                {
                    var epf        = EPFImage.FromArchive(file.Name, DATArchive.Legend);
                    int fileNumber = int.Parse(match.Groups[1].Value);
                    epfImages.Add(new Tuple <int, EPFImage>(fileNumber, epf));
                    pageComboBox.Items.Add(epfImages.Count);
                }
            }
            this.spriteCache = new Dictionary <int, Bitmap>();
        }
示例#4
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;
        }
示例#5
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;
        }
示例#6
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;
                        }
                    }
                }
            }
        }
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Environment.CurrentDirectory)
                          .AddJsonFile("LoruleConfig.json");

            var config         = builder.Build();
            var editorSettings = config.GetSection("Editor").Get <EditorOptions>();
            var assetLocation  = Path.Combine(editorSettings.Location, "Assets", "Bitmaps", "legend");

            if (!Directory.Exists(assetLocation))
            {
                Directory.CreateDirectory(assetLocation);
            }


            Dictionary <string, Palette> pals = new Dictionary <string, Palette>();

            foreach (var palfile in Directory.GetFiles(editorSettings.Location + @"\Extractions\setoa", "*.pal"))
            {
                var pallete = Palette.FromFile(palfile);

                pals[Path.GetFileNameWithoutExtension(palfile)] = pallete;
            }

            Palette palette = null;

            foreach (var file in Directory.GetFiles(editorSettings.Location + @"\Extractions\setoa", "*.*").OrderBy(i => i.Length).ToArray())
            {
                if (Path.GetExtension(file) == ".epf")
                {
                    var epf = EPFImage.FromFile(file);

                    var palleteName = File.Exists(Path.GetFileNameWithoutExtension(file) + ".pal")
                        ? Path.GetFileNameWithoutExtension(file)
                        : "legend";

                    palette = pals[palleteName];

                    foreach (var frame in epf.Frames)
                    {
                        if (frame.RawData.Length > 0 && palette != null)
                        {
                            var bitmap = frame.Render(frame.Width, frame.Height, frame.RawData, palette,
                                                      EPFFrame.ImageType.EPF);
                            bitmap.Save(
                                Path.Combine(assetLocation,
                                             Path.GetFileNameWithoutExtension(file) + ".bmp"),
                                ImageFormat.Bmp);
                        }
                    }
                }

                if (Path.GetExtension(file) == ".spf")
                {
                    var spf = SpfFile.FromFile(file);

                    foreach (var frame in spf.Frames)
                    {
                        frame.FrameBitmap?.Save(
                            Path.Combine(assetLocation,
                                         Path.GetFileNameWithoutExtension(spf.FileName) + $"{spf.FrameCount}.bmp"),
                            ImageFormat.Bmp);
                    }
                }

                if (Path.GetExtension(file) == ".txt")
                {
                    var data = await File.ReadAllLinesAsync(file);

                    if (data != null && data.Length > 0)
                    {
                        AssetControl control = new AssetControl();
                        for (var index = 0; index < data.Length; index++)
                        {
                            var line = data[index];

                            if (line == "<CONTROL>")
                            {
                                control.Name = data[index + 1].Replace("<NAME>", string.Empty).Replace("\"", "").Trim();
                                control.Type = data[index + 2].Replace("<TYPE>", string.Empty).Replace("\"", "").Trim();

                                var rect      = data[index + 3].Replace("<RECT>", string.Empty).Replace("\"", "").Trim();
                                var rectparts = rect.Split(" ");

                                if (rectparts.Length == 4)
                                {
                                    TryParse(rectparts[0], out var x);
                                    TryParse(rectparts[1], out var y);
                                    TryParse(rectparts[2], out var w);
                                    TryParse(rectparts[3], out var h);

                                    control.Rect = new Rectangle(x, y, w, h);
                                }

                                if (data[index + 4] == "\t<IMAGE>")
                                {
                                    var imageparts = data[index + 5].Replace("\t\t", string.Empty).Replace("\"", "")
                                                     .Trim().Split(" ");

                                    if (imageparts.Length == 2)
                                    {
                                        control.Image      = imageparts[0];
                                        control.FrameCount = imageparts[1];
                                    }
                                    else
                                    {
                                        control.Image = imageparts[0];
                                    }
                                }
                            }

                            if (line == "<ENDCONTROL>")
                            {
                                ControiAssetControls.Add(control);
                                control = new AssetControl();
                            }
                        }
                    }
                }
            }


            List <AssetControl> saveableControls = new List <AssetControl>();


            foreach (var control in ControiAssetControls)
            {
                if (!string.IsNullOrEmpty(control.Image) && Path.GetExtension(control.Image) == ".spf")
                {
                    var path = Path.GetRelativePath(Path.Combine(assetLocation, editorSettings.Location), assetLocation);

                    if (File.Exists(path))
                    {
                        control.Image = path;
                        saveableControls.Add(control);
                    }
                }
            }

            var jsonFile = JsonConvert.SerializeObject(saveableControls);

            File.WriteAllText(assetLocation + "\\metafile.json", jsonFile);
        }