Пример #1
0
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag != null && e.Node.Text == "payload")
     {
         payloadField          = (Tools.Field)e.Node.Tag;
         txtPayloadEditor.Text = System.Text.Encoding.ASCII.GetString((byte[])payloadField.data);
     }
 }
        private void FindTextures(List <Tools.Entry> bundle)
        {
            foreach (Tools.Entry e in bundle)
            {
                if (e.type == 0x82)
                {
                    bool        foundc = false;
                    bool        foundr = false;
                    string      path   = "";
                    Tools.Field chunks = new Tools.Field();
                    Tools.Field res    = new Tools.Field();
                    #region findfields
                    foreach (Tools.Field f in e.fields)
                    {
                        if (f.fieldname == "path")
                        {
                            path = (string)f.data;
                        }
                        else if (f.fieldname == "res")
                        {
                            foundr = true;
                            res    = f;
                            if (foundc)
                            {
                                break;
                            }
                        }
                        else if (f.fieldname == "chunks")
                        {
                            foundc = true;
                            chunks = f;
                            if (foundr)
                            {
                                break;
                            }
                        }
                    }
                    #endregion
                    path += "/";
                    if (foundr && foundc) //contains textures at all
                    {
                        #region gettextures
                        List <Tools.Entry> reslist = (List <Tools.Entry>)res.data;
                        foreach (Tools.Entry e2 in reslist)
                        {
                            if (e2.type == 0x82)
                            {
                                bool foundt = false;
                                foreach (Tools.Field f2 in e2.fields)
                                {
                                    if (f2.fieldname == "resType")
                                    {
                                        if (Tools.GetResType(BitConverter.ToUInt32((byte[])f2.data, 0)) == ".itexture")
                                        {
                                            foundt = true;
                                            break;
                                        }
                                    }
                                }
                                if (foundt) //is a texture
                                {
                                    TextureInfo t = new TextureInfo();
                                    foreach (Tools.Field f2 in e2.fields)
                                    {
                                        switch (f2.fieldname)
                                        {
                                        case "name":
                                            t.path     = (string)f2.data;
                                            t.fullpath = path + t.path;
                                            break;

                                        case "sha1":
                                            t.sha1 = (byte[])f2.data;
                                            break;
                                        }
                                    }
                                    listTex.Add(t);
                                }
                            }
                        }
                        #endregion

                        #region getchunks
                        List <Tools.Entry> chunklist = (List <Tools.Entry>)chunks.data;
                        foreach (Tools.Entry e2 in chunklist)
                        {
                            if (e2.type == 0x82)
                            {
                                ChunkInfo c = new ChunkInfo();
                                foreach (Tools.Field f2 in e2.fields)
                                {
                                    switch (f2.fieldname)
                                    {
                                    case "id":
                                        c.id = (byte[])f2.data;
                                        break;

                                    case "sha1":
                                        c.sha1 = (byte[])f2.data;
                                        break;
                                    }
                                }
                                listChunks.Add(c);
                            }
                        }
                        #endregion
                    }
                }
            }
        }