示例#1
0
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return(new Uchar(member.identifier));

            case "bool":
            case "UInt8":
                return(new Uint8(member.identifier));

            case "int":
                return(new Uint32(member.identifier));

            case "unsigned int":
                return(new Uuint32(member.identifier));

            case "float":
                return(new Ufloat(member.identifier));
            }

            UType cls;

            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier);
            }
            else if (member.type == "Array")
            {
                cls = new Uarray();
            }
            else
            {
                cls = new UClass(member.type, member.identifier);
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return(cls);
        }
示例#2
0
文件: TypeParser.cs 项目: kkdevs/sb3u
 public static void UpdatePointersUType(UType t)
 {
     if (t is UPPtr)
     {
         UPPtr p = (UPPtr)t;
         p.Value.Refresh();
     }
     else if (t is Uarray)
     {
         Uarray a = (Uarray)t;
         for (int i = 0; i < a.Value.Length; i++)
         {
             UpdatePointersUType(a.Value[i]);
         }
     }
     else if (t is UClass)
     {
         UpdatePointersUClass((UClass)t);
     }
 }
示例#3
0
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return new Uchar(member.identifier);
            case "bool":
            case "UInt8":
                return new Uint8(member.identifier);
            case "int":
                return new Uint32(member.identifier);
            case "unsigned int":
                return new Uuint32(member.identifier);
            case "float":
                return new Ufloat(member.identifier);
            }

            UType cls;
            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier);
            }
            else if (member.type == "Array")
            {
                cls = new Uarray();
            }
            else
            {
                cls = new UClass(member.type, member.identifier);
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return cls;
        }
示例#4
0
文件: TypeParser.cs 项目: kkdevs/sb3u
 public static void MovePointersUType(UType t, Component old, Component replacement, AssetCabinet destFile)
 {
     if (t is UPPtr)
     {
         UPPtr p = (UPPtr)t;
         if (p.Value.asset == old || p.Value.asset is NotLoaded && ((NotLoaded)p.Value.asset).replacement == old)
         {
             p.Value = new PPtr <Object>(replacement, destFile);
         }
     }
     else if (t is Uarray)
     {
         Uarray a = (Uarray)t;
         for (int i = 0; i < a.Value.Length; i++)
         {
             MovePointersUType(a.Value[i], old, replacement, destFile);
         }
     }
     else if (t is UClass)
     {
         MovePointersUClass((UClass)t, old, replacement, destFile);
     }
 }
示例#5
0
 public UPPtr(UPPtr ptr)
 {
     Name      = ptr.Name;
     this.file = ptr.file;
 }
