Ejemplo n.º 1
0
        private void Button_parse_Click(object sender, EventArgs e)
        {
            if (listView_lumps_index < 0)
            {
                return;
            }
            var lump     = bsp.Header.lumps[listView_lumps_index];
            var lumptype = SourceBSPStructs.GetLump(listView_lumps_index);

            if (lumptype == SourceBSPStructs.Lumps.LUMP_ENTITIES) //Lump 0
            {
                bsp.BR.BaseStream.Seek(lump.fileofs, SeekOrigin.Begin);
                new FormEntityList(Encoding.ASCII.GetString(bsp.BR.ReadBytes(lump.filelen))).ShowDialog();
            }
            else if (lumptype == SourceBSPStructs.Lumps.LUMP_PAKFILE) //Lump 40
            {
                //SharpVPK.VpkArchive vpk = new SharpVPK.VpkArchive();
                //vpk.Load(lump.Parse<byte>(bsp.BR), SharpVPK.VpkVersions.Versions.V1);
                bsp.BR.BaseStream.Seek(lump.fileofs, SeekOrigin.Begin);
                new FormFileBrowser(bsp.BR.ReadBytes(lump.filelen)).ShowDialog();
            }
            else
            {
                var table = new FormShowTable();
                if (CreateLumpTable(lump, lumptype, table))
                {
                    table.ShowDialog();
                }
                else
                {
                    MessageBox.Show("This lump is not supported yet.");
                    table.Dispose();
                }
            }

            GC.Collect();
        }
Ejemplo n.º 2
0
        private bool CreateLumpTable(SourceBSPStructs.lump_t lump, SourceBSPStructs.Lumps lumptype, FormShowTable table, bool isv2 = false)
        {
            if (lumptype == SourceBSPStructs.Lumps.LUMP_PLANES) //Lump 1
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dplane_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_TEXDATA) //Lump 2
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dtexdata_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_VERTEXES) //Lump 3
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dvertexes_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_NODES) //Lump 5
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dnode_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_TEXINFO) //Lump 6
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.texinfo_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_FACES ||
                     lumptype == SourceBSPStructs.Lumps.LUMP_ORIGINALFACES) //Lump 7 + Lump 27
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dface_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_LIGHTING ||
                     lumptype == SourceBSPStructs.Lumps.LUMP_LIGHTING_HDR ||                 //Lump 8 (LDR) + Lump 53 (HDR)
                     lumptype == SourceBSPStructs.Lumps.LUMP_DISP_LIGHTMAP_ALPHAS ||
                     lumptype == SourceBSPStructs.Lumps.LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS) //Lump 32 + Lump 34
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.ColorRGBExp32>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_LEAFS) //Lump 10
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dleaf_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_EDGES) //Lump 12
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dedge_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_SURFEDGES) //Lump 13
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dsurfedge_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_MODELS) //Lump 14
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dmodel_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_LEAFFACES) //Lump 16
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dleafface_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_LEAFBRUSHES) //Lump 17
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dleafbrush_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_BRUSHES) //Lump 18
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dbrush_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_BRUSHSIDES) //Lump 19
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dbrushside_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_DISPINFO) //Lump 26
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.ddispinfo_t>(bsp.BR), isv2);
            }

            else if (lumptype == SourceBSPStructs.Lumps.LUMP_DISP_VERTS) //Lump 33
            {
                table.CreateTable(lump.Parse <SourceBSPStructs.dDispVert>(bsp.BR), isv2);
            }

            else
            {
                return(false);
            }
            return(true);
        }