Exemple #1
0
        public void ParsePlugin(string fileName)
        {
            List <mValue> list     = new List <mValue>();
            XmlDocument   document = new XmlDocument();

            document.Load(fileName);
            XmlElement documentElement = document.DocumentElement;

            TagClass   = documentElement.Attributes["class"].Value;
            HeaderSize = int.Parse(documentElement.Attributes["headersize"].Value);
            Revisions  = new List <mRevision>();
            ValueList  = new List <mValue>();
            for (int i = 0; i < documentElement.ChildNodes.Count; i++)
            {
                if (documentElement.ChildNodes[i].Name != "revision")
                {
                    mValue item = ReadNode(documentElement.ChildNodes[i]);
                    if (item.Attributes != mValue.ObjectAttributes.None)
                    {
                        ValueList.Add(item);
                    }
                }
                else
                {
                    mRevision revision = new mRevision {
                        Author      = documentElement.ChildNodes[i].Attributes["author"].Value,
                        Version     = float.Parse(documentElement.ChildNodes[i].Attributes["version"].Value),
                        Description = documentElement.ChildNodes[i].InnerText
                    };
                    Revisions.Add(revision);
                }
            }
        }
Exemple #2
0
        public uiEnum(mValue enumdata)
        {
            components = null;
            InitializeComponent();
            EnumData = (mEnum)enumdata;
            foreach (Control control in base.Controls)
            {
                control.ContextMenuStrip = contextMenuStrip1;
            }
            lblValueName.Text = EnumData.Name;
            EnumOptions       = EnumData.Options;
            switch (enumdata.Attributes)
            {
            case mValue.ObjectAttributes.Enum8:
                lblValueType.Text = "enum8";
                break;

            case mValue.ObjectAttributes.Enum16:
                lblValueType.Text = "enum16";
                break;

            case mValue.ObjectAttributes.Enum32:
                lblValueType.Text = "enum32";
                break;
            }
            LoadOptions();
            Editted = false;
        }
Exemple #3
0
        public void ParsePlugin(string fileName)
        {
            //Initialize our Value List.
            List <mValue> valueList = new List <mValue>();

            //Initialize our XmlDocument for parsing
            XmlDocument xmlDoc = new XmlDocument();

            //Load our plugin
            xmlDoc.Load(fileName);

            //Get the root to read the header information from
            XmlElement root = xmlDoc.DocumentElement;

            //Parse our basic information. Plugin Class first.
            TagClass = root.Attributes["class"].Value;
            //Now we parse the author.
            Author = root.Attributes["author"].Value;
            //Then we parse the version of the plugin.
            Version = float.Parse(root.Attributes["version"].Value);
            //Parse the headersize, which will indicate how big the Tag is without any reflexives.
            HeaderSize = int.Parse(root.Attributes["headersize"].Value);

            //Initialize our revision list incase there are revisions.
            Revisions = new List <mRevision>();
            //Initialize our value list.
            ValueList = new List <mValue>();
            //Loop through all the nodes
            for (int i = 0; i < root.ChildNodes.Count; i++)
            {
                //If the name isnt revision...
                if (root.ChildNodes[i].Name != "revision")
                {
                    //Then get the returned value.
                    mValue returnedVal = ReadNode(root.ChildNodes[i]);
                    //And if it isn't an unknown value
                    if (returnedVal.Attributes != mValue.ObjectAttributes.None)
                    {
                        //Then add it to the list.
                        ValueList.Add(returnedVal);
                    }
                }
                else
                {
                    //Otherwise...
                    //Initialize a new instance of our revision.
                    mRevision revision = new mRevision();
                    //Set the author for this revision.
                    revision.Author = root.ChildNodes[i].Attributes["author"].Value;
                    //Set the version for this revision.
                    revision.Version = float.Parse(root.ChildNodes[i].Attributes["version"].Value);
                    //Set the description for this revision.
                    revision.Description = root.ChildNodes[i].InnerText;
                    //Add the revision to the Revisions list.
                    Revisions.Add(revision);
                }
            }
        }
