Beispiel #1
0
        private void AddGridRow(DataGridView grid, object wzObject) {
            int id;
            string name = null;
            WzObject png;
            string properties = GetAllProperties(wzObject);

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

                png = img.GetFromPath("stand/0");
                if (img.WzFileParent.Name.StartsWith("Npc")) {
                    // icon path like: '{ID}/stand/0'
                    name = StringWz.GetNpc(id);
                } else if (img.WzFileParent.Name.StartsWith("Mob")) {
                    // icon path like: '{ID}/(move|stand|fly)/0'
                    name = StringWz.GetMob(id);
                    if (png == null) {
                        png = img.GetFromPath("fly/0") ??
                              img.GetFromPath("move/0"); // attempt to get image of the monster
                    }
                } else if (img.WzFileParent.Name.StartsWith("Reactor")) {
                    name = img.GetFromPath("action")?.GetString();
                    png = img.GetFromPath("0/0");
                } else if (img.WzFileParent.Name.StartsWith("Map")) {
                    name = StringWz.GetFieldFullName(id);
                    png = img.GetFromPath("miniMap/canvas");
                } else {
                    // for breadcrumb like: '{ID}.img/info/icon'
                    if (ItemConstants.IsEquip(id)) name = StringWz.GetEqp(id);
                    else if (ItemConstants.IsPet(id)) name = StringWz.GetPet(id);
                    png = img.GetFromPath("info/icon");
                }
            } else if (wzObject is WzSubProperty subProperty) {
                id = int.Parse(subProperty.Name);

                if (subProperty.WzFileParent.Name.StartsWith("Skill")) {
                    name = StringWz.GetSkill(subProperty.Name);
                    properties = GetAllProperties(subProperty);
                    png = subProperty.GetFromPath("icon");
                } else {
                    // for path like: 'category.img/{ID}/info/icon' (Etc.wz)
                    id = int.Parse(subProperty.Name);
                    if (ItemConstants.IsEtc(id)) name = StringWz.GetEtc(id);
                    else if (ItemConstants.IsCash(id)) name = StringWz.GetCash(id);
                    else if (ItemConstants.IsChair(id)) name = StringWz.GetChair(id);
                    else if (ItemConstants.IsConsume(id)) name = StringWz.GetConsume(id);

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

            if (grid.Parent is DataViewport dv) {
                ((List<BinData>)dv.Tag)?.Add(new BinData(id, png?.GetBitmap(), name, properties));
            }
            grid.Rows.Add(id, png?.GetBitmap(), name, properties);
        }