示例#6
0
        public static void CreateMember(ref int line, UType utype, int arrayIndex, TreeNodeCollection nodes)
        {
            if (utype is UClass)
            {
                if (((UClass)utype).ClassName == "string")
                {
                    CreateTreeNode(line, nodes, utype.Name, " (string)", ((UClass)utype).GetString(), arrayIndex);
                }
                else if (((UClass)utype).ClassName == "Vector2f")
                {
                    string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString();
                    CreateTreeNode(line, nodes, utype.Name, " (Vector2f)", value, arrayIndex);
                }
                else if (((UClass)utype).ClassName == "Vector3f")
                {
                    string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString();
                    CreateTreeNode(line, nodes, utype.Name, " (Vector3f)", value, arrayIndex);
                }
                else if (((UClass)utype).ClassName == "Vector4f")
                {
                    string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString();
                    CreateTreeNode(line, nodes, utype.Name, " (Vector4f)", value, arrayIndex);
                }
                else if (((UClass)utype).ClassName == "Quaternionf")
                {
                    string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString();
                    CreateTreeNode(line, nodes, utype.Name, " (Quaternionf)", value, arrayIndex);
                }
                else if (((UClass)utype).ClassName == "ColorRGBA" && ((UClass)utype).Members.Count == 4)
                {
                    string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString()
                                   + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString();
                    CreateTreeNode(line, nodes, utype.Name, " (ColorRGBA)", value, arrayIndex);
                }
                else
                {
                    TreeNode classNode = CreateTreeNode(line, nodes, utype.Name, " " + ((UClass)utype).ClassName, null, arrayIndex, false);
                    line++;
                    for (int i = 0; i < ((UClass)utype).Members.Count; i++)
                    {
                        CreateMember(ref line, ((UClass)utype).Members[i], -1, classNode.Nodes);
                    }
                    line--;
                }
            }
            else if (utype is UPPtr)
            {
                UPPtr     ptr   = (UPPtr)utype;
                Component asset = ptr.Value != null ? ptr.Value.asset : null;
                CreateTreeNode(line, nodes, utype.Name, " (PPtr<" + (asset != null ? asset.classID().ToString() : "") + ">)",
                               ptr.Value != null ? (asset != null ? asset is NotLoaded ? ((NotLoaded)asset).Name : AssetCabinet.ToString(asset) : String.Empty) + " PathID=" + ptr.Value.m_PathID : null, arrayIndex);
            }
            else if (utype is Uarray)
            {
                TreeNode arrayNode = CreateTreeNode(line, nodes, "", "Array size " + (((Uarray)utype).Value != null ? ((Uarray)utype).Value.Length : 0), null, arrayIndex, false);
                arrayNode.Tag = utype;
                line++;

                if (((Uarray)utype).Value != null)
                {
                    for (int i = 0; i < ((Uarray)utype).Value.Length; i++)
                    {
                        CreateMember(ref line, ((Uarray)utype).Value[i], i, arrayNode.Nodes);
                    }
                }
                line--;
            }
            else if (utype is Ufloat)
            {
                CreateTreeNode(line, nodes, utype.Name, " (float)", ((Ufloat)utype).Value.ToFloatString(), arrayIndex);
            }
            else if (utype is Udouble)
            {
                CreateTreeNode(line, nodes, utype.Name, " (double)", ((Udouble)utype).Value.ToDoubleString(), arrayIndex);
            }
            else if (utype is Uint8)
            {
                CreateTreeNode(line, nodes, utype.Name, " (int8)", ((Uint8)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uint16)
            {
                CreateTreeNode(line, nodes, utype.Name, " (int16)", ((Uint16)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uuint16)
            {
                CreateTreeNode(line, nodes, utype.Name, " (uint16)", ((Uuint16)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uint32)
            {
                CreateTreeNode(line, nodes, utype.Name, " (int32)", ((Uint32)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uuint32)
            {
                CreateTreeNode(line, nodes, utype.Name, " (uint32)", ((Uuint32)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uint64)
            {
                CreateTreeNode(line, nodes, utype.Name, " (int64)", ((Uint64)utype).Value.ToString(), arrayIndex);
            }
            else if (utype is Uuint64)
            {
                CreateTreeNode(line, nodes, utype.Name, " (uint64)", ((Uuint64)utype).Value.ToString(), arrayIndex);
            }
            else
            {
                CreateTreeNode(line, nodes, utype.Name, " " + utype.GetType() + " unhandled", null, arrayIndex, false);
            }
            line++;
        }
示例#7
0
文件: TypeParser.cs 项目: kkdevs/sb3u
 public UPPtr(UPPtr ptr)
 {
     Name           = ptr.Name;
     NeedsAlignment = ptr.NeedsAlignment;
     this.file      = ptr.file;
 }
示例#8
0
文件: TypeParser.cs 项目: kkdevs/sb3u
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return(new Uchar(member.identifier, member.align()));

            case "bool":
            case "SInt8":
            case "UInt8":
                return(new Uint8(member.identifier, member.align()));

            case "SInt16":
                return(new Uint16(member.identifier, member.align()));

            case "UInt16":
                return(new Uuint16(member.identifier, member.align()));

            case "int":
                return(new Uint32(member.identifier, member.align()));

            case "unsigned int":
                return(new Uuint32(member.identifier, member.align()));

            case "int64":
                return(new Uint64(member.identifier, member.align()));

            case "UInt64":
                return(new Uuint64(member.identifier, member.align()));

            case "float":
                return(new Ufloat(member.identifier, member.align()));

            case "double":
                return(new Udouble(member.identifier, member.align()));
            }

            UType cls;

            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier, member.type, member.align());
            }
            else if (member.type == "Array")
            {
                cls = new Uarray(member.align());
            }
            else
            {
                if (member.type == "StreamedResource")
                {
                    cls = new UStreamedResource(member.type, member.identifier, member.align(), file);
                }
                else
                {
                    cls = new UClass(member.type, member.identifier, member.align());
                }
                if (member.children.Length == 0)
                {
                    Report.ReportLog("Warning! " + member.identifier + " has no members!");
                }
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return(cls);
        }
示例#9
0
 public UPPtr(UPPtr ptr)
 {
     Name = ptr.Name;
     this.file = ptr.file;
 }