Exemple #4
0
        public iEnum(mValue enumdata)
        {
            InitializeComponent();
            //Set our Enum Data
            EnumData = (mEnum)enumdata;

            //Set our tooltip name.
            ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText =
                "Type: " + EnumData.Attributes.ToString() + Environment.NewLine +
                "Name: " + EnumData.Name + Environment.NewLine +
                "Offset: " + EnumData.Offset.ToString() + Environment.NewLine +
                "Visible: " + EnumData.Visible.ToString();

            //Loop through each control..
            for (int i = 0; i < this.Controls.Count; i++)
            {
                //Set the super tool tip info.
                try
                {
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).HeaderText    = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).BodyText      = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).FooterVisible = false;
                }
                catch
                {
                    this.superTooltip1.SetSuperTooltip(this.Controls[i], new DevComponents.DotNetBar.SuperTooltipInfo(((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText, "", ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText, null, null, DevComponents.DotNetBar.eTooltipColor.System, true, false, new System.Drawing.Size(0, 0)));
                }
            }

            //Set our enumName
            lblName.Text = EnumData.Name;
            //Set our enum options
            EnumOptions = EnumData.Options;
            //Determine our type of enum
            switch (enumdata.Attributes)
            {
            //set the data accordingly
            case mValue.ObjectAttributes.Enum8:
            {
                lblValueType.Text = "enum8";
                break;
            }

            case mValue.ObjectAttributes.Enum16:
            {
                lblValueType.Text = "enum16";
                break;
            }

            case mValue.ObjectAttributes.Enum32:
            {
                lblValueType.Text = "enum32";
                break;
            }
            }
            LoadOptions();
        }
Exemple #5
0
 public uiSlider(mValue valdata)
 {
     components = null;
     floater    = false;
     viewing    = false;
     InitializeComponent();
     foreach (Control control in base.Controls)
     {
         control.ContextMenuStrip = contextMenuStrip1;
     }
     ValueData         = valdata;
     lblValueName.Text = ValueData.Name;
     Editted           = false;
 }
Exemple #6
0
 public uiValue(mValue valdata)
 {
     floater     = false;
     viewing     = false;
     calculating = true;
     components  = null;
     InitializeComponent();
     foreach (Control control in base.Controls)
     {
         control.ContextMenuStrip = contextMenuStrip1;
     }
     ValueData         = valdata;
     lblValueName.Text = ValueData.Name;
     Editted           = false;
     if (valdata.Attributes == mValue.ObjectAttributes.Float)
     {
         MD_value.Visible = true;
     }
 }
Exemple #7
0
        public iBitmask(mValue bitmaskdata)
        {
            InitializeComponent();
            //Set our bitmask Data
            BitmaskData = bitmaskdata;

            //Chec what type of bitmask it is
            switch (BitmaskData.Attributes)
            {
            //Based off what type of bitmask it is, we set the name and count.
            case mValue.ObjectAttributes.Bitmask8:
            {
                mBitmask8 mbit8 = (mBitmask8)BitmaskData;
                lblName.Text  = mbit8.Name;
                lblCount.Text = "(8)";
                LoadBit8Options(mbit8);
                break;
            }

            case mValue.ObjectAttributes.Bitmask16:
            {
                mBitmask16 mbit16 = (mBitmask16)BitmaskData;
                lblName.Text  = mbit16.Name;
                lblCount.Text = "(16)";
                LoadBit16Options(mbit16);
                break;
            }

            case mValue.ObjectAttributes.Bitmask32:
            {
                mBitmask32 mbit32 = (mBitmask32)BitmaskData;
                lblName.Text  = mbit32.Name;
                lblCount.Text = "(32)";
                LoadBit32Options(mbit32);
                break;
            }
            }

            //Set our tooltip name.
            ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText =
                "Type: " + BitmaskData.Attributes.ToString() + Environment.NewLine +
                "Name: " + BitmaskData.Name + Environment.NewLine +
                "Offset: " + BitmaskData.Offset.ToString() + Environment.NewLine +
                "Visible: " + BitmaskData.Visible.ToString() + Environment.NewLine + Environment.NewLine +
                "OPTIONS:";

            //Loop for each option
            for (int i = 0; i < chkBits.Items.Count; i++)
            {
                if (chkBits.Items[i].ToString() != "Bit " + i.ToString())
                {
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText += Environment.NewLine + i.ToString() + " - " + chkBits.Items[i].ToString();
                }
            }
            //Loop through each control..
            for (int i = 0; i < this.Controls.Count; i++)
            {
                //Set the super tool tip info.
                try
                {
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).HeaderText    = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).BodyText      = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).FooterVisible = false;
                }
                catch
                {
                    this.superTooltip1.SetSuperTooltip(this.Controls[i], new DevComponents.DotNetBar.SuperTooltipInfo(((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText, "", ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText, null, null, DevComponents.DotNetBar.eTooltipColor.System, true, false, new System.Drawing.Size(0, 0)));
                }
            }
        }
