示例#1
0
        public void Read(int tagoff, string st, ref Panel Meta, TagObject ST, Map map)
        {
            #region Reading
            string C = st.Replace('*', '!');
            C = C.Replace('/', '_');
            C = C.Replace('\\', '_');
            C = C.Replace('<', '_');
            C = C.Replace('>', '_');
            string Location = Application.StartupPath + "\\Plugins\\" + C + ".Xml";

            if (!File.Exists(Location))
            {
                MessageBox.Show("Can not find plugin!");
            }
            else
            {
                xr = new XmlTextReader(new FileStream(Location, FileMode.Open, FileAccess.Read, FileShare.Read));

                Controls.Clear();
                Meta.Hide();
                Meta.Refresh();
                Meta.SuspendLayout();
                Class   = "";
                Author  = "";
                Version = "";
                while (xr.Read())
                {
                    switch (xr.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        switch (xr.Name.ToLower())
                        {
                        case "plugin":
                        {
                            Class   = xr.GetAttribute("class");
                            Author  = xr.GetAttribute("author");
                            Version = xr.GetAttribute("version");
                            break;
                        }

                        case "revision":
                        {
                            Revisions.Add(xr.ReadElementString());
                            break;
                        }

                        case "byte":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(byte), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "short":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(short), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "ushort":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(ushort), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "int":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(int), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "uint":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(uint), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "float":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(float), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "string":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            int    Length      = Convert.ToInt32(xr.GetAttribute("length"));
                            Value  b           = new Value(Description, typeof(string), "", Length, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "unknown":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(int), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "long":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Value  b           = new Value(Description, typeof(long), 0, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "ident":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            Ident  i           = new Ident("Null", 0, tagoff, Offset, Description, map);
                            Controls.Add(i);
                            i.Dock = DockStyle.Top;
                            i.BringToFront();
                            break;
                        }

                        case "reflexive":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            int    Size        = Convert.ToInt32(xr.GetAttribute("size"));
                            map.Reader.BaseStream.Position = ((Offset + tagoff) - map.Index.SecondaryMagic);
                            Reflexive b = new Reflexive(map, Description, map.Reader.ReadInt32(), tagoff, Offset, Size, xr.ReadSubtree());
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "stringid":
                        {
                            string   Description = xr.GetAttribute("name");
                            int      Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            StringID b           = new StringID(Description, tagoff, Offset, 0, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "enum8":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic);
                            //int Index = map.Reader.ReadByte();
                            List <string> Items  = new List <string>();
                            List <int>    Values = new List <int>();
                            XmlReader     x      = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Enum e = new Enum(Description, tagoff, Offset, typeof(byte), Items, Values, 0, map);
                            Controls.Add(e);
                            e.Dock = DockStyle.Top;
                            e.BringToFront();
                            break;
                        }

                        case "enum16":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic);
                            //int Index = map.Reader.ReadInt16();
                            List <string> Items  = new List <string>();
                            List <int>    Values = new List <int>();
                            XmlReader     x      = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Enum e = new Enum(Description, tagoff, Offset, typeof(short), Items, Values, 0, map);
                            Controls.Add(e);
                            e.Dock = DockStyle.Top;
                            e.BringToFront();
                            break;
                        }

                        case "enum32":
                        {
                            string Description = xr.GetAttribute("name");
                            int    Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            //map.Reader.BaseStream.Position = ((Offset+tagoff) - map.Index.SecondaryMagic);
                            //int Index = map.Reader.ReadInt32();
                            List <string> Items  = new List <string>();
                            List <int>    Values = new List <int>();
                            XmlReader     x      = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Enum e = new Enum(Description, tagoff, Offset, typeof(int), Items, Values, 0, map);
                            Controls.Add(e);
                            e.Dock = DockStyle.Top;
                            e.BringToFront();
                            break;
                        }

                        case "bitmask8":
                        {
                            string        Description = xr.GetAttribute("name");
                            int           Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            List <string> Items       = new List <string>();
                            List <int>    Values      = new List <int>();
                            XmlReader     x           = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Bitmask b = new Bitmask(Description, typeof(byte), Items, Values, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "bitmask16":
                        {
                            string        Description = xr.GetAttribute("name");
                            int           Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            List <string> Items       = new List <string>();
                            List <int>    Values      = new List <int>();
                            XmlReader     x           = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Bitmask b = new Bitmask(Description, typeof(short), Items, Values, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "bitmask32":
                        {
                            string        Description = xr.GetAttribute("name");
                            int           Offset      = Convert.ToInt32(xr.GetAttribute("offset"));
                            List <string> Items       = new List <string>();
                            List <int>    Values      = new List <int>();
                            XmlReader     x           = xr.ReadSubtree();
                            while (x.Read())
                            {
                                switch (x.Name.ToLower())
                                {
                                case "option":
                                {
                                    Items.Add(xr.GetAttribute("name"));
                                    Values.Add(Convert.ToInt32(xr.GetAttribute("value")));
                                    break;
                                }
                                }
                            }
                            Bitmask b = new Bitmask(Description, typeof(int), Items, Values, tagoff, Offset, map);
                            Controls.Add(b);
                            b.Dock = DockStyle.Top;
                            b.BringToFront();
                            break;
                        }

                        case "string32":
                        {
                            //string Description = xr.GetAttribute("name");
                            //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset;
                            //map.br.BaseStream.Position = Offset;
                            //string Value = new string(map.br.ReadChars(32));
                            //String s = new String(Description, Offset, ValueringType.String32);
                            //Controls.Add(s);
                            //s.Dock = DockStyle.Top;
                            //s.BringToFront();
                            break;
                        }

                        case "string64":
                        {
                            //string Description = xr.GetAttribute("name");
                            //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset;
                            //map.br.BaseStream.Position = Offset;
                            //string Value = new string(map.br.ReadChars(64));
                            //String s = new String(Description, Offset, ValueringType.String64);
                            //Controls.Add(s);
                            //s.Dock = DockStyle.Top;
                            //s.BringToFront();
                            break;
                        }

                        case "unicode64":
                        {
                            //string Description = xr.GetAttribute("name");
                            //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset;
                            //map.br.BaseStream.Position = Offset;
                            //string Value = "";
                            //for (int i = 0; i < 32; i++)
                            //{
                            //    Value += Convert.ToChar(map.br.ReadByte());
                            //    map.br.BaseStream.Position++;
                            //}
                            //String s = new String(Description, Offset, ValueringType.Unicode64);
                            //Controls.Add(s);
                            //s.Dock = DockStyle.Top;
                            //s.BringToFront();
                            break;
                        }

                        case "unicode256":
                        {
                            //string Description = xr.GetAttribute("name");
                            //int Offset = Convert.ToInt32(xr.GetAttribute("offset")) + map.SelectedTag.MetaOffset;
                            //map.br.BaseStream.Position = Offset;
                            //string Value = "";
                            //for (int i = 0; i < 128; i++)
                            //{
                            //    Value += Convert.ToChar(map.br.ReadByte());
                            //    map.br.BaseStream.Position++;
                            //}
                            //String s = new String(Description, Offset, ValueringType.Unicode256);
                            //Controls.Add(s);
                            //s.Dock = DockStyle.Top;
                            //s.BringToFront();
                            break;
                        }
                        }
                        break;
                    }
                    }
                }

                xr.Close();

                //Load Controls
                for (int i = Controls.Count - 1; i > -1; i--)
                {
                    Meta.Controls.Add(Controls[i]);
                }
                Meta.ResumeLayout(true);
                Meta.Show();
            }
            #endregion
        }
示例#2
0
 public void ReadControls()
 {
     Reader.ReadStartElement();
     List<Control> Controls = new List<Control>();
     while (Reader.Read())
         {
             switch (Reader.NodeType)
             {
                 case XmlNodeType.Element:
                     {
                         switch (Reader.Name.ToLower())
                         {
                             case "byte":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(byte), 0,RawTranslation, Offset,Map);
                                     else
                                        b = new Value(Description, typeof(byte), -1,RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "short":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(short), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(short), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "ushort":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(ushort), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(ushort), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "int":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(int), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(int), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "uint":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(uint), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(uint), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "float":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(float), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(float), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "string":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     int Length = Convert.ToInt32(Reader.GetAttribute("length"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(string), "",Length,RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(string), "Null",0,RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "unknown":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(int), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(int), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "long":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Value b;
                                     if (Count > 0)
                                         b = new Value(Description, typeof(long), 0, RawTranslation, Offset,Map);
                                     else
                                         b = new Value(Description, typeof(long), -1, RawTranslation, Offset,Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "ident":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     Ident i;
                                     if (Count > 0)
                                     {
                                         try
                                         {
                                             i = new Ident("", 0,RawTranslation,Offset, Description, Map);
                                         }
                                         catch (Exception)
                                         {
                                             i = new Ident("Null", -1,RawTranslation, Offset, Description, Map);
                                         }
                                     }
                                     else
                                          i = new Ident("Null", -1,RawTranslation, Offset, Description, Map);
                                     Controls.Add(i);
                                     i.Dock = DockStyle.Top;
                                     i.BringToFront();
                                     break;
                                 }
                             case "reflexive":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     int Size = Convert.ToInt32(Reader.GetAttribute("size"));
                                     Reflexive b;
                                     if (Count > 0)
                                     {
                                         Map.Reader.BaseStream.Position = ((Offset+RawTranslation) - Map.Index.SecondaryMagic);
                                         b = new Reflexive(Map, Description, Map.Reader.ReadInt32(),RawTranslation, Offset, Size, Reader.ReadSubtree());
                                     }
                                     else
                                         b = new Reflexive(Map, Description, 0,RawTranslation, Offset, Size, Reader.ReadSubtree());
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "stringid":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     StringID b;
                                     if (Count > 0)
                                         b = new StringID(Description,RawTranslation, Offset, 0, Map);
                                     else
                                         b = new StringID(Description,RawTranslation, Offset, -1, Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "enum8":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Enum e;
                                     if (Count > 0)
                                         e = new Enum(Description,RawTranslation, Offset, typeof(byte), Items, Values, 0,Map);
                                     else
                                         e = new Enum(Description,RawTranslation, Offset, typeof(byte), new List<string>(), new List<int>(), -1,Map);
                                     Controls.Add(e);
                                     e.Dock = DockStyle.Top;
                                     e.BringToFront();
                                     break;
                                 }
                             case "enum16":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Enum e;
                                     if (Count > 0)
                                         e = new Enum(Description, RawTranslation, Offset, typeof(int), Items, Values, 0,Map);
                                     else
                                         e = new Enum(Description, RawTranslation, Offset, typeof(int), new List<string>(), new List<int>(), -1,Map);
                                     Controls.Add(e);
                                     e.Dock = DockStyle.Top;
                                     e.BringToFront();
                                     break;
                                 }
                             case "enum32":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Enum e;
                                     if (Count > 0)
                                         e = new Enum(Description, RawTranslation, Offset, typeof(int), Items, Values, 0,Map);
                                     else
                                         e = new Enum(Description, RawTranslation, Offset, typeof(int), new List<string>(), new List<int>(), -1,Map);
                                     Controls.Add(e);
                                     e.Dock = DockStyle.Top;
                                     e.BringToFront();
                                     break;
                                 }
                             case "bitmask8":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Bitmask b;
                                     if (Count > 0)
                                         b = new Bitmask(Description, typeof(byte), Items, Values, RawTranslation, Offset, Map);
                                     else
                                         b = new Bitmask(Description, -1, typeof(byte), Items, Values, RawTranslation, Offset, Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "bitmask16":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Bitmask b;
                                     if (Count > 0)
                                         b = new Bitmask(Description, typeof(short), Items, Values, RawTranslation, Offset, Map);
                                     else
                                         b = new Bitmask(Description,-1, typeof(short), Items, Values, RawTranslation, Offset, Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "bitmask32":
                                 {
                                     string Description = Reader.GetAttribute("name");
                                     int Offset = Convert.ToInt32(Reader.GetAttribute("offset"));
                                     List<string> Items = new List<string>();
                                     List<int> Values = new List<int>();
                                     XmlReader x = Reader.ReadSubtree();
                                     while (x.Read())
                                     {
                                         switch (x.Name.ToLower())
                                         {
                                             case "option":
                                                 {
                                                     Items.Add(Reader.GetAttribute("name"));
                                                     Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                                     break;
                                                 }
                                         }
                                     }
                                     Bitmask b;
                                     if (Count > 0)
                                         b = new Bitmask(Description, typeof(int), Items, Values, RawTranslation, Offset, Map);
                                     else
                                         b = new Bitmask(Description, -1, typeof(int), Items, Values, RawTranslation, Offset, Map);
                                     Controls.Add(b);
                                     b.Dock = DockStyle.Top;
                                     b.BringToFront();
                                     break;
                                 }
                             case "string32":
                                 {
                                     //string Description = Reader.GetAttribute("name");
                                     //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                                     //Map.br.BaseStream.Position = Offset;
                                     //string Value = new string(Map.br.ReadChars(32));
                                     //String s = new String(Description, Offset, Value, StringType.String32);
                                     //Controls.Add(s);
                                     //s.Dock = DockStyle.Top;
                                     //s.BringToFront();
                                     break;
                                 }
                             case "string64":
                                 {
                                     //string Description = Reader.GetAttribute("name");
                                     //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                                     //Map.br.BaseStream.Position = Offset;
                                     //string Value = new string(Map.br.ReadChars(64));
                                     //String s = new String(Description, Offset, Value, StringType.String64);
                                     //Controls.Add(s);
                                     //s.Dock = DockStyle.Top;
                                     //s.BringToFront();
                                     break;
                                 }
                             case "unicode64":
                                 {
                                     //string Description = Reader.GetAttribute("name");
                                     //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                                     //Map.br.BaseStream.Position = Offset;
                                     //string Value = "";
                                     //for (int i = 0; i < 32; i++)
                                     //{
                                     //    Value += Convert.ToChar(Map.br.ReadByte());
                                     //    Map.br.BaseStream.Position++;
                                     //}
                                     //String s = new String(Description, Offset, Value, StringType.Unicode64);
                                     //Controls.Add(s);
                                     //s.Dock = DockStyle.Top;
                                     //s.BringToFront();
                                     break;
                                 }
                             case "unicode256":
                                 {
                                     //string Description = Reader.GetAttribute("name");
                                     //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                                     //Map.br.BaseStream.Position = Offset;
                                     //string Value = "";
                                     //for (int i = 0; i < 128; i++)
                                     //{
                                     //    Value += Convert.ToChar(Map.br.ReadByte());
                                     //    Map.br.BaseStream.Position++;
                                     //}
                                     //String s = new String(Description, Offset, Value, StringType.Unicode256);
                                     //Controls.Add(s);
                                     //s.Dock = DockStyle.Top;
                                     //s.BringToFront();
                                     break;
                                 }
                         }
                         break;
                     }
             }
         }
         Reader.Close();
         for (int i = Controls.Count - 1; i > -1; i--)
             this.panel1.Controls.Add(Controls[i]);
 }
示例#3
0
        public void ReadControls()
        {
            Reader.ReadStartElement();
            List <Control> Controls = new List <Control>();

            while (Reader.Read())
            {
                switch (Reader.NodeType)
                {
                case XmlNodeType.Element:
                {
                    switch (Reader.Name.ToLower())
                    {
                    case "byte":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(byte), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(byte), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "short":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(short), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(short), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "ushort":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(ushort), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(ushort), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "int":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(int), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(int), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "uint":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(uint), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(uint), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "float":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(float), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(float), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "string":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        int    Length      = Convert.ToInt32(Reader.GetAttribute("length"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(string), "", Length, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(string), "Null", 0, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "unknown":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(int), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(int), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "long":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Value  b;
                        if (Count > 0)
                        {
                            b = new Value(Description, typeof(long), 0, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Value(Description, typeof(long), -1, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "ident":
                    {
                        string Description = Reader.GetAttribute("name");
                        int    Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        Ident  i;
                        if (Count > 0)
                        {
                            try
                            {
                                i = new Ident("", 0, RawTranslation, Offset, Description, Map);
                            }
                            catch (Exception)
                            {
                                i = new Ident("Null", -1, RawTranslation, Offset, Description, Map);
                            }
                        }
                        else
                        {
                            i = new Ident("Null", -1, RawTranslation, Offset, Description, Map);
                        }
                        Controls.Add(i);
                        i.Dock = DockStyle.Top;
                        i.BringToFront();
                        break;
                    }

                    case "reflexive":
                    {
                        string    Description = Reader.GetAttribute("name");
                        int       Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        int       Size        = Convert.ToInt32(Reader.GetAttribute("size"));
                        Reflexive b;
                        if (Count > 0)
                        {
                            Map.Reader.BaseStream.Position = ((Offset + RawTranslation) - Map.Index.SecondaryMagic);
                            b = new Reflexive(Map, Description, Map.Reader.ReadInt32(), RawTranslation, Offset, Size, Reader.ReadSubtree());
                        }
                        else
                        {
                            b = new Reflexive(Map, Description, 0, RawTranslation, Offset, Size, Reader.ReadSubtree());
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "stringid":
                    {
                        string   Description = Reader.GetAttribute("name");
                        int      Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        StringID b;
                        if (Count > 0)
                        {
                            b = new StringID(Description, RawTranslation, Offset, 0, Map);
                        }
                        else
                        {
                            b = new StringID(Description, RawTranslation, Offset, -1, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "enum8":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Enum e;
                        if (Count > 0)
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(byte), Items, Values, 0, Map);
                        }
                        else
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(byte), new List <string>(), new List <int>(), -1, Map);
                        }
                        Controls.Add(e);
                        e.Dock = DockStyle.Top;
                        e.BringToFront();
                        break;
                    }

                    case "enum16":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Enum e;
                        if (Count > 0)
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(int), Items, Values, 0, Map);
                        }
                        else
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(int), new List <string>(), new List <int>(), -1, Map);
                        }
                        Controls.Add(e);
                        e.Dock = DockStyle.Top;
                        e.BringToFront();
                        break;
                    }

                    case "enum32":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Enum e;
                        if (Count > 0)
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(int), Items, Values, 0, Map);
                        }
                        else
                        {
                            e = new Enum(Description, RawTranslation, Offset, typeof(int), new List <string>(), new List <int>(), -1, Map);
                        }
                        Controls.Add(e);
                        e.Dock = DockStyle.Top;
                        e.BringToFront();
                        break;
                    }

                    case "bitmask8":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Bitmask b;
                        if (Count > 0)
                        {
                            b = new Bitmask(Description, typeof(byte), Items, Values, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Bitmask(Description, -1, typeof(byte), Items, Values, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "bitmask16":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Bitmask b;
                        if (Count > 0)
                        {
                            b = new Bitmask(Description, typeof(short), Items, Values, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Bitmask(Description, -1, typeof(short), Items, Values, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "bitmask32":
                    {
                        string        Description = Reader.GetAttribute("name");
                        int           Offset      = Convert.ToInt32(Reader.GetAttribute("offset"));
                        List <string> Items       = new List <string>();
                        List <int>    Values      = new List <int>();
                        XmlReader     x           = Reader.ReadSubtree();
                        while (x.Read())
                        {
                            switch (x.Name.ToLower())
                            {
                            case "option":
                            {
                                Items.Add(Reader.GetAttribute("name"));
                                Values.Add(Convert.ToInt32(Reader.GetAttribute("value")));
                                break;
                            }
                            }
                        }
                        Bitmask b;
                        if (Count > 0)
                        {
                            b = new Bitmask(Description, typeof(int), Items, Values, RawTranslation, Offset, Map);
                        }
                        else
                        {
                            b = new Bitmask(Description, -1, typeof(int), Items, Values, RawTranslation, Offset, Map);
                        }
                        Controls.Add(b);
                        b.Dock = DockStyle.Top;
                        b.BringToFront();
                        break;
                    }

                    case "string32":
                    {
                        //string Description = Reader.GetAttribute("name");
                        //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                        //Map.br.BaseStream.Position = Offset;
                        //string Value = new string(Map.br.ReadChars(32));
                        //String s = new String(Description, Offset, Value, StringType.String32);
                        //Controls.Add(s);
                        //s.Dock = DockStyle.Top;
                        //s.BringToFront();
                        break;
                    }

                    case "string64":
                    {
                        //string Description = Reader.GetAttribute("name");
                        //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                        //Map.br.BaseStream.Position = Offset;
                        //string Value = new string(Map.br.ReadChars(64));
                        //String s = new String(Description, Offset, Value, StringType.String64);
                        //Controls.Add(s);
                        //s.Dock = DockStyle.Top;
                        //s.BringToFront();
                        break;
                    }

                    case "unicode64":
                    {
                        //string Description = Reader.GetAttribute("name");
                        //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                        //Map.br.BaseStream.Position = Offset;
                        //string Value = "";
                        //for (int i = 0; i < 32; i++)
                        //{
                        //    Value += Convert.ToChar(Map.br.ReadByte());
                        //    Map.br.BaseStream.Position++;
                        //}
                        //String s = new String(Description, Offset, Value, StringType.Unicode64);
                        //Controls.Add(s);
                        //s.Dock = DockStyle.Top;
                        //s.BringToFront();
                        break;
                    }

                    case "unicode256":
                    {
                        //string Description = Reader.GetAttribute("name");
                        //int Offset = Convert.ToInt32(Reader.GetAttribute("offset")) + Map.SelectedTag.MetaOffset;
                        //Map.br.BaseStream.Position = Offset;
                        //string Value = "";
                        //for (int i = 0; i < 128; i++)
                        //{
                        //    Value += Convert.ToChar(Map.br.ReadByte());
                        //    Map.br.BaseStream.Position++;
                        //}
                        //String s = new String(Description, Offset, Value, StringType.Unicode256);
                        //Controls.Add(s);
                        //s.Dock = DockStyle.Top;
                        //s.BringToFront();
                        break;
                    }
                    }
                    break;
                }
                }
            }
            Reader.Close();
            for (int i = Controls.Count - 1; i > -1; i--)
            {
                this.panel1.Controls.Add(Controls[i]);
            }
        }