Exemplo 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));
            }
        }
Exemplo n.º 2
0
        public static Location[] GetLocationList(Action <long> totalCallback, Action <long> progressCallback)
        {
            List <Location> result = new List <Location>(850);

            try
            {
                string           mapFilePath = Path.Combine(SourcePath, MaplistFileName);
                ArchiveFileEntry mapFile     = Archives.GetEntry <ArchiveFileEntry>(mapFilePath);

                totalCallback.Invoke(result.Capacity);

                using (FileSegment stream = mapFile.OpenReadableContentStream())
                    using (StreamReader sr = stream.GetStreamReader())
                        while (!sr.EndOfStream)
                        {
                            string name = sr.ReadLine();
                            if (name == "testno")
                            {
                                progressCallback.Invoke(1);
                                continue;
                            }

                            Location location = FindLocation(name);
                            if (location == null)
                            {
                                progressCallback.Invoke(1);
                                continue;
                            }

                            result.Add(location);
                            location.LoadBaseInformation();
                            progressCallback.Invoke(1);
                        }

                totalCallback.Invoke(result.Count);
            }
            catch
            {
                result.SafeDispose();
                throw;
            }

            return(result.ToArray());
        }
Exemplo n.º 3
0
        public static void HiResToGameData(GameFont gameFont)
        {
            using (DisposableStack disposables = new DisposableStack(2))
            {
                GLTexture leftTexture;
                GLTexture rightTexture;
                GLTextureFactory.HorizontalSplit(gameFont.CharactersImage.Layer, out leftTexture, out rightTexture);
                disposables.Add(leftTexture);
                disposables.Add(rightTexture);

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

                using (Stream output = tdwEntry.OpenWritableCapacityStream())
                    using (TdwFileWriter tdwWriter = new TdwFileWriter(output))
                    {
                        tdwWriter.WriteFontCharactersWidths(gameFont.CharactersWidths);
                        tdwEntry.UpdateMetrics((int)output.Position, tdwEntry.ContentOffset, Compression.None);
                    }

                using (Stream output = image01.OpenWritableCapacityStream())
                    using (TexFileWriter texWriter = new TexFileWriter(output))
                    {
                        texWriter.WriteImage(leftTexture, gameFont.CharactersImage.Palettes);
                        image01.UpdateMetrics((int)output.Position, image01.ContentOffset, Compression.None);
                    }

                using (Stream output = image02.OpenWritableCapacityStream())
                    using (TexFileWriter texWriter = new TexFileWriter(output))
                    {
                        texWriter.WriteImage(rightTexture, gameFont.CharactersImage.Palettes);
                        image02.UpdateMetrics((int)output.Position, image02.ContentOffset, Compression.None);
                    }

                Archives.GetInfo(ArchiveName.Main).Update();
                Archives.GetInfo(ArchiveName.Menu).Update();
            }
        }
Exemplo n.º 4
0
        private static LocalizableStrings LoadAreaNames()
        {
            lock (_glossaryNode)
            {
                if (_glossaryNode.Value != null)
                {
                    XmlElement node = _glossaryNode.Value.GetChildElement("AreaNames");
                    return(LocalizableString.FromXml(node));
                }

                ArchiveDirectoryEntry dir    = Archives.GetEntry <ArchiveDirectoryEntry>(SourcePath);
                ArchiveFileEntry      entry1 = dir.GetChildEntry <ArchiveFileEntry>(AreaNamesFileName);

                LocalizableStrings result = new LocalizableStrings(256);

                using (DictionaryFileReader dicReader = new DictionaryFileReader(entry1.OpenReadableContentStream()))
                    foreach (string title in dicReader.Titles)
                    {
                        result.Add(new LocalizableString(title, title));
                    }

                return(result);
            }
        }