Exemple #8
0
        private void LoadControls()
        {
            pnlContainer.Controls.Clear();

            int yLoc = 5;

            foreach (XmlNode n in element.ChildNodes)
            {
                iValue val;
                try { val = new iValue(n); }
                catch { continue; }
                if (!val.Visible && !showInvis)
                {
                    continue;
                }

                MetaViewerControl mvc = new MetaViewerControl();

                switch (val.Type)
                {
                case iValue.ValueType.Comment:
                    mvc = new mComment(val, cache);
                    break;

                case iValue.ValueType.Struct:
                    mvc = new mStructure(val, cache, tag, showInvis);
                    ((mStructure)mvc).RequestTagLoad += new RequestTagLoadEventHandler(MetaViewer_TagLoadRequested);
                    ((mStructure)mvc).ResizeNeeded   += new ResizeNeededEvent(mStructure_ResizeNeeded);
                    break;

                case iValue.ValueType.TagRef:
                    mvc = new mTagRef(val, cache);
                    ((mTagRef)mvc).RequestTagLoad += new RequestTagLoadEventHandler(MetaViewer_TagLoadRequested);
                    break;

                case iValue.ValueType.String:
                case iValue.ValueType.StringID:
                    mvc = new mString(val, cache);
                    break;

                case iValue.ValueType.Bitmask8:
                case iValue.ValueType.Bitmask16:
                case iValue.ValueType.Bitmask32:
                    mvc = new mBitmask(val, cache);
                    break;

                case iValue.ValueType.Int8:
                case iValue.ValueType.Int16:
                case iValue.ValueType.Int32:
                case iValue.ValueType.Float32:
                case iValue.ValueType.UInt16:
                case iValue.ValueType.UInt32:
                case iValue.ValueType.Undefined:
                case iValue.ValueType.RawID:
                    mvc = new mValue(val, cache);
                    break;

                case iValue.ValueType.Enum8:
                case iValue.ValueType.Enum16:
                case iValue.ValueType.Enum32:
                    mvc = new mEnum(val, cache);
                    break;

                case iValue.ValueType.ShortBounds:
                case iValue.ValueType.RealBounds:
                case iValue.ValueType.ShortPoint2D:
                case iValue.ValueType.RealPoint2D:
                case iValue.ValueType.RealPoint3D:
                case iValue.ValueType.RealPoint4D:
                case iValue.ValueType.RealVector2D:
                case iValue.ValueType.RealVector3D:
                case iValue.ValueType.RealVector4D:
                case iValue.ValueType.Colour32RGB:
                case iValue.ValueType.Colour32ARGB:
                    mvc = new mMultiValue(val, cache);
                    break;
                }

                mvc.Reload(tag.Offset);
                if (mvc is mStructure || mvc is mComment)
                {
                    yLoc += 5;
                }
                mvc.Location = new Point(5, yLoc);
                yLoc        += mvc.Height;
                if (mvc is mStructure || mvc is mComment)
                {
                    yLoc += 5;
                }
                pnlContainer.Controls.Add(mvc);
            }
        }
