LoadMetaFromFile() public method

Load meta from an XML file.
public LoadMetaFromFile ( string inputFileName ) : void
inputFileName string The XML file name.
return void
Example #1
0
        /// <summary>
        /// The build map from info file.
        /// </summary>
        /// <param name="inputFile">The input file.</param>
        /// <param name="layout">The layout.</param>
        /// <param name="map">The map.</param>
        /// <param name="addsounds">The addsounds.</param>
        /// <remarks></remarks>
        public void BuildMapFromInfoFile(string inputFile, ref MapLayout layout, Map map, bool addsounds)
        {
            ArrayList metas = new ArrayList(0);
            string[] split = inputFile.Split('.');
            if (split[split.Length - 1] == "info")
            {
                FileStream FS = new FileStream(inputFile, FileMode.Open);
                StreamReader SR = new StreamReader(FS);
                string temps = string.Empty;
                do
                {
                    temps = SR.ReadLine();

                    if (temps == null)
                    {
                        break;
                    }

                    Meta m = new Meta(map);
                    m.LoadMetaFromFile(temps);
                    if (addsounds == false)
                    {
                        if (m.type == "snd!")
                        {
                            continue;
                        }
                    }

                    bool exists = false;
                    for (int x = 0; x < map.IndexHeader.metaCount; x++)
                    {
                        if (map.FileNames.Name[x] == m.name && map.MetaInfo.TagType[x] == m.type)
                        {
                            exists = true;
                            break;
                        }
                    }

                    if (exists == false)
                    {
                        for (int x = 0; x < metas.Count; x++)
                        {
                            if (((Meta)metas[x]).name == m.name && ((Meta)metas[x]).type == m.type)
                            {
                                exists = true;
                                break;
                            }
                        }
                    }

                    if (exists == false)
                    {
                        metas.Add(m);
                    }
                }
                while (temps != null);

                SR.Close();
                FS.Close();
            }
            else
            {
                Meta m = new Meta(map);
                m.LoadMetaFromFile(inputFile);
                bool exists = false;
                for (int x = 0; x < map.IndexHeader.metaCount; x++)
                {
                    if (map.FileNames.Name[x] == m.name && map.MetaInfo.TagType[x] == m.type)
                    {
                        exists = true;
                        break;
                    }
                }

                if (exists == false)
                {
                    metas.Add(m);
                }
            }

            MapBuilder(metas, ref layout, map, addsounds);
        }
