Пример #1
0
 public CAttribute(int id, object data, CPSSGFile file, CNode ParentNode)
 {
     this.id         = id;
     this.data       = data;
     this.file       = file;
     this.ParentNode = ParentNode;
 }
Пример #2
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file, CNode node)
        {
            this.file  = file;
            ParentNode = node;

            id   = reader.ReadInt32();
            size = reader.ReadInt32();
            if (size == 4)
            {
                data = reader.ReadBytes(size);
                return;
            }
            else if (size > 4)
            {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen)
                {
                    data = reader.ReadPSSGString(strlen);
                    return;
                }
                else
                {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Пример #3
0
 public AddBox(CPSSGFile file)
 {
     InitializeComponent();
     pssgFile = file;
     // NodeInfo Combo
     nodeInfoComboBox1.BeginUpdate();
     foreach (CNodeInfo nodeInfo in pssgFile.nodeInfo)
     {
         nodeInfoComboBox1.Items.Add(nodeInfo.name);
     }
     nodeInfoComboBox1.EndUpdate();
     // AttributeInfo Combo
     attributeInfoComboBox.BeginUpdate();
     foreach (CAttributeInfo attributeInfo in pssgFile.attributeInfo)
     {
         attributeInfoComboBox.Items.Add(attributeInfo.name);
     }
     attributeInfoComboBox.EndUpdate();
     // ValueType Combo
     valueTypeComboBox.Items.Add(typeof(System.UInt16).ToString());
     valueTypeComboBox.Items.Add(typeof(System.UInt32).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Int16).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Int32).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Single).ToString());
     //valueTypeComboBox.Items.Add(typeof(System.Boolean).ToString());
     valueTypeComboBox.Items.Add(typeof(System.String).ToString());
     // Select
     nodeInfoComboBox1.SelectedIndex = 0;
     if (attributeInfoComboBox.Items.Count > 0)
     {
         attributeInfoComboBox.SelectedIndex = 0;
     }
     valueTypeComboBox.SelectedIndex = 5;
 }
Пример #4
0
 public AddBox(CPSSGFile file)
 {
     InitializeComponent();
     pssgFile = file;
     // NodeInfo Combo
     nodeInfoComboBox1.BeginUpdate();
     foreach (CNodeInfo nodeInfo in pssgFile.nodeInfo) {
         nodeInfoComboBox1.Items.Add(nodeInfo.name);
     }
     nodeInfoComboBox1.EndUpdate();
     // AttributeInfo Combo
     attributeInfoComboBox.BeginUpdate();
     foreach (CAttributeInfo attributeInfo in pssgFile.attributeInfo) {
         attributeInfoComboBox.Items.Add(attributeInfo.name);
     }
     attributeInfoComboBox.EndUpdate();
     // ValueType Combo
     valueTypeComboBox.Items.Add(typeof(System.UInt16).ToString());
     valueTypeComboBox.Items.Add(typeof(System.UInt32).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Int16).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Int32).ToString());
     valueTypeComboBox.Items.Add(typeof(System.Single).ToString());
     //valueTypeComboBox.Items.Add(typeof(System.Boolean).ToString());
     valueTypeComboBox.Items.Add(typeof(System.String).ToString());
     // Select
     nodeInfoComboBox1.SelectedIndex = 0;
     if (attributeInfoComboBox.Items.Count > 0)
     {
         attributeInfoComboBox.SelectedIndex = 0;
     }
     valueTypeComboBox.SelectedIndex = 5;
 }
Пример #5
0
 public CAttribute(int id, object data, CPSSGFile file, CNode ParentNode)
 {
     this.id = id;
     this.data = data;
     this.file = file;
     this.ParentNode = ParentNode;
 }
Пример #6
0
        public CAttribute(CAttribute attrToCopy)
        {
            this.file  = attrToCopy.file;
            ParentNode = attrToCopy.ParentNode;

            id   = attrToCopy.id;
            size = attrToCopy.size;
            data = attrToCopy.data;
        }
Пример #7
0
        public CAttribute(CAttribute attrToCopy)
        {
            this.file = attrToCopy.file;
            ParentNode = attrToCopy.ParentNode;

            id = attrToCopy.id;
            size = attrToCopy.size;
            data = attrToCopy.data;
        }
Пример #8
0
 public CNode(int id, CPSSGFile file, CNode node, bool isDataNode)
 {
     this.id         = id;
     this.file       = file;
     this.ParentNode = node;
     this.isDataNode = isDataNode;
     attributes      = new Dictionary <string, CAttribute>();
     if (isDataNode == true)
     {
         data = new byte[0];
     }
 }
Пример #9
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new SortedDictionary <int, CAttributeInfo>();

            id   = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int            attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;

            for (int i = 0; i < attributeInfoCount; i++)
            {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Пример #10
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file, CNode node)
        {
            this.file = file;
            ParentNode = node;

            id = reader.ReadInt32();
            size = reader.ReadInt32();
            if (size == 4) {
                data = reader.ReadBytes(size);
                return;
            } else if (size > 4) {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen) {
                    data = reader.ReadPSSGString(strlen);
                    return;
                } else {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Пример #11
0
        public CNode(CNode nodeToCopy)
        {
            this.file  = nodeToCopy.file;
            ParentNode = nodeToCopy.ParentNode;

            id            = nodeToCopy.id;
            size          = nodeToCopy.size;
            attributeSize = nodeToCopy.attributeSize;
            attributes    = new Dictionary <string, CAttribute>();
            CAttribute attr;

            foreach (KeyValuePair <string, CAttribute> attrToCopy in nodeToCopy.attributes)
            {
                attr = new CAttribute(attrToCopy.Value);
                attributes.Add(attr.Name, attr);
            }

            isDataNode = nodeToCopy.isDataNode;

            if (isDataNode)
            {
                data = nodeToCopy.data;
            }
            else
            {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[nodeToCopy.subNodes.Length];
                int nodeCount = 0;
                foreach (CNode subNodeToCopy in nodeToCopy.subNodes)
                {
                    subNodes[nodeCount] = new CNode(subNodeToCopy);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }
        }
Пример #12
0
        public CNode(EndianBinaryReaderEx reader, CPSSGFile file, CNode node, bool useDataNodeCheck)
        {
            this.file  = file;
            ParentNode = node;

            id   = reader.ReadInt32();
            size = reader.ReadInt32();
            long end = reader.BaseStream.Position + size;

            attributeSize = reader.ReadInt32();
            long attributeEnd = reader.BaseStream.Position + attributeSize;

            if (attributeEnd > reader.BaseStream.Length || end > reader.BaseStream.Length)
            {
                throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                                    "Get an older version of the program if you wish to take out its contents, but, put it back together using this program and a non-modded version of the pssg file.");
            }
            // Each attr is at least 8 bytes (id + size), so take a conservative guess
            attributes = new Dictionary <string, CAttribute>();
            CAttribute attr;

            while (reader.BaseStream.Position < attributeEnd)
            {
                attr = new CAttribute(reader, file, this);
                attributes.Add(attr.Name, attr);
            }

            switch (Name)
            {
            case "BOUNDINGBOX":
            case "DATA":
            case "DATABLOCKDATA":
            case "DATABLOCKBUFFERED":
            case "INDEXSOURCEDATA":
            case "INVERSEBINDMATRIX":
            case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT":
            case "NeAnimPacketData_B1":
            case "NeAnimPacketData_B4":
            case "RENDERINTERFACEBOUNDBUFFERED":
            case "SHADERINPUT":
            case "TEXTUREIMAGEBLOCKDATA":
            case "TRANSFORM":
                isDataNode = true;
                break;
            }
            if (isDataNode == false && useDataNodeCheck == true)
            {
                long currentPos = reader.BaseStream.Position;
                // Check if it has subnodes
                while (reader.BaseStream.Position < end)
                {
                    int tempID = reader.ReadInt32();
                    if (tempID > file.nodeInfo.Length || tempID < 0)
                    {
                        isDataNode = true;
                        break;
                    }
                    else
                    {
                        int tempSize = reader.ReadInt32();
                        if ((reader.BaseStream.Position + tempSize > end) || (tempSize == 0 && tempID == 0) || tempSize < 0)
                        {
                            isDataNode = true;
                            break;
                        }
                        else if (reader.BaseStream.Position + tempSize == end)
                        {
                            break;
                        }
                        else
                        {
                            reader.BaseStream.Position += tempSize;
                        }
                    }
                }
                reader.BaseStream.Position = currentPos;
            }

            if (isDataNode)
            {
                data = reader.ReadBytes((int)(end - reader.BaseStream.Position));
            }
            else
            {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[(end - reader.BaseStream.Position) / 12];
                int nodeCount = 0;
                while (reader.BaseStream.Position < end)
                {
                    subNodes[nodeCount] = new CNode(reader, file, this, useDataNodeCheck);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }

            file.nodeInfo[id - 1].isDataNode = isDataNode;
        }
Пример #13
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new SortedDictionary<int, CAttributeInfo>();

            id = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;
            for (int i = 0; i < attributeInfoCount; i++) {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Пример #14
0
 public CNode(int id, CPSSGFile file, CNode node, bool isDataNode)
 {
     this.id = id;
     this.file = file;
     this.ParentNode = node;
     this.isDataNode = isDataNode;
     attributes = new Dictionary<string, CAttribute>();
     if (isDataNode == true) {
         data = new byte[0];
     }
 }
Пример #15
0
        public CNode(CNode nodeToCopy)
        {
            this.file = nodeToCopy.file;
            ParentNode = nodeToCopy.ParentNode;

            id = nodeToCopy.id;
            size = nodeToCopy.size;
            attributeSize = nodeToCopy.attributeSize;
            attributes = new Dictionary<string, CAttribute>();
            CAttribute attr;
            foreach (KeyValuePair<string, CAttribute> attrToCopy in nodeToCopy.attributes) {
                attr = new CAttribute(attrToCopy.Value);
                attributes.Add(attr.Name, attr);
            }

            isDataNode = nodeToCopy.isDataNode;

            if (isDataNode) {
                data = nodeToCopy.data;
            } else {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[nodeToCopy.subNodes.Length];
                int nodeCount = 0;
                foreach (CNode subNodeToCopy in nodeToCopy.subNodes) {
                    subNodes[nodeCount] = new CNode(subNodeToCopy);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }
        }
Пример #16
0
        public CNode(EndianBinaryReaderEx reader, CPSSGFile file, CNode node, bool useDataNodeCheck)
        {
            this.file = file;
            ParentNode = node;

            id = reader.ReadInt32();
            size = reader.ReadInt32();
            long end = reader.BaseStream.Position + size;

            attributeSize = reader.ReadInt32();
            long attributeEnd = reader.BaseStream.Position + attributeSize;
            if (attributeEnd > reader.BaseStream.Length || end > reader.BaseStream.Length) {
                throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                            "Get an older version of the program if you wish to take out its contents, but, put it back together using this program and a non-modded version of the pssg file.");
            }
            // Each attr is at least 8 bytes (id + size), so take a conservative guess
            attributes = new Dictionary<string, CAttribute>();
            CAttribute attr;
            while (reader.BaseStream.Position < attributeEnd) {
                attr = new CAttribute(reader, file, this);
                attributes.Add(attr.Name, attr);
            }

            switch (Name) {
                case "BOUNDINGBOX":
                case "DATA":
                case "DATABLOCKDATA":
                case "DATABLOCKBUFFERED":
                case "INDEXSOURCEDATA":
                case "INVERSEBINDMATRIX":
                case "MODIFIERNETWORKINSTANCEUNIQUEMODIFIERINPUT":
                case "NeAnimPacketData_B1":
                case "NeAnimPacketData_B4":
                case "RENDERINTERFACEBOUNDBUFFERED":
                case "SHADERINPUT":
                case "TEXTUREIMAGEBLOCKDATA":
                case "TRANSFORM":
                    isDataNode = true;
                    break;
            }
            if (isDataNode == false && useDataNodeCheck == true) {
                long currentPos = reader.BaseStream.Position;
                // Check if it has subnodes
                while (reader.BaseStream.Position < end) {
                    int tempID = reader.ReadInt32();
                    if (tempID > file.nodeInfo.Length || tempID < 0) {
                        isDataNode = true;
                        break;
                    } else {
                        int tempSize = reader.ReadInt32();
                        if ((reader.BaseStream.Position + tempSize > end) || (tempSize == 0 && tempID == 0) || tempSize < 0) {
                            isDataNode = true;
                            break;
                        } else if (reader.BaseStream.Position + tempSize == end) {
                            break;
                        } else {
                            reader.BaseStream.Position += tempSize;
                        }
                    }
                }
                reader.BaseStream.Position = currentPos;
            }

            if (isDataNode) {
                data = reader.ReadBytes((int)(end - reader.BaseStream.Position));
            } else {
                // Each node at least 12 bytes (id + size + arg size)
                subNodes = new CNode[(end - reader.BaseStream.Position) / 12];
                int nodeCount = 0;
                while (reader.BaseStream.Position < end) {
                    subNodes[nodeCount] = new CNode(reader, file, this, useDataNodeCheck);
                    nodeCount++;
                }
                Array.Resize(ref subNodes, nodeCount);
            }

            file.nodeInfo[id - 1].isDataNode = isDataNode;
        }