Exemple #9
0
        public void WriteNode(XmlTextWriter xtw, mValue mVal)
        {
            //Determine our value type
            switch (mVal.Attributes)
            {
            case mValue.ObjectAttributes.Bitmask8:
            {
                //Write our values
                xtw.WriteStartElement("bitmask8");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a bitmask8
                foreach (mBitOption bit in ((mBitmask8)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", bit.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", bit.BitIndex.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Bitmask16:
            {
                //Write our values
                xtw.WriteStartElement("bitmask16");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a bitmask16
                foreach (mBitOption bit in ((mBitmask16)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", bit.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", bit.BitIndex.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Bitmask32:
            {
                //Write our values
                xtw.WriteStartElement("bitmask32");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a bitmask32
                foreach (mBitOption bit in ((mBitmask32)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", bit.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", bit.BitIndex.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Enum8:
            {
                //Write our values
                xtw.WriteStartElement("enum8");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a enum
                foreach (mEnumOption opt in ((mEnum8)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", opt.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", opt.Value.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Enum16:
            {
                //Write our values
                xtw.WriteStartElement("enum16");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a enum
                foreach (mEnumOption opt in ((mEnum16)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", opt.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", opt.Value.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Enum32:
            {
                //Write our values
                xtw.WriteStartElement("enum32");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());

                //Get our value as a enum
                foreach (mEnumOption opt in ((mEnum32)mVal).Options)
                {
                    //Write our bit start
                    xtw.WriteStartElement("option");

                    //Write our name
                    xtw.WriteAttributeString("name", opt.Name);

                    //Write our value
                    xtw.WriteAttributeString("value", opt.Value.ToString());

                    //Write our end element
                    xtw.WriteEndElement();
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Byte:
            {
                //Write our values
                xtw.WriteStartElement("byte");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Float:
            {
                //Write our values
                xtw.WriteStartElement("float");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Int16:
            {
                //Write our values
                xtw.WriteStartElement("short");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Int32:
            {
                //Write our values
                xtw.WriteStartElement("int");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.String32:
            {
                //Write our values
                xtw.WriteStartElement("string32");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.String256:
            {
                //Write our values
                xtw.WriteStartElement("string256");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.StringID:
            {
                //Write our values
                xtw.WriteStartElement("stringid");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.TagRef:
            {
                //Write our values
                xtw.WriteStartElement("tag");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Ident:
            {
                //Write our values
                xtw.WriteStartElement("id");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.UInt16:
            {
                //Write our values
                xtw.WriteStartElement("ushort");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.UInt32:
            {
                //Write our values
                xtw.WriteStartElement("uint");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Undefined:
            {
                //Write our values
                xtw.WriteStartElement("undefined");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Unicode64:
            {
                //Write our values
                xtw.WriteStartElement("unicode64");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Unicode256:
            {
                //Write our values
                xtw.WriteStartElement("unicode256");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Unused:
            {
                //Write our values
                xtw.WriteStartElement("unused");
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("size", ((mUnused)mVal).Size.ToString());
                //Write our end element
                xtw.WriteEndElement();
                break;
            }

            case mValue.ObjectAttributes.Reflexive:
            {
                //Write our values
                xtw.WriteStartElement("struct");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteAttributeString("size", ((mReflexive)mVal).Size.ToString());
                //Loop for each child
                foreach (mValue val2 in ((mReflexive)mVal).Values)
                {
                    //Write our node
                    WriteNode(xtw, val2);
                }

                //Write our end element
                xtw.WriteEndElement();
                break;
            }
            }
        }
Exemple #10
0
        private mValue ReadNode(XmlNode xmlNode)
        {
            //Indiciate what type of value this is.
            switch (xmlNode.Name.ToLower())
            {
            case "reflexive":
            case "structure":
            case "reflex":
            case "struct":
            {
                //Initialize our instance of a reflexive.
                mReflexive reflexive = new mReflexive();
                //Retrieve the structure's name.
                reflexive.Name = xmlNode.Attributes["name"].Value;
                //Retrieve its offset within its parent.
                reflexive.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Retrieve its chunk size.
                reflexive.Size = int.Parse(xmlNode.Attributes["size"].Value);
                //Retrieve its visibility flag.
                reflexive.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);

                //Initialize the value list for the reflexive
                reflexive.Values = new List <mValue>();

                //Recursively add any nodes that belong to it.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //Get our returned value.
                    mValue returnedVal = ReadNode(xmlNode.ChildNodes[i]);

                    //If its not some unknown node that couldnt be read...
                    if (returnedVal.Attributes != mValue.ObjectAttributes.None)
                    {
                        //Then add it to this reflexive value list.
                        reflexive.Values.Add(returnedVal);
                    }
                }
                //Return our reflexive
                return(reflexive);
            }

            case "tagref":
            case "tag":
            {
                //Initialize our instance of TagRef
                mTagRef tagRef = new mTagRef();
                //Assign the name
                tagRef.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                tagRef.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                tagRef.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(tagRef);
            }

            case "ident":
            case "id":
            case "tagid":
            {
                //Initialize our instance of ident
                mIdent ident = new mIdent();
                //Assign the name
                ident.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                ident.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                ident.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(ident);
            }

            case "sid":
            case "stringid":
            case "stringidentifier":
            {
                //Initialize our instance of string
                mStringID stringID = new mStringID();
                //Assign the name
                stringID.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                stringID.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                stringID.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(stringID);
            }

            case "bitmask8":
            case "bit8":
            {
                //Initialize our instance of bitmask8
                mBitmask8 bitmask8 = new mBitmask8();
                //Assign the name
                bitmask8.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask8.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask8.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask8.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask8);
            }

            case "bitmask16":
            case "bit16":
            {
                //Initialize our instance of bitmask16
                mBitmask16 bitmask16 = new mBitmask16();
                //Assign the name
                bitmask16.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask16.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask16.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask16.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask16);
            }

            case "bitmask32":
            case "bit32":
            {
                //Initialize our instance of bitmask32
                mBitmask32 bitmask32 = new mBitmask32();
                //Assign the name
                bitmask32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask32.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask32.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask32);
            }

            case "enum8":
            {
                //Initialize our instance of enum8
                mEnum8 enum8 = new mEnum8();
                //Assign the name
                enum8.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum8.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum8.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum8.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum8);
            }

            case "enum16":
            {
                //Initialize our instance of enum16
                mEnum16 enum16 = new mEnum16();
                //Assign the name
                enum16.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum16.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum16.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum16.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum16);
            }

            case "enum32":
            {
                //Initialize our instance of enum32
                mEnum32 enum32 = new mEnum32();
                //Assign the name
                enum32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum32.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum32.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum32);
            }

            case "int8":
            case "byte":
            {
                //Initialize our instance of byte
                mByte byteVal = new mByte();
                //Assign the name
                byteVal.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                byteVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                byteVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(byteVal);
            }

            case "int16":
            case "short":
            {
                //Initialize our instance of int16
                mInt16 int16Val = new mInt16();
                //Assign the name
                int16Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                int16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                int16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(int16Val);
            }

            case "uint16":
            case "ushort":
            {
                //Initialize our instance of uint16
                mUInt16 uint16Val = new mUInt16();
                //Assign the name
                uint16Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                uint16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                uint16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(uint16Val);
            }

            case "int32":
            case "long":
            case "int":
            {
                //Initialize our instance of int32
                mInt32 int32Val = new mInt32();
                //Assign the name
                int32Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                int32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                int32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(int32Val);
            }

            case "uint32":
            case "ulong":
            case "uint":
            {
                //Initialize our instance of uint32
                mUInt32 uint32Val = new mUInt32();
                //Assign the name
                uint32Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                uint32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                uint32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(uint32Val);
            }

            case "single":
            case "float":
            {
                //Initialize our instance of float
                mFloat floatVal = new mFloat();
                //Assign the name
                floatVal.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                floatVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                floatVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(floatVal);
            }

            case "string32":
            case "32string":
            {
                //Initialize our instance of string32
                mString32 string32 = new mString32();
                //Assign the name
                string32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                string32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                string32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(string32);
            }

            case "string256":
            case "256string":
            {
                //Initialize our instance of string32
                mString256 string256 = new mString256();
                //Assign the name
                string256.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                string256.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                string256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(string256);
            }

            case "unic64":
            case "unicode64":
            case "64unic":
            case "64unicode":
            {
                //Initialize our instance of unicode64
                mUnicode64 unicode64 = new mUnicode64();
                //Assign the name
                unicode64.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                unicode64.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unicode64.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(unicode64);
            }

            case "unic256":
            case "unicode256":
            case "256unic":
            case "256unicode":
            {
                //Initialize our instance of unicode64
                mUnicode256 unicode256 = new mUnicode256();
                //Assign the name
                unicode256.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                unicode256.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unicode256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(unicode256);
            }

            case "undefined":
            case "unknown":
            {
                //Initialize our instance of undefined
                mUndefined undefined = new mUndefined();
                //Assign the name
                undefined.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                undefined.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                undefined.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(undefined);
            }

            case "unused":
            case "blank":
            {
                //Initialize our instance of undefined
                mUnused unused = new mUnused();
                //Assign the offset
                unused.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unused.Size = int.Parse(xmlNode.Attributes["size"].Value);
                //return the value
                return(unused);
            }
            }
            //If all else fails, make a 'none' value.
            mValue blankVal = new mValue();

            blankVal.Attributes = mValue.ObjectAttributes.None;
            return(blankVal);
        }
Exemple #11
0
        public iValue(mValue valdata)
        {
            InitializeComponent();
            //Set our value data.
            ValueData = valdata;

            //Set our tooltip name.
            ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText =
                "Type: " + ValueData.Attributes.ToString() + Environment.NewLine +
                "Name: " + ValueData.Name + Environment.NewLine +
                "Offset: " + ValueData.Offset.ToString() + Environment.NewLine +
                "Visible: " + ValueData.Visible.ToString() + Environment.NewLine + Environment.NewLine;
            //Set our type
            ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText = ValueData.Attributes.ToString();

            //Determine our type
            switch (ValueData.Attributes)
            {
            case mValue.ObjectAttributes.Byte:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a byte.";
                break;
            }

            case mValue.ObjectAttributes.Float:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a floating point integer(4 bytes in length).";
                break;
            }

            case mValue.ObjectAttributes.Int16:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a short(int16, 2 bytes in length).";
                break;
            }

            case mValue.ObjectAttributes.Int32:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a integer/long(int32, 4 bytes in length).";
                break;
            }

            case mValue.ObjectAttributes.UInt16:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a unsigned-short(uint16, 2 bytes in length).";
                break;
            }

            case mValue.ObjectAttributes.UInt32:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a unsigned-integer/long(uint32, 4 bytes in length).";
                break;
            }

            case mValue.ObjectAttributes.Undefined:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is undefined, and will be read as a floating-point integer.";
                break;
            }

            case mValue.ObjectAttributes.String32:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a 32-byte long ASCII string.";
                break;
            }

            case mValue.ObjectAttributes.String256:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a 256-byte long ASCII string.";
                break;
            }

            case mValue.ObjectAttributes.Unicode64:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a 64-byte long Unicode string.";
                break;
            }

            case mValue.ObjectAttributes.Unicode256:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a 64-byte long Unicode string.";
                break;
            }

            case mValue.ObjectAttributes.StringID:
            {
                //Set our tooltip name.
                ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText +=
                    "This value is a StringID.";
                break;
            }
            }

            //Loop through each control..
            for (int i = 0; i < this.Controls.Count; i++)
            {
                //Set the super tool tip info.
                try
                {
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).HeaderText    = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).BodyText      = ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText;
                    ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this.Controls[i]]).FooterVisible = false;
                }
                catch
                {
                    this.superTooltip1.SetSuperTooltip(this.Controls[i], new DevComponents.DotNetBar.SuperTooltipInfo(((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).HeaderText, "", ((SuperTooltipInfo)superTooltip1.SuperTooltipInfoTable[this]).BodyText, null, null, DevComponents.DotNetBar.eTooltipColor.System, true, false, new System.Drawing.Size(0, 0)));
                }
            }

            //Set our Name
            lblName.Text = ValueData.Name;
            //Set our valueType
            lblType.Text = ValueData.Attributes.ToString().ToLower();
        }
Exemple #12
0
        private mValue ReadNode(XmlNode xmlNode)
        {
            int         num;
            mColorBlock block2;
            mBitOption  option;
            mEnumOption option2;
            string      str3 = xmlNode.Name.ToLower();

            switch (str3)
            {
            case "reflexive":
            case "structure":
            case "reflex":
            case "struct":
            case "tagblock":
            case "block":
            {
                mTagBlock block = new mTagBlock {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Size    = int.Parse(xmlNode.Attributes["size"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Values  = new List <mValue>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    mValue item = ReadNode(xmlNode.ChildNodes[num]);
                    if (item.Attributes != mValue.ObjectAttributes.None)
                    {
                        block.Values.Add(item);
                    }
                }
                return(block);
            }

            case "tagdata":
            case "void":
                return(new mTagData {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "array":
            case "bytearray":
            case "bytes":
                return(new mByteArray {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "comment":
            case "note":
                return(new mComment {
                    Title = xmlNode.Attributes["title"].Value,
                    Description = xmlNode.InnerText.Replace(@"\n", "\n").Replace(@"\t", "\t").Replace(@"\'", "\""),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "color8":
            case "color16":
            case "color32":
            case "colorf":
                if (xmlNode.Name.ToLower() != "color8")
                {
                    if (xmlNode.Name.ToLower() == "color16")
                    {
                        block2 = new mColorBlock16();
                    }
                    else if (xmlNode.Name.ToLower() == "color32")
                    {
                        block2 = new mColorBlock32();
                    }
                    else
                    {
                        block2 = new mColorBlockF();
                    }
                    break;
                }
                block2 = new mColorBlock8();
                break;

            case "tagref":
            case "tag":
            case "tagid":
                return(new mTagReference {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "sid":
            case "stringid":
            case "stringidentifier":
                return(new mStringID {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "bitmask8":
            case "bit8":
            {
                mBitmask8 bitmask = new mBitmask8 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask.Options.Add(option);
                    }
                }
                return(bitmask);
            }

            case "bitmask16":
            case "bit16":
            {
                mBitmask16 bitmask2 = new mBitmask16 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask2.Options.Add(option);
                    }
                }
                return(bitmask2);
            }

            case "bitmask32":
            case "bit32":
            {
                mBitmask32 bitmask3 = new mBitmask32 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mBitOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if ((xmlNode.ChildNodes[num].Name.ToLower() == "bit") | (xmlNode.ChildNodes[num].Name.ToLower() == "option"))
                    {
                        option = new mBitOption {
                            Name = xmlNode.ChildNodes[num].Attributes["name"].Value
                        };
                        try
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["index"].Value);
                        }
                        catch
                        {
                            option.BitIndex = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value);
                        }
                        bitmask3.Options.Add(option);
                    }
                }
                return(bitmask3);
            }

            case "enum8":
            {
                mEnum8 enum2 = new mEnum8 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum2.Options.Add(option2);
                    }
                }
                return(enum2);
            }

            case "enum16":
            {
                mEnum16 enum3 = new mEnum16 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum3.Options.Add(option2);
                    }
                }
                return(enum3);
            }

            case "enum32":
            {
                mEnum32 enum4 = new mEnum32 {
                    Name    = xmlNode.Attributes["name"].Value,
                    Offset  = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Options = new List <mEnumOption>()
                };
                for (num = 0; num < xmlNode.ChildNodes.Count; num++)
                {
                    if (xmlNode.ChildNodes[num].Name.ToLower() == "option")
                    {
                        option2 = new mEnumOption {
                            Name  = xmlNode.ChildNodes[num].Attributes["name"].Value,
                            Value = int.Parse(xmlNode.ChildNodes[num].Attributes["value"].Value)
                        };
                        enum4.Options.Add(option2);
                    }
                }
                return(enum4);
            }

            case "int8":
            case "byte":
                return(new mByte {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "int16":
            case "short":
                return(new mInt16 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "uint16":
            case "ushort":
                return(new mUInt16 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "int32":
            case "long":
            case "int":
                return(new mInt32 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "uint32":
            case "ulong":
            case "uint":
                return(new mUInt32 {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "single":
            case "float":
                return(new mFloat {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "string":
            case "str":
                return(new mString {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "unic":
            case "unicode":
                return(new mUnicode {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value),
                    Length = int.Parse(xmlNode.Attributes["length"].Value)
                });

            case "undefined":
            case "unknown":
                return(new mUndefined {
                    Name = xmlNode.Attributes["name"].Value,
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Visible = bool.Parse(xmlNode.Attributes["visible"].Value)
                });

            case "unused":
            case "blank":
                return(new mUnused {
                    Offset = int.Parse(xmlNode.Attributes["offset"].Value),
                    Size = int.Parse(xmlNode.Attributes["size"].Value)
                });

            default:
                return(new mValue {
                    Attributes = mValue.ObjectAttributes.None
                });
            }
            block2.Name       = xmlNode.Attributes["name"].Value;
            block2.Offset     = int.Parse(xmlNode.Attributes["offset"].Value);
            block2.Visible    = bool.Parse(xmlNode.Attributes["visible"].Value);
            block2.Real_Color = bool.Parse(xmlNode.Attributes["real"].Value);
            string str = xmlNode.Attributes["order"].Value;

            foreach (char ch in str)
            {
                str3 = ch.ToString().ToUpper();
                if (str3 != null)
                {
                    if (str3 != "R")
                    {
                        if (str3 == "G")
                        {
                            goto Label_07F1;
                        }
                        if (str3 == "B")
                        {
                            goto Label_0802;
                        }
                        if (str3 == "A")
                        {
                            goto Label_0813;
                        }
                        if (str3 == "N")
                        {
                            goto Label_0824;
                        }
                    }
                    else
                    {
                        block2.Color_Order.Add(ColorBlockPart.Red);
                    }
                }
                continue;
Label_07F1:
                block2.Color_Order.Add(ColorBlockPart.Green);
                continue;
Label_0802:
                block2.Color_Order.Add(ColorBlockPart.Blue);
                continue;
Label_0813:
                block2.Color_Order.Add(ColorBlockPart.Alpha);
                continue;
Label_0824:
                block2.Color_Order.Add(ColorBlockPart.None);
            }
            return(block2);
        }
Exemple #13
0
        public void WriteNode(XmlTextWriter xtw, mValue mVal)
        {
            mColorBlock block;

            switch (mVal.Attributes)
            {
            case mValue.ObjectAttributes.Comment:
                xtw.WriteStartElement("comment");
                xtw.WriteAttributeString("title", ((mComment)mVal).Title);
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteString(((mComment)mVal).Description);
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.ByteArray:
                xtw.WriteStartElement("bytearray");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteAttributeString("length", ((mByteArray)mVal).Length.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.ColorBlock8:
            case mValue.ObjectAttributes.ColorBlock16:
            case mValue.ObjectAttributes.ColorBlock32:
            case mValue.ObjectAttributes.ColorBlockF:
                block = (mColorBlock)mVal;
                switch (mVal.Attributes)
                {
                case mValue.ObjectAttributes.ColorBlock8:
                    xtw.WriteStartElement("color8");
                    goto Label_0CDE;

                case mValue.ObjectAttributes.ColorBlock16:
                    xtw.WriteStartElement("color16");
                    goto Label_0CDE;

                case mValue.ObjectAttributes.ColorBlock32:
                    xtw.WriteStartElement("color32");
                    goto Label_0CDE;

                case mValue.ObjectAttributes.ColorBlockF:
                    xtw.WriteStartElement("colorf");
                    goto Label_0CDE;
                }
                break;

            case mValue.ObjectAttributes.TagBlock:
                xtw.WriteStartElement("struct");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteAttributeString("size", ((mTagBlock)mVal).Size.ToString());
                foreach (mValue value2 in ((mTagBlock)mVal).Values)
                {
                    WriteNode(xtw, value2);
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.TagData:
                xtw.WriteStartElement("tagdata");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.TagReference:
                xtw.WriteStartElement("tagref");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.StringID:
                xtw.WriteStartElement("stringid");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Unicode:
                xtw.WriteStartElement("unicode");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteAttributeString("length", ((mUnicode)mVal).Length.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.String:
                xtw.WriteStartElement("string");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteAttributeString("length", ((mString)mVal).Length.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Bitmask8:
                xtw.WriteStartElement("bitmask8");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mBitOption option in ((mBitmask8)mVal).Options)
                {
                    xtw.WriteStartElement("bit");
                    xtw.WriteAttributeString("name", option.Name);
                    xtw.WriteAttributeString("index", option.BitIndex.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Bitmask16:
                xtw.WriteStartElement("bitmask16");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mBitOption option in ((mBitmask16)mVal).Options)
                {
                    xtw.WriteStartElement("bit");
                    xtw.WriteAttributeString("name", option.Name);
                    xtw.WriteAttributeString("index", option.BitIndex.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Bitmask32:
                xtw.WriteStartElement("bitmask32");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mBitOption option in ((mBitmask32)mVal).Options)
                {
                    xtw.WriteStartElement("bit");
                    xtw.WriteAttributeString("name", option.Name);
                    xtw.WriteAttributeString("index", option.BitIndex.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Float:
                xtw.WriteStartElement("float");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Int16:
                xtw.WriteStartElement("short");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.UInt16:
                xtw.WriteStartElement("ushort");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Int32:
                xtw.WriteStartElement("int");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.UInt32:
                xtw.WriteStartElement("uint");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Byte:
                xtw.WriteStartElement("byte");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Enum8:
                xtw.WriteStartElement("enum8");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mEnumOption option2 in ((mEnum8)mVal).Options)
                {
                    xtw.WriteStartElement("option");
                    xtw.WriteAttributeString("name", option2.Name);
                    xtw.WriteAttributeString("value", option2.Value.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Enum16:
                xtw.WriteStartElement("enum16");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mEnumOption option2 in ((mEnum16)mVal).Options)
                {
                    xtw.WriteStartElement("option");
                    xtw.WriteAttributeString("name", option2.Name);
                    xtw.WriteAttributeString("value", option2.Value.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Enum32:
                xtw.WriteStartElement("enum32");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                foreach (mEnumOption option2 in ((mEnum32)mVal).Options)
                {
                    xtw.WriteStartElement("option");
                    xtw.WriteAttributeString("name", option2.Name);
                    xtw.WriteAttributeString("value", option2.Value.ToString());
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Undefined:
                xtw.WriteStartElement("undefined");
                xtw.WriteAttributeString("name", mVal.Name);
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("visible", mVal.Visible.ToString());
                xtw.WriteEndElement();
                return;

            case mValue.ObjectAttributes.Unused:
                xtw.WriteStartElement("unused");
                xtw.WriteAttributeString("offset", mVal.Offset.ToString());
                xtw.WriteAttributeString("size", ((mUnused)mVal).Size.ToString());
                xtw.WriteEndElement();
                return;

            default:
                return;
            }
Label_0CDE:
            xtw.WriteAttributeString("name", block.Name);
            xtw.WriteAttributeString("offset", block.Offset.ToString());
            xtw.WriteAttributeString("visible", mVal.Visible.ToString());
            xtw.WriteAttributeString("real", block.Real_Color.ToString());
            string str = "";

            using (List <ColorBlockPart> .Enumerator enumerator4 = block.Color_Order.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    switch (enumerator4.Current)
                    {
                    case ColorBlockPart.None:
                        str = str + "N";
                        break;

                    case ColorBlockPart.Red:
                        str = str + "R";
                        break;

                    case ColorBlockPart.Green:
                        str = str + "G";
                        break;

                    case ColorBlockPart.Blue:
                        str = str + "B";
                        break;

                    case ColorBlockPart.Alpha:
                        str = str + "A";
                        break;
                    }
                }
            }
            xtw.WriteAttributeString("order", str);
            xtw.WriteEndElement();
        }