Esempio n. 1
0
        public static GameFont HiResFromGameData()
        {
            using (DisposableStack disposables = new DisposableStack(2))
            {
                GameImage firstImage, secondImage;

                ArchiveDirectoryEntry mainDirectory  = Archives.GetEntry <ArchiveDirectoryEntry>(MainPath);
                ArchiveDirectoryEntry menuDirectory  = Archives.GetEntry <ArchiveDirectoryEntry>(MenuPath);
                ArchiveDirectoryEntry hiresDirectory = menuDirectory.GetChildEntry <ArchiveDirectoryEntry>(HiResDirectoryName);
                ArchiveFileEntry      tdwEntry       = mainDirectory.GetChildEntry <ArchiveFileEntry>(HiResCharactersWidthsFileName);
                ArchiveFileEntry      image01        = hiresDirectory.GetChildEntry <ArchiveFileEntry>(HiResFontImage1FileName);
                ArchiveFileEntry      image02        = hiresDirectory.GetChildEntry <ArchiveFileEntry>(HiResFontImage2FileName);

                byte[] widths;
                using (TdwFileReader tdwReader = new TdwFileReader(tdwEntry.OpenReadableContentStream()))
                    widths = tdwReader.Table;

                using (TexFileReader texReader = new TexFileReader(image01.OpenReadableContentStream()))
                {
                    firstImage = GameImageReader.FromTex(texReader);
                    disposables.Add(firstImage.Layer);
                }

                using (TexFileReader texReader = new TexFileReader(image02.OpenReadableContentStream()))
                    secondImage = disposables.Add(GameImageReader.FromTex(texReader));

                int       x        = firstImage.X;
                int       y        = firstImage.Y;
                GLTexture palettes = firstImage.Palettes;
                GLTexture layer    = GLTextureFactory.HorizontalJoin(firstImage.Layer, secondImage.Layer);
                GameImage image    = new GameImage(x, y, layer, palettes);

                return(new GameFont(image, widths));
            }
        }
        private void ReadTextureFromTexFiles(string[] files)
        {
            GLTexture[] textures = new GLTexture[2];
            using (DisposableStack disposables = new DisposableStack(2))
            {
                for (int i = 0; i < 2; i++)
                {
                    using (FileStream input = File.OpenRead(files[i]))
                        using (TexFileReader texReader = new TexFileReader(input))
                            textures[i] = disposables.Add(texReader.ReadImage());
                }

                _texture    = GLTextureFactory.HorizontalJoin(textures[0], textures[1]);
                _ownTexture = true;
            }
        }