Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (bsp.Header.ident != SourceBSPStructs.VBSP)
            {
                label_bspinfo.Text += $"Identifier={bsp.Header.ident} " + (bsp.Header.ident == SourceBSPStructs.VBSP ? "(Valid)" : "(Not valid)");
                return;
            }

            #region print lumps
            int lumpslen  = bsp.Header.lumps.Length;
            int lumpsskip = 0;
            for (int i = 0; i < lumpslen; i++)
            {
                var lump = bsp.Header.lumps[i];
                //if (lump.fileofs == 0) { lumpsskip++; continue; } //skip empty
                string       lump_name = SourceBSPStructs.GetLump(i).ToString();
                ListViewItem item      = new ListViewItem(new string[]
                {
                    i.ToString(),
                    lump_name,
                    lump.filelen.ToString(),
                    lump.fileofs.ToString()
                });
                listView_lumps.Items.Add(item);
            }
            listView_lumps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            #endregion

            label_bspinfo.Text += $"Identifier={bsp.Header.ident} " + (bsp.Header.ident == SourceBSPStructs.VBSP ? "(Valid)" : "(Not valid)") + "\n" +
                                  $"Version={bsp.Header.version}\n" +
                                  $"{bsp.Header.lumps.Length} Lumps ({lumpsskip} skipped)\n" +
                                  $"The map's revision (iteration, version)={bsp.Header.mapRevision}\n";

            this.TopMost = true;
            Application.DoEvents();
            this.TopMost = false;
        }
Esempio n. 2
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();
        }