示例#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));
            }
        }
示例#2
0
        public static GameFont FromGameData(ArchiveDirectoryEntry directory, string name)
        {
            ArchiveFileEntry tdwEntry = (ArchiveFileEntry)directory.Childs.TryGetValue(name + ".tdw");

            if (tdwEntry == null)
            {
                return(null);
            }

            using (TdwFileReader tdwReader = new TdwFileReader(tdwEntry.OpenReadableContentStream()))
                using (TimFileReader timReader = tdwReader.TimReader)
                {
                    if (timReader == null)
                    {
                        return(null);
                    }

                    GameImage image = GameImageReader.FromTim(timReader);
                    return(new GameFont(image, tdwReader.Table));
                }
        }
示例#3
0
        public static GameFont FromDirectory(string dirPath)
        {
            string xmlPath = Path.Combine(dirPath, "Characters.xml");

            if (!File.Exists(xmlPath))
            {
                return(null);
            }

            XmlElement node = XmlHelper.LoadDocument(xmlPath);

            byte[] fontWidths = new byte[node.ChildNodes.Count];
            for (int i = 0; i < fontWidths.Length; i++)
            {
                fontWidths[i] = ((XmlElement)node.ChildNodes[i]).GetByte("Width");
            }

            GameImage image = GameImageReader.FromDirectory(dirPath);

            return(new GameFont(image, fontWidths));
        }