Example #2
0
        /// <summary>
        /// The load meta button_ click_1.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void loadMetaButton_Click_1(object sender, EventArgs e)
        {
            loadMetaDialog.Filter = "XML Files (*.xml) | *.xml";
            loadMetaDialog.InitialDirectory = Prefs.pathExtractsFolder;
            if (loadMetaDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            Prefs.pathExtractsFolder = loadMetaDialog.InitialDirectory;

            Meta newm = new Meta(map);

            // remove the xml extension now that we are forcing loading of XML files
            loadMetaDialog.FileName = loadMetaDialog.FileName.Substring(0, loadMetaDialog.FileName.Length - 4);
            if (loadMetaDialog.FileName.EndsWith("raw"))
            {
                MessageBox.Show("Do not inject raw files, they are injected with the parent tags!");
                return;
            }

            newm.LoadMetaFromFile(loadMetaDialog.FileName);

            if (newm.size >= 0 && newm.size <= map.SelectedMeta.size)
            {
                map.OpenMap(MapTypes.Internal);
                map.BW.BaseStream.Position = map.SelectedMeta.offset;
                map.BW.BaseStream.Write(newm.MS.ToArray(), 0, newm.size);
                map.CloseMap();
                formFuncs.AddReferencesToListView(map.SelectedMeta, references, map.DisplayType);
                MessageBox.Show("Done");
            }
            else
            {
                MessageBox.Show("Meta Won't Fit");
                return;
            }
        }
Example #3
0
        /// <summary>
        /// The overwrite meta tool strip menu item_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void overwriteMetaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            loadMetaDialog.Filter = "XML Files (*.xml) | *.xml";
            if (loadMetaDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            Meta newm = new Meta(map);

            // remove the xml extension now that we are forcing loading of XML files
            loadMetaDialog.FileName = loadMetaDialog.FileName.Substring(0, loadMetaDialog.FileName.Length - 4);
            if (loadMetaDialog.FileName.EndsWith("raw"))
            {
                MessageBox.Show("Do not inject raw files, they are injected with the parent tags!");
                return;
            }

            newm.LoadMetaFromFile(loadMetaDialog.FileName);
            MetaOverWriter.OverWrite(map, map.SelectedMeta.TagIndex, ref newm);
            int i = map.SelectedMeta.TagIndex;
            Meta.ItemType me = map.DisplayType;
            map = Map.Refresh(map);
            LoadMeta(i);
            formFuncs.AddReferencesToListView(map.SelectedMeta, references, me);
            MessageBox.Show("Done");
        }
Example #4
0
        /// <summary>
        /// The extract map button_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void extractMapButton_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            count = 4 + map.BSP.sbsp.Length;

            // MetaList.Capacity = 10000;
            StatusLabel1.Text = "Processing Map Metas...";
            Application.DoEvents();

            if (treeView1.Nodes[0].Checked)
            {
                RecursivelyCheckMetas(treeView1.Nodes[0]);
            }

            StatusLabel1.Text = "Processing Imported Metas...";
            Application.DoEvents();

            foreach (ListViewItem l in listView2.Items)
            {
                if (l.Checked == false)
                {
                    continue;
                }

                StatusLabel1.Text = "Processing: " + l.Text + "...";
                Application.DoEvents();

                string[] split = l.Text.Split('.');
                if (split[split.Length - 1] != "info")
                {
                    Meta m = new Meta(map);
                    m.LoadMetaFromFile(l.Text);
                    MetaList.Add(m);
                }
                else
                {
                    FileStream FS = new FileStream(l.Text, FileMode.Open);
                    StreamReader SR = new StreamReader(FS);
                    string temps = string.Empty;
                    do
                    {
                        temps = SR.ReadLine();

                        if (temps == null)
                        {
                            break;
                        }

                        Meta m = new Meta(map);
                        m.LoadMetaFromFile(temps);
                        bool exists = false;
                        for (int x = 0; x < map.IndexHeader.metaCount; x++)
                        {
                            if (map.FileNames.Name[x] == m.name && map.MetaInfo.TagType[x] == m.type)
                            {
                                exists = true;
                                break;
                            }
                        }

                        if (exists == false)
                        {
                            for (int x = 0; x < MetaList.Count; x++)
                            {
                                if (((Meta)MetaList[x]).name == m.name && ((Meta)MetaList[x]).type == m.type)
                                {
                                    exists = true;
                                    break;
                                }
                            }
                        }

                        if (exists == false)
                        {
                            switch (m.type.Trim())
                            {
                                case "matg":
                                    matg = m;
                                    break;
                                case "sncl":
                                    sncl = m;
                                    break;
                                case "spk!":
                                    spk = m;
                                    break;
                                case "scnr":
                                    scnr = m;
                                    break;

                                case "sky":
                                    this.Skies.Add(m);
                                    skycount++;
                                    break;
                                default:
                                    MetaList.Add(m);
                                    count++;
                                    break;
                            }
                        }
                    }
                    while (temps != null);

                    SR.Close();
                    FS.Close();
                }
            }

            for (int x = skycount - 1; x > -1; x--)
            {
                MetaList.Insert(0, Skies[x]);
            }

            MetaList.Insert(0, scnr);
            MetaList.Insert(0, spk);
            MetaList.Insert(0, sncl);
            MetaList.Insert(0, matg);
            StatusLabel1.Text = "Starting Rebuild....";
            Application.DoEvents();
            MapAnalyzer ma = new MapAnalyzer();
            MapLayout lay = ma.ScanMapForLayOut(map, false);
            lay.ReadChunks(map);

            MapRebuilder(ref lay);
            MetaList.Clear();
            StatusLabel1.Text = "Done";
            this.Enabled = true;
        }