Esempio n. 1
0
        private void DisplayBiffResource(BIFResource resource)
        {
            biffTreeViewer.Nodes.Clear();

            var fileEntryNode = new TreeNode(string.Format("File Entries [{0}]", resource.FileEntries.Count));
            var tileEntryNode = new TreeNode(string.Format("Tile Entries [{0}]", resource.TilesetEntries.Count));

            for(int i = 0; i < resource.FileEntries.Count; i++)
            { fileEntryNode.Nodes.Add(CreateFileEntryTreeNode(resource.FileEntries[i], i)); }

            for(int i = 0; i < resource.TilesetEntries.Count; i++)
            { tileEntryNode.Nodes.Add(CreateTileEntryTreeNode(resource.TilesetEntries[i], i)); }

            biffTreeViewer.Nodes.Add(fileEntryNode);
            biffTreeViewer.Nodes.Add(tileEntryNode);
        }
Esempio n. 2
0
        public void should_correctly_read_bif_stream()
        {
            var dummyStream = CreateDummyBIFStream();
            var plugin = new BIFPlugin();

            var expectedBIF = new BIFResource();

            expectedBIF.FileEntries.Add(new BIFFileEntry(0x1, 0x2, 0x3, 0x4, 0x5));
            expectedBIF.FileEntries.Add(new BIFFileEntry(0x6, 0x7, 0x8, 0x9, 0xA));

            expectedBIF.TilesetEntries.Add(new BIFTilesetEntry(0x1,0x2,0x3,0x4,0x5,0x6));
            expectedBIF.TilesetEntries.Add(new BIFTilesetEntry(0x7,0x8,0x9,0xA,0xB,0xC));

            var result = plugin.Import(dummyStream);

            Assert.That(result, Is.EqualTo(expectedBIF));
        }
Esempio n. 3
0
        public BIFResource Import(Stream stream)
        {
            var binaryReader = new BinaryReader(stream);

            var signature = ConvertToSignature(binaryReader.ReadBytes(SignatureBIF.Length));
            if (!signature.Equals(SignatureBIF, StringComparison.CurrentCultureIgnoreCase))
            { LoggingConfiguration.LogAndThrowError(new Exception("Invalid signature for BIF file")); }

            var descriptor = ReadDescriptor(binaryReader, (int)binaryReader.BaseStream.Position);

            var bifResource = new BIFResource(
                    ReadFileEntries(binaryReader, descriptor),
                    ReadTileEntries(binaryReader, descriptor)
                );

            return bifResource;
        }