コード例 #1
0
        //function display the tag structure
        private void getTagStructureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                if (treeView1.SelectedNode != null)
                {
                    string type = DATA_READ.ReadTAG_TYPE(Int32.Parse(treeView1.SelectedNode.Name), map_stream);

                    plugins_field temp = DATA_READ.Get_Tag_stucture_from_plugin(type);
                    if (temp != null)
                    {
                        TreeNode tn = temp.Get_field_structure();

                        tn.Text = type;

                        treeView1.Nodes.Clear();
                        treeView1.Nodes.Add(tn);
                    }
                    else
                    {
                        MessageBox.Show("The plugin of type " + type + " doesn't exist", "ERROR");
                    }

                    map_loaded = false;
                }
                else
                {
                    MessageBox.Show("Select a TAG", "Hint");
                }
            }
            else
            {
                MessageBox.Show("Select a map First", "Hint");
            }
        }
コード例 #2
0
    /// <summary>
    /// Function to read a concerned field from the xml file and return its sub fields
    /// </summary>
    /// <param name="name">the name of the field</param>
    /// <param name="off">the offset of the field</param>
    /// <param name="entry_size">the entry size of the field</param>
    /// <param name="xr">the xmlTextReader object</param>
    /// <param name="child">a flag to denote whether the field being read is a child field or not</param>
    /// <returns></returns>
    public static plugins_field Get_nodes(string name, int off, int entry_size, XmlTextReader xr, bool child)
    {
        plugins_field ret = new plugins_field(name, off, entry_size);

        bool work_done = false;//at boolean to show whether reading in the concerned node is done

        while (xr.Read() && !work_done)
        {
            if ((xr.NodeType == XmlNodeType.Element))
            {
                switch (xr.Name.ToLower())
                {
                case "tagref":
                    if (xr.AttributeCount == 3)
                    {
                        ret.Add_tag_ref(Int32.Parse(xr.GetAttribute("offset").Substring(2), NumberStyles.HexNumber), xr.GetAttribute("name"));
                    }
                    else if (xr.AttributeCount == 4)
                    {
                        ret.Add_WCtag_ref(Int32.Parse(xr.GetAttribute("offset").Substring(2), NumberStyles.HexNumber), xr.GetAttribute("name"));
                    }
                    break;

                case "dataref":
                    ret.Add_data_ref(Int32.Parse(xr.GetAttribute("offset").Substring(2), NumberStyles.HexNumber), xr.GetAttribute("name"));
                    break;

                case "stringid":
                    ret.Add_stringid_ref(Int32.Parse(xr.GetAttribute("offset").Substring(2), NumberStyles.HexNumber), xr.GetAttribute("name"));
                    break;

                case "reflexive":
                    string Tname       = xr.GetAttribute("name");
                    int    Toff        = Int32.Parse(xr.GetAttribute("offset").Substring(2), NumberStyles.HexNumber);
                    int    Tentry_size = Int32.Parse(xr.GetAttribute("entrySize").Substring(2), NumberStyles.HexNumber);;

                    ret.Add_field(Get_nodes(Tname, Toff, Tentry_size, xr, true));
                    break;
                }
            }
            //this is for the child nodes
            if (xr.NodeType == XmlNodeType.EndElement && (child))
            {
                switch (xr.Name.ToLower())
                {
                case "reflexive":
                    work_done = true;
                    break;
                }
            }
        }

        return(ret);
    }