Exemple #1
0
        private void AddGridRow(DataGridView grid, object wzObject)
        {
            int      id;
            string   properties = BuildProperties(wzObject);
            string   name       = null;
            WzObject icon       = null;

            if (wzObject is WzImage image)
            {
                id         = int.Parse(Path.GetFileNameWithoutExtension(image.Name));
                properties = BuildProperties(image) ?? "";
                WzImageProperty linkProperty = image.GetFromPath("info/link");
                if (linkProperty != null)
                {
                    string linkName = ((WzStringProperty)linkProperty).Value;
                    image = ((WzDirectory)image.Parent).GetChildImages().Find(p => p.Name.Equals(linkName + ".img"));
                    if (image == null)
                    {
                        return;
                    }
                }

                WzObject entityIcon = image.GetFromPath("stand/0");
                if (image.WzFileParent.Name.StartsWith("Npc"))   // icon path like: '{ID}/stand/0'
                {
                    name = StringUtility.GetNPC(id);
                }
                else if (image.WzFileParent.Name.StartsWith("Mob"))     // icon path like: '{ID}/(move|stand|fly)/0'
                {
                    name = StringUtility.GetMob(id);
                    if (entityIcon == null)
                    {
                        entityIcon = image.GetFromPath("fly/0") ?? image.GetFromPath("move/0");                     // attempt to get image of the monster
                    }
                }
                else if (image.WzFileParent.Name.StartsWith("Reactor"))
                {
                    name       = image.GetFromPath("action")?.WzValue.ToString();
                    entityIcon = image.GetFromPath("0/0");
                }
                else      // for breadcrumb like: '{ID}.img/info/icon'
                {
                    if (ItemConstants.IsEquip(id))
                    {
                        name = StringUtility.GetEqp(id);
                    }
                    else if (ItemConstants.IsPet(id))
                    {
                        name = StringUtility.GetPet(id);
                    }
                    icon = image.GetFromPath("info/icon");
                }

                if (icon == null)
                {
                    icon = entityIcon;
                }
            }
            else if (wzObject is WzSubProperty subProperty)
            {
                // for path like: 'category.img/{ID}/info/icon' (Etc.wz)
                string imgName = subProperty.Name;
                id = int.Parse(imgName);
                if (ItemConstants.IsEtc(id))
                {
                    name = StringUtility.GetEtc(id);
                }
                else if (ItemConstants.IsCash(id))
                {
                    name = StringUtility.GetCash(id);
                }
                else if (ItemConstants.IsChair(id))
                {
                    name = StringUtility.GetChair(id);
                }
                else if (ItemConstants.IsConsume(id))
                {
                    name = StringUtility.GetConsume(id);
                }

                icon = subProperty.GetFromPath("info/icon");
            }
            else
            {
                return;
            }

            grid.Rows.Add(id, icon?.GetBitmap(), name, properties);
        }
Exemple #2
0
        private void AddGridRow(DataGridView grid, object wzObject)
        {
            int              id;
            string           properties = BuildProperties(wzObject);
            string           name       = null;
            WzCanvasProperty icon       = null;

            if (wzObject is WzImage image)
            {
                image.ParseImage();
                string imgName = Path.GetFileNameWithoutExtension(image.Name);
                properties = BuildProperties(image) ?? "";
                id         = int.Parse(imgName);
                WzImageProperty entityIcon   = image.GetFromPath("stand/0");
                WzImageProperty linkProperty = image.GetFromPath("info/link");
                if (linkProperty != null)
                {
                    string linkName = ((WzStringProperty)linkProperty).Value;
                    image = ((WzDirectory)image.Parent).GetChildImages().Find(p => p.Name.Equals(linkName + ".img"));
                    if (image == null)
                    {
                        return;
                    }
                }

                if (image.WzFileParent.Name.StartsWith("Npc"))   // icon path like: '{ID}/stand/0'
                // and also sometimes contains a link STRING property instead of using UOL
                {
                    name = StringUtility.GetNPC(id);
                }
                else if (image.WzFileParent.Name.StartsWith("Mob"))
                {
                    // icon path like: '{ID}/(move|stand|fly)/0'
                    name = StringUtility.GetMob(id);
                    // attempt to get image of the monster
                    entityIcon = image.GetFromPath("fly/0") ?? image.GetFromPath("move/0");
                }
                else if (image.WzFileParent.Name.StartsWith("Reactor"))
                {
                    name       = image.GetFromPath("action")?.WzValue.ToString();
                    entityIcon = image.GetFromPath("0/0");
                }
                else      // for breadcrumb like: '{ID}.img/info/icon'
                {
                    if (ItemConstants.IsEquip(id))
                    {
                        name = StringUtility.GetEqp(id);
                    }
                    else if (ItemConstants.IsPet(id))
                    {
                        name = StringUtility.GetPet(id);
                    }
                    icon = (WzCanvasProperty)image.GetFromPath("info/icon");
                }

                if (icon == null)
                {
                    if (entityIcon is WzUOLProperty uol)
                    {
                        icon = (WzCanvasProperty)uol.LinkValue;
                    }
                    else
                    {
                        icon = (WzCanvasProperty)entityIcon;
                    }
                }
            }
            else if (wzObject is WzSubProperty subProperty)
            {
                if (subProperty.WzFileParent.Name.StartsWith("Skill"))
                {
                    id   = int.Parse(subProperty.Name);
                    name = StringUtility.GetSkill(subProperty.Name);

                    icon = (WzCanvasProperty)subProperty.GetFromPath("icon");
                }
                else     // for breadcrumb like: 'category.img/{ID}/info/icon' (etc.wz)
                {
                    string imgName = subProperty.Name;
                    id = int.Parse(imgName);
                    if (ItemConstants.IsEtc(id))
                    {
                        name = StringUtility.GetEtc(id);
                    }
                    else if (ItemConstants.IsCash(id))
                    {
                        name = StringUtility.GetCash(id);
                    }
                    else if (ItemConstants.IsChair(id))
                    {
                        name = StringUtility.GetChair(id);
                    }
                    else if (ItemConstants.IsConsume(id))
                    {
                        name = StringUtility.GetConsume(id);
                    }

                    WzImageProperty imgIcon = subProperty.GetFromPath("info/icon");
                    if (imgIcon is WzUOLProperty ufo)
                    {
                        imgIcon = (WzCanvasProperty)ufo.LinkValue;
                    }
                    else if (imgIcon is WzCanvasProperty canvas)
                    {
                        imgIcon = canvas;
                    }
                    if (imgIcon != null)
                    {
                        icon = (WzCanvasProperty)imgIcon;
                    }
                }
            }
            else
            {
                return;
            }
            Bitmap bitmap = null;

            try { bitmap = icon?.GetBitmap(); } catch (Exception) { }
            grid.Rows.Add(id, bitmap, name, properties);
        }