Exemplo n.º 1
0
        private void removeReference_Click(object sender, EventArgs e)
        {
            MeshTextureObject selectedObject = (MeshTextureObject)this.treeListView1.SelectedObject;
            UnitVariantObject parent         = (UnitVariantObject)this.treeListView1.GetParent(this.treeListView1.SelectedObject);

            parent.RemoveMesh(selectedObject);
            this.treeListView1.RemoveObject(this.treeListView1.SelectedObject);
            this.treeListView1.RefreshObjects(this.EditedFile.UnitVariantObjects);
            this.DataChanged = true;
            this.Refresh();
        }
        private static MeshTextureObject ReadMTO(BinaryReader reader)
        {
            MeshTextureObject obj3 = new MeshTextureObject
            {
                Mesh    = IOFunctions.ReadZeroTerminatedUnicode(reader),
                Texture = IOFunctions.ReadZeroTerminatedUnicode(reader),
                Bool1   = reader.ReadBoolean(),
                Bool2   = reader.ReadBoolean()
            };

            return(obj3);
        }
Exemplo n.º 3
0
        private void addReference_Click(object sender, EventArgs e)
        {
            UnitVariantObject entry = null;

            if (this.treeListView1.SelectedObject is MeshTextureObject)
            {
                entry = (UnitVariantObject)this.treeListView1.GetParent(this.treeListView1.SelectedObject);
            }
            else
            {
                entry = (UnitVariantObject)this.treeListView1.SelectedObject;
            }
            MeshTextureObject mTO = new MeshTextureObject("NEW_ENTRY", "NEW_ENTRY", false, false);

            entry.AddMesh(mTO);
            this.treeListView1.RefreshObjects(this.EditedFile.UnitVariantObjects);
            this.DataChanged = true;
            this.Refresh();
        }
        // read from file
        public UnitVariantFile Decode(Stream stream)
        {
            UnitVariantFile file = new UnitVariantFile();

            using (BinaryReader reader = new BinaryReader(stream))
            {
                byte[] buffer = reader.ReadBytes(4);
                if ((((buffer[0] != 0x56) || (buffer[1] != 0x52)) || (buffer[2] != 0x4e)) || (buffer[3] != 0x54))
                {
                    throw new FileLoadException("Illegal unit_variant file: Does not start with 'VRNT'");
                }
                file.Version = reader.ReadUInt32();
                int entries = (int)reader.ReadUInt32();
                file.Unknown1 = reader.ReadUInt32();
                byte[] buffer3 = reader.ReadBytes(4);
                file.B1       = buffer3[0];
                file.B2       = buffer3[1];
                file.B3       = buffer3[2];
                file.B4       = buffer3[3];
                file.Unknown2 = BitConverter.ToUInt32(buffer3, 0);
                if (file.Version == 2)
                {
                    file.Unknown3 = reader.ReadInt32();
                }
                file.UnitVariantObjects = new List <UnitVariantObject>(entries);
                for (int i = 0; i < entries; i++)
                {
                    UnitVariantObject item = ReadObject(reader);
                    file.UnitVariantObjects.Add(item);
                }
                for (int j = 0; j < file.UnitVariantObjects.Count; j++)
                {
                    for (int k = 0; k < file.UnitVariantObjects[j].StoredEntryCount; k++)
                    {
                        MeshTextureObject mto = ReadMTO(reader);
                        file.UnitVariantObjects[j].MeshTextureList.Add(mto);
                    }
                }
            }
            return(